﻿// JScript File
function Print()
{
	window.print();
}

function Close()
{
	window.close();
}

//The month needs to be a 0 (zero) for Jan, upto 11 to Dec.
function isValidDate(year, month, day)
{
//Purpose: return true if the date is valid, false otherwise
//Arguments: day integer representing day of month
//month integer representing month of year
//year integer representing year Variables: dteDate - date object
var dteDate;

//set up a Date object based on the day, month and year arguments
//javascript months start at 0 (0-11 instead of 1-12)
month = month*1 - 1; 
dteDate=new Date(year,month,day);

//Javascript Dates are a little too forgiving and will change 
//the date to a reasonable guess if it's invalid. 
//We'll use this to our advantage by creating the date object 
//and then comparing it to the details we put it. 
//If the Date object is different, then it must have been an invalid date to start with...
return ((day==dteDate.getDate()) 
          && (month==dteDate.getMonth()) 
            && (year==dteDate.getFullYear()));
}

//return true if any of supporting formats 'mm/dd/yyyy', 'dd/mm/yyyy', 'yyyy/mm/dd
//separators '/', ' ', '-', '.'
function isValidDateString(myDateString)
{
  myDateString = myDateString.replace(" ", "/");
  myDateString = myDateString.replace(" ", "/");
  myDateString = myDateString.replace("-", "/");
  myDateString = myDateString.replace("-", "/");
  myDateString = myDateString.replace(".", "/");
  myDateString = myDateString.replace(".", "/");
  
  var myDateArray = myDateString.split("/");
  if(myDateArray.length != 3)
  {
	alert( 'Sorry, but "' + myDateString + '" is NOT a valid date.' );
     return false;
  }
  
  //check if valid mm/dd/yyyy is entered
   if (isValidDate(myDateArray[2], myDateArray[0], myDateArray[1]))
   {
     return true;
   }
   //check for dd/mm/yyyy
   else if (isValidDate(myDateArray[2], myDateArray[1], myDateArray[0]))
   {
     return true;
   }
   //check for yyyy/mm/dd
   else if (isValidDate(myDateArray[0], myDateArray[1], myDateArray[2]))
   {
     return true;
   }
   else
   {
    
    alert( 'Sorry, but "' + myDateString + '" is NOT a valid date.' );
    return false
   }
   
  function isValidDate(month, day, year)
  {
    return true;  
  }
       

}


