function CheckDate(dtObj){
 
	 var sDate=dtObj;
	 if (sDate=="" || sDate==" "){
	   return true;
	 }
		var d1 = new Date(); 
		var sysDate,sysDate1;
		sysDate1 = curDate()
		
	 if (sDate.indexOf("/")>0){       // for mm/dd/yyy format
		   sysDate = (d1.getMonth()+1).toString()+"/"+d1.getDate().toString()+"/"+d1.getYear().toString(); 
		   sysDate1 =sysDate
	 }else if(sDate.indexOf("-")>0){  // for dd-mon-yyyy format
		
		dDate = sDate.replace("-"," ")
		dDate = dDate.replace("-"," ")
		sDate = dDate
		sysDate = curDate().replace("-"," ")
		sysDate = sysDate.replace("-"," ")
		
	 }

	if ((suycDateDiff( sysDate, sDate,"D", false,dtObj))>=0){
		
	 }else{
		return false;
	 }  
}

function curDate()
{
 
    var now   = new Date();
    var day   = now.getDate();
    var month = now.getMonth();
    var year  = now.getYear();
 
    if ((""+month).length == 1)
    {
      month= "0"+ month;
    }
    if ((""+day).length == 1)
    {
        day="0"+day;
    }
    var sysDate = new Date()
    if (day != "     ") {
       var deldate = new Date(Number(year),Number(month)-1,Number(day))
      
       var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
  month = monthname[Number(month)] 
  var fullyear = deldate.getFullYear()
  var maxDate = new Date(sysDate.getYear(),sysDate.getMonth()+3,sysDate.getDate())//added for validation 03-07-2001
  
        return (day + "-" + month.toUpperCase() + "-" + year);
    }
}

function suycDateDiff( start, end, interval, rounding,objDt ) {
 
    var iOut = 0;
    
    // Create 2 error messages, 1 for each argument. 
    var startMsg = "Check the Date format\n"
        startMsg += "must be a valid date format (dd-MON-yyyy) .\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 ) ;
        objDt.focus()
        return false;
        return start ;
    }
 
    // 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 ;
}
