
function popWindow(theURL, winName, features) {
	window.open(theURL, winName, features);
}


POPUP_W = 420;
POPUP_H = 400;
POPUP_SCROLL = true;
POPUP_EXTRAS = 'location=0,statusbar=0,menubar=0';
// USAGE: popuplink(['non-js url',] this[, w[, h[, scroll[, extras]]]])
function popuplink() {
	var undef, i=0, args=popuplink.arguments;
	var url = (typeof(args[i])=='string') ? args[i++] : args[i].getAttribute('href');
	var target = args[i++].getAttribute('target') || '_blank';
	var w = args[i++];
	var h = args[i++];
	var s = (args[i]===undef) ? POPUP_SCROLL : args[i++];
	var features = 'width=' + (w || POPUP_W)
					+ ',height=' + (h || POPUP_H)
					+ ',scrollbars=' + (s ? 'yes,' : 'no,')
					+ (args[i] || POPUP_EXTRAS);
	var win = window.open(url, target, features);
	win.focus();
	return false;
}

// Header Javascript/dhtml menu code


	var ns4, dom
	if (parseInt(navigator.appVersion) == 4) {
		if (navigator.appName == "Netscape") {
			ns4 = true
		} else {
			dom = true
		}
	}

	
var contentIndex = "";

// mouseover
function swapOld() {
	if (document.images) {
		for (var i=0; i < swapOld.arguments.length; i+=2) {
			document[swapOld.arguments[i]].src = eval(swapOld.arguments[i+1] + ".src");
		}
	}
}

// preload
if (document.images) {
home = new Image(60,9);
home.src = "/_img/template/navMain_home.gif";
home_mo = new Image(60,9);
home_mo.src = "/_img/template/navMain_home.gif";

purchase = new Image(147,9);
purchase.src = "/_img/template/navMain_purchase.gif";
purchase_mo = new Image(147,9);
purchase_mo.src = "/_img/template/navMain_purchase.gif";

company = new Image(114,9);
company.src = "/_img/template/navMain_company.gif";
company_mo = new Image(114,9);
company_mo.src = "/_img/template/navMain_company.gif";

learn = new Image(106,9);
learn.src = "/_img/template/navMain_learn.gif";
learn_mo = new Image(106,9);
learn_mo.src = "/_img/template/navMain_learn.gif";

support = new Image(77,9);
support.src = "/_img/template/navMain_support.gif";
support_mo = new Image(77,9);
support_mo.src = "/_img/template/navMain_support.gif";

}

function popWindow(theURL,winName,features) {
	window.open(theURL,winName,features);
}


//begin rollover code
function imageLoader(a) {
	if (document.images) {
		if (!document.p) document.p=new Array();
		var i, j=document.p.length;
		for (i=0; i < a.length; i++)
			if (a[i].indexOf("#")!=0) { document.p[j] = new Image; document.p[j++].src = a[i]; }
	}
}
function preloadImages() {
	imageLoader(preloadArray);
}

// list images to preload here:
var preloadArray = ["/_img/template/navMain_home.gif",
"/_img/template/navMain_purchase.gif",
"/_img/template/navMain_company.gif",
"/_img/template/navMain_learn.gif",
"/_img/template/navMain_support.gif"];

// start preloading images after page load
if (window.addEventListener) {
	window.addEventListener("load", preloadImages, true);
} else if (window.attachEvent) {
	window.attachEvent("onload", preloadImages);
} else {
	window.onload = preloadImages;
}

HOVER_X = "_mo"; // mouse-over extension
// USAGE: swap(this, ['newimage.gif'])
function swap(i) {
	if (document.images && i.childNodes) {
		var a = swap.arguments[1], s = i.childNodes[0];
		if (a) s.src = a;
		else {
			var x = s.src.lastIndexOf('.'), xl = HOVER_X.length;
			if (s.src.substring(x-xl, x) == HOVER_X)
				s.src = s.src.substring(0,x-xl)+s.src.substring(x,s.src.length);
			else s.src = s.src.substring(0,x)+HOVER_X+s.src.substring(x,s.src.length);
		}
	}
}
//end rollover code

// dhtml flyout menu; old codebase.

var activeSub=0;
var SubNum=0;

//Define global variables
var timerID = null;
var timerOn = false;
var timecount = 4000;
var what = null;
var newbrowser = true;
var check = false;
var selectvisible = true;
var monthselectvisible = true;
var screenSize = 2000;
var menuTop = 48;

function reDo(){ if((check) && (what!="ns4")) window.location.reload() }
window.onresize = reDo;


