function changejoinemail()
{
	if(document.getElementById('joinemailaddress').value=="Enter your e-mail")
	{
		document.getElementById('joinemailaddress').value='';
		document.form2.joinemailaddress.focus();
		return false;
	}
}

function joinlist()
{
	var m=document.form2.joinemailaddress;
	var n=document.form2.joinemailaddress.value;
	if ((n==null)||(n==""))
		{
			alert("Please Enter your Email ID")
			m.select()
			return false
		}
	if (echeck1(n)==false)
		{
			alert('Please enter valid email ID');
			m.select();
			return false;
		}
}
	function echeck1(str) 
		{
			at = str.indexOf("@");
			dot = str.lastIndexOf(".");
			lengt = str.length;
			con1 = str.substring(0,at);
			con2 = str.substring(at+1,dot);
			con3 = str.substring(dot+1,lengt);

			if(con1=='' || con2=='' || con3=='') return false;

			if(str.indexOf("  ") > -1 || str.indexOf("..") > -1 || str.indexOf("__") > -1 || str.indexOf("--") > -1) return false;
			
			if(at==-1 || dot==-1) return false;

			x = con1.substring(0,1);
			if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;

			x = con1.substring((con1.length)-1,(con1.length));
			if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;

			x = con1.substring(1,(con1.length)-1);
			for(i=0, y=0; i<con1.length-2; i++, y=x.substring(i, i+1)) if ((y < "a" || "z" < y) && (y < "A" || "Z" < y) && isNaN(y) && y!='.' && y!='_' && y!='-') return false;
			
			x = con2.substring(0,1);
			if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;

			x = con2.substring((con2.length)-1,(con2.length));
			if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;
			
			x = con2.substring(1,(con2.length)-1);
			for(i=0, y=0; i<con2.length-2; i++, y=x.substring(i, i+1)) if ((y < "a" || "z" < y) && (y < "A" || "Z" < y) && isNaN(y) && y!='.' && y!='_' && y!='-') return false;		
			
			for(i=0, x=0; i<con3.length; i++, x = con3.substring(i, i+1)) if ((x < "a" || "z" < x) && (x < "A" || "Z" < x)) return false;
			if ((con3.length)<2 || (con3.length)>4)  return false;
		}

function checkRadio (frmName, rbGroupName) 
{
	var radios = document[frmName].elements[rbGroupName];
	for (var i=0; i <radios.length; i++) 
	{
		if (radios[i].checked) 
		{
			return true;
		}
	}
	return false;
} 

