function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function isFloat(s)
{
var n = trim(s);
return n.length>0 && !(/[^0-9.]/).test(n) || (/\.\d/).test(n);
}

function trim(s)
{
return s.replace(/^\s+|\s+$/g, "");
}

function suycDateDiff( start, end, interval, rounding ) {

    var iOut = 0;
    
    // Create 2 error messages, 1 for each argument. 
    var startMsg = "Check the Start Date and End Date\n"
        startMsg += "must be a valid date format.\n\n"
        startMsg += "Please try again." ;
		
    var intervalMsg = "Sorry the dateAdd function only accepts\n"
        intervalMsg += "d, h, m OR s intervals.\n\n"
        intervalMsg += "Please try again." ;

    var bufferA = Date.parse( start ) ;
    var bufferB = Date.parse( end ) ;
    	
    // check that the start parameter is a valid Date. 
    if ( isNaN (bufferA) || isNaN (bufferB) ) {
        alert( startMsg ) ;
        return null ;
    }
	
    // check that an interval parameter was not numeric. 
    if ( interval.charAt == 'undefined' ) {
        // the user specified an incorrect interval, handle the error. 
        alert( intervalMsg ) ;
        return null ;
    }
    
    var number = bufferB-bufferA ;
    
    // what kind of add to do? 
    switch (interval.charAt(0))
    {
        case 'd': case 'D': 
            iOut = parseInt(number / 86400000) ;
            if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
            break ;
        case 'h': case 'H':
            iOut = parseInt(number / 3600000 ) ;
            if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
            break ;
        case 'm': case 'M':
            iOut = parseInt(number / 60000 ) ;
            if(rounding) iOut += parseInt((number % 60000)/30001) ;
            break ;
        case 's': case 'S':
            iOut = parseInt(number / 1000 ) ;
            if(rounding) iOut += parseInt((number % 1000)/501) ;
            break ;
        default:
        // If we get to here then the interval parameter
        // didn't meet the d,h,m,s criteria.  Handle
        // the error. 		
        alert(intervalMsg) ;
        return null ;
    }
    return iOut ;
}

function monthName(monthNum) {

	if(monthNum == 1){
		str = "Jan";
	}else if(monthNum == 2){
		str = "Feb";
	}else if(monthNum == 3){
		str = "Mar";
	}else if(monthNum == 4){
		str = "Apr";
	}else if(monthNum == 5){
		str = "May";
	}else if(monthNum == 6){
		str = "Jun";
	}else if(monthNum == 7){
		str = "Jul";
	}else if(monthNum == 8){
		str = "Aug";
	}else if(monthNum == 9){
		str = "Sep";
	}else if(monthNum == 10){
		str = "Oct";
	}else if(monthNum == 11){
		str = "Nov";
	}else if(monthNum == 12){
		str = "Dec";
	}
	return str;
}


function check_date(day, month, year){
var leap = 0;
var err = 0;
   
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == "FEB") && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == "FEB") && (leap != 1) && (day > 28)) {
      err = 24;
   }
   if ((day > 30) && ((month == "APR") || (month == "JUN") || (month == "SEP") || (month == "NOV"))) {
      err = 26;
   }
  
   /* Error-message if err != 0 */
   if (err > 0 ) {
   			if (err == 26)
				alert('This month has only 30 days.');
			if (err == 23)
				alert('This month as only 29 days');
			if (err == 24)
				alert('This month as only 28 days');
      alert("Invalid Date! Please check the date");
	  return false;
   }
   return true;
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