function init() {

	if (document.layers) {
		layerRef="document.layers";
		styleSwitch="";
		visibleVar="show";
		screenSize = window.innerWidth;
		what ="ns4";
		menuTop = 116;
		//alert('layers!');

	} else if(document.all) {
		layerRef="document.all";
		styleSwitch=".style";
		visibleVar="visible";
		screenSize = document.body.clientWidth + 18;
		what ="ie";
		//alert('all!');

	} else if(document.getElementById) {
		layerRef="document.getElementByID";
		styleSwitch=".style";
		visibleVar="visible";
		what="moz";
		//alert('id!');

	} else {
		what="none";
		newbrowser = false;
		//alert('you are false!');
	}

	if(newbrowser && (what!="ns4"))	{
		// Use the values below to set the menu position for IE (mac and pc) and use the css file for all other browsers.
		// The values won't be exactly the same, but they are close
		positionLayer('navHome',178);
		positionLayer('navPurchase',248);
		positionLayer('navCompany',407);
		positionLayer('navLearn',530);
		positionLayer('navSupport',625);

		document.body.onmouseup = closeMenus;
	}
	check = true;
}

// set left and top for a layer
function positionLayer(layerName,leftOffset)
{
	if (what =="none") return;
	else if (what == "moz")
	{
		document.getElementById(layerName).style.top = menuTop;
		document.getElementById(layerName).style.left = ((screenSize-760)/2)+leftOffset;
	}
	else
	{
		eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.top="'+menuTop+'px"');
		eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.left="'+(((screenSize-760)/2)+leftOffset)+'px"');
	}	
}



// Makes the Sub-Category pulldown select box invisible
// should only be called on IE browsers
function hideSortSelect() {
	//alert(document.forms.length);
	//alert(document.forms[0].elements.length);
	//alert(document.forms[0].elements[1].name);                              //"site" is the name of the form element to hide
	if ((document.forms.length > 0)&&(document.forms[0].elements.length > 0)&&((document.forms[0].elements[1].name=="sort"))) {
		eval(layerRef+'["sortHider"]'+styleSwitch+'.visibility="hidden"');
		selectvisible = false;
		//alert('selectvisible is:' + selectvisible);
	}
}

function hideMonthSelect() {
	//alert(document.forms.length);
	//alert(document.forms[0].elements.length);
	//alert(document.forms[0].elements[1].name);                              //"site" is the name of the form element to hide
	if ((document.forms.length > 0)&&(document.forms[0].elements.length > 0)&&((document.forms[0].elements[2].name=="monthyearselect"))) {
		eval(layerRef+'["monthHider"]'+styleSwitch+'.visibility="hidden"');
		monthselectvisible = false;
		//alert('selectvisible is:' + selectvisible);
	}
}



// Makes the Sub-Category pulldown select box visible
// should only be called on IE browsers
function showSortSelect() {
	if ((document.forms.length > 0)&&(document.forms[0].elements.length > 0)&&((document.forms[0].elements[1].name=="sort"))) {
		eval(layerRef+'["sortHider"]'+styleSwitch+'.visibility="visible"');
		selectvisible = true;
	}
}

// Makes the Sub-Category pulldown select box visible
// should only be called on IE browsers
function showMonthSelect() {
	if ((document.forms.length > 0)&&(document.forms[0].elements.length > 0)&&((document.forms[0].elements[2].name=="monthyearselect"))) {
		eval(layerRef+'["monthHider"]'+styleSwitch+'.visibility="visible"');
		monthselectvisible = true;
	}
}



// Turns the layers on and off
function showLayer(layerName) {

	if((check)&&(what!="ns4")) {
		hideAll();
		if (what =="none") return;
		else if (what == "moz")	{
			document.getElementById(layerName).style.visibility="visible";
		} else {
			eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
			//if (  (what=="ie") && (eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.left').substring(0,eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.left').length-2)>650) )
			if (layerName=="navAbout") {
				if(location.href.indexOf("/laopera/index.aspx") > -1){
				hideSortSelect();
				}
			}
		}

	} else {
		return;
	}
	stopTime();
}

function hideLayer(layerName) {
	if((check)&&(what!="ns4")) {
		if (what =="none") return;
		else if (what == "moz") document.getElementById(layerName).style.visibility="hidden";
		else eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
		if (selectvisible==false) {
			//alert('should be happening');
			showSortSelect();
		}
		
		if (monthselectvisible==false) {
			//alert('should be happening');
			showMonthSelect();
		}

	} else {
		return;
	}
}

function hideAll() {
	hideLayer('navHome');
	hideLayer('navPurchase');
	hideLayer('navCompany');
	hideLayer('navLearn');
	hideLayer('navSupport');
}

function closeMenus() {

	
	if(check){
		hideAll();
	}
}

function startTime() {

	if (what=="ns4") {
		closeMenus();
	} else if (timerOn == false) {
		timerID=setTimeout( "closeMenus()" , timecount);
		timerOn = true;
	}
}

function stopTime() {
	if (timerOn) {
		clearTimeout(timerID);
		timerID = null;
		timerOn = false;
	}
}

function onLoad() {
	init();
}