


function canc() {
if (window.event.shiftKey) 
    window.event.returnValue = false;
}



function chkEmail(strEmail){
	var at_count=0;
	var per_count=strEmail.indexOf('.');
	var space_count=strEmail.indexOf(' ')
	
	if (space_count==-1)
		if(0<per_count&& per_count+1<strEmail.length) {
			for(i=0;i<strEmail.length;i++) {	
				if (strEmail.charAt(i)=='@'	&& i>0&& i+1<strEmail.length) at_count++;
			}	
			if(at_count==1)	return true;	
		}
	return false;
}


function chkdq(s) {
  var ndq = true;
  var temp;
  var strName;
  sLength =s.length;
  strName=s;
  for (var i = 0;i<sLength;i++) {
    temp=strName.charCodeAt(i);
    if (temp==34) ndq=false;        
  }
  return ndq;
}

function chkPostalCode(theField)
 { 
	var PC = theField.toUpperCase();
	if (PC.length == 6){       
		for (var x = 0; x < 5; x = x+2){
			if ( (PC.charAt(x)<"A") || (PC.charAt(x) > "Z") || (PC.charAt(x+1)<"0") || (PC.charAt(x+1)>"9") ){
				return false;
			}
		}
	 	return true;
	}
	else
       return false;
  }


function chkName(s) {
  var isAlpha = true;
  var temp;
  var strName;
  
  sLength =s.length;
  strName=s;
  for (var i = 0;i<sLength;i++) {
    temp=strName.charCodeAt(i);
    if (!(((temp>=65)&&(temp <=90))||((temp>=97)&&(temp<=122))||(temp==32)||(temp==40)||(temp==41)||(temp==46)||(temp==44)||(temp==45)||(temp==95)||(temp==39)))   isAlpha=false;        
  }
  return isAlpha;
}

function removeSpace(s){
	var len = s.length
	var str=''
	for (var i=0 ; i < len; i++){if(s.charAt(i) != ' ') str +=s.charAt(i)}
	return(str)
}

function hasSpace(s){
	var isSpace = false;
	var len = s.length
	
	for (var i=0 ; i < len; i++){if(s.charAt(i) == ' ') isSpace = true;}
	return isSpace;
}

