function checkProjectDate()
{

		var mToday = new Date();
		var mTodayDate = (mToday.getMonth()+1)+"/"+mToday.getDate()+"/"+mToday.getYear();
		var theForm = document.frmViewer
		if (isDate(theForm.txtProjectDate))
		{
		    if (Date.parse(theForm.txtProjectDate.value) < Date.parse(mTodayDate)) 
		    {
	            alert("Please enter a future display date");
	            return false;
	        }
	        else
	        {
	            return true;
	        }

	    }    
	    return false;	
	
}



//------------------------------------------------------------------------
function formatDate(theDate)
{
	var theMonth=theDate.getMonth()+1;
		if(theMonth<10)theMonth="0"+theMonth;
	var theDay=theDate.getDay();
		if(theDay<10)theDay="0"+theDay;
	var theYear=theDate.getYear();
	return theMonth+"/"+theDay+"/"+theYear;
}

function stripCharString (InString, CharString)  {
	OutString="";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar=InString.substring (Count, Count+1);
		Strip = false;
		for (Countx = 0; Countx < CharString.length; Countx++) {
			StripThis = CharString.substring(Countx, Countx+1)
			if (TempChar == StripThis) {
				Strip = true;
				break;
			}
		}
		if (!Strip)
			OutString=OutString+TempChar;
	}
	return (OutString);
}



function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

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 stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}


function isDate(objName){
	// Reformat date
	
	var dtStr = objName.value;	
	dtStr = replace(dtStr,"-","/");
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	//strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	
	//Reformat Year.
	var strDatestyle = "US";
	if (strYear.length == 2 ) {
		var mToday = new Date();
		//If the year is greater than 30 years from now use 19, otherwise use 20
		var checkYear = mToday.getFullYear() + 30; 
		var mCheckYear = '20' + strYear;
		if (mCheckYear >= checkYear)
			strYear = '19' + strYear;		
		else 		
			strYear = '20' + strYear;				
		
	}else if (strYear.length == 1)
	{
		strYear = '200' + strYear;	
	}
	
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYear)
 
	
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	else if  (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	else if  (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	else if  (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	else if  (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
	if (strDatestyle == "US") {
	objName.value = strMonth + "/" + strDay + "/" + strYear;
	}

return true
}

function replace(string, text, by) 
{
	// Replaces text with by in string
    	var strLength = string.length, txtLength = text.length;
    	if ((strLength == 0) || (txtLength == 0)) return string;

    	var i = string.indexOf(text);
    	if ((!i) && (text != string.substring(0,txtLength))) return string;
    	if (i == -1) return string;

    	var newstr = string.substring(0,i) + by;
    	if (i+txtLength < strLength)
        	newstr += replace(string.substring(i+txtLength,strLength),text,by);

    	return newstr;
}
function kp_numericsign() {
	if ((event.keyCode != 46 && event.keyCode != 45) && (event.keyCode < 48 || event.keyCode > 57))
		event.returnValue = false;
		
}
function kp_numeric() {
	if ((event.keyCode != 46 && event.keyCode != 45) && (event.keyCode < 48 || event.keyCode > 57))
		event.returnValue = false;
		
}