// Menu Functions

// Hides the graphical "banner", and replaces the text in the Msg element with the passed text.
function msgText(txtMsg) {
	var Banner=document.getElementById("Banner");
	var Msg=document.getElementById("Msg");
	if (Banner != null) {Banner.style.visibility=((txtMsg.length == 0) ? "visible" : "hidden");}
	if (Msg != null) Msg.innerHTML=txtMsg;
}

function imgOver(navid, msg) { //depracated, should be able to delete soon, not doing image rollovers
	var nav=document.getElementById(navid);  //navigation image
	if (nav==null) return;
	var anavid="a"+navid;
	var anav=document.getElementById(anavid); //<A> tag related to image
	var ynavimg="/img/y"+navid+".gif"; // rollover image
	nav.src=ynavimg;
	anav.style.color="yellow";
	msgText(msg);
}

function imgOut(navid) { //deprecated, should be able to delete soon
	var nav=document.getElementById(navid);  //navigation image
	if (nav==null) return;
	var anavid="a"+navid;
	var anav=document.getElementById(anavid); //<A> tag related to image
	var navimg="/img/"+navid+".gif"; // rollover image
	nav.src=navimg;
	anav.style.color="";
	msgText("");
}

function linkCheckCart(anavid) {
	if (parent.ex_list==null) {return true;}
	var objForm=parent.ex_list.document.PartsForm;
	var anav=document.getElementById(anavid);
	var numChecked=0;
	var i;
	for (i=0; i<objForm.PartsList.length; i++){ //search for checked parts
		if (objForm.PartsList[i].checked) numChecked++;
	}
	if (numChecked==0) {
		return true;
	}
	else {
		var msg="You still have "+numChecked + (numChecked==1 ? " item" : " items") + " checked, but have not yet saved to your Shopping Cart. Click OK to add the"+(numChecked==1 ? " item" : " items")+" to your Shopping Cart, or click CANCEL to discard your selection.";
		var confirmResponse=window.confirm(msg);
		if (confirmResponse) {
			var LinkURL=parent.ex_list.document.PartsForm.LinkURL;
			LinkURL.value=anav.getAttribute("href");
			objForm.submit();
			return false;
		}
		else {
			return true;
		}		
	}
}

function navOver(anavid, msg) { //replaces imgOver, no rollover
	var anav=document.getElementById(anavid); //<A> tag to change
	anav.style.color="yellow";
	msgText(msg);
}

function navOut(anavid) {
	var anav=document.getElementById(anavid); //<A> tag
	anav.style.color="";
	msgText("");
}

function trim(inString)
{//this function trims off leading and trailing spaces
inString = inString.toString();
var x = inString.length - 1;
var y = inString.charAt(x);
while (y == " ")
	{
	inString = inString.substring(0,x);
	x = x - 1;
	y = inString.charAt(x);
	}
x = inString.length;
y = inString.charAt(0);
while (y == " ")
	{
	inString = inString.substring(1,x);
	y = inString.charAt(0);
	}
return inString;
}
