//**********************************************************************************//
Cart.addToCartHandler = function(shopType, id){
   
   if (XMLHTTP.xmlHttpObj.readyState==4 || XMLHTTP.xmlHttpObj.readyState=="complete") { 
      if (shopType == "ecpdSignup"){
         eval("var resultObj = " + XMLHTTP.xmlHttpObj.responseText);
         if (resultObj.status == "not logged in") {
            var xUrl = "index.php?_room=member&_action=loginForm";
            document.location = xUrl;
            //alert("Please login before you sign-up for the events");
            return;
         }
      
         var url = "index.php?_room=cart&_action=viewCart" +  "&shopType=" + shopType + "&prevPage=shop";
      
         var addToCartRowObj  = document.getElementById("cartRow__" + id);
         addToCartRowObj.innerHTML = "&#10004; Added <a href=" + url + ">view your sign-ups</a>";
      }
   }
}

//**********************************************************************************//
Cart.packagePayment = function(shopType, cart_id, checkboxObj){
   var packageTag = 0;
   if (checkboxObj.checked) {
      packageTag = 1;
   }
   
   var url = "index.php?_room=cart&_action=packagePayment" + 
             "&cart_id=" + cart_id + "&package_tag="+ packageTag + "&shopType=" + shopType + 
             "&room=&showHTML=0" ;
   
   XMLHTTP.xmlHttpObj = XMLHTTP.getXMLHTTPObject(function () {Cart.setPackagePaymentHandler();});
   XMLHTTP.xmlHttpObj.open("GET", url, true);
   XMLHTTP.xmlHttpObj.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
   XMLHTTP.xmlHttpObj.send(null);
}

//**********************************************************************************//
Cart.setPackagePaymentHandler = function(){
}

//**********************************************************************************//
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;
           }
         }         
} 

//**********************************************************************************//
