
var agt=navigator.userAgent.toLowerCase();
var is_ie =((agt.indexOf("msie 5.5\; windows nt 5.0")!= -1) || (agt.indexOf("msie 5.01\; windows nt 5.0")!= -1));  
function win2000() {
	if (is_ie == true) {
		window.open('/security.php3','newin','toolbar=yes,location=top,directories=0,status=0,resizable=yes,menubar=yes,scrollbars=yes,width=350,height=200');
	}
}

var selected_option;
function changeMenu(menuNum,subMenuName,formName,productNum,itemNum) {

	//mysubMenu = eval('document.' + formName + '.' + subMenuName);
	mysubMenu = document[formName][subMenuName];

	//alert (subMenuName);
	for (i=mysubMenu.options.length-1;i>0;i--){
		mysubMenu.options[i]=null
		}
		
	for (i=0;i<eval('menu'+productNum)[menuNum].length;i++){
		mysubMenu.options[i]=new Option(eval('menu'+productNum)[menuNum][i].text,eval('menu'+productNum)[menuNum][i].value)
		}
		
	mysubMenu.selectedIndex=0
	
}


function selectmenu(mySelect){
	
	//alert ('2selected option is ' + selected_option);
	formName = mySelect.form.name;
	//alert ('2 formname is '+formName);
	str_params = mySelect.options[mySelect.selectedIndex].value;
	params = str_params.split(',');
	selected_option = params[4].substr(0,params[4].indexOf(')'));
	if (mySelect.options[mySelect.selectedIndex].value == "null"){
		alert('Select a topMenu');
		}
	else{
		window.top.location.href = mySelect.options[mySelect.selectedIndex].value;
		mySelect.options[mySelect.selectedIndex].value = selected_option;
	}
		
	return formName;
}

function check_options(thisform) {

	var error_message = '';
	
	//alert("checking options for " + thisform);
	
	theForm = document.forms[thisform];
	
	for (formElementCounter = 0; formElementCounter < theForm.elements.length; formElementCounter++)
	{
		theElement = theForm.elements[formElementCounter];
		elementName = new String(theElement.name);
		elementID = new String(theElement.id);
		//alert("checking " + elementName);
		if (theElement.name.indexOf("*") == 0) { //a required attribute
			if (theElement.type == "select-one"){
				thisvalue = theElement.options[theElement.selectedIndex].value;
			} else {
				thisvalue = theElement.value;
			}
			
			//alert(elementName + "is required " + theElement.type + " value is *" +thisvalue+ "*");
			//alert (where_change);
			if ((thisvalue == '') || (thisvalue == 'null')){
				if ((elementID != '') && (elementID != 'undefined')) {
					error_message += elementID +"\n";
				} else {
					error_message += str_replace("_"," ",elementName)+"\n";
				}
				//alert(error_message);
			}
			
		}
	}
	
	if (error_message != '') {
		alert("Please select the following required options:"+"\n"+error_message);
		return false;
	} else {
		return true;
	}

}

function toggleDiv(whichLayer, action) {

	if (document.getElementById) {
	 	//this is the way the standards work
		var divtag = document.getElementById(whichLayer);
	} else 
	if (document.all) {
		// this is the way old msie versions work
		var divtag = document.all[whichLayer];
	} else if (document.layers) {
		// this is the way nn4 works
		var divtag = document.layers[whichLayer];
	}
	
	style2 = divtag.style;

	if (!action) { //just toggle
		if (style2.display == "block") {
			//alert("1 style2.display "+style2.display);
			style2.display = "none";
		} else {
			//alert("2 style2.display "+style2.display);
			style2.display = "block";
		}
	} else { //show or hide
		if (action == 'show')
			style2.display = "block";
		else
			style2.display = "none";
	}
	
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function displayWindow(url, width, height) {
  var Win = window.open(url,"popupWindow",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes');
  window.name='parent';

}

function updatecart_js(code,form) {
	
	_uacct=code;
	_udn="none";
	_ulink=1;
	__utmLinkPost(form);
	
}

function checkout_test(zip,country) {
	
	okay = true;
	if (check_simple_options()) { 
		if ((zip == '') || (country == '')) { 
			alert ('Please enter your Zip/Postal Code and Country Code before proceeding.'); 
			okay = false;
		}
	} else	{
		okay = false;
	}
	
	return okay;
}

function check_simple_options() {

	okay = 1;
	
	count = 0;
	option1 = document.getElementById("option1_"+count);
	while (option1){
		value = option1[option1.selectedIndex].value;
		if (!value) {
			okay = 0;
			break;
		}
		count++;
		option1 = document.getElementById("option1_"+count);
	}

	if (okay) {
		count = 0;
		option2 = document.getElementById("option2_"+count);
		while (option2){
			value = option2[option2.selectedIndex].value;
			if (!value) {
				okay = 0;
				break;
			}
			count++;
			option2 = document.getElementById("option2_"+count);
		}
	}
	
	if (okay) {
		count = 0;
		option3 = document.getElementById("option3_"+count);
		while (option3){
			value = option3[option3.selectedIndex].value;
			if (!value) {
				okay = 0;
				break;
			}
			count++;
			option3 = document.getElementById("option3_"+count);
		}
	}
	
	if (okay) {
		return true;
	} else {
		alert("Some items have options that you have not selected. Please select options for all items.");
		return false;
	}
		
}