function isEmpty(s)
{
		return ((s == null) || (s.length == 0))
}


function isWhitespace(s)
{
	var whitespace = " \t\n\r";				
	var i;
    if (isEmpty(s)) return true;

    for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}

function checknsubmit()
{
	var name=document.form1.name.value;
	var email=document.form1.email.value;
	var phone=document.form1.phone.value;
	var primary_address_city=document.form1.primary_address_city.value;
	var primary_address_state=document.form1.primary_address_state.value;
	
	if (isWhitespace(name))
	{
		alert("Please Enter Full Name");
		window.document.form1.name.focus();	
		return(false);
	}					
		if (isWhitespace(email))
	{
		alert("Please Enter Email Address");
		window.document.form1.email.focus();	
		return(false);
	}
	
	
	if (document.form1.email.value.search(/^[A-Z0-9\._-]+@[A-Z0-9\._-]+\.[A-Z]{2,4}$/i)) {
				alert ("Please Enter a Valid Email Address");
				window.document.form1.email.focus();
				return false;
			}
			
	if (isWhitespace(phone))
	{
		alert("Please Enter Phone Number");
		window.document.form1.phone.focus();	
		return(false);
	}
	
	if (isWhitespace(primary_address_city))
	{
		alert("Please Enter City");
		window.document.form1.primary_address_city.focus();	
		return(false);
	}	
	if (isWhitespace(primary_address_state))
	{
		alert("Please Enter State");
		window.document.form1.primary_address_state.focus();	
		return(false);
	}
	
	
	return(true);
}	





function checkRequired()
{
	theForm = document.form1 ;
	var width = theForm.o_width.value ;
	var height = theForm.o_height.value ;

	var pass = true ; 

	if (width == "")
	{
		alert("Please enter an opening width") ; return false ;
	}
	
	if (height == "")
	{
		
		alert("Please enter an opening height") ;  return false ;
	}

	return pass ; 
}

function checkNum(loc,obj)
{	
	theForm = "document." + loc ;
	objValue = eval(theForm + "." + obj + ".value") ;
	objValue = parseInt(objValue) ; // if there are any alpha character this will remove them without needing to give an error
	eval(theForm + "." + obj + ".value = objValue") ;
 	if(isNaN(objValue)) 
	{   
		alert("Please enter a number."); 

		if (obj == "o_width") {  
			eval(theForm + "." + obj + ".value = ''") ;
		}
		if (obj == "o_height") {  
			eval(theForm + "." + obj + ".value = ''") ;
		}
		if (obj == "qty") {  
			eval(theForm + "." + obj + ".value = 1") ;
		}

	}
}

function minMax(objName, objVal)
{
	theForm = document.form1 ;
	var note = "\n\nWe, most likely, can accomodate your needs. This shopping cart is intended to satisfy popular opening sizes. Please call 1-877-299-1955."
	
	if (objName == "o_width") 
	{
		if (objVal < 18) 
		{ 
			alert("The minimum width for Accordion Shutters is 18 inches.") 
			theForm.o_width.value = 18 ;
		}
		if (objVal > 144) 
		{ 
			alert("The maximum width for Accordion Shutters is 144 inches." + note) 
			theForm.o_width.value = 144 ;
		}
	}
		if (objName == "o_height") 
	{
		if (objVal < 18) 
		{ 
			alert("The minimum height for Accordion Shutters is 18 inches.") 
			theForm.o_height.value = 18 ;
		}
		if (objVal > 144) 
		{ 
			alert("The maximum height for Accordion Shutters is 144 inches." + note) 
			theForm.o_height.value = 144 ;
		}
	}
	
}





