/* Function CheckDays()

Purpose is to count down the days from a today to a given day.

Variables
CheckDay: a date object containing the date today.
XYear: 4 digit year value of date
XDay: The picked date in the given year.
DayCount: The number of days til the picked date.
WorkDay: the date sent to the function to be used to do countdown
*/

function CheckDays(WorkDay)
{
	var CheckDay =new Date()
	var XYear = CheckDay.getFullYear();
	// var XDay = new Date("June, 28 2008");
	var leapAdd = 0;
	if (XYear % 4 == 0 && ((XYear % 100 != 0) || (XYear % 400 == 0)))
	{
		if (CheckDay.getMonth()==1)
		{
			if (CheckDay.getDay()< 29)
			{
				leapAdd = 1;
			}
			
			
		}
	}
/*	if (CheckDay.getMonth()>1)
	{
		leapAdd = 0;
		
	}*/
	var timeOfDay = new Date();
	var timeOffSet=0;
	if(timeOfDay.getHours()>=12)
	{
		timeOffSet = 1;
	}



	var XDay = new Date(WorkDay);
	XDay.setFullYear(XYear);
	Math.round(XDay);
	Math.round(CheckDay);
	var DayCount=(XDay-CheckDay)/(1000*60*60*24);
	DayCount = Math.round(DayCount)+leapAdd+timeOffSet;
	return DayCount;
	
}



function UpdateClock() 
{
   if(clockID) 
   {
      clearTimeout(clockID);
      clockID  = 0;
   }

   var thetime=new Date();

var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var AorP=" ";

if (nhours>=12)
    AorP="P.M.";
else
    AorP="A.M.";

if (nhours>=13)
    nhours-=12;

if (nhours==0)
 nhours=12;

if (nsecn<10)
 nsecn="0"+nsecn;

if (nmins<10)
 nmins="0"+nmins;

   document.theClock.theTime.value =nhours+":"+nmins+":"+nsecn+" "+AorP;
   
   clockID = setTimeout("UpdateClock()", 1000);
}
function StartClock() 
{
   clockID = setTimeout("UpdateClock()", 500);
}

function KillClock() 
{
   if(clockID) 
   {
      clearTimeout(clockID);
      clockID  = 0;
   }
}

function changeColor(changeText)
{
	var lenText = changeText.length();
	var forCount = 1;
	 
	for (forCount =1; forCount < lenText; forCount++)
	{
		
	}
	
	setTimeout("changeColor()",200);
	
}
// page 491 
var objPopUp = null;
function popUp(whichLink) {
		fetchData('dataPage.php',whichLink,'popUpMessage');	
		objPopTrig = document.getElementById(whichLink);
		objPopUp = document.getElementById('popUpMessage');
		objPopUp.innerHTML='<b>Loading</b>';
		xPos = objPopTrig.offsetLeft;
		yPos = (objPopTrig.offsetTop + objPopTrig.offsetHeight);
		if (xPos + objPopUp.offsetWidth > document.body.clientWidth) xPos = xPos - objPopUp.offsetWidth;
		if (yPos + objPopUp.offsetHeight > document.body.clientHeight) yPos = yPos - objPopUp.offsetHeight;
		objPopUp.style.left = xPos + 'px';
		objPopUp.style.top = yPos + 'px';
		objPopUp.style.visibility = 'visible';
	
}
function popHide() {
		objPopUp.style.visibility = 'hidden';
		objPopUp = null;
}
function filterData(pageRequest ,objectID) {
	if (pageRequest.readyState == 4 && (pageRequest.status==200 || window.location.href.indexOf("http") ==-1))
	document.getElementById(objectID).innerHTML=pageRequest.responseText;
}
function setText(objectID, newTop, newLeft)
{
	var object = document.getElementById(objectID);
	object.style.top = newTop + 'px';
	object.style.left = newLeft + 'px';
	object.style.visibility = 'visible';
}
function hidePic(objectID)
{
	var object = document.getElementById(objectID);
	object.style.visibility = 'hidden';
}