   NS4 = (document.layers);
   IE4 = (document.all);
  ver4 = (NS4 || IE4);   
 isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (NS4 || (IE4 && !isMac ));     

if (document.images){
	// On images
	store_front_on = new Image(130,20);
	store_front_on.src = "graphics/mmui/store_front_on.gif";
	search_on = new Image(90,20);
	search_on.src = "graphics/mmui/search_on.gif";
	basket_contents_on = new Image(160,20);
	basket_contents_on.src = "graphics/mmui/basket_contents_on.gif";
	your_account_on = new Image(150,20);
	your_account_on.src = "graphics/mmui/your_account_on.gif";
	check_out_on = new Image(110,20);
	check_out_on.src = "graphics/mmui/check_out_on.gif";
	add_to_basket_on = new Image(130,20);
	add_to_basket_on.src = "graphics/mmui/add_to_basket_on.gif";
	help_on = new Image(22,22);
	help_on.src = "graphics/mmui/help_on.gif";
	continue_shopping_on = new Image(210,20);
	continue_shopping_on.src = "graphics/mmui/continue_shopping_on.gif";
	close_on = new Image(63,20);
	close_on.src = "graphics/mmui/close_on.gif";

	// Off images
	store_front_off = new Image(130,20);
	store_front_off.src = "graphics/mmui/store_front_off.gif";
	search_off = new Image(90,20);
	search_off.src = "graphics/mmui/search_off.gif";
	basket_contents_off = new Image(160,20);
	basket_contents_off.src = "graphics/mmui/basket_contents_off.gif";
	your_account_off = new Image(150,20);
	your_account_off.src = "graphics/mmui/your_account_off.gif";
	check_out_off = new Image(110,20);
	check_out_off.src = "graphics/mmui/check_out_off.gif";
	add_to_basket_off = new Image(130,20);
	add_to_basket_off.src = "graphics/mmui/add_to_basket_off.gif";
	help_off = new Image(22,22);
	help_off.src = "graphics/mmui/help_off.gif";
	continue_shopping_off = new Image(210,20);
	continue_shopping_off.src = "graphics/mmui/continue_shopping_off.gif";
	close_off = new Image(63,20);
	close_off.src = "graphics/mmui/close_off.gif";
}

//Code For Main Navigation Menus
        
function popUp(){return};
function popDown(){return};
function startIt(){return};

if (!ver4) event = null;        
 

// Functions
      
// Functions to "hilite" images
function Act(imgName){ 
    if (document.images){
	    document[imgName].src = eval(imgName + '_on.src');
	}
}

function InAct(imgName) {
    if (document.images) document[imgName].src = eval(imgName + '_off.src') 
}


// functions that check form entries on cust info
function InfoValidator(theForm){		
	if (theForm.ShipEmail.value == ""){
		alert("Please enter your email address.");
		theForm.ShipEmail.focus();
		return (false);
	}
	else{
	theForm.ShipEmail.value = theForm.ShipEmail.value.toLowerCase() ;
	}
				
	if (theForm.ShipFirstName.value == ""){
		alert("Please enter your first name.");
		theForm.ShipFirstName.focus();
		return (false);
	}
	else{
		theForm.ShipFirstName.value = capitalize(theForm.ShipFirstName.value);
	}
	
	if (theForm.ShipLastName.value == ""){
		alert("Please enter your last name.");
		theForm.ShipLastName.focus();
		return (false);
	}
	else{
		theForm.ShipLastName.value = capitalize(theForm.ShipLastName.value);
	}
	
	if (theForm.ShipPhone.value == ""){
		alert("Please enter your phone number.");
		theForm.ShipPhone.focus();
		return (false);
	}
	
	if (theForm.ShipAddress.value == ""){
		alert("Please enter your street address with any unit or apartment number.");
		theForm.ShipAddress.focus();
		return (false);
	}
	else{
		theForm.ShipAddress.value = findwords(theForm.ShipAddress.value);
	}
	
	if (theForm.ShipCity.value == ""){
		alert("Please enter your city.");
		theForm.ShipCity.focus();
		return (false);
	}
	
	if (theForm.ShipState_Select.options[theForm.ShipState_Select.selectedIndex].text == "Select US State"){	
	  if (theForm.ShipCountry.options[theForm.ShipCountry.selectedIndex].text == "United States"){
		alert("Please enter your state or country from the popup lists.");
		theForm.ShipState_Select.focus();
		return (false);
	  }
	}
	
	if (theForm.ShipZip.value == ""){
		alert("Please enter your zip code.");
		theForm.ShipZip.focus();
		return (false);
	}
	if (theForm.ShipEmail.value.length > 0){
		var checkOK = "@";
		var checkStr = theForm.ShipEmail.value;
		var allValid = false;
		for (i = 0;	 i < checkStr.length;  i++){
			ch = checkStr.charAt(i);
			for (j = 0;	 j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j)){
				allValid = true;
				break;	
			}	  
		}
	}
	if (!allValid)
	{
		alert("The email address is in the wrong format! Use the name@company.com format in lower case.");
		theForm.ShipEmail.focus();
		return (false);
	}
	
	return (true);
}
 
 function capitalize(astring){
	var astring = astring.toLowerCase();
	var tempstring = astring.substring(0,1).toUpperCase();
	tempstring += astring.substring(1);
	return (tempstring);
}
 
function findwords(theString){
	var firstposition = 0;
	var tempstring = "";
	do {
	theString = capitalize( theString );
	firstposition = theString.indexOf(" ");
	if (firstposition != -1){
		tempstring += theString.substring(0,firstposition + 1);
		theString = theString.substring( firstposition + 1 );
	}
	}while ( theString.indexOf(" ") != -1 )tempstring += capitalize( theString );

	return(tempstring)
}
        
        
if(!orderform){
	var orderform;
}

function closeOrderForm(){
	if(!orderform || orderform.closed){}
	else{
		orderform.close();
	}
}

function openOrderForm(color,cat_code){
	var tempURL ="/Merchant2/order_form.mv?";
	tempURL += "form_color=" + color;
	tempURL += "&Category_Code=" + document.order.Category_Code.value;
	tempURL += "&Store_Code=" +  document.order.Store_Code.value;
	
	if(!orderform || orderform.closed){
		orderform = window.open(tempURL,"OrderForm","menubar,height=440,width=600");
		orderform.focus();
	}
	else{
		orderform.focus();
		orderform.location=(tempURL);
	}
}


function validateEmail(email){
	email.value=email.value.toLowerCase();
	if (email.value.length > 9){
		if((email.value.indexOf("@") > 1) && (email.value.indexOf(".") > 0)){
			return true;		
		}
		else{
			alert("Invalid email address format. Should be in the form of \'user@domain.com\'.");
			email.focus();
			return false;
		}
	}
	else{
		alert("Invalid email address format. Should be in the form of \'user@domain.com\'.");
		email.focus();
		return false;
	}

}

// capitalize the first letter of a string and make the rest lowercase
 function capitalize(astring){
	astring=astring.toLowerCase();
	var tempstring=astring.substring(0,1).toUpperCase();
	tempstring += astring.substring(1);
	return (tempstring);
}
 
function findwords(theString){
	var firstposition = 0;
	var tempstring = "";
	do{
		theString.value = capitalize( theString.value );
		firstposition = theString.value.indexOf(" ");
		if (firstposition != -1){
			tempstring += theString.value.substring(0,firstposition + 1);
			theString.value = theString.value.substring( firstposition + 1 );
		}
	}
	while ( theString.value.indexOf(" ") != -1 )
			
	theString.value = tempstring + capitalize( theString.value );
		
	return(tempstring)
}


