var xmlhttp
function check_Xhr_Object(){
	//check the browser and assign the correct XMLHttpRequest Object
	if (window.XMLHttpRequest){
	  // code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	if (window.ActiveXObject){
	  // code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
}
//version 0
function forgot_pswd(){
	check_Xhr_Object(); //check the browser and assign the correct XMLHttpRequest Object
	if (xmlhttp!=null){
	  	var url="includes_dao/dao-c.asp?forgot_pswd=1";
	  	xmlhttp.open("GET",url,true);
	  	xmlhttp.send(null);
	  }
	else{
	  alert("Your browser does not support XMLHTTP.");
	  }
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
  			document.getElementById("login_fgpswd_spn").innerHTML=xmlhttp.responseText;
			changeDivHeight();
  		}
	}
}
//version 1
function forgot_pass(){
	check_Xhr_Object(); //check the browser and assign the correct XMLHttpRequest Object
	if (xmlhttp!=null){
	  	var url="includes_dao/dao-c.asp?forgot_pass=1";
	  	xmlhttp.open("GET",url,true);
	  	xmlhttp.send(null);
	  }
	else{
	  alert("Your browser does not support XMLHTTP.");
	  }
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
  			document.getElementById("login_fgpswd_spn").innerHTML=xmlhttp.responseText;
			changeDivHeight();
  		}
	}
}
//version 0
function forgot_pswd_post(){
	email_txt= document.getElementById("email_txt").value;
	email_removespaces= email_txt.replace(/ /g, "");
	email_numchars= email_removespaces.length;
	email_txt=email_removespaces;
	if (email_numchars>0){
		if (validate_email(email_txt)==true){
			//alert("hit forgot_pswd_post() and email_numchars>0 and it is a valid email so post the forgot_pswd_form");
			check_Xhr_Object(); //check the browser and assign the correct XMLHttpRequest Object
			if (xmlhttp!=null){
				var url="includes_dao/dao-c.asp?forgot_pswd_post=1";
				xmlhttp.open("POST",url,true);
				xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
				form_values= "email_txt="+email_txt;
				xmlhttp.send (form_values);
			  }
			else{
			  alert("Your browser does not support XMLHTTP.");
			  }
			xmlhttp.onreadystatechange=function(){
				if(xmlhttp.readyState==4){
					document.getElementById("login_fgpswd_spn").innerHTML=xmlhttp.responseText;
					changeDivHeight();
				}
			}
		}
	}
	else{
		//alert("hit forgot_pswd_post() and email_numchars=0 so email is blank thus invalid");
		 alert("Invalid Email.");
	}
}
//version 0
function validate_email(str) {
	//Function is used to verify if the given value is a possible valid email address. This function thus simply makes sure the email address has one (@), atleast one (.). It also makes sure that there are no spaces, extra '@'s or a (.) just before or after the @. It also makes sure that there is atleast one (.) after the @.
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid Email.")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid Email.")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid Email.")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid Email.")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid Email.")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid Email.")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Invalid Email.")
		return false
	 }

	 return true					
}
//version 0
function backto_login(){
	check_Xhr_Object(); //check the browser and assign the correct XMLHttpRequest Object
	if (xmlhttp!=null){
	  	var url="includes_dao/dao-c.asp?backto_login=1";
	  	xmlhttp.open("GET",url,true);
	  	xmlhttp.send(null);
	  }
	else{
	  alert("Your browser does not support XMLHTTP.");
	  }
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
  			document.getElementById("login_fgpswd_spn").innerHTML=xmlhttp.responseText;
			changeDivHeight();
  		}
	}
}
//version 1
function back_login(){
	check_Xhr_Object(); //check the browser and assign the correct XMLHttpRequest Object
	if (xmlhttp!=null){
	  	var url="includes_dao/dao-c.asp?back_login=1";
	  	xmlhttp.open("GET",url,true);
	  	xmlhttp.send(null);
	  }
	else{
	  alert("Your browser does not support XMLHTTP.");
	  }
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
  			document.getElementById("login_fgpswd_spn").innerHTML=xmlhttp.responseText;
			changeDivHeight();
  		}
	}
}


