/*  Project Name		: cogswellgallery.com
   	Program name		: checkout.js
 	Program function	: js validation for checkout
	Author				: David Bishop(Jinsy Panamkattu)
	Developed by	   	: Bishop web works- www.bishopwebworks.com 
 	Created Date  		: 26 JAN 08
 	
	Update History
    -------------------------------------------------------------------
    Date       	 By 				    	short desc. of what updated 
 	-------------------------------------------------------------------*/
function validate(theform){
	if(theform.type[0].value.checked==false&&theform.type[1].checked==false){
		alert("Please select member type.");
		theform.type[0].focus();
		return false;
	}		
	if(theform.type[0].checked==true){
		if(isEmpty(theform.frm_old_email.value)){
			alert("Please enter the email.");
			theform.frm_old_email.focus();
			return false;
		}else{
			if (emailCheck(theform.frm_old_email.value) == false){
				theform.frm_old_email.focus();
		  		return false;
			}
		}
		if(isEmpty(theform.frm_old_password.value)){
			alert("Please enter Password.");
			theform.frm_old_password.focus();
			return false;
		}
	}else{
		if(isEmpty(theform.frm_new_email.value)){
			alert("Please enter the email.");
			theform.frm_new_email.focus();
			return false;
		}else{
			if (emailCheck(theform.frm_new_email.value) == false){
				theform.frm_new_email.focus();
		  		return false;
			}
		}
		if(isEmpty(theform.frm_cnf_email.value)){
			alert("Please enter the confirmation email.");
			theform.frm_cnf_email.focus();
			return false;
		}else{
			if (emailCheck(theform.frm_cnf_email.value) == false){
				theform.frm_cnf_email.focus();
		  		return false;
			}
		}
		if(theform.frm_cnf_email.value!=theform.frm_new_email.value){
			alert("Email and Confirmation email must be same.");
			theform.frm_cnf_email.focus();
			return false;
		}
		if(isEmpty(theform.frm_new_password.value)){
			alert("Please enter Password.");
			theform.frm_new_password.focus();
			return false;
		}
	}	
	
}
function checkReturnCustomerOption(){
	document.frm_checkout.type[0].checked = true;
	if(document.frm_checkout.frm_new_email.value){
		document.frm_checkout.frm_old_email.value = document.frm_checkout.frm_new_email.value;
		document.frm_checkout.frm_old_password.value = document.frm_checkout.frm_new_password.value;
	}

	document.frm_checkout.frm_new_email.value = "";
	document.frm_checkout.frm_new_password.value = "";
}

function checkNewCustomerOption(){
	document.frm_checkout.type[1].checked = true;
	if(document.frm_checkout.frm_old_email.value){
		document.frm_checkout.frm_new_email.value = document.frm_checkout.frm_old_email.value;
		document.frm_checkout.frm_new_password.value = document.frm_checkout.frm_old_password.value;
	}
	document.frm_checkout.frm_old_email.value = "";
	document.frm_checkout.frm_old_password.value = "";
}	
