var LastMenuId ="";


function UpdateHPImage(varCatCode){
	document.getElementById("TheThreadProcessor").src="GetFPImages.asp?Code=" + varCatCode;}

function selectTheSelected(){
		}
	function hideIt(obj) 				{
	obj.style.visibility = "hidden";
	}
	function showIt(obj) 				{
	obj.style.visibility = "visible";
	}
	function moveIt(obj, x, y)			
	{if(x!=null){obj.x=obj.style.left=x;}
	if(y!=null){
	obj.y=obj.style.top=y;}
	}
	function sizeIt(obj, w, h) 			
	{
	if(w!=null){
		obj.style.width=w;}
		if(h!=null){
		obj.style.height=h;}
	}
	//function moveIt(obj, x, y)			{if(x!=null){obj.x=obj.style.left=x;}if(y!=null){obj.y=obj.style.top=y;}}
	//function sizeIt(obj, w, h) 			{if(w!=null){obj.style.pixelWidth=obj.style.width=w;}if(h!=null){obj.style.pixelHeight=obj.style.height=h;}}

	function checkCollection( collection ){
		for(var i=0;i<collection.length;i++){collection[i].className=((!active.selectedId)||(active.selectedId!=collection[i].id))?"":"selected";}
	}


	function resize(){
		var HeightBelowWhichVerticalScrollAppears = 800;
		var HeightBelowWhichHorizontalScrollAppears = 1100;
		if(false)return;
		page={
			w : document.body.clientWidth,
			h : document.body.clientHeight
		}
		var newW = (page.w>HeightBelowWhichHorizontalScrollAppears)? page.w: HeightBelowWhichHorizontalScrollAppears; 
			newW = (page.h<630)? (newW-16) : newW;
		var newH = (page.h>HeightBelowWhichVerticalScrollAppears)? page.h : HeightBelowWhichVerticalScrollAppears; 
			newH = (page.w<1100)? (newH-16) : newH;
	}

	function PreHideSub(){ 
	timerID=setTimeout('HideSub()',500);
	selectTheSelected(); 
	}
	function HideSub(e){ 
		clearTimeout(timerID);
		hideIt(active.sub);
		ieCoverSub.style.display="none";
		selectTheSelected();
		}
	function ShowSub(){
		clearTimeout(timerID);
		showIt(active.sub);
		
			ieCoverSub.style.display = "block";
		}


function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent){while (obj.offsetParent){curleft += obj.offsetLeft; obj = obj.offsetParent;}}
	else if (obj.x) curleft += obj.x;
	return curleft;
}
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent){while (obj.offsetParent){curtop += obj.offsetTop; obj = obj.offsetParent;}}
	else if (obj.y) curtop += obj.y;
	return curtop;
}

function menuItemOut(element){
	try{
	if( document.getElementById(element.id+"Sub") && sub )
		PreHideSub();
}catch(e){}
}

function UnHiMainMen( elementID ){
	var strTemp = elementID.id.substr(0,elementID.id.length - 4);
	document.getElementById(strTemp).className="";
	try{document.getElementById(LastMenuId).className="selected";}catch(e){}
}

function HiMainMen( elementID ){
	var strTemp = elementID.id.substr(0,elementID.id.length - 4);
	document.getElementById(strTemp).className="selected";
}


function menuItemOver( element ){
	try{
	parent.window.parent.window.active.id = element.id;
	var subWin = parent.window.parent.window;
	if( document.getElementById(element.id+"Sub") && subWin.sub ){
		var sub = subWin.sub;
		parent.window.parent.window.active.sub = sub;

		var subContent = document.getElementById(element.id+"Sub").innerHTML;//.replace(/a> <a/gi, "a><a");
		subWin.Sub.document.getElementById("SubContent").innerHTML = subContent;

		var subContentH = subWin.Sub.document.getElementById("SubContent").offsetHeight;
		var newH = (79+subContentH);
		var newY = (0+findPosY( element )-40);
		subWin.sizeIt(sub, null, newH + "px");
		
			var ieCoverSub = parent.window.parent.document.getElementById("IECoverSub");
			var backgrounder = subWin.Sub.document.getElementById("Backgrounder");
			subWin.sizeIt(backgrounder, null, subContentH);
			subWin.sizeIt(ieCoverSub, null, newH);
			subWin.moveIt(ieCoverSub, (80-subWin.frameSetWrapper.scrollLeft), newY);
		subWin.moveIt(sub, (80-subWin.frameSetWrapper.scrollLeft), newY);
		subWin.ShowSub();
	}}catch(e){}
}

function menuItemDown(url, element){
	var allLinksHere = document.getElementsByTagName("a");
	for(var i=0;i<allLinksHere.length;i++){
		allLinksHere[i].className = (allLinksHere[i].id==element.id)?"selected":"";
	}
	if(document.getElementById(element.id+"Sub")){
		window.parent.frames.Sub.document.getElementById(element.id+"Sub1").className = "selected";
		window.parent.window.active.selectedSubId = element.id+"Sub1";
	}
	Content.location.href = url;
	window.parent.window.active.selectedId = element.id;
	window.parent.window.selectTheSelected();
}

function openFirstSubMenuItem(nodeId){
	try{
	var node = document.getElementById(nodeId+"Sub").getElementsByTagName("a").item(0);
	Sub.changeContent(node.name,node.id);
	}catch(e){}
}
