function ShowAbuseForm( messageId, location )
{
    var width   = 500;
    var height  = 350;
    var left    = parseInt((screen.availWidth/2) - (width/2));
    var top     = parseInt((screen.availHeight/2) - (height/2));
    var options = 'width=' + width +',height=' + height + ',left=' + left + ',top=' + top +'menubar=no,toolbar=no,status=no,location=no';
    window.open('/Pages/ReportAbuse.aspx?MessageId=' + messageId + '&TopicURL=' + escape(window.location.href.replace('hsn_', 'xxx_')), 'ReportAbuseForm', options );
    return false;
}


function getEvent(eventobj) {
	if(eventobj.stopPropagation) {
		eventobj.stopPropagation();
		eventobj.preventDefault();
		return eventobj;
	} else {
		window.event.returnValue = false;
		window.event.cancelBubble = true;
		return window.event;
	}
}

function yaf_mouseover() {
	var evt = getEvent(window.event);
	if(evt.srcElement) {
		evt.srcElement.style.cursor = "hand";
	} else if(evt.target) {
		evt.target.style.cursor = "pointer";
	}
}

function yaf_left(obj) {
	var x = 0;
	while(obj) {
		x += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return x;
}

function yaf_top(obj) {
	var y = obj.offsetHeight;
	while(obj) {
		y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return y;
}

function showPos(e)
{
    e = (e) ? e : window.event;
    var element = (e.target) ? e.target: e.srcElement;
    var left = element.offsetLeft;
    var top  = element.offsetTop;
    while(element=element.offsetParent)
    {
        left += element.offsetLeft;
        top  += element.offsetTop;
    }
    alert("Left:"+left+"px Top:"+top+"px");
}



function yaf_popit(menuName, anchorId ) {

	var evt = getEvent(window.event);
	var target,newmenu;

	if(!document.getElementById) {
		throw('ERROR: missing getElementById');
		return false;
	}
    
	
	if(evt.srcElement)
		target = evt.srcElement;
	else if(evt.target)
		target = evt.target;
	else {
		throw('ERROR: missing event target');
		return false;
	}
	
	newmenu = document.getElementById(menuName);
	var anchor = document.getElementById(anchorId);

	if(window.themenu && window.themenu.id!=newmenu.id)
		yaf_hidemenu();

	window.themenu = newmenu;
	if(!window.themenu.style) {
		throw('ERROR: missing style');
		return false;
	}

	if(themenu.style.visibility == "hidden") {

        // Use the clone function from the prototype.js file to set the location of the popup.
        Position.clone( anchor, newmenu, { setWidth: false, setHeight: false, offsetLeft: 0, offsetTop: 12} );
		themenu.style.visibility = "visible";
		themenu.style.zIndex = "10000";
	} else {
		yaf_hidemenu();
	}

	return false;
}

function yaf_hidemenu() {
	if(window.themenu) {
		window.themenu.style.visibility = "hidden";
		window.themenu = null;
	}
}

function mouseHover(cell,hover) {
	if(hover) {
		cell.className = "postfooter";
		try {
			cell.style.cursor = "pointer";
		}
		catch(e) {
			cell.style.cursor = "hand";
		}
	} else {
		cell.className = "post";
	}
}

document.onclick = yaf_hidemenu;
if(document.addEventListener) document.addEventListener("click",function(e){window.event=e;},true);
if(document.addEventListener) document.addEventListener("mouseover",function(e){window.event=e;},true);
