	//Generic Cart Functions
	//Copyright 2005 Lezon Corporation

	//This script cannot be used on sites other than
	//those authorized by Lezon Corporation. 
	
	//Contact: support@lezon.com
	//Last Updated: 7/4/2005
	
	function navigate_accordingly(){
		register_form.btn_submit.disabled=true;

		if(register_form.order_billing_type.value.toLowerCase()=="paypal" || register_form.order_billing_type.value=="Online Check"){
			alert("Please MAKE SURE you press the CONTINUE button after making your purchase on the PayPal web site.\n\nYou must be navigated back to our web site in order to finalize the transaction.\n\nPlease press CONTINUE.\nThank You!");
			window.location.href = "https://www.paypal.com/xclick/business=ms-sales%40memorysource.com&item_name=MemorySource.com+-+ORDER+" + register_form.order_session_id.value + "&item_number=" + register_form.order_id.value + "&amount=" + register_form.order_total_cost.value + "&no_shipping=1&return=http%3A//www.memorysource.com/cgi-bin/user/order.pl&no_note=1&currency_code=USD";	
		}else{
			register_form.submit();
		}
	}
	
		
	function validate_before_submit_step_1(){
		if(register_form.email.value.length < 3 || register_form.email.value.indexOf("\@")==-1 || register_form.email.value.indexOf(".")==-1){
			register_form.email.focus();
			alert("Please enter a valid e-mail address into the e-mail field. This e-mail address will be used to send you your download link and serial number. We will never spam you or resell your e-mail.");
			return 0;	
		}else if(register_form.name.value.length<3){
			register_form.name.focus();
			alert("Please enter a valid full name into the billing Full Name field.");
			return 0;
		}else if(register_form.address_1.value.length<3){
			register_form.address_1.focus();		
			alert("Please enter a valid billing address into the billing address field.");
			return 0;
		}else if(register_form.city.value.length<3){
			register_form.city.focus();
			alert("Please enter a valid billing city into the billing city field.");
			return 0;			
		}else if(register_form.state.value=="--"){
			register_form.state.focus();
			alert("Please enter a valid billing state into the billing state field. If you do not live in the U.S. please enter N/A as your state.");
			return 0;
		}else if(register_form.zip.value.length<4 && (register_form.country.value=="United States" || register_form.country.value=="Canada")){
			register_form.zip.focus();
			alert("Please enter a valid billing zip code into the billing zip code field. If you do not reside in the U.S. or country which has zip codes, please select a proper country.");
			return 0;
		}else if(register_form.country.value=="--"){
			register_form.country.focus();		
			alert("Please enter a valid billing country into the billing country field.");
			return 0;
		}else if(register_form.phone.value==""){
			register_form.phone.focus();
			alert("Please enter a valid contact phone number into the billing contact-phone field. We may use this phone number to contact you in order to verify order placement prior to shipping. Occasional validation calls are part of our fraud prevention process. We will NEVER sell or distribute your phone number or any other contact information.");
			return 0;
		}
		
		if(register_form.type.value=="--"){
			register_form.type.focus();
			alert("Please select a valid payment type.");
			return 0;
		}else if(register_form.cc_number.value.length< 2){
			register_form.cc_number.focus();
			alert("The provide a valid expiration credit card number. All information sent across the network is encrypted for your security.");
			return 0;						
		}else if(register_form.expiration_month.value=="--" && (register_form.type.value=="Visa" || register_form.type.value=="Mastercard" || register_form.type.value=="American Express" || register_form.type.value=="Discover")){
			register_form.expiration_month.focus();
			alert("The provide a valid expiration month for your credit card, or if you are not using a credit card please select a different payment type.");
			return 0;
		}else if(register_form.expiration_year.value=="--" && (register_form.type.value=="Visa" || register_form.type.value=="MasterCard" || register_form.type.value=="American Express" || register_form.type.value=="Discover")){
			register_form.expiration_year.focus();
			alert("The provide a valid expiration year for your credit card, or if you are not using a credit card please select a different payment type.");
			return 0;
		}else if(register_form.cvv.value.length < 2 && (register_form.type.value=="Visa" || register_form.type.value=="Mastercard" || register_form.type.value=="Discover")){
			register_form.cvv.focus();
			alert("Please enter a valid " + register_form.type.value + " verification number. This is a three digit number usually located on the back of your card near the signature area. If you cannot find this number please contact your credit card company or select a different payment method (ex: PayPal).");
			return 0;
		}else if(register_form.referal.value=="--"){
			register_form.referal.focus();		
			alert("Please let us know how you\'ve found out about us by selecting a referral.");
			return 0;
		}
		
		var temp1=register_form.cc_number.value;
		
		temp1=temp1.replace(/\-/g, "");
		temp1=temp1.replace(/\-/g, "");
		
		register_form.btn_submit.disabled=true;
		register_form.btn_submit.value="Processing Order...";
		register_form.cc_number.value=temp1;
		register_form.submit();
	}
	
	function validate_before_submit_contact(){
		if(register_form.text_department.value=="--"){
			register_form.text_department.focus();
			alert("Please enter a valid department name before contacting us.");
			return 0;
		}else if(register_form.text_email.value.length < 3 || register_form.text_email.value.indexOf("\@")==-1 || register_form.text_email.value.indexOf(".")==-1){
			register_form.text_email.focus();
			alert("Please enter a valid e-mail address into the e-mail field. Without an e-mail address we will not be able to answer your inquiry.");
			return 0;	
		}else if(register_form.text_message.value.length<5){
			register_form.text_message.focus();
			alert("Please enter a message or question into the message field.");
			return 0;
		}
		
		register_form.btn_submit.disabled=true;
		register_form.btn_submit.value="Sending Message...";
		register_form.submit();
	}
	
	
	function validate_before_submit_affiliate(){
		if(register_form.text_email.value.length < 3 || register_form.text_email.value.indexOf("\@")==-1 || register_form.text_email.value.indexOf(".")==-1){
			register_form.text_email.focus();
			alert("Please enter a valid e-mail address into the e-mail field. This e-mail address will be used to send you your download link and serial number. We will never spam you or resell your e-mail.");
			return 0;	
		}else if(register_form.text_password.value.length < 4){
			register_form.text_password.focus();
			alert("The desired account password you've entered is invalid. A password must contain at least 4 characters.");
			return 0;			
		}else if(register_form.text_password.value != register_form.text_password_2.value){
			register_form.text_password.focus();
			alert("The confirmation password you've entered does not match. Please re-enter your desired password.");
			return 0;
		}else if(register_form.text_billing_full_name.value.length<3){
			register_form.text_billing_full_name.focus();
			alert("Please enter a valid full payment name into the Check Out To Name field.");
			return 0;
		}else if(register_form.text_billing_address_1.value.length<3){
			register_form.text_billing_address_1.focus();		
			alert("Please enter a valid mailing address into the address field.");
			return 0;
		}else if(register_form.text_billing_city.value.length<3){
			register_form.text_billing_city.focus();
			alert("Please enter a valid mailing city into the city field.");
			return 0;			
		}else if(register_form.text_billing_state.value=="--"){
			register_form.text_billing_state.focus();
			alert("Please enter a valid mailing state into the state field. If you do not live in the U.S. please enter N/A as your state.");
			return 0;
		}else if(register_form.zip.value.length<4 && (register_form.text_billing_country.value=="United States" || register_form.text_billing_country.value=="Canada")){
			register_form.zip.focus();
			alert("Please enter a valid mailing zip code into the zip code field. If you do not reside in the U.S. or country which has zip codes, please select a proper country.");
			return 0;
		}else if(register_form.text_billing_country.value=="--"){
			register_form.text_billing_country.focus();		
			alert("Please enter a valid mailing country into the country field.");
			return 0;
		}else if(register_form.text_url.value==""){
			register_form.text_url.focus();
			alert("Please enter the web address of the site you wish to promote DRT on. If you do not yet have a web site please enter NO SITE into the field.");
			return 0;
		}else if(register_form.text_payment_type.value=="PayPal" && register_form.text_paypal_email.value==""){
			register_form.text_paypal_email.focus();
			alert("You've chosen PayPal payments but have not specified a valid PayPal e-mail address. Please provide us with your PayPal payment e-mail address.");
			return 0;
		}
		register_form.btn_submit.disabled=true;
		register_form.btn_submit.value="Registering...";
		register_form.submit();
	}
	
	//hides an object such as div/table/etc
	function hideObject(obj) {
		var el = document.getElementById(obj);
		el.style.display = 'none';
	}	 
	
	//hides an object such as div/table/etc
	function showObject(obj) {
		var el = document.getElementById(obj);
		el.style.display = '';
	}
	
	function selectAll(formObj, isInverse){
   		for (var i=0;i < formObj.length;i++){
      		fldObj = formObj.elements[i];
      		if (fldObj.type == 'checkbox'){ 
         		if(isInverse) fldObj.checked = (fldObj.checked) ? false : true;
         		else fldObj.checked = true; 
			}
   		}
   	}
		