
	function validateForm(formCheck){
	
		
		if(formCheck.fname.value ==""){
    	    alert("Please provide First Name:"); 
        	formCheck.fname.focus();
	        return false;
	    }
		else if(formCheck.lname.value ==""){
    	    alert("Please provide Last Name:"); 
        	formCheck.lname.focus();
	        return false;
	    }
		else if(formCheck.zip.value ==""){
    	    alert("Please provide zipcode:"); 
        	formCheck.zip.focus();
	        return false;
	    }
		else if(formCheck.delivaryInfo.value ==""){
    	    alert("Please provide book(s) delivaryInformation:"); 
        	formCheck.delivaryInfo.focus();
	        return false;
	    }
		
		else if(formCheck.email.value ==""){
    	    alert("Please provide email address:"); 
        	formCheck.email.focus();
	        return false;
	    }		
		
		else if(formCheck.pwd.value ==""){
    	    alert("Please provide password for the user:"); 
        	formCheck.pwd.focus();
	        return false;
	    }
		else if(formCheck.cpwd.value ==""){
    	    alert("Please verify password provided for the user:"); 
        	formCheck.cpwd.focus();
	        return false;
	    }		
		else if(!formCheck.trc.checked){
    	    alert("Please agree to terms and conditions in order to register"); 
        	return false;
	    }	
			
		else if(!validateEmail())  return false;
		else if(!validateZip())    return false;
		else if(!validateCPwd())   return false; 
		else return true;
		
	}
	
	function trim(str)
	{
	  return str.replace(/^\s+|\s+$/g, '');
	}
	
	function updateContact(){
		if(document.adduser.bph.checked)	
			document.adduser.Bcontact.value="Y";
		else
			document.adduser.Bcontact.value="N";  
	}
	
	function validateZip(){
		var zip = trim(document.adduser.zip.value);
		var zipRE = /^[0-9]{1,5}$/	
		
		if (!zipRE.test(zip) || zip.length >5) {
    		alert("ERROR: not a valid zipcode");
	    	document.adduser.zip.focus();
			document.adduser.zip.select();
	    	return false;
 		 }	
		 else
		 	return true;
		
	}
	
	function validateEmail(){
		var email = trim(document.adduser.email.value);
		var emailRE = /^[^@]+@[^@.]+\.[^@]*\w\w$/
		
		if (!emailRE.test(email)) {
    		alert("ERROR: not a valid e-mail address");
	    	document.adduser.email.focus();
			document.adduser.email.select();
	    	return false;
 		 }	
		 else
		 	return true;
		
	}
	
	function validateVEmail(){
		if(document.adduser.email.value!=document.adduser.vemail.value){
			alert("ERROR: email and verify email does not match please re-enter again");		
			return false; 
		}
		else
			return true;
	}
	
	function validateNPwd(){
		if(document.adduser.cpwd.value!=""){
			if(document.adduser.email.value!=document.adduser.vemail.value){
				alert("ERROR: email and verify email does not match please re-enter again");		
				return false; 
			}
			
		}
		else
			return true;
	}
	
	function validateCPwd(){
		if(document.adduser.pwd.value!=document.adduser.cpwd.value){
			alert("ERROR: password and confirm password does not match please re-enter again");		
			return false; 
		}
		else
			return true;
	}
	
	function validateDphone(){
		var dphone = trim(document.adduser.dphone.value);
		var dphoneRE = /^[0-9]{1,10}$/
		
		if (!dphoneRE.test(dphone) || dphone.length < 10) {
    		alert("ERROR: not a valid Day telephone number, Please enter numbers only");
	    	document.adduser.dphone.focus();
			document.adduser.dphone.select();
	    	return false;
 		 }	 
		 else
		 	return true;
	}	
	
	
	function validateEphone(){
		var dphone = trim(document.adduser.ephone.value);
		var dphoneRE = /^\+?[0-9 ()-]+[0-9]$/
		
		if (!dphoneRE.test(dphone)) {
    		alert("ERROR: not a valid evening telephone number");
	    	document.adduser.ephone.focus();
			document.adduser.ephone.select();
	    	return false;
 		 }	
		 else
		 	return true;
	}
	
	function loadTersmandCond(){
		window.open('http://www.collegebooks4all.com/terms.php','mywindow','scrollbars=yes,width=800,height=600')
	}
	
/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}

