var poppedMenu = "";
var selWhiteMenu = "";
var popID;
var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

function setCursor() {
	switch (document.title) {
		case ("Newsletter - Aquarius Health Care Videos"): {
			document.forms['newsletter'].emailAddress.focus();
			break;
		}
		case ("Catalog - Aquarius Health Care Videos"): {
			document.forms['requestCatalog'].firstName.focus();
			break;
		}
		case ("New Producer Form - Aquarius Health Care Videos"): {
			document.forms['newProducer'].prodName.focus();
			break;
		}
	}
	/*this fixes the mozilla bug where the table doesn't expand with its content*/

}

function clearSearch(sel) {
	/*Clears search box if default term is in place*/
	if (sel.form.searchTerm.value == 'Use "..." for exact film search')
		sel.form.searchTerm.value = "";
}

function getRef(id)
{
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}

function getSty(id){
	return (isNS4 ? getRef(id) : getRef(id).style);
}

function pop(menuToPop){  //called on white menu mouseover
	parentMenu = getParent(menuToPop); //set new selected white menu variable
	parentRef = getRef(parentMenu);
	if (menuToPop=="gNew"||menuToPop=="gBest"||menuToPop=="gClosed"||menuToPop=="gDVD"||menuToPop=="gWebOnly"){
		parentRef.style.backgroundColor="#006666";
	}else{
		parentRef.style.backgroundColor="#E6E7E8";
	}
	selWhiteMenu = parentMenu;
	if(poppedMenu>""){
		hideMenu(poppedMenu); //first hide any open grey menus
	}
	childRef = getRef(menuToPop);
	childRef.style.top = getTop(getParent(menuToPop));
	popID = setTimeout('childRef.style.visibility = "visible"',200);
	poppedMenu = menuToPop;
}

function hideMenu(menuToHide) {
	clearTimeout(popID);
	menu = getRef(menuToHide);
	parentName = getParent(menuToHide);
	parentMenu = getRef(parentName);
	
	if (!(parentName==selWhiteMenu)){
		
		menu.style.visibility = "hidden";
	if (parentName=="wBest"||parentName=="wNew"||parentName=="wClosed"||parentName=="wDVD"||parentName=="wWebOnly") {
		parentMenu.style.backgroundColor="#336666";
	}else{
		parentMenu.style.backgroundColor="#FFF";
	}
		poppedMenu="";
	}
}
function hideAway(menuToHide){
	if(poppedMenu>""){
	menu = getRef(menuToHide);
	parentName = getParent(menuToHide);
	parentMenu = getRef(parentName);
	menu.style.visibility = "hidden";

	if (parentName=="wBest"||parentName=="wNew"||parentName=="wClosed"||parentName=="wDVD"||parentName=="wWebOnly") {
		parentMenu.style.backgroundColor="#336666";
	}else{
		parentMenu.style.backgroundColor="#FFF";
	}
	poppedMenu="";
	}
}

function getChild (parentName){
	childName = parentName.replace('w','g');
	return childName;
}
function getParent (childName){
	parentName = childName.replace('g','w');
	return parentName;
}

function getTop(objectId) {
	o = document.getElementById(objectId);
	oTop = o.offsetTop;
	while(o.offsetParent!=null) { 
		oParent = o.offsetParent;
		oTop += oParent.offsetTop;
		o = oParent;
	}
	return oTop+'px';
}

function confirmDelete(itemName, addressToGo) {
    checkString = "Delete "+ itemName +" (and any contents)?";

    if(confirm(checkString)) {
    	location=addressToGo;
    }
}

