function setPaymentInfo(isChecked)
{
	with (window.document.frmCheckout) {
		if (isChecked) {
			od_shipping_first_name.value  = od_customer_first_name.value;
			od_shipping_last_name.value   = od_customer_last_name.value;
			od_shipping_address1.value   = od_customer_address1.value;
			od_shipping_address2.value   = od_customer_address2.value;
			od_shipping_company_name.value   = od_company_name.value;
			od_shipping_phone.value      = od_customer_phone.value;
			od_shipping_state.value       = od_customer_state.value;
			od_shipping_city.value      = od_customer_city.value;	
			od_shipping_postal_code.value = od_customer_postal_code.value;
			
			od_shipping_first_name.readOnly  = true;
			od_shipping_last_name.readOnly   = true;
			od_shipping_address1.readOnly   = true;
			od_shipping_address2.readOnly   = true;
			od_shipping_phone.readOnly      = true;
			od_shipping_city.readOnly      = true;			
			freezeList(od_shipping_state);
			od_shipping_postal_code.readOnly = true;			
		} else {
			od_shipping_first_name.readOnly  = false;
			od_shipping_last_name.readOnly   = false;
			od_shipping_address1.readOnly   = false;
			od_shipping_address2.readOnly   = false;
			od_shipping_company_name.readOnly      = false;
			od_shipping_phone.readOnly      = false;
			od_shipping_city.readOnly      = false;			
			//od_shipping_state.disabled       = false;
			//makeEnable();
			od_shipping_postal_code.readOnly = false;
			od_shipping_first_name.value  = "";
			od_shipping_last_name.value   = "";
			od_shipping_address1.value   = "";
			od_shipping_address2.value   = "";
			od_shipping_company_name.value      = "";
			od_shipping_phone.value      = "";
			od_shipping_city.value      = "";			
			od_shipping_state.value       = "";
			od_shipping_postal_code.value = "";
		}
	}
}


function checkShippingAndPaymentInfo()
{
	with (window.document.frmCheckout) {
		if (isEmpty(od_customer_first_name, 'Enter First Name')) {
			return false;
		} else if (isEmpty(od_customer_last_name, 'Enter Last Name')) {
			return false;
		} else if (isEmpty(od_customer_address1, 'Enter Customer Address')) {
			return false;
		} else if (isEmpty(od_customer_phone, 'Enter Phone Number')) {
			return false;
		} else if (isEmpty(od_customer_city, 'Enter Customer Address City')) {
			return false;
		} else if (isEmpty(od_customer_state, 'Enter Customer Address State')) {
			return false;
		} else if (isEmpty(od_customer_postal_code, 'Enter the Customer Address Postal/Zip Code')) {
			return false;
		}
		else if (isEmpty(od_shipping_first_name, 'Enter First Name')) {
			return false;
		} else if (isEmpty(od_shipping_last_name, 'Enter Last Name')) {
			return false;
		} else if (isEmpty(od_shipping_address1, 'Enter Shipping Address')) {
			return false;
		} else if (isEmpty(od_shipping_phone, 'Enter Phone Number')) {
			return false;
		} else if (isEmpty(od_shipping_city, 'Enter Shipping Address City')) {
			return false;
		} else if (isEmpty(od_shipping_state, 'Enter Shipping Address State')) {
			return false;
		} else if (isEmpty(od_shipping_postal_code, 'Enter the Shipping Address Postal/Zip code')) {
			return false;
		} 
	}
	window.document.frmCheckout.submit();
}

function validatecardinfo()
{
	with (window.document.frmCreditinfo) 
	{
		if (isEmpty(cc_hname, 'Enter Card holder First Name')) 
		{
			return false;
		}else if (isEmpty(cc_lname, 'Enter Card holder Last Name')) {
			return false;
		}
		else if (isEmpty(billing_street_address, 'Enter Billing Street Address')) {
			return false;
		}else if (isEmpty(billing_state, 'Select Billing State')) {
			return false;
		}else if (isEmpty(billing_zip_code, 'Enter Billing Zip Code')) {
			return false;
		}else if (isEmpty(cc_number, 'Enter Credit Card Number')) {
			return false;
		}else if (isEmpty(cc_cvn, 'Enter Card verification number')) {
			return false;
		}
	}
	window.document.frmCreditinfo.submit();
}

function validateecheckinfo(frm)
{
	
	if(frm.bank_aba_code.value=='')
	{
		alert("Please Enter Bank ABA Routing Number");
		frm.bank_aba_code.focus;
		frm.bank_aba_code.select();
		return false;
	}
	if(frm.bank_acct_num.value=='')
	{
		alert("Please Enter Bank Account Number");
		frm.bank_acct_num.focus;
		frm.bank_acct_num.select();
		return false;
	}
	if(frm.bank_acct_type.value=='')
	{
		alert("Please Select Bank Account Type");
		frm.bank_acct_num.focus;
		frm.bank_acct_num.select();
		return false;
	}
	if(frm.bank_name.value=='')
	{
		alert("Please Enter Bank Name");
		frm.bank_name.focus;
		frm.bank_name.select();
		return false;
	}
	if(frm.bank_acct_name.value=='')
	{
		alert("Please Enter Bank Account Name");
		frm.bank_acct_name.focus;
		frm.bank_acct_name.select();
		return false;
	}
	window.document.frmecheckinfo.submit();
}

