function chkbox(field,msg){
var i,frmvalue,flag=0
	for(i=0;i<field.length;i++){
		if (field[i].checked){
			frmvalue=field[i].value;
			flag=1
			break
		}
	}
	if (flag==0){
		alert(msg)
		field[0].focus()
		return true
	}
}

function trim(field){
if (field.charAt(0)==" "){
	field=field.substring(1,field.length)
	return trim(field)
}else
if(field.charAt(field.length-1)==" "){
	field=field.substring(0,field.length-1)
	return trim(field)
}
return field
}

function validate(field) {
	if(field.length!=0){
		var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\' "
		var ok = "yes";
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") {
			alert("Invalid entry!  Only valid characters are accepted!");
			return false;
		}
		return true

	}else{
		return false
	}
}

function namefield(field) {
	if(field.length!=0){
		var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. "
		var ok = "yes";
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") {
			alert("Invalid entry!  Only valid characters are accepted!");
			return false
		}
		return true

	}else{
		return false
	}
}
function validate2(field) {
	if(field.length!=0){
		var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890. "
		var ok = "yes";
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") {
			alert("Invalid entry!  Only valid characters are accepted!");
			return false
		}
		return true

	}else{
		return false
	}
}

function loginvalidate(field) {
	if(field.length!=0){
		var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"
		var ok = "yes";
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") {
			alert("Special Character not allowed!");
			return false
		}
		return true

	}else{
		return false
	}
}


function alphanumeric(field) {
	if(field.length!=0){
		var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' "
		var ok = "yes";
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") {
			alert("Invalid entry!  Only valid characters are accepted!");
			return false
		}
		return true

	}else{
		return false
	}
}
function alphanumeric1(field) {
	if(field.length!=0){
		var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',;/)][@#&!?._*( +"
		var ok = "yes";
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") {
			alert("Invalid entry!  Only valid characters are accepted!");
			return false
		}
		return true

	}else{
		return false
	}
}
function nmbr(field) {
	if(field.length!=0){
		var valid = "0123456789 -/"
		var ok = "yes"
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1)
			if (valid.indexOf(temp) == "-1") ok = "no"
		}
		if (ok == "no") {
			alert("Please enter integer value")
			return false
		}
		return true

	}else{
		alert("Please enter integer value")
		return false
	}
}

function nmbr1(field) {
	if(field.length!=0){
		var valid = "0123456789"
		var ok = "yes"
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1)
			if (valid.indexOf(temp) == "-1") ok = "no"
		}
		if (ok == "no") {
			alert("Please enter integer value")
			return false
		}
		return true

	}else{
		alert("Please enter integer value")
		return false
	}
}
function nmbr2(field) {
	if(field.length!=0){
		var valid = "0123456789."
		var ok = "yes"
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1)
			if (valid.indexOf(temp) == "-1") ok = "no"
		}
		if (ok == "no") {
			alert("Please enter decimal value")
			return false
		}
		return true

	}else{
		alert("Please enter decimal value")
		return false
	}
}

function textarea(field) {
	if(field.length!=0){
		var valid = "@123456789ABCD EFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_ ]*[;:?&.,+(\#\)/\\-_\"\'"
		var ok = "yes";
		var temp;
		for (var i=0; i<field.length; i++) {
			temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "no";
		}
		if (ok == "no") {
			alert("Invalid entry!  Only valid characters are accepted!");
			return false
		}
		return true

	}else{
		return false
	}
}

function emailCheck(emailStr){
var valid1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ -_1234567890@.abcdefghijklmnopqrstuvwxyz"
var ok1="yes";
var temp1;
for (var i=0; i<emailStr.length; i++) {
temp1 = "" + emailStr.substring(i, i+1);
if (valid1.indexOf(temp1) == "-1") ok1 = "no";
}
if (ok1 == "no") {
alert("Enter a valid e-mail ID!")
return false
}
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Enter a valid e-mail ID!");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("The username contains invalid characters.");
return false;
}
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}
if (user.match(userPat)==null) {
alert("Enter a valid e-mail ID!");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
}
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
}
}
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("Enter a valid e-mail ID!");
return false;
}
if (len<2) {
alert("This address is missing a hostname!");
return false;
}
return true;
}


function isValidDate(day,month,year)
{
	var dteDate;
	dteDate=new Date(year,month,day);
	//alert(((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear())));
	return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));
	
}