var okayusername = false;

/*-------------*/
function douserCheck()
{

	//alert("in function");
		document.getElementById("chkclick3").value	=	1;
        var username = document.getElementById('newusername').value;
		if(username=="")
		{
	//alert("in if");
	alert("Please enter user name");
			document.getElementById('newusername').focus();
			document.getElementById("chkclick3").value	=	0;
			return false;
		}
        if (username) {
				//alert("in if 2");
                new Ajax.Request("/signup/chkusr?q=" + username, {
                                        onSuccess: function(transport) {
                                                updateUsernameStatus((transport.responseText == "ok")?true:false);
                                        },
                                        onFailure: function() {
                                                alert("Error connecting to site.  Try again.");
                                        }
                                }
                        );
        }
			//alert("out");
}
/*-------------*/
function updateUsernameStatus(to)
{
        var bad  = "<img align=\"top\" src=\"/images/bad.png\"> User name not available.";
        var good = "<img align=\"top\" src=\"/images/ok.png\"> User name is available!";

        var res = document.getElementById("UserCheckResult");

        okayusername = !okayusername;

        if (to) {
                res.innerHTML = good;
                okayusername = true;
        }
        else {
			document.getElementById("chkclick3").value	=	0;
                res.innerHTML = bad;
                okayusername = false;
        }
}
/*-------------*/
function hasProperUsername()
{
	 	var emailid = document.getElementById('email').value;
		//document.getElementById("chkclick1").value	=	1;

		/*if(emailid=="")
		{
			alert("Please enter email address");
			document.getElementById('email').focus();
			document.getElementById("chkclick1").value	=	0;
			return false;
		}
		else
		{
			 var reg = /^\w+[\.\w]+@\w+[\-\w]+[\.]+[A-Za-z]{2,3}/;
			 if(!reg.test(emailid))
			 {
				alert("Please provide correct email address.");
				document.getElementById('email').focus();
				document.getElementById("chkclick1").value	=	0;
				return false;
			 }
		}*/
		/* if (document.getElementById('imstudent').checked == true) 
		 {
			 if(document.getElementById('districtname').value==0)
			 {
				alert("please select a district name");	document.getElementById('districtname').focus();return false;
			}
			else if(document.getElementById('school_city').value=="")
			{
					alert("please enter school city name");document.getElementById('school_city').focus();return false;
			}
			else if(document.getElementById('school_state').value=="")
			{
					alert("please enter school  state name");document.getElementById('school_state').focus();return false;
			}
			else if(document.getElementById('subject').value=="")
			{
					alert("please enter subject name");document.getElementById('subject').focus();return false;
			}
			else if(document.getElementById('teacher_name').value=="")
			{
					alert("please enter the teacher name");document.getElementById('teacher_name').focus();return false;
			}
			else if(document.getElementById('school_city').value=="")
			{
					alert("please enter the city name");document.getElementById('school_city').focus();return false;
			}
			else if(!reg.test(document.getElementById('parent_email_address').value))
			{
				//parent_email_address
			 alert("please enter valid parents email address");document.getElementById('parent_email_address').focus();return false;
			}
		
	}*/
		var username = document.getElementById('newusername').value;
		if(username=="")
		{
			alert("Please enter user name");
			document.getElementById('newusername').focus();
			document.getElementById("chkclick3").value	=	0;
			return false;
		}
		
	
        if (document.getElementById('chkclick1').value == 0) 
			 {
			 //	alert("We require a unique email to sign up.\nType a email, and click 'check email availability'.");
			//	return false;
			 }
			  if (document.getElementById('chkclick3').value == 0) 
			 {
			 alert("We require a unique adfs username to sign up.\nType a name, and click 'check username availability'.");
				return false;
			 }
			 
}
function chkUser1()
{
	
	 	var emailid = document.getElementById('email').value;

		if(emailid=="")
		{
			alert("Please enter email address");
			document.getElementById('email').focus();
			return false;
		}
		else
		{
			 var reg = /^\w+[\.\w]+@\w+[\-\w]+[\.]+[A-Za-z]{2,3}/;
			 if(!reg.test(emailid))
			 {
				alert("Please provide correct email address.");
				document.getElementById('email').focus();
				document.getElementById("chkclick1").value	=	0;
				return false;
			 }
		}
}
function chkUser_StepOne()
{
	
		
	 	var emailid = document.getElementById('email').value;

		if(emailid=="")
		{
			alert("Please enter email address");
			document.getElementById('email').focus();
			return false;
		}
		else
		{
			 var reg = /^\w+[\.\w]+@\w+[\-\w]+[\.]+[A-Za-z]{2,3}/;
			 if(!reg.test(emailid))
			 {
				alert("Please provide correct email address.");
				document.getElementById('email').focus();
			//	document.getElementById("chkclick1").value	=	0;
				return false;
			 }
		}
}

function hasProperUsernameNew()
{
	alert ("in function");
	 	//var emailid = document.getElementById('email').value;
		//document.getElementById("chkclick1").value	=	1;

		
		/* if (document.getElementById('imstudent').checked == true) 
		 {
			 if(document.getElementById('districtname').value==0)
			 {
				alert("please select a district name");	document.getElementById('districtname').focus();return false;
			}
			else if(document.getElementById('school_city').value=="")
			{
					alert("please enter school city name");document.getElementById('school_city').focus();return false;
			}
			else if(document.getElementById('school_state').value=="")
			{
					alert("please enter school  state name");document.getElementById('school_state').focus();return false;
			}
			else if(document.getElementById('subject').value=="")
			{
					alert("please enter subject name");document.getElementById('subject').focus();return false;
			}
			else if(document.getElementById('teacher_name').value=="")
			{
					alert("please enter the teacher name");document.getElementById('teacher_name').focus();return false;
			}
			else if(document.getElementById('school_city').value=="")
			{
					alert("please enter the city name");document.getElementById('school_city').focus();return false;
			}
			else if(!reg.test(document.getElementById('parent_email_address').value))
			{
				//parent_email_address
			 alert("please enter valid parents email address");document.getElementById('parent_email_address').focus();return false;
			}
		
	}*/
		var username = document.getElementById('newusername').value;
		if(username=="")
		{
			alert("Please enter user name");
			document.getElementById('newusername').focus();
			document.getElementById("chkclick3").value	=	0;
			return false;
		}
		
	
        if (document.getElementById('chkclick1').value == 0) 
			 {
			 //	alert("We require a unique email to sign up.\nType a email, and click 'check email availability'.");
			//	return false;
			 }
			  if (document.getElementById('chkclick3').value == 0) 
			 {
			 alert("We require a unique adfs username to sign up.\nType a name, and click 'check username availability'.");
				return false;
			 }
			 
}
/*-------------*/
