function chkamount(amt)
{
     data=amt.value;
     if(data!="")
     {
     sdata=data.split("$");
     if(isNaN(sdata[1]))
     {
       alert("Please enter valid data");
       amt.focus();
       amt.select();
       return false;
     }
    }
}
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.\nOnly '()- ' is permitted other than Numbers.");
			phno.focus();
			phno.select();
			return false;
		}
	if(ph.length<3 || ph.length>23){
		alert("Enter a valid Phone number.");
		phno.focus();
		phno.select();
		return false;
	}
	else return true;
}

function chkfax(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 Fax number.\nOnly '()- ' is permitted other than Numbers.");
                         else
				alert("Enter a valid Fax number.\nOnly '()- ' is permitted other than Numbers.");
			phno.focus();
			phno.select();
			return false;
		}
	if(ph.length<3 || ph.length>23){
		alert("Enter a valid Fax number.");
		phno.focus();
		phno.select();
		return false;
	}
	else return true;
}

function chkmobile(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 Mobile number.\nOnly '()- ' is permitted other than Numbers.");
                         else
				alert("Enter a valid Mobile number.\nOnly '()- ' is permitted other than Numbers.");
			phno.focus();
			phno.select();
			return false;
		}
	if(ph.length<3 || ph.length>23){
		alert("Enter a valid Mobile number.");
		phno.focus();
		phno.select();
		return false;
	}
	else return true;
}

function chkphone1(phno){
	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)!=' ')){
                      {		
			phno.focus();
			return false;
                      }  
		}
	if(ph.length<3 || ph.length>23){
		alert("Enter a valid Phone number.");
		phno.focus();
		phno.select();
		return false;
	}
	else 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) || (compval.value.indexOf('`') != -1)) {
		alert("Please enter proper Data");
		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("Invalid email address. Enter valid email address");
		compemail.focus();
		compemail.select();				
		return false;
	}
	else{
		elen=compemail.value.length;
		len=elen-4;
		if(compemail.value.indexOf('.',compemail.value.indexOf('@')) == -1){
			alert("Invalid email address. Enter valid email address");
			compemail.focus();
			compemail.select();					
			return false;
		}
		for(i=0;i<junkchars.length;i++){
			if(compemail.value.indexOf(junkchars.charAt(i)) != -1){
				alert("Invalid email address. Enter valid email address");
				compemail.focus();
				compemail.select();					
				return false;
			}
		}
		if(compemail.value.charAt(len)!='.' && compemail.value.charAt(len+1)!='.'){
			alert("Invalid email address. Enter valid email address");
			compemail.focus();
			compemail.select();					
			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

// Date Validatiom(mm/dd/yy)
	function validate(data1)
	{
	    data=data1.value;
		error = 0;
		sDate=data.split("/")
		//if((data.charAt(2)!="/" && data.charAt(5)!="/"))
		if(data.indexOf("/")==-1)
			error = 1;
		else if(isNaN(sDate[0])||isNaN(sDate[1])||isNaN(sDate[2]))
			error = 1;
		else
		{
			day = parseInt(sDate[1]);
			mnth = parseInt(sDate[0]);
			yr = parseInt(sDate[2]);

			if(mnth>12 || mnth<1)
				error = 2;

                        // mnthArray[0] is january, mnthArray[11] is december
			mnthArray = new Array(31,29,31,30,31,30,31,31,30,31,30,31);

			// netscape/IE number months starting with january = 0
			mnth = mnth-1;
			mydate = new Date(yr,mnth,day);
//			if(mydate.getDay() != 5) // sunday==0 , saturday==6 we're checking for friday
//				error = 4;

			if(day > parseInt(mnthArray[parseInt(mnth)]))
				error = 3;
		}

		switch(error)
		{
		case 1: alert("Date must be in mm/dd/yy format");
				data1.focus();
				data1.select();
				return false;
				break;
		case 2: alert("The month you entered is invalid.");
				data1.focus();		
				data1.select();
				return false;
				break;
		case 3: alert("The day you entered is invalid for the month.");
				data1.focus();
				data1.select();		
				return false;
				break;
		case 4: alert("The date you entered is invalid.");
				data1.focus();
				data1.select();		
				return false;
				break;
		default: return true;
		}
	}
