﻿
//---------------------------------------------------------------------||
// FUNCTION:    todaysDate                                             ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:  Display today's date                                      ||
//---------------------------------------------------------------------||   
function todaysDate()
{              
   document.getElementById("ctl00_mastercontent_Date_of_Occurence").value = document.getElementById("ctl00_mastercontent_date").value
}
//---------------------------------------------------------------------||
// FUNCTION:    Calendar                                               ||
// PARAMETERS:                                                         ||
// RETURNS:                                                            ||
// PURPOSE:  Display Calendar                                          ||
//---------------------------------------------------------------------||   
function y2k(number)    { return (number < 1000) ? number + 1900 : number; }
function padout(number) { return (number < 10) ? '0' + number : number; }
var today = new Date();
var day = today.getDate(), month = today.getMonth(), year = y2k(today.getYear()), whichOne = 0;

function restart() {    
    document.getElementById("ctl00_mastercontent_Date_of_Occurence").value = '' + padout(month - 0 + 1) + '/'  + padout(day) + '/' + year;   
    mywindow.close();
}

function calendar(number) {  
    screenW = screen.width/2;
    screenH = screen.height/4; 
    whichOne = number;
    day = today.getDate(), month = today.getMonth(), year = y2k(today.getYear());
    mywindow=open("cal.htm","myname","resizable=no,top="+screenH+",left="+screenW+",width=350,height=270");
   
    if (mywindow.opener == null) mywindow.opener = self;
}
function isDate (day,month,year) {
// checks if date passed is valid
// will accept dates in following format:
// isDate(dd,mm,ccyy), or
// isDate(dd,mm) - which defaults to the current year, or
// isDate(dd) - which defaults to the current month and year.
// Note, if passed the month must be between 1 and 12, and the
// year in ccyy format.

    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) )
        return true;
    else
        return false
}
   
//---------------------------------------------------------------------||
// FUNCTION:    checkInHouseDate                                       ||
// PARAMETERS:  Check-In Date ID                                       ||
// RETURNS:     Alert Message if dates don't match                     ||
// PURPOSE:     Checks to see if date matches the system date,         ||
//              if not, display alert message. If user ignores alert,  ||
//              process the input date.                                ||
//---------------------------------------------------------------------|| 

var count = 0;

function checkInHouseDate()
{
    var today = new Date();
    var day = today.getDate(), month = today.getMonth(), year = today.getYear();
    var todayDate = month+1 + '/' + day + '/' + year;
    var inputDate = document.getElementById("txtCheckInDate").value
    
    if(inputDate == '')
    { alert("You must enter a valid Check-In Date before updating this map.")
        return false;
    }
    
    count++;
    if(count == 1 && inputDate != todayDate)
    { alert("Attention: The Check-In date does not match today's date.\n" + 
            "If you want to use " + inputDate + ", click Update again.");
        return false;
    }
    else if(count > 1 && inputDate != todayDate)
        return true;
    else
        return true;
}

