function press(e)
{
	if (e.keyCode == 27)
	{
		self.close();
	}
}

function ValidateEmail( email )
{
	var atCharPresent = false;
	var dotPresent = false;

	for ( var Idx = 0; Idx < email.length; Idx++ )
	{
		if ( email.charAt ( Idx ) == '@' )
			atCharPresent = true;
		if ( email.charAt ( Idx ) == '.' )
			dotPresent = true;
	}

	if (!atCharPresent || !dotPresent )
	{
		return false;
	}
	
	return true;
}

function validateLogin()
{
	//user id
	if(document.getElementById("login_emailid").value == "")
	{
		alert("Enter Valid Email Id.");
		document.getElementById("login_emailid").focus();
		return false;
	}
	else 
	{
		if (!checkspace(document.getElementById("login_emailid").value))
		{
			alert("You Can Not Enter Space As Value.");
			document.getElementById("login_emailid").focus();
			document.getElementById("login_emailid").value="";
			return false;
		}
		
		if (!ValidateEmail( document.getElementById("login_emailid").value ) )
		{
			alert( "Invalid Email " + document.getElementById("login_emailid").value);
			document.getElementById("login_emailid").focus();
			document.getElementById("login_emailid").value = "";
			return false;
		}
	}
	
	//pass word
	if(document.getElementById("login_password").value == "")
	{
		alert("Enter Valid Password.");
		document.getElementById("login_password").focus();
		return false;
	}
	else
	{
		if (!checkspace(document.getElementById("login_password").value))
		{
			alert("You Can Not Enter Space As Value.");
			document.getElementById("login_password").focus();
			document.getElementById("login_password").value="";
			return false;
		}
	}
	
	return true;
}

//Check whether space entered or not?
function checkspace(x)
{
	var isAllSpace = true;

	for(var i=0; i<x.length; i++)
	{
		if(x.charCodeAt(i) != 32)
		{
			isAllSpace = false;
			return true;
			break;
		}
	}
	if (isAllSpace)
	{
		return false;
	}
}

function textfocus()
{
	document.getElementById("login_emailid").focus();
}

function openwin(str) 
{
	var newwin;

	if (!newwin || newwin.closed)
	{
		newwin=eval("window.open(str,'child','left=130,top=120,width=370,height=300,scrollbars=no')");
	}
	else
	{
		newwin.close();
		newwin=eval("window.open(str,'child','left=130,top=120,width=370,height=300,scrollbars=no')");
	}
}