function enableState()
{
   formName  = document.forms['frmCustInfo'];
   if(formName.cust_address_country.value == "United States"){
      formName.cust_address_state.disabled  = false;
   }   
   else{
      formName.cust_address_state.value = "";      
      formName.cust_address_state.disabled  = true;      
   }
   
   if(formName.shipping_address_country.value == "United States"){
      formName.shipping_address_state.disabled = false;
   }   
   else{
      formName.cust_address_state.value = "";        
      formName.shipping_address_state.disabled = true;      
   }
        
}

function setPaymentInfo(isChecked)
{
	with (window.document.frmCustInfo) {
		if (isChecked) {
			shipping_name.value            = cust_name.value;            
			shipping_email.value           = cust_email.value;           
			shipping_phone.value           = cust_phone.value;           
			shipping_fax.value             = cust_fax.value;             
			shipping_address_street.value  = cust_address_street.value;  
			shipping_address_town.value    = cust_address_town.value;    
			shipping_address_state.value   = cust_address_state.value;   
			shipping_address_country.value = cust_address_country.value; 
			shipping_address_po_code.value = cust_address_po_code.value; 
/*			
			shipping_name.readOnly            = true;
			shipping_email.readOnly           = true;
			shipping_phone.readOnly           = true;
			shipping_fax.readOnly             = true;
			shipping_address_street.readOnly  = true;
			shipping_address_town.readOnly    = true;			
			shipping_address_state.readOnly   = true;
			shipping_address_country.readOnly = true;
			shipping_address_po_code.readOnly = true;
					
		} else {
			shipping_name.readOnly            = false;
			shipping_email.readOnly           = false;
			shipping_phone.readOnly           = false;
			shipping_fax.readOnly             = false;
			shipping_address_street.readOnly  = false;
			shipping_address_town.readOnly    = false;			
			shipping_address_state.readOnly   = false;
			shipping_address_country.readOnly = false;	
			shipping_address_po_code.readOnly = false;  
*/				
		}
	}
}

//**********************************************************************************//

function validateShippingInfo()
{
  formName  = document.forms['frmCustInfo'];

// shipping_name
         if (isTextEmpty(formName.shipping_name.value))
         {
           alert('Please enter your full name in shipping information!');
           formName.shipping_name.select();
           return false;
         }

// shipping_email
         if (!isValidEmail(formName.shipping_email.value))
         {
           alert('Please enter a valid email address in shipping information!');
           formName.shipping_email.select();
           return false;
         }        

// shipping_phone
         if (isTextEmpty(formName.shipping_phone.value))
         {
           alert('Please enter your contact no in shipping information!');
           formName.shipping_phone.select();
           return false;
         }

// shipping_address_street
         if (isTextEmpty(formName.shipping_address_street.value) && isTextEmpty(formName.shipping_address_town.value)  && isTextEmpty(formName.shipping_address_po_code.value))
         {
           alert('Please enter the address in shipping information!');
           formName.shipping_address_street.select();
           return false;
         }
/*         
// shipping_address_town
         if (isTextEmpty(formName.shipping_address_town.value))
         {
           alert('Please enter your town/suburb!');
           formName.shipping_address_town.select();
           return false;
         }         

// shipping_address_state
         if (isTextEmpty(formName.shipping_address_state.value))
         {
           alert('Please enter your state!');
           formName.shipping_address_state.select();
           return false;
         }  
*/
// shipping_address_country
         if (isTextEmpty(formName.shipping_address_country.value))
         {
           alert('Please select your country in shipping information!');
           formName.shipping_address_country.focus();
           return false;
         }

// shipping_address_state         
         if (formName.shipping_address_country.value == "United States")
         {
           if (isTextEmpty(formName.shipping_address_state.value))
           {
             alert('Please select your state in shipping information!');
             formName.shipping_address_state.focus();
             return false;
           }
         } 
} 
//**********************************************************************************//

//**********************************************************************************//

function validateBillingAndShippingInfo()
{
  formName  = document.forms['frmCustInfo'];

// cust_name
         if (isTextEmpty(formName.cust_name.value))
         {
           alert('Please enter your full name in billing information!');
           formName.cust_name.select();
           return false;
         }

// cust_email
         if (!isValidEmail(formName.cust_email.value))
         {
           alert('Please enter a valid email address in billing information!');
           formName.cust_email.select();
           return false;
         }        

// pass_word
         if (!checkPassword(formName.pass_word.value))
         {
           formName.pass_word.focus();
           return false;
         }

// cpass_word
         if (isTextEmpty(formName.cpass_word.value))
         {
           alert('Please confirm your password!');
           formName.cpass_word.focus();
           return false;
         }

// cpass_word
         if (formName.pass_word.value != formName.cpass_word.value)
         {
           alert('The password and confirm password are not the same!');
           formName.cpass_word.focus();
           return false;
         }

// cust_phone
         if (isTextEmpty(formName.cust_phone.value))
         {
           alert('Please enter your contact no in billing information!');
           formName.cust_phone.select();
           return false;
         }

// cust_address_street , cust_address_town , cust_address_po_code
         if (isTextEmpty(formName.cust_address_street.value) && isTextEmpty(formName.cust_address_town.value)  && isTextEmpty(formName.cust_address_po_code.value))
         {
           alert('Please enter the address in billing information!');
           formName.cust_address_street.select();
           return false;
         }

// cust_address_country
         if (isTextEmpty(formName.cust_address_country.value))
         {
           alert('Please select your country in billing information!');
           formName.cust_address_country.focus();
           return false;
         }

// cust_address_state         
         if (formName.cust_address_country.value == "United States")
         {
           if (isTextEmpty(formName.cust_address_state.value))
           {
             alert('Please select your state in billing information!');
             formName.cust_address_state.focus();
             return false;
           }
         } 
         

// shipping_name
         if (isTextEmpty(formName.shipping_name.value))
         {
           alert('Please enter your full name in shipping information!');
           formName.shipping_name.select();
           return false;
         }

// shipping_email
         if (!isValidEmail(formName.shipping_email.value))
         {
           alert('Please enter a valid email address in shipping information!');
           formName.shipping_email.select();
           return false;
         }        

// shipping_phone
         if (isTextEmpty(formName.shipping_phone.value))
         {
           alert('Please enter your contact no in shipping information!');
           formName.shipping_phone.select();
           return false;
         }

// shipping_address_street, shipping_address_town, shipping_address_po_code
         if (isTextEmpty(formName.shipping_address_street.value) && isTextEmpty(formName.shipping_address_town.value)  && isTextEmpty(formName.shipping_address_po_code.value))
         {
           alert('Please enter the address in shipping information!');
           formName.shipping_address_street.select();
           return false;
         }

// shipping_address_country
         if (isTextEmpty(formName.shipping_address_country.value))
         {
           alert('Please select your country in shipping information!');
           formName.shipping_address_country.focus();
           return false;
         }

// shipping_address_state         
         if (formName.shipping_address_country.value == "United States")
         {
           if (isTextEmpty(formName.shipping_address_state.value))
           {
             alert('Please select your state in shipping information!');
             formName.shipping_address_state.focus();
             return false;
           }
         }         
} 
//**********************************************************************************//
