var xmlhttp
function showHint(str)
{
	if (str.replace(/ /g,'').length==0)
	{
		document.getElementById("userid").innerHTML="";
		return;
	}
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support XMLHTTP!");
		return;
	}
	var url="/MyAccount/checkid.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("userid").innerHTML=xmlhttp.responseText;
	}
}
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
function validate()
{
	with ( window.document.InboxRegistration)
	{
		var fname= FirstName.value.replace(/ /g,"");
		if(fname.length < 1 || FirstName.value == "First Name")
		{
			alert("Please Enter your First Name");
			FirstName.focus();
			return false;
		}
		var lname= LastName.value.replace(/ /g,"");
		if(lname.length<1 || LastName.value == "Last Name")
		{
			alert("Please Enter your Last Name");
			LastName.focus();
			return false;
		}
		if (gender.value == "Gender")
		{
			alert ("Please Select Gender!");
			gender.focus();
			return false;
		}
		if (country.value == "Select Country")
		{
			alert ("Please Select Country!");
			country.focus();
			return false;
		}
		if (CheckID.value == "")
		{
			alert ("Please enter desired User ID!");
			CheckID.focus();
			return false;
		}
		if (CheckID.value.length < 4 || password.value.length > 20)
		{
			alert ("Min 4, max 20 characters for User ID!");
			CheckID.focus();
			return false;
		}
		var regex = /^([a-zA-Z0-9\-\.\_])+$/;
		if (!regex.test(CheckID.value))
		{
			alert("Invalid User ID format. Check following points to Create a Valid User ID.\n1. Avoid Special Characters.\n2. Space is not allowed.\n3. Its not your Email ID.\n4. User ID should start with an Alphabet.");
			CheckID.focus();
			return false;
		}
		if (NewEmailID.value.length < 1)
		{
			alert ("Please Enter Email ID!");
			NewEmailID.focus();
			return false;
		}
		var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if(!regex.test(NewEmailID.value))
		{
			alert("Invalid email address format");
			NewEmailID.focus();
			return false;
		}
		if(NewEmailID.value.indexOf("@go2inbox") > 0)
		{
			document.getElementById("email_of_go2inbox").style.display = "block";
			document.getElementById("email_of_go2inbox").style.color = "#FF0000";
			document.getElementById("email_of_go2inbox").style.fontSize = "9px";
			document.getElementById("email_of_go2inbox").style.fontFamily = "tahoma,arial,verdana";
			document.getElementById("email_of_go2inbox").innerHTML=NewEmailID.value+" is not your Email ID.<br>It should be your existing email id!";
			NewEmailID.focus();
			return false;
		}
		if(NewEmailID.value.indexOf("@go2inbox")<0)
		{
			document.getElementById("email_of_go2inbox").style.display = "none";
		}
		if  (password.value.length < 4 || password.value.length > 20)
		{
			alert ("Min 4, max 20 characters for password!");
			password.focus();
			return false;
		}
		if (password.value != confirm_password.value)
		{
			alert ("Wrong Confirmation Password.");
			confirm_password.focus();
			return false;
		}
	}
	return true;
}
function clearemail()
{
	if(document.InboxRegistration.NewEmailID.value == "Your Existing Email ID")
		document.InboxRegistration.NewEmailID.value="";
}
function putemail()
{
	if(document.InboxRegistration.NewEmailID.value == "")
		document.InboxRegistration.NewEmailID.value="Your Existing Email ID";
}
function clear_fn()
{
	if(document.InboxRegistration.FirstName.value == "First Name")
		document.InboxRegistration.FirstName.value="";
}
function put_fn()
{
	if(document.InboxRegistration.FirstName.value == "")
		document.InboxRegistration.FirstName.value="First Name";
}
function clear_ln()
{
	if(document.InboxRegistration.LastName.value == "Last Name")
		document.InboxRegistration.LastName.value="";
}
function put_ln()
{
	if(document.InboxRegistration.LastName.value == "")
		document.InboxRegistration.LastName.value="Last Name";
}