function chkTele(number){
	var sLength = number.length

	//remove (),#,- and blankspace
	for (var i=0; i < sLength; i++){
		number =number.replace(/\(/,'').replace(/\ /,'').replace(/\)/,'').replace(/\#/,'').replace(/\-/,'').replace(/\./,'');
	}
	return ( number );
}

function chkNumber(s) {
	var strNumber;
	var i;
	var len;
	
	strNumber=removeSpace(s);
	len=strNumber.length
	for (var i=0 ; i < len; i++) {
		if(strNumber.charCodeAt(i)>57 || strNumber.charCodeAt(i)<48) return false;		
	}
	strNumber=parseInt(strNumber,10);	
	if (isNaN(strNumber)) 	return false;	
	
	return true;
}


function chkDNumber(s) {
  var ndq = true;
  var temp;
  var strName;
  sLength =s.length;
  strName=s;
  
  if (sLength != 5) ndq=false;	
  
  temp=strName.charCodeAt(0);
  if ((temp!=65) && (temp!=97) && (temp!=66) && (temp!=98)) ndq=false; 
  
  for (var i = 1;i<sLength;i++) {
    temp=strName.charCodeAt(i);
    if(temp>57 || temp<48) ndq=false;
		       
  }
    
  return ndq;
}


function chkName(s) {
  var isAlpha = true;
  var temp;
  var strName;
  
  sLength =s.length;
  strName=s;
  for (var i = 0;i<sLength;i++) {
    temp=strName.charCodeAt(i);
    if (!((temp>=192) ||((temp>=48)&&(temp <=57)) || ((temp>=65)&&(temp <=90))||((temp>=97)&&(temp<=122))||(temp==32)||(temp==40)||(temp==41)||(temp==46)||(temp==47)||(temp==44)||(temp==45)||(temp==95)||(temp==39) ||(temp==38)))   isAlpha=false;        
  }
  return isAlpha;
}

function chkName2(s) {
  var isAlpha = true;
  var temp;
  var strName;
  
  sLength =s.length;
  strName=s;
  for (var i = 0;i<sLength;i++) {
    temp=strName.charCodeAt(i);
    //if (!(((temp>=65)&&(temp <=90))||((temp>=97)&&(temp<=122))||(temp==32)||(temp==40)||(temp==41)||(temp==46)||(temp==44)||(temp==45)||(temp==95)||(temp==39)))   isAlpha=false;        
    if (!((temp>=192) || ((temp>=65)&&(temp <=90))||((temp>=97)&&(temp<=122))||(temp==32)||(temp==40)||(temp==41)||(temp==46)||(temp==47)||(temp==44)||(temp==45)||(temp==95)||(temp==39) ||(temp==38)))   isAlpha=false;        
  }
  return isAlpha;
}

function LeapYear(intYear){
	if (intYear % 100 == 0){
		if (intYear % 400 == 0) { return true; }
	}
	else {
		if ((intYear % 4) == 0) { return true; }
	}
		return false;
	}
	

function chkdate(strDate)
	{
		var strDateArray;
		var strDay;
		var strMonth;
		var strYear;
		var intday;
		var intMonth;
		var intYear;
		var blnFound = false;
		var strSeparatorArray = new Array("/");
		var intElementNr;
		var err = 0;
		var strMonthArray = new Array(12);
		strMonthArray[0] = "01/";
		strMonthArray[1] = "02/";
		strMonthArray[2] = "03/";
		strMonthArray[3] = "04/";
		strMonthArray[4] = "05/";
		strMonthArray[5] = "06/";
		strMonthArray[6] = "07/";
		strMonthArray[7] = "08/";
		strMonthArray[8] = "09/";
		strMonthArray[9] = "10/";
		strMonthArray[10] = "11/";
		strMonthArray[11] = "12/";

		
		if (strDate.length < 6)		//min date entry should be eg, 3/1/01 -- 6 chars
		{return false;}
		
		for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++)
		{
			if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) 
			{
				strDateArray = strDate.split(strSeparatorArray[intElementNr]);
				if (strDateArray.length != 3)		//after split, this should now be in day, month, year format
				{
					err = 1;
					return false;
				}
				else 
				{
					strDay = strDateArray[1];
					strMonth = strDateArray[0];
					strYear = strDateArray[2];
				}
				blnFound = true;
			}
		}
		if (blnFound == false) 
		{return false;}
		
		intday = parseInt(strDay, 10);
		if (isNaN(intday)) 
		{
			err = 2;
			return false;
		}
		intMonth = parseInt(strMonth, 10);
		if (isNaN(intMonth)) 
		{
			for (i = 0;i<12;i++) 
			{
				if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) 
				{
					intMonth = i+1;
					strMonth = strMonthArray[i];
					i = 12;
				}
			}
			if (isNaN(intMonth)){return false;}
		}
		
		
		if (strYear.length == 2){strYear = '20' + strYear;}
		intYear = parseInt(strYear, 10);
		if (isNaN(intYear))	{return false;}
		if (intYear < 1900 || intYear > 2004) {return false;}
		if (strYear.length > 4 || strYear.length == 3){return false;} 
				
		if (intMonth>12 || intMonth<1){return false;}
		
		//mos w/ 31 days
		if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) 
		{return false;}
		
		//mos w/ 30 days
		if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) 
		{return false;}
		
		//february, evaluate if leap year
		if (intMonth == 2) 
		{	if (intday < 1) 
			{return false;}
			if (LeapYear(intYear) == true) 
			{
				if (intday > 29) 
				{return false;}
			}
			else 
			{
				if (intday > 28) 
				{return false;}
			}
		}
		return true;
	}