function customervalidate(vall)
{
	
	var date = new Date();
	var d  = date.getDate()+1;
	var m = date.getMonth()+1;
	var y = date.getFullYear()-18;
	var yr = date.getFullYear()-21;
	
	if(document.customerlogin.name.value=='')
	{
		alert("Enter your First Name");
		document.customerlogin.name.focus();
		document.customerlogin.name.select();
		return false;
	}
	else if(document.customerlogin.name.value.substring(0, 1)==' ')
	{
		alert("First character of a First Name should not be space");
		document.customerlogin.name.focus();
		document.customerlogin.name.select();
		return false;
	}

	
	if(document.customerlogin.namel.value=='')
	{
		alert("Enter your Last Name");
		document.customerlogin.namel.focus();
		document.customerlogin.namel.select();
		return false;
	}
	else if(document.customerlogin.namel.value.substring(0, 1)==' ')
	{
		alert("First character of a Last Name should not be space");
		document.customerlogin.namel.focus();
		document.customerlogin.namel.select();
		return false;
	}

	
	if(document.customerlogin.Zipcode.value=='')
	{
		alert("Enter your Zipcode");
		document.customerlogin.Zipcode.focus();
		document.customerlogin.Zipcode.select();
		return false;
	}
	else
	{
		if(document.customerlogin.Zipcode.value.substring(0, 1)==' ')
		{
			alert("First character of a Zipcode should not be space");
			document.customerlogin.Zipcode.focus();
			document.customerlogin.Zipcode.select();
			return false;
		}

		if(isNaN(document.customerlogin.Zipcode.value))
		{
			alert("Zipcode should be Numeral");
			document.customerlogin.Zipcode.focus();
			document.customerlogin.Zipcode.select();
			return false;
		}


	}

	/*if(document.customerlogin.address.value=='')
	{
		alert("Enter your Address");
		document.customerlogin.address.focus();
		document.customerlogin.address.select();
		return false;
	}
	else if(document.customerlogin.address.value.substring(0, 1)==' ')
	{
		alert("First character of an Address should not be space");
		document.customerlogin.address.focus();
		document.customerlogin.address.select();
		return false;
	}*/


	if(document.customerlogin.dd.value=='')
	{
		alert("Please Select your Birthday Date");
		document.customerlogin.dd.focus();
		return false;
	}
	if(document.customerlogin.mm.value=='')
	{
		alert("Please Select your Birthday Month");
		document.customerlogin.mm.focus();
		return false;
	}
	if(document.customerlogin.yyyy.value=='')
	{
		alert("Please Select your Birthday Year");
		document.customerlogin.yyyy.focus();
		return false;
	}

	var dd= document.customerlogin.dd.value;
	var mm= document.customerlogin.mm.value;
	var yyyy= document.customerlogin.yyyy.value;
	
	if(yyyy<=y)
	{
		if(yyyy == y)
			{	
				if(mm<=m)	
					{
						if(mm==m)
							{
								if(dd>=d) {var result ='yes';}
								else { var age='18';}
							}
						else {var age='18';}
					}
				else	{var result ='yes';}
			}
			else {var age='18';}
	}
	else {var result ='yes';}


	if(yyyy<=yr)
	{
		if(yyyy == yr)
			{	
				if(mm<=m)	
					{
						if(mm==m)
							{
								if(dd>=d) {var result1 ='yes';}
								else {var age='21';}
							}
						else
							{var age='21';}
					}
				else	{var result1 ='yes';}
			}
			else {var age='21';}
	}
	else {var result1 ='yes';}

	if(result)	
		{			
			alert('You must be at least 18 years of age to sign up');
			document.customerlogin.dd.focus();
				return false;
		}
	
	if (!checkRadio("customerlogin","penalty")) 
	{
	alert("Please select Age Cerfication");
	return false;
	}

	var radis = document['customerlogin'].elements['penalty'];
	for (var i=0; i <radis.length; i++) 
	{
		if (radis[i].checked) 
		{
			var checkedage = radis[i].value;
		}
	}


	if(age =='18')
	{
		if(checkedage !='18')
		{
			alert ("please select the correct certification");
			return false;
		}
	}

	if(age =='21')
	{
		if(checkedage !='21')
		{
			alert ("please select the correct certification");
			return false;
		}
	}


	if(document.customerlogin.username.value=='')
	{
		alert("Enter your Username");
		document.customerlogin.username.focus();
		document.customerlogin.username.select();
		return false;
	}

	else if(document.customerlogin.username.value.substring(0, 1)==' ')
	{
		alert("First character of a Username should not be space");
		document.customerlogin.username.focus();
		document.customerlogin.username.select();
		return false;
	}

	if (document.customerlogin.username.value.length <4 || document.customerlogin.username.value.length >12 )
	{
		alert("Username must be within 4-12 chars");
		document.customerlogin.username.focus();
		document.customerlogin.username.select();
		return false;
	}

	if(document.customerlogin.password.value=='')
	{
		alert("Enter your Password");
		document.customerlogin.password.focus();
		document.customerlogin.password.select();
		return false;
	}
	else if(document.customerlogin.password.value.substring(0, 1)==' ')
	{
		alert("First character of a Password should not be space");
		document.customerlogin.password.focus();
		document.customerlogin.password.select();
		return false;
	}

	if (document.customerlogin.password.value.length <4 || document.customerlogin.password.value.length >12 )
	{
		alert("Password must be within 4-12 chars");
		document.customerlogin.password.focus();
		document.customerlogin.password.select();
		return false;
	}
if (vall='No')
	{
		if(document.customerlogin.password.value!=document.customerlogin.cpassword.value)
		{
			alert("Your Confirm Password is not match, please re enter again");
			document.customerlogin.cpassword.focus();
			document.customerlogin.cpassword.select();
			return false;
		}
	}


	var m=document.customerlogin.email;
	var n=document.customerlogin.email.value;
	if ((n==null)||(n==""))
		{
			alert("Please Enter your Email ID")
			m.select()
			return false
		}
	if (echeck(n)==false)
		{
			alert('Please enter valid email ID');
			m.select();
			return false;
		}
	function echeck(str) 
		{
			at = str.indexOf("@");
			dot = str.lastIndexOf(".");
			lengt = str.length;
			con1 = str.substring(0,at);
			con2 = str.substring(at+1,dot);
			con3 = str.substring(dot+1,lengt);

			if(con1=='' || con2=='' || con3=='') return false;

			if(str.indexOf("  ") > -1 || str.indexOf("..") > -1 || str.indexOf("__") > -1 || str.indexOf("--") > -1) return false;
			
			if(at==-1 || dot==-1) return false;

			x = con1.substring(0,1);
			if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;

			x = con1.substring((con1.length)-1,(con1.length));
			if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;

			x = con1.substring(1,(con1.length)-1);
			for(i=0, y=0; i<con1.length-2; i++, y=x.substring(i, i+1)) if ((y < "a" || "z" < y) && (y < "A" || "Z" < y) && isNaN(y) && y!='.' && y!='_' && y!='-') return false;
			
			x = con2.substring(0,1);
			if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;

			x = con2.substring((con2.length)-1,(con2.length));
			if ((x < "a" || "z" < x) && (x < "A" || "Z" < x) && isNaN(x)) return false;
			
			x = con2.substring(1,(con2.length)-1);
			for(i=0, y=0; i<con2.length-2; i++, y=x.substring(i, i+1)) if ((y < "a" || "z" < y) && (y < "A" || "Z" < y) && isNaN(y) && y!='.' && y!='_' && y!='-') return false;		
			
			for(i=0, x=0; i<con3.length; i++, x = con3.substring(i, i+1)) if ((x < "a" || "z" < x) && (x < "A" || "Z" < x)) return false;
			if ((con3.length)<2 || (con3.length)>4)  return false;
		}

/*
	if(document.customerlogin.PromoCode.value=='')
		{
			alert("Enter your PromoCode");
			document.customerlogin.PromoCode.focus();
			document.customerlogin.PromoCode.select();
			return false;
		}
	else if(document.customerlogin.PromoCode.value.substring(0, 1)==' ')
		{
			alert("First character of an PromoCode should not be space");
			document.customerlogin.PromoCode.focus();
			document.customerlogin.PromoCode.select();
			return false;
		}
*/


if(document.customerlogin.agreed.checked==false)
	{

	alert ("Please agree to our terms and conditions");
	return false;
	}


}


	function MM_swapImgRestore() 
		{ //v3.0
		  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
		}

	function MM_preloadImages() 
		{ //v3.0
		  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
			var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
		}

	function MM_findObj(n, d) 
		{ //v4.01
			var p,i,x;  
			if(!d) d=document; 
			if((p=n.indexOf("?"))>0&&parent.frames.length) 
				{
					d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
				}
			if(!(x=d[n])&&d.all) x=d.all[n]; 
			for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
			for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
			if(!x && d.getElementById) x=d.getElementById(n); return x;
		}

	function MM_swapImage() 
		{ //v3.0
		  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
		   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
		}

	function form_submit() 
		{
			window.open("looking-bar.php",null,"height=400,width=300,status=no,toolbar=no,menubar=no,location=no");
		}
