		function trimStr(str) 
	{
		
  	while (str.charAt(0) == ' '){
    	str = str.substring(1);
	}
  	while (str.charAt(str.length - 1) == ' '){
    	str = str.substring(0, str.length - 1);
	}
  	return str;
	}
	function isblank(str)
	{if ((str = null) || (str.length = 0)){return true;}else{return false;}}
	
 function checkemail(str) {
		re=/^\w+([\.-]?\w+)*@+([\.-]?\w+)*(\.\w{2,4})+$/;
		if (re.test(str)) {
			return true;
		}		else {
			
			return false;
		}
}

function CheckForSubmit(form) 
	{
			var msgstr="";
			
		if(form.hidPaymentMethod[1].checked) {
			sfname = trimStr(form.sfname.value);
			
			if (isblank(sfname)) {msgstr += "First Name is required!\n";}
					
			slname = trimStr(form.slname.value);
			if (isblank(slname)) {msgstr += "Last Name is required!\n";}
				
			semail = trimStr(form.semail.value);
				if (isblank(semail)||(!checkemail(semail))){msgstr += "Your Email is wrong!\n";}
			scemail = trimStr(form.scemail.value);
				if ((isblank(scemail))||(!checkemail(scemail))||(semail!=scemail)){msgstr += "Your Emails do not match!\n";}
		}	
		
	if(msgstr!=="") {alert(msgstr);return false;} else {return true;}
	}
	
function unhide(box)
{
	if ((box.value == "moneyorder") && (box.checked))
	{
	slidedown('shipaddress');
	}
	else
	{
	slideup('shipaddress');
	}
}

function check_form(f) { 
	if(f.password.value.length > 0){f.useroption[1].click();}
	if(!checkemail(f.email.value)){alert("Invalid email");f.email.focus(); 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){f.email.style.border = "1px red solid";}
return false;
}
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=250,left = 570,top = 350');");
}

