var clockID = 0;

function UpdateClock()
{
	if(clockID) {
		clearTimeout(clockID);
		clockID  = 0;
	}
	var clock_time = new Date();
	var clock_hours = clock_time.getHours();
	var clock_minutes = clock_time.getMinutes();
	var clock_suffix = "AM";
	if (clock_hours > 11) {
		clock_suffix = "PM";
		clock_hours = clock_hours - 12;
	}
	if (clock_hours == 0) {
		clock_hours = 12;
	}
	if (clock_hours < 10) {
		clock_hours = "0" + clock_hours;
	}
	if (clock_minutes < 10) {
		clock_minutes = "0" + clock_minutes;
	}
	var clock_div = document.getElementById('clock');
	clock_div.innerHTML = clock_hours + ":" + clock_minutes + " " + clock_suffix;
	clockID = setTimeout("UpdateClock()", 1000);
}

function StopClock() 
{
	if(clockID) {
		clearTimeout(clockID);
		clockID  = 0;
	}
}

function StartClock() 
{
	clockID = setTimeout("UpdateClock()", 500);
}


function OnLoad() 
{
	StartClock();
}

function OnUnload() 
{
	StopClock();
}


function is_iPhone()
{
	return ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)));
}

/*
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{
	document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"style-ip.css\" />");
}
else
{
	document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />");
}
*/


function getScrollTop() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    return(window.pageYOffset);
  }
  if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
  	return(document.body.scrollTop);
  }
  if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    return(document.documentElement.scrollTop);
  }
  return 300;
}

function getWindowHeight() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    return(window.innerHeight);
  }
  if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    return(document.documentElement.clientHeight);
  }
  if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    return(document.body.clientHeight);
  }
  return(300);
}

function closeVideo()
{
	document.getElementById('movie').innerHTML = "";
	document.getElementById('movie').style.display='none';
	document.getElementById('fade').style.display='none';

}

function showVideo(vidfile)
{
	movhtml = "";
	topOffset = 40;
	
	if (is_iPhone()) 
	{
		vidfile = vidfile + '.m4v';
		topOffset = 100;
		movhtml += "<p style=\"text-align: center;\"><embed src=\"" + vidfile + "\" width=\"200\" height=\"100\" autoplay=\"true\" loop=\"false\" controller=\"true\" pluginspage=\"http://www.apple.com/quicktime/\"></embed></p>";
	}
	else 
	{
		vidfile = vidfile + '.mov';
	
		movhtml  = "<object CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" width=\"320\" height=\"460\" CODEBASE=\"http://www.apple.com/qtactivex/qtplugin.cab\">";
		movhtml += "<param name=\"src\" value=\"" + vidfile + "\">";
		movhtml += "<param name=\"autoplay\" value=\"true\">";
		movhtml += "<param name=\"controller\" value=\"false\">";
		movhtml += "<param name=\"loop\" value=\"false\">";

		movhtml += "<embed src=\"" + vidfile + "\" width=\"320\" height=\"476\" autoplay=\"true\" loop=\"false\" controller=\"true\" pluginspage=\"http://www.apple.com/quicktime/\"></embed>";
		movhtml += "</object>";
		
	}

	movhtml += "<p style=\"text-align: center; font-size: 18px;\"><a href=\"javascript:void(0)\" onclick=\"closeVideo()\">Close Video Window</a></p>";

	document.getElementById('movie').style.top = getScrollTop() + topOffset + 'px';

	document.getElementById('fade').style.display='block';
	document.getElementById('movie').style.display='block';
	document.getElementById('movie').innerHTML = movhtml;
}
