// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}
function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}
function posLeft() {return window.pageXOffset != null? window.pageXOffset: document.body.scrollLeft != null? document.body.scrollLeft:0;}
function posTop() {return window.pageYOffset != null? window.pageYOffset: document.body.scrollTop != null? document.body.scrollTop:0;}
function posRight() {return posLeft()+pageWidth();}
function posBottom() {return posTop()+pageHeight();}
function RequiredField(fName, promptTxt) {
	if (fName.value.length == 0) {
		alert(promptTxt + " field is required."); 
		fName.focus(); 
		return false;
	} 
	return true;
}

monthNames = new Array(12);
monthNames[1] = "January";
monthNames[2] = "February";
monthNames[3] = "March";
monthNames[4] = "April";
monthNames[5] = "May";
monthNames[6] = "June";
monthNames[7] = "July";
monthNames[8] = "August";
monthNames[9] = "September";
monthNames[10] = "October";
monthNames[11] = "November";
monthNames[12] = "December";
var oneMinute = 60 * 1000;
var oneHour = oneMinute * 60;
var oneDay = oneHour * 24;
var oneWeek = oneDay * 7;

function doPopup(url, h, w)
{
        winl = (screen.width - w) / 2;
        wint = (screen.height - h) / 2;
        day = new Date();
        id = day.getTime();
        eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width="+w+",height="+h+",top="+wint+",left="+winl+"');");
}
function daysBetween(date1, date2) {

    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24;

    // Convert both dates to milliseconds
    var date1_ms = date1.getTime();
    var date2_ms = date2.getTime();

    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(date1_ms - date2_ms);
    
    // Convert back to days and return
    return Math.round(difference_ms/ONE_DAY);

}
function dateAdd(date3, addDays) {
    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24;

	var d3 = new Date(date3);
	var d3_ms = d3.getTime();
	var days_ms = addDays * ONE_DAY;

    var d4_ms = d3_ms + days_ms;
    
    d3.setTime(d4_ms);

	return d3;
}
