window.onload = start;

function calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadingZero && s.length < 2)
    s = "0" + s;
  return "<strong>" + s + "</strong>";
}

function CountBack(secs) {
  if (secs < 0) {
    document.getElementById("cntdwn").innerHTML = FinishMessage;
    return;
  }
  DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
  DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
  DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
  DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

  document.getElementById("cntdwn").innerHTML = DisplayStr;
  if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}

function start(){
	CountStepper = Math.ceil(CountStepper);
	if (CountStepper == 0)
	  CountActive = false;
	var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
	var dthen = new Date(TargetDate);
	var dnow = new Date();
	if(CountStepper>0)
	  ddiff = new Date(dnow-dthen);
	else
	  ddiff = new Date(dthen-dnow);
	gsecs = Math.floor(ddiff.valueOf()/1000);
	CountBack(gsecs);
}


function Clock () {
	var d = new Date ();
	var nhours = d.getHours ();
	if (nhours < 10) nhours = "0"+nhours;
	var nmins = d.getMinutes ();
	if (nmins < 10) nmins = "0"+nmins;
	var nday = d.getDay ();
	var mday = d.getDate ();
	var nmonth = d.getMonth ();
	var nyear = d.getFullYear ();
	var uhours = d.getUTCHours();
	if (uhours < 10) uhours = "0"+uhours;
	var umins = d.getUTCMinutes();
	if (umins < 10) umins = "0"+umins;
	document.getElementById('timezones').innerHTML = nhours+":"+nmins+" <strong>("+uhours+":"+umins+" UTC)</strong>";
	document.getElementById('timezones').title = daysOfWeek[nday]+" "+mday+" "+monthsOfYear[nmonth]+" "+nyear;
	setTimeout('Clock ()',10000);
}

winAddLoadEvent (Clock);
/**************************************************
END HIJAX
**************************************************/

function popUp(URL,WIDTH,HEIGHT,SCROLL,RESIZE) {
	var int_windowLeft = (screen.width - WIDTH) / 2;
	var int_windowTop = (screen.height - HEIGHT) / 2;
	winpops=window.open(URL,"","width=" + WIDTH + ",height=" + HEIGHT + ",left=" + int_windowLeft + ",top=" + int_windowTop + ",status=0,scrollbars=" + SCROLL + ",resizable=" + RESIZE + ",menubar=0,location=0,toolbar=0");
}

function popUpInfo(URL) {
	var int_windowLeft = (screen.width - 640) / 2;
	var int_windowTop = (screen.height - 480) / 2;
	winpops=window.open(URL,"","width=640,height=480,left=" + int_windowLeft + ",top=" + int_windowTop + ",status=0,scrollbars=1,resizable=1,menubar=0,location=0,toolbar=0");
}

function popUpHelp(URL){
	winpops=window.open(URL,"","width=640,height=480,left=100,top=100,status=1,scrollbars=1,resizable=1,menubar=0,location=0,toolbar=0");
}
function popUpTerms(URL){
	winpops=window.open(URL,"","width=640,height=480,left=100,top=100,status=0,scrollbars=1,resizable=0,menubar=0,location=0,toolbar=0");
}

function popUpDriver(URL){
	winpops=window.open(URL,"","width=660,height=500,status=0,scrollbars=1,resizable=0,menubar=0,location=0,toolbar=0");
}

function confirmAction(url,msg){
 var where_to= confirm(msg);
 if (where_to== true)
 {
   window.location=url;
 }
}

function textCounter (field, countfield, maxlimit){
	if (field.value.length > maxlimit)
	field.value = field.value.substring(0, maxlimit);
	else
	countfield.value = maxlimit - field.value.length;
}

function fullScreen(theURL){
window.open(theURL, '', 'fullscreen=yes, scrollbars=auto, status=1,scrollbars=1,resizable=1,menubar=0,location=0,toolbar=0');
}

function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}



// Nannette Thacker http://www.shiningstar.net
function confirmDeleteMessage(){
var agree=confirm("Are you sure you wish to delete this message?");
if (agree)
	return true ;
else
	return false ;
}


function FullScreen(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

//===========================================================================
// YouTube Functions
//===========================================================================
function showInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "inline";
	}
}
function hideInline (elName) {
	var theElemenet = document.getElementById(elName);
	if (theElemenet) {
		theElemenet.style.display = "none";
	}
}

function resizeIframe() {

	// Must launched on the body onload event handler for IE
	// Use document.documentElement if you are in Compat mode
	i = parent.document.getElementById(window.name)
	iHeight = document.body.scrollHeight
	i.style.height = iHeight + 5 + "px"
}

function switchMenu(obj) {
var el = document.getElementById(obj);
if ( el.style.display != 'none' ) {
el.style.display = 'none';
}
else {
el.style.display = '';
}
}

/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["events"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="no"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller