// JavaScript Document
	function check()
	{
		var msg = "Please fill in the following values to proceed:";
		var elename = new Array("First Name","Last Name","Email","","Address","City","State","","Zip Code","Phone","Event","Event Month","Event Day","Event Year","Registry Expiration Month","Registry Expiration Day","Registry Expiration Year","Username (for your use)","Password (for your use) ","Confirm Password (for your use)","Username (for friend’s use) ","Password (for friend’s use)","Confirm Password (for friend’s use)");
	
		for(j=1;j<=23;j++)
		{
			
			switch(j)
			{
				case 4:
				case 10:
				continue;
			} 
	
			if(document.form1.elements[j].value == "")
			{
				status = 1;
				msg = msg + "\n" + elename[j-1];
				eleId = j;
			}			

			var FN = document.form1.elements[j].value.substring(0,1); 
			if ( FN == ' ')
			{ 
				alert("\n First character should not be a space"); 
				document.form1.elements[j].select(); 
				document.form1.elements[j].focus();
				return false;
			}
			
		}
		if(status == 1)
		{
			alert(msg);
			status = 0;
			eleId = 0;
			return false;
		}
		else
		{
			event_datecheck();
			return false;
		}
	}
	
	function event_datecheck()
	{
		var emonth = document.form1.event_month.value;
		var eday   = document.form1.event_day.value;
		var eyear  = document.form1.event_year.value;
		var a,b;
		
		 b = (eyear%4);
		
		if( (emonth == 01) || (emonth == 03) || (emonth == 05) || (emonth == 07) || (emonth == 08) || (emonth == 10) || (emonth == 12))
		{
			a = 31;
		}
		if( (emonth == 04) || (emonth == 06) || (emonth == 09) || (emonth == 11))
		{
			a = 30;
		}
		
		if( (emonth == 02) && (b == 0) )
		{
			a = 29;
		}
		if ( (emonth == 02) && ( b != 0 ) )
		{
			a = 28;
		}
		if( eday <= a )
		{
			expiry_datecheck(); 
			return false;
		}
		else
		{
			alert("Please check the event date you have entered!");
			return false;
		}
	}
	
	function expiry_datecheck()
	{
		var exmonth = document.form1.expiry_month.value;
		var exday   = document.form1.expiry_day.value;
		var exyear  = document.form1.expiry_year.value;
		var a1,b1;
		
		 b1 = (exyear%4);
		
		if( (exmonth == 01) || (exmonth == 03) || (exmonth == 05) || (exmonth == 07) || (exmonth == 08) || (exmonth == 10) || (exmonth == 12))
		{
			a1 = 31;
		}
		if( (exmonth == 04) || (exmonth == 06) || (exmonth == 09) || (exmonth == 11))
		{
			a1 = 30;
		}
		
		if( (exmonth == 02) && (b1 == 0) )
		{
			a1 = 29;
		}
		if ( (exmonth == 02) && ( b1 != 0 ) )
		{
			a1 = 28;
		}
		if( exday <= a1 )
		{
			password_check(); 
			return false;
		}
		else
		{
			alert("Please check the expiration date of the registry, you have entered!");
			return false;
		}
	}
	
	function password_check()
	{
		var UName	 = document.form1.username.value;
		var PWord	 = document.form1.password.value;
		var PWord1	 = document.form1.confirmpassword.value;
		
		var OName	 = document.form1.other_username.value;
		var OPWord	 = document.form1.other_password.value;
		var OPWord1  = document.form1.other_confirmpassword.value;
		
		var len		= PWord.length;
		var len1 	= PWord1.length;
		var len2 	= UName.length;
		
		var len3	= OPWord.length;
		var len4 	= OPWord1.length;
		var len5 	= OName.length;
		
		if( len2 < 6 ) 
		{
			alert("Username must at least be 6 characters in length");
			document.form1.username.select(); 
			document.form1.username.focus();
			return false;
		}
		
		if(usernamepassword_check(document.form1.username.value) == 0)
		{
			alert("Username must contain alphabets and numbers only. No blank spaces allowed in between");
			document.form1.username.select(); 
			document.form1.username.focus();
			return false;
		}
		
		if( len < 6 ) 
		{
			alert("Password must at least be 6 characters in length");
			document.form1.password.select(); 
			document.form1.password.focus();
			return false;
		}
		
		if(usernamepassword_check(document.form1.password.value) == 0)
		{
			alert("Password must contain alphabets and numbers only. No blank spaces allowed in between");
			document.form1.password.select(); 
			document.form1.password.focus();
			return false;
		}

		if( len1 < 6 ) 
		{
			alert("Confirm password must at least be 6 characters in length");
			document.form1.confirmpassword.select(); 
			document.form1.confirmpassword.focus();
			return false;
		}
		
		if(usernamepassword_check(document.form1.confirmpassword.value) == 0)
		{
			alert("Password must contain alphabets and numbers only. No blank spaces allowed in between");
			document.form1.confirmpassword.select(); 
			document.form1.confirmpassword.focus();
			return false;
		}
	
		if(PWord != PWord1)
		{
			alert("The Confirm Password should exactly match your Password");
			document.form1.password.select(); 
			document.form1.password.focus();
			return false;
		}
		
		if( len5 < 6 ) 
		{
			alert("Username must at least be 6 characters in length");
			document.form1.other_username.select(); 
			document.form1.other_username.focus();
			return false;
		}
		
		if(usernamepassword_check(document.form1.other_username.value) == 0)
		{
			alert("Username must contain alphabets and numbers only. No blank spaces allowed in between");
			document.form1.other_username.select(); 
			document.form1.other_username.focus();
			return false;
		}

		if( len3 < 6 ) 
		{
			alert("Password must at least be 6 characters in length");
			document.form1.other_password.select(); 
			document.form1.other_password.focus();
			return false;
		}

		if(usernamepassword_check(document.form1.other_password.value) == 0)
		{
			alert("Password must contain alphabets and numbers only. No blank spaces allowed in between");
			document.form1.other_password.select(); 
			document.form1.other_password.focus();
			return false;
		}

		if( len4 < 6 ) 
		{
			alert("Confirm Password must at least be 6 characters in length");
			document.form1.other_confirmpassword.select(); 
			document.form1.other_confirmpassword.focus();
			return false;
		}
	
		if(usernamepassword_check(document.form1.other_confirmpassword.value) == 0)
		{
			alert("Password must contain alphabets and numbers only. No blank spaces allowed in between");
			document.form1.other_confirmpassword.select(); 
			document.form1.other_confirmpassword.focus();
			return false;
		}
		
		if(OPWord != OPWord1)
		{
			alert("The Confirm Password should exactly match your Password");
			document.form1.other_password.select(); 
			document.form1.other_password.focus();
			return false;
		}

		if(UName == OName)
		{
			alert("The username you have chosen has already been taken. Please enter another value");
			document.form1.username.select(); 
			document.form1.username.focus();
			return false;
		}

		passcheck();	
		return false;
	}
	
	function usernamepassword_check(str)
	{
		var s;
		var c=str;
		var fl = 0;
		for(var i=0;i<c.length;i++)
		{
			s=c.charAt(i);
			if( (s>='0' && s<='9') || (s=='-') || (s>='a' &&s<='z') || (s>='A' &&s<='Z') ) 		
			{			
			}
			else
			{
				fl = 1;
			}
		 }
	 
		if(fl == 1)
		return 0;
		else
		return 1;	
	}
	

	function passcheck()
	{
		if (document.form1.image.value == "")
		{
			document.form1.pass.value=0;
			username_check();
			return true;
		}
		else
		{
			document.form1.pass.value=1;
			username_check();
			return true;
		}
	}
		
	function emails()
	{
		var email2 = document.form1.email.value;

		var e3,e4;
		var err1 = new Array(0,0);
		e3 = email2.indexOf("@");
		e4 = email2.lastIndexOf("@");
		
		if(e3 != -1 && e3 == e4)
		{
			var a = email2.indexOf(".",e3);
			if((a-e3) < 2)
			err1[0] = 1;
		}
		else{	err1[0] = 1;		}
		
		if(err1[0] == 1)
		{
			alert("The email id you have entered is in an invalid format. Please check and re-enter again");
			document.form1.email.focus();	
			return false;			
		}
		else
		{
			username_check();
			return false;			
		}
	}

	function image_part()
	{
		var image_file =document.form1.image.value;
		var c1,c2;
		c1 = image_file.lastIndexOf('.');
		c2 = image_file.substring(c1);
		
		if( (c2 == '.jpg') || (c2 == '.gif') || (c2 == '.JPG') || (c2 == '.GIF') )
		{
			document.form1.submit.disabled=false;
			return true;
		}
		else
		{
			alert("The image you upload must be in JGP or GIF format");
			document.form1.image.focus();
			document.form1.submit.disabled=true;
			return false;
		}
	}

