/* 

'ööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööö
'	FileName	:	Validation.js
'	Author		:	Samir Sudrik
'	Created On	:	29/1/03
'	Description	:	File is Containg All the Global Function Required 
					For the Application.
'ööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööööö
*/

// ööööööööööööööööööööööööö FUNCTIONS ööööööööööööööööööööööööö 

var reWhitespace = /^\s+$/;

function checkdate(yy,mm,dd){
		var today = new Date();
		xdate = new Date(yy,parseInt(mm)-1,dd);
		if (xdate > today)	{
			return true;
		}else	{
			return false;
		}	
}

function chkit(form,fieldname,msg){
	var val;
	val="";	
	val=eval("document."+ form+"."+fieldname+".value");
	if (val.length > 0){
		val=trim(val);
    }
	if(val == ""){
		alert(msg);
		eval("document."+form+"."+fieldname+".focus()");
		return false;
	}	
	else {
		return true; }				
}

/*
	Trim Function To Remove all the Spaces From Right nd Left side Of the passed(Given) String
*/
function trim(txt){
	txt=txt.replace(/^[\s]+/g,"");
	txt=txt.replace(/[\s]+$/g,"");
	return txt;
}

/*
	check mail Function Check The MailId And Returns True/False 
*/
var reEmail = /^.+\@.+\..+$/

function isEmail (s)
{
	var reEmail = /^.+\@.+\..+$/
    return reEmail.test(s)
}

function checkemail(s)
{
	if (!isEmail(s.value))
	{
		return false;
		//alert("Invalid Email Address");
		//document.me.ccno.focus();
	}else{
		return true;
	}
}


/* 
Function used to Count the number of charecters in the text area field
if charecters exceeds the Limit It will Pop the Msg.
*/
function charcount(form,fldname,maxcount){
	var newval;
	var tmpval="";
	tmpval=eval("document."+form+"."+fldname+".value");		
	tmpval=trim(tmpval);
	tot=(tmpval.length )
	if (tot > maxcount) {		
		newval="";
		newval=tmpval.substr(0,maxcount-1);		
		
		eval("document."+form+"."+fldname+".value='"+newval+"'");
		eval("document."+form+"."+fldname+".focus()");
		alert("Sorry, No More  Charecters Accepted."); 
		return false;
	}	
	else{
		return true;	
	}
}

/* 
Check the Date . if the date is invalid Date it will return false.
*/
function chkdate(dx1){
	xarray = dx1.split("/");

	m=xarray[0];
	d=xarray[1];
	y=xarray[2]
	//alert(d+""+m+""+y)
	if ((isEmpty(d)) || (isEmpty(m)) || (isEmpty(y))){
		return false;
	}

	var today = new Date();
	toyear = today.getYear();

	/*if (y>(toyear+1)){
		return false;
	}*/
	var arr=new Array(12);
	arr[0]=31;
	arr[1]=28;
	arr[2]=31;
	arr[3]=30;
	arr[4]=31;
	arr[5]=30;
	arr[6]=31;
	arr[7]=31;
	arr[8]=30;	
	arr[9]=31;
	arr[10]=30;
	arr[11]=31;
	if (m > 12)
		return false;
		
	if((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)){
		arr[1]=29;
	}	
	if (d > arr[m-1])
		return false;
	else
		return true;
}

// Checking For the delete Check Boxes will return true/ false. value according to the selection of checkbox.
// if no checkboxes are selected will return false else true.

function checkdelete(form,fld) {
	  var chkd = false;
	  var cnt = eval("document."+form+"."+fld+".length");		  	  
	  if (isNaN(cnt)==true){
		if (eval("document."+form+"."+fld+".checked")){			
				 chkd = true;
			}	 
		else{
			 chkd = false;
		}
			
	  }
	 else{
	   for(var i=0;i<cnt;i++){
			if (eval("document."+form+"."+fld+"["+i+"]"+".checked")){	
				 chkd = true;
			}	 
		}
	  }	
	 if(chkd){					
		return true;
			//U r code to confirm the delete if any will come here			
	 }
	 else{
			return false;
		 }	 
 }

function isWhitespace (s)

{   // Is s empty?
    //return (isEmpty(s) || reWhitespace.test(s));
	alert(reWhitespace.test(s));
	return (isEmpty(s) || reWhitespace.test(s));
}


function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}



//	ööööööööööööööööööööööööö END OF FUNCTIONS ööööööööööööööööööööööööö 

