/*****************/
/* Indranil Basu */
/*****************/
/*
 *  Regular expression function to check integer only
 */
function integeronly(THIS){
	var pattern = /^[0-9]+$/;
	if(!pattern.test(THIS.value)){
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);		
		return false;
	}
}
/*
 *  Regular expression function to check user name of login
 */
function username(THIS){
	var pattern = /^[0-9a-zA-z_]+$/;
	if(!pattern.test(THIS.value)){
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
		return false;
	}
}

function checkPassword(THIS){
	/*var pattern = /^[0-9a-zA-z_()-]+$/;
	if(!pattern.test(THIS.value)){
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
		return false;
	}*/
	//alert(THIS.value);
	if(THIS.value.length < 8 || THIS.value.length > 16){
		alert("The length of password must be between 8 to 16 characters.")
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
	}
}

function passMatch(passwd,THIS){
	if(THIS.value.length > 7 || THIS.value.length < 17){
		if(document.getElementById(passwd).value != THIS.value){
			alert("Password mismatch");
			document.getElementById(passwd).value = "";
			THIS.value = "";
			setTimeout("document.getElementById('"+passwd+"').focus()", 50);
		}
	}
	else{
		alert("The length of re-type password must be between 8 to 16 characters.")
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
	}
}

/*
 *  Regular expression function to check a-z A-Z characters
 */
function checkAlphabets(THIS){
	var pattern = /^[a-zA-Z ]+$/;
	if(!pattern.test(THIS.value)){
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
		return false;
	}
}

/*
 * Regular Expression function to check Pin Code.
 */
function checkPinCode(THIS){
	var pattern = /^(\d{6})?$/;
	if(!pattern.test(THIS.value)){
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
	}
}

/*
 * Regular Expression function to check Telephone.
 */
function checkTelephone(THIS){
	var pattern = /^(\d{10})?$/;
	if(!pattern.test(THIS.value)){
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
	}
}
/*
 * Regular Expression function to check Email
 */
function checkEmail(THIS){
	/*var pattern = /^[0-9a-zA-z_-@.]+$/;
	if(!pattern.test(THIS.value)){
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
		return false;
	}*/
}

function checkemail(THIS){
 	var str = THIS.value
	if(str != ''){
		var filter=/^.+@.+\..{2,3}$/
		if (filter.test(str))
			testresults=true
		else {
			THIS.value = "";
			setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
		}
	}
}


function emailcheck(THIS)
{
	str = THIS.value;
	if((str.lastIndexOf(".") > 2 && str.lastIndexOf(".") < (str.length - 1)) && (str.indexOf("@") > 0) && (str.lastIndexOf("@") == str.indexOf("@")))
	{
	s=1;
	}
	else{
		THIS.value = "";
		setTimeout("document.getElementById('"+THIS.id+"').focus()", 50);
	}
}
