
function isInt(elm) {
	var elmstr = elm.value + ""
	if (elmstr == ""){
		return false
	}
	for (var i = 0; i < elmstr.length; i++) {
		if (elmstr.charAt(i) < "0" || elmstr.charAt(i) > "9") {
			return false
		}    
	}
return true
}

function isNumeric(s) {
	var elmstr = s + ""
	if (elmstr == ""){
		return false
	}
	for (var i = 0; i < elmstr.length; i++) {
		if (elmstr.charAt(i) < "0" || elmstr.charAt(i) > "9") {
			return false
		}    
	}
return true
}

function isEmail(elm) {
	if (elm.value.indexOf("@") + "" != "-1" &&
        	elm.value.indexOf(".") + "" != "-1" &&
	        elm.value.length >= 7){ 
	    	return true
	}
	else{
		return false
	}
}

function isPhone(s){
var str1;
	str1 = s;
   if ((str1.length > 11) && (isNumeric(str1.substring(0,3))) && (isNumeric(str1.substring(4,7))) 
   && ( (isNumeric(str1.substring(8,12))) && (str1.charAt(3)=="-") && (str1.charAt(7)=="-") ) || 
   ((isNumeric(str1.substring(10,14))) && (str1.charAt(0)=="(") && (str1.charAt(4)==")") && (str1.charAt(9)=="-") )    ) {
	    	return true
	}
	else{
		alert("Please enter the Correct Phone Number with Area Code.(i.e.: (999) 999-1234 or 999-999-1234 ) ");
    	//alert("Please enter correct Phone Number with Area Code.\n For example: 777-777-7777");
		return false
	}
}

function Validate_Info(form){
   if (form.name.value==""){
      alert("Please enter the First Name & Last Name.");
      form.name.focus();
      return (false);}  
   if (form.address.value==""){
      alert("Please enter the  Address.");
      form.address.focus();
      return (false);}  
   if (form.city.value==""){
      alert("Please enter the City.");
      form.city.focus();
      return (false);}  
   if (form.state.value==""){
      alert("Please enter the State.");
      form.state.focus();
      return (false);}  
   if (form.zip.value==""){
      alert("Please enter the Zip.");
      form.zip.focus();
      return (false);}  
   if (form.country.value==""){
      alert("Please enter the Country.");
      form.country.focus();
      return (false);}  
   if (form.phone.value==""){
      alert("Please enter your Phone Number.");
      form.phone.focus();
      return (false);}  
   if (!isPhone(form.phone.value)){
      form.phone.focus();
      return (false);}  

   if(!isEmail(form.email)){
    alert("Please enter a valid email address.(e.g.: johndoe@yahoo.com). An order confirmation will be sent to this email address.");
    form.email.focus();
    return (false);}  

		if(form.email.value!=form.confirm_email.value){
    alert("Please confirm your email address.");
    form.confirm_email.focus();
    return (false);}  

 } 
