//----START --> NEW CSS FOR MENUS AND SUBMENUS ----

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

//----END --> END CSS------

function ShowChatWindow()  {
	document.getElementById("divChat").style.visibility = "visible";
	//setTimeout("document.getElementById('chatwindow').src = 'http://www.pa1call.org/chat/POCS2.htm'",1000);
	setTimeout("document.getElementById('chatwindow').src = 'http://webchat.pa1call.org/webchatasp/default.aspx'",1000);
}

function CloseChatWindow()  {
	//document.getElementById("divChat").style.visibility = "hidden";
	setTimeout("document.getElementById('divChat').style.visibility = 'hidden';", 1000);
	document.getElementById("chatwindow").src = "chatloading.aspx";
}

/*----------START - handles NON-CSS menus and sub-menus--------------------------------------
var SubMenuVisible = false;

function GetTable(theElement)  {
	if (theElement != null && theElement.id != "DIVcontainer")  {
		var pElement;
		pElement = theElement;
		while (pElement.tagName != "TABLE" && pElement != null)
			pElement = pElement.parentElement
		return pElement;
	}
	else
	{
		//alert("caught the error"); 
		return "this table is undefined";
	}
}


function ChangeBG_onmouseover(IsThereSubs)  { 
	//var starttimer = gettime()
	HideSubs();

	if (window.event.srcElement.id != "empty")  {
		document.Form1.style.cursor = "hand";
		window.event.srcElement.style.backgroundColor = "#BEB8B8";
		//window.status = string.replace(window.event.srcElement.id,"midlinkstable_","");
		window.status = window.event.srcElement.id.replace("midlinkstable_","");
	}

	if (IsThereSubs == "true")  {
		SubMenuVisible = true;
		var test ;
		test = GetTable(window.event.srcElement);
		var tablename ;
		tablename = test.id + "_" + window.event.srcElement.id ;
		//alert(document.all(tablename).id);
		//window.status = tablename;
		window.status = window.event.srcElement.id.replace("midlinkstable_","");
		//document.all("midlinkstable_About Us_Who is POCS").style.visibility = "visible";
		document.all(tablename).style.visibility = "visible" ;
		document.all(tablename).style.position = "absolute" ;
		document.all(tablename).style.width = "auto" ;
		//document.all(tablename).refresh
		//alert(test.id);
		if (test.id == "midlinkstable")  {
			document.all(tablename).style.posLeft = GetAbsoluteX(window.event.srcElement) ;
			document.all(tablename).style.posTop = (GetAbsoluteY(window.event.srcElement) + document.getElementById("midlinksrow").clientHeight + 5);
		}
		if (test.id != "midlinkstable")  {
			document.all(tablename).style.posLeft = GetAbsoluteX(window.event.srcElement) + window.event.srcElement.offsetWidth;
			document.all(tablename).style.posTop = GetAbsoluteY(window.event.srcElement);
			//document.all(tablename).style.posLeft = window.event.srcElement.offsetLeft + window.event.srcElement.offsetWidth;
			//document.all(tablename).style.posTop = window.event.srcElement.offsetTop;

		}
	}
	//var endtimer = gettime()
	//var showtime = (endtimer - starttimer);
	//alert("onmouseover took = " + showtime);
	//window.status = "onmouseover = " + showtime;
}

function thebody_onmousemove()  {
	//var LeftBound = (GetAbsoluteX(document.getElementById("midlinkstable")) + 10);
	//var TopBound = 97;
	//var RightBound = (GetAbsoluteX(document.getElementById("midlinkstable")) + 10 + document.getElementById("midlinkstable").offsetWidth);
	//window.status = "leftB = " + LeftBound + " | TopB = " + TopBound + " | RightB = " + RightBound
	//window.status = "x = " + window.event.x + " | y = " + window.event.y;
	//window.status = "Height = " + document.getElementById("midlinkstable").offsetHeight + "Width = " + document.getElementById("midlinkstable").offsetWidth + "top = " + document.getElementById("midlinkstable").offsetTop
	//window.status = "id = " + window.event.srcElement.id;
	//window.status = "SubMenuVisible = " + SubMenuVisible
	if (SubMenuVisible)  {
		var testid ;
		testid = window.event.srcElement.id
		if (window.event.srcElement.tagName == "TD") {
			var test ;
			test = GetTable(window.event.srcElement);
			testid = test.id;
		}

		if (testid.indexOf("midlinkstable") == -1 && window.event.srcElement.id != "outermostcell")  {
			//window.status = "call HideSubs";
			HideSubs();
			SubMenuVisible = false;
		}
	}
}

function ChangeBG_onmouseout(IsThereSubs)   {
	//HideSubs();
	//alert("hide = " + tableobj.id + "_" + window.event.srcElement.id);
	//HideMenu();
	window.event.srcElement.style.backgroundColor  = "#999999";
	document.Form1.style.cursor = "auto";
	window.status = "";
}

function HideSubs()  {
	//var starttimer = gettime()
	//alert("hiding allsubs");
	//----- START HANDLES WHEN YOU ADD ALL SUB TABLES TO NEW DIVcontainer ----------------
	if (window.event.srcElement.id == "thebody") {
		for (var elenum = 0; elenum < DIVcontainer.all.length; elenum++)  {
			if (DIVcontainer.all(elenum).tagName == "TABLE")  {
				if (DIVcontainer.all(elenum).id.indexOf("midlinkstable_") != -1)  {
					DIVcontainer.all(elenum).style.visibility = "hidden";
				}
			}
		}
	}
	
	if (window.event.srcElement.id != "thebody") {
		var thetable = GetTable(window.event.srcElement);
		if (thetable != "this table is undefined")  {
			var tablename = thetable.id;
			//alert(tablename);
			//alert("length" + DIVcontainer.all.length);
			for (var elenum = 0; elenum < DIVcontainer.all.length; elenum++)  {
				if (DIVcontainer.all(elenum).tagName == "TABLE")  {
					//alert("DIVcontainer.all(elenum).id  = " + DIVcontainer.all(elenum).id  + " | tablename = " + tablename + " | tablename_srcElementid = " + tablename + "_" + window.event.srcElement.id);
					if ((DIVcontainer.all(elenum).id != tablename) && (DIVcontainer.all(elenum).id != tablename + "_" + window.event.srcElement.id))  {
						//alert(DIVcontainer.all(elenum).id + " | indexOf = " + DIVcontainer.all(elenum).id.indexOf("midlinkstable_"));
						//if (DIVcontainer.all(elenum).id.indexOf("midlinkstable_") != -1)  {
							//alert((tablename + " | " + DIVcontainer.all(elenum).id) + " | " + tablename.indexOf(DIVcontainer.all(elenum).id));
							if (tablename.indexOf(DIVcontainer.all(elenum).id) == -1)  {
								//alert("hiding it");
								DIVcontainer.all(elenum).style.visibility = "hidden";
							}
							if (tablename.indexOf(DIVcontainer.all(elenum).id) != -1)  {
								//alert("showing it --> id = " + DIVcontainer.all(elenum).id);
								DIVcontainer.all(elenum).style.visibility = "visible";
							}
						//}
					}
				}
			}
		}
	}	
	//----- END HANDLES WHEN YOU ADD ALL SUB TABLES TO NEW DIVcontainer ----------------

	//var endtimer = gettime()
	//var showtime = (endtimer - starttimer);
	//window.status = "hidesubs = " + showtime;
}

function IsPopupBlocker() {
	var oWin = window.open("","testpopupblocker","width=100,height=50,top=5000,left=5000");
	if (oWin==null || typeof(oWin)=="undefined") {
		return true;
	} else {
		oWin.close();
		return false;
	}
}

function CheckIsPopupBlocker()  {
	if (IsPopupBlocker()) {
		alert("Please disable your popup blocking software in order to view the requested page.");
		return true;
	} 
	else  {
		return false;
	}
}

function GoToLink(strLink)   {
	if (CheckIsPopupBlocker() == false)  {
		if (window.event.srcElement.id == "Home")  {
			window.location.href = "http://www.pa1call.org";
		}
		else	window.open(strLink);
	}
}

function GetAbsoluteX(pObject)  {
	var ParentObject = pObject
	var RetX = 0

	do  {
		if (ParentObject.tagName != "TR") {		
			RetX = RetX + ParentObject.offsetLeft
		}
		ParentObject = ParentObject.parentElement
	}
	while (ParentObject.tagName != "BODY")	
	
	return RetX;
}


function GetAbsoluteY(pObject)  {
	var ParentObject = pObject.parentElement
	var RetY = 0
	
	do  {
		if (ParentObject.tagName != "TD") {		
			RetY = RetY + ParentObject.offsetTop
		}
		ParentObject = ParentObject.parentElement
	
	}
	while (ParentObject.tagName != "BODY")	
	
	return RetY;
}	
/* ----------END - handles NON-CSS menus and sub-menus--------------------------------------*/
function alternatebackground(bubbleobject,flag){
	b=document.getElementById(bubbleobject.id);
	color=b.id.replace('bubble','');
	if (flag==1){
		b.background="../WebSite/WhiteBubbles/" + color + "over2.png"; 
		//b.className="bubblelinkalt"; 
		//b.onclick='alert("' + b.innerHTML + '")';
		l=b.getElementsByTagName('a')
		//b.onclick="window.location='l[0].href'"		
	}
	else {
		b.background="../WebSite/WhiteBubbles/" + color + ".png"; 
		//b.className="bubblelink";
	}
}
function Form1_onsubmit() {
	gobutton_onclick();
}

function gobutton_onclick() {
	//window.open("content.aspx?pg=search&f=" + Trim(document.Form1.searchbox.value) + "); 
	if (document.Form1.searchbox.value != "") {
		window.open("content.aspx?pg=search&f=" + document.Form1.searchbox.value);
	}
	else {
		alert("Please enter your search criteria.");
		document.Form1.searchbox.focus();
	}
}