// ****  Time Zone Count Down Javascript  **** //
/*
Visit http://rainbow.arch.scriptmania.com/scripts/
for this script and many more
*/

////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////
var month = '11';     //  '*' for next month, '0' for this month or 1 through 12 for the month 
var day = '7';        //  Offset for day of month day or + day  
var hour = '11';       //  0 through 23 for the hours of the day
var tz = +1;          //  Offset for your timezone in hours from UTC
//Sommerzeit ist hier nicht korrekt!
var lab = 'tzcd';
var textday = ' Tage';
var textdayfra = ' jours';

function startDisplayTZCountDown() {
    try {
        //if (typeof (tzcd) != "undefined" && tzcd != null && typeof (g_Lang) != "undefined" && g_Lang != null && g_Lang.length == 3) {
        if (typeof (g_Lang) != "undefined" && g_Lang != null && g_Lang.length == 3) {
            displayTZCountDown(setTZCountDown(month, day, hour, tz), lab);
        }
    }
    catch (err) {
    }
}

////////// DO NOT EDIT PAST THIS LINE //////////////////
function setTZCountDown(month, day, hour, tz) {
    var toDate = new Date();
    if (month == '*') toDate.setMonth(toDate.getMonth() + 1);
    else if (month > 0) {
        if (month <= toDate.getMonth()) toDate.setYear(toDate.getYear() + 1);
        toDate.setMonth(month - 1);
    }
    if (day.substr(0, 1) == '+') {
        var day1 = parseInt(day.substr(1));
        toDate.setDate(toDate.getDate() + day1);
    }
    else {
        toDate.setDate(day);
    }
    toDate.setHours(hour);
    toDate.setMinutes(0 - (tz * 60));
    toDate.setSeconds(0);
    var fromDate = new Date();
    fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());
    var diffDate = new Date(0);
    diffDate.setMilliseconds(toDate - fromDate);
    return Math.floor(diffDate.valueOf() / 1000);
}

function displayTZCountDown(countdown, tzcd) {
    try {
        var strToLate = "";
        if (g_Lang == "ger") {
            strToLate = "Die Fachmesse ist noch bis zum 10.11.2010 geöffnet.";
        }
        else {
            strToLate = "Le Salon professionnel est encore ouvert jusquau 10.11.2010.";
        }
        if (countdown < 0) document.getElementById(tzcd).innerHTML = strToLate;
        else {
            var secs = countdown % 60;
            if (secs < 10) secs = '0' + secs;
            var countdown1 = (countdown - secs) / 60;
            var mins = countdown1 % 60;
            if (mins < 10) mins = '0' + mins;
            countdown1 = (countdown1 - mins) / 60;
            var hours = countdown1 % 24;
            var days = (countdown1 - hours) / 24;
			
			//Textwechsel von Tage zu Tage bei Restzeit von 1 Tag
			if (days == 1) 
			{
			textday = ' Tag';
			textdayfra = ' jour';
			}
			
			//Ausgabe der Zeit in ger und fra
            if (g_Lang == "ger") {
                document.getElementById(tzcd).innerHTML = "Nur noch" + "<br/><p class=\"tzcd_p\">" + days + textday + "</p>" + "bis zur" + "<br/>" + "Gastronomia 2010";
            }
            else {
                document.getElementById(tzcd).innerHTML = "Plus que" + "<br/><p class=\"tzcd_p\">" + days + textdayfra + "</p>" + "jusqu' à" + "<br/>" + "Gastronomia 2010";
            }
            setTimeout('displayTZCountDown(' + (countdown - 1) + ',\'' + tzcd + '\');', 999);
        }
    }
    catch (err) {
    }
}

