// Removes leading whitespaces
function LTrim(value) {
	
	//alert(value);
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	//alert(value);
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

function emailvalidation(str)
{
	var emailRegxp = /^[a-zA-Z]*[\w\.-]*[a-zA-Z0-9]@[a-zA-Z]*[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	//alert(emailRegxp.test(str));
	return emailRegxp.test(str);
}

function formvalid()
{
	objform=eval(document.form1);
	// Registration form validation
	if(trim(objform.username.value)=="")
	{
		alert("'Email' is a required field!");
		objform.username.focus();
		return false;
	}
		
	if(!emailvalidation(objform.username.value))
   	{
		alert("The E-mail is in an invalid format.Please enter valid email format.");
		objform.username.focus();
		return false;
   	}
	objform.tar.value="forgotpassword";
	//objform.submit();
	return true;
}
