function chkphone(phno,compul){
	ph = phno.value;
	for(i=0;i<ph.length;i++)
		if(isNaN(ph.charAt(i)) && (ph.charAt(i) != '-') && (ph.charAt(i)!='(') && (ph.charAt(i)!=')') && (ph.charAt(i)!=' ')){
			if(compul)
				alert("Enter a valid Phone number.\nOnly '()- ' is permitted other than Numbers.");
			else
				alert("Enter a valid Phone number or leave empty.\nOnly '()- ' is permitted other than Numbers.");
			phno.focus();
			return false;
		}
	if(ph.length<3 || ph.length>23){
		alert("Enter a valid Phone number.");
		phno.focus();
		return false;
	}
	else return true;
}
function chkpin(comppin){
	var pinlen = comppin.value.length;
	var pinval = comppin.value;
	for(i=0;i<pinlen;i++){
		if(isNaN(parseInt(comppin.value.charAt(i))) && comppin.value.charAt(i)!=' '){
			alert("Enter a valid pincode or leave blank.")
			comppin.focus();
			comppin.select();
			return false;
		}
	}
	return true;
}
function onsubmitchecksearch()
{
	if ((window.document.searchform.search.value=='') ||
		(window.document.searchform.select.selectedIndex==0))
	{
		alert("Please give the search criterion");
		return false;
	}
	if(!chkjunk(document.searchform.search))
		return false;	
}
// function to check if atleast one check box is checked
function chkall(frms){
	numchk = 0;
	cont = frms.length;
	for(i=0;i<cont;i++){
		cmp = eval("frms["+i+"]");
		if(cmp.type =="checkbox")
			if(cmp.checked && (cmp.name.substr(0,3)=="del" || cmp.name.substr(0,3)=="sta"))
				numchk += 1;
	}
	if(numchk == 0){
		alert("Please select atleast one, to continue.");
		return false;
	}
}
// function to check for the "'" and '"' char within the data entered
function chkjunk(compval)
{
	if((compval.value.indexOf("'") != -1) || (compval.value.indexOf('"') != -1)){
		alert("Please enter proper value");
		compval.focus();
		compval.select();
		return false;
	}
	else return true;
}
// function to check for whether the email id is valid or not
var junkchars = "#%$&*()+|!~`^=\/'><;:,";
function chkemail(compemail){
	if(compemail.value.indexOf('@')==-1 || compemail.value.indexOf('@')==0 || compemail.value.indexOf('.')==-1 || compemail.value.indexOf('.')==0){
		alert("Please Enter Valid Email ID");
		compemail.focus();
		return false;
	}
	else{
		elen=compemail.value.length;
		len=elen-4;
		if(compemail.value.indexOf('.',compemail.value.indexOf('@')) == -1){
		alert("Please Enter Valid Email ID");
			compemail.focus();
			return false;
		}
		for(i=0;i<junkchars.length;i++){
			if(compemail.value.indexOf(junkchars.charAt(i)) != -1){
		alert("Please Enter Valid Email ID");
				compemail.focus();
				return false;
			}
		}
		if(compemail.value.charAt(len)!='.' && compemail.value.charAt(len+1)!='.'){
		alert("Please Enter Valid Email ID");
			compemail.focus();
			return false;
		}
	else 
	return true;
	}
}
// Date validation starts here
var day = null;
var month = null;
var year = null;
function validate(compd,compm,compy)
{
	day = compd[compd.selectedIndex].value;
	month = compm[compm.selectedIndex].value;
	year = compy[compy.selectedIndex].value;
	
	if(isDate(year, month, day)){
		return true;
	}
	else{
		alert("\nPlease enter appropriate date.");
		return false;
	}
}
function isDate (year, month, day){
	month = month - 1; // javascript month range : 0- 11
	var aaj = new Date();
	var tempDate = new Date(year,month,day);
	if ((getYear(tempDate.getYear()) == year) &&
		(month == tempDate.getMonth()) && (day == tempDate.getDate()) )
		return true;
	else
		return false;
}
function getYear(d) { 
	return (d < 1000) ? d + 1900 : d;
}
// Date validation ends here