﻿
function getStyleObject(objectId) {
    // checkW3C DOM, then MSIE 4, then NN 4.
    if(document.getElementById && document.getElementById(objectId))
        return document.getElementById(objectId).style;
    else if (document.all && document.all(objectId))
        return document.all(objectId).style;
    else if (document.layers && document.layers[objectId])
        return document.layers[objectId];
    else
        return false;
}
function hideObject(objectId) {
    var styleObject = getStyleObject(objectId);
    if (styleObject) {
        styleObject.display = "none";
        styleObject.visibility = "hidden";
    }
}
function showObject(objectId) {
    var styleObject = getStyleObject(objectId);
    if (styleObject) {
        styleObject.display = "block";
        styleObject.visibility = "visible";
    }
}
function switchSection(objectId) {
    var styleObject = getStyleObject(objectId);
    if (styleObject) {
        if (styleObject.visibility == "hidden") {
            showObject(objectId);
        } else {
            hideObject(objectId);
        }
    }
}
function focus(objectId) {
    var el = document.getElementById(objectId);
    if (el) {
        el.focus();
        el.select();
    }
}
function showMenu(name) {
    return false;
}

var secsToGo;
var counter;
var countdownDisplay;
var countdownSeconds;
function countdown() {
	secsToGo--;
	if (secsToGo <= 0) 	{
		countdownDisplay.innerHTML = '00h:00m:00s';
		clearInterval(counter);
	} else {
		disp_days = Math.floor(secsToGo/86400)
		if (disp_days) {
			if (disp_days > 3) {
				countdownDisplay.innerHTML = disp_days + ' days';
			} else {
			    disp_secs = Math.floor(secsToGo%60);
			    disp_mins = Math.floor(secsToGo/60%60);
			    disp_hours = Math.floor(secsToGo/3600);
			    disp_hours = disp_hours%24;
	    		countdownDisplay.innerHTML = disp_days + ' day' + (disp_days - 1 ? 's' : '') + ', ' + disp_hours + ' hr' + (disp_hours - 1 ? 's' : '');
			}
		} else {
			disp_secs = Math.floor(secsToGo%60);
			disp_mins = Math.floor(secsToGo/60%60);
			disp_hours = Math.floor(secsToGo/3600);
			countdownDisplay.innerHTML = (disp_hours < 10 ? '0' + disp_hours : disp_hours) + 'h:' + (disp_mins < 10 ? '0' + disp_mins : disp_mins) + 'm:' + (disp_secs < 10 ? '0' + disp_secs : disp_secs) + 's';
		}
	}
}
