

//Validate Integers
function IsValidInteger (strValue)
{

	var objRegExp  = /(^-?\d\d*$)/;

	//check for integer characters
	return objRegExp.test(strValue);


}

//Validate Numaric
function IsNumaric(strValue)
{

	var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;

	//check for numeric characters
	return objRegExp.test(strValue);


}


function IsNotEmpty(strValue)
{

	var strTemp = strValue;
	strTemp = trimAll(strTemp);
	if(strTemp.length > 0)
	{
	     return true;
	}
	return false;


}


function trimAll(strValue)
{
	var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;


}



//Valid date dd.mm.yyyy

function IsValidUKDate(strValue)
{


	var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/

	//check to see if in correct format
	if(!objRegExp.test(strValue))
    		return false; //doesn't match pattern, bad date
		
	else{
    	
			
    	 var strSeparator = strValue.substring(2,3)
    	// bug fix by Radovan Radic to get the first separator
    	//for (i=0; i<strValue.length; i++) {
      	//	if (strValue.charAt(i)>'9') or (strValue.charAt(i)<'0')
        //		break;
    	//}
	
	//alert(strSeparator);	
	
    	//var strSeparator=strValue.charAt(i);
	

    	var arrayDate = strValue.split(strSeparator); //split date into day, month, year
    	//create a lookup for months not equal to Feb.
    	var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31}
	
	
	
	//First eliment of the array is the Day
    	var intDay = parseInt(arrayDate[0]);
	

	
    	//check if month value and day value agree
    	if(arrayLookup[arrayDate[1]] != null) {
      		if(intDay <= arrayLookup[arrayDate[1]] && intDay != 0)
        		return true; //found in lookup table, good date

    	}
		

    	//check for February (bugfix 20050322)
    	var intMonth = parseInt(arrayDate[1]);
    	if (intMonth == 2) { 
       	var intYear = parseInt(arrayDate[2]);
       		if( ((intYear % 4 == 0 && intDay <= 29) || (intYear % 4 != 0 && intDay <=28)) && intDay !=0)
          		return true; //Feb. had valid number of days
       		}
  	}
 	return false; //any other values, bad date



}


