function newWindow(file){window.open(file,"subwindow","height=800,width=875");}


function verifyEmailformat(string)
{
	var email = string;
	var AtPos = email.indexOf("@");
	var StopPos = email.lastIndexOf(".");
	var long = email.length;
	if (AtPos == -1 || AtPos ==0 || StopPos == -1 || StopPos==long-1) 
	{
		return false;
	}
	else if (StopPos < AtPos) 
	{
		return false;
	}
	else if (StopPos - AtPos == 1) 
	{
		return false;
	}
	else 
	{
		return true;	
	}
}
function clr(name, defaultText1){var box = window.document.getElementById(name);if (box.value==defaultText1){box.value="";}}
function rplace(name, defaultTxt){var box2 = window.document.getElementById(name);if (box2.value==""){box2.value=defaultTxt;}}



function validateProcess(box, text, name) 
{
	var ckEmailFormat;
	var errorDiv=null;
	var Email= ckEmailFormat = ((name=="email")?verifyEmailformat(box.value):false);
	if (box.value == "" || name=="email"&&!Email)
	{
		if (!document.getElementById(name+"box"))
		{
			errorDiv=document.createElement("div");	
			errorDiv.className="error";
			errorDiv.id=name+"Box";
			errorDiv.style.color = "red";
			errorDiv.style.marginTop= "-8px";
			errorDiv.style.marginBottom="10px";
			errorDiv.innerText=text;
			box.insertAdjacentElement("afterend", errorDiv);
			return 0;
		}
		else if (document.getElementById(name+"box"))
		{
			if (document.getElementById(name+"box").style.display!="block")
				{
					document.getElementById(name+"box").style.display="block";	
				}
			return 0;
		}
	}	
	Email=(name!="Email") ? true : ckEmailFormat;	
	if (box.value != "" && box.value != text && Email&&document.getElementById(name+"box"))
		{
			document.getElementById(name+"box").style.display="none";
			return 1;
		}
	if (box.value != "" && box.value != text && Email)
	{
		return 1;
	}
}
function validate()
{	//check name;
	var code=0;
    
	code = parseInt(validateProcess(document.getElementById("firstName"), "Please enter your name:", document.getElementById("firstName").id));
	
	//check email;
	
	code += parseInt(validateProcess(document.getElementById("email"), "Please enter a valid email:", document.getElementById("email").id));
	
	
	
	if (code==2)
	{
		return true;	
	}
	else
	{
	    
		return false;	
	}
}