function customerRegstnInfo(thisform)
{
	
	with (thisform) {
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if (isEmpty(cust_fname, 'Enter First Name')) {
			return false;
		} else if (isEmpty(cust_lname, 'Enter Last Name')) {
			return false;
		}else if (isEmpty(cust_email, 'Enter Email Address')) {
			return false;
		} else if (reg.test(thisform.cust_email.value) == false) {
			alert('Invalid Email Address');
	  cust_email.focus();
	  cust_email.select();
      return false;
		}else if (isEmpty(cust_address, 'Enter Street Address')) {
			return false;
		} else if (isEmpty(cust_zip, 'Enter Postal/Zip code')) {
			return false;
		} else if (zres = IsPhone(thisform.cust_zip.value)== false) {
			alert("Enter Postal/Zip code");
			thisform.cust_zip.focus();
			thisform.cust_zip.select();
			return false;
		}else if (isEmpty(cust_city, 'Enter  city')) {
			return false;
		}  else if (isEmpty(cust_state, 'Select State')) {
			return false;
		} else if (isEmpty(cust_phone, 'Enter Phone Number')) {
			return false;
		}else if(res = IsPhone(thisform.cust_phone.value)== false )
		{
			alert("Enter Phone Number");
			thisform.cust_phone.focus();
			thisform.cust_phone.select();
			return false;
		}else if (isEmpty(cust_pwd, 'Enter Password')) {
			return false;
		}else if(thisform.cust_pwd.value!=thisform.repassword.value)
	{
		alert('Please Confirm password');
		thisform.repassword.focus();
		thisform.repassword.select();
		return false;
	
		} 
	}
	thisform.submit();
}
function validate(thisform)
{
	with (thisform) {
		var minval = document.getElementById('quantity').value;
		var maxval = document.getElementById('maxqty').value;
		var p_qty  = document.getElementById('product_qty').value;

		if (isEmpty(product_qty, 'Minimum quantity is '+ minval+'')) 
		{
			return false;
		}
		
			//var res = valRange('product_qty', minval, 99999999);
			//alert(product_qty.value);		
			
			if(parseInt(product_qty.value) < parseInt(minval))
			{
				alert("Oops ! Minimum quantity is "+ minval +"");
				product_qty.select();
				product_qty.focus();
				return false;			
			}
			if(parseInt(product_qty.value) > parseInt(maxval))
			{
				alert("Oops ! Maximum quantity is "+ maxval +"");
				product_qty.select();
				product_qty.focus();
				return false;			
			}
		
		if (isEmpty(color, 'Please select color'))
		{
			return false;
		}
		else if(isEmpty(fragrance, 'Please select one Color/Fragrance'))
		{
			return false;
		}
	}
	thisform.submit();
}


function valRange(strFieldName, strMin, strMax) {

	var sValue = document.getElementById(strFieldName).value;
	var blnResult = true;
		if (isNaN(sValue) && isNaN(strMin) && isNaN(strMax) )
		{
					blnResult = false;
		}
		else 
		{
				/*strMin = strMin.toString();
				strMax = strMax.toString();
				sValue = sValue.toString();*/
				if (sValue < strMin ) {
				blnResult = false;
			}
		}
			
	return blnResult;
}

function validate_cart(thisform)
{
	with (thisform) 
	{
			var min_val = document.getElementsByName('mn_qty[]');
			var max_val = document.getElementsByName('mx_qty[]');
			var pdt_qty  = document.getElementsByName('product_qty[]');
			
		for(i=0;i<min_val.length;i++)
		{			
			if(parseInt(pdt_qty[i].value) < parseInt(min_val[i].value))
			{
				alert("Oops ! Minimum quantity is "+ min_val[i].value +"");
				pdt_qty[i].select();
				pdt_qty[i].focus();
				return false;			
			}
			if(parseInt(pdt_qty[i].value) > parseInt(max_val[i].value))
			{
				alert("Oops ! Maximum quantity is "+ max_val[i].value +"");
				pdt_qty[i].select();
				pdt_qty[i].focus();
				return false;			
			}
		}
	}
	thisform.submit();
}

function getshippingrate(shipform)
{
	shipform.submit();
}

function isNumberKey(evt)
{
         
		 var charCode = (evt.which) ? evt.which : event.keyCode
		 var actualkey=String.fromCharCode(charCode);
         if (charCode > 31 && (charCode < 48 || charCode > 57))
		 {
            return false;
		}
		else			
         return true;
		
}

function isEmpty(formElement, message) {
	//formElement.value = trim(formElement.value);
	_isEmpty = false;
	if (trim(formElement.value) == '') {
		formElement.value=trim(formElement.value);
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}



function emptyvalidation(entered, alertbox)
{
	with (entered)
	{
		while (value.charAt(0) == ' ')
			value = value.substring(1);
		while (value.charAt(value.length - 1) == ' ')
			value = value.substring(0, value.length - 1);
		if (value==null || value=="")
		{
			if (alertbox!="") alert(alertbox);
			return false;
		}
		else return true;
	}
}
function isZip(s) 
{

     // Check for correct zip code
     reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);

     if (!reZip.test(s)) {
          alert("Zip Code Is Not Valid");
          return false;
     }

return true;
}
function IsPhone(strString)
{
   var strValidChars = "0123456789()- ";
   var strChar;
   var blnResult = true;

   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1) blnResult = false;
      }
   return blnResult;
}

function trim(str)  
{  
 return str.replace(/^\s+|\s+$/g,'');  
} 
