﻿function js_clock(lng) {
    var clock_time = new Date();
    var day = clock_time.getDate();
    var month = clock_time.getMonth();
    var year = clock_time.getFullYear();
    var hours = clock_time.getHours();
    var minutes = clock_time.getMinutes();
    var seconds = clock_time.getSeconds();

    var MonthDE = new Array("Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
    var MonthEN = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "Oktober", "November", "December");

    if (day < 10)
        day = "0" + day;
    if (seconds < 10)
        seconds = "0" + seconds;
    if (minutes < 10)
        minutes = "0" + minutes;
    if (hours < 10)
        hours = "0" + hours;

    var clock_div = document.getElementById('Clock');
    
    if(lng == "DE" || lng == "de")
        clock_div.innerHTML = day + ". " + MonthDE[month] + " " + year + " " + hours + ":" + minutes + ":" + seconds;
    else if(day == 1)
        clock_div.innerHTML = MonthEN[month] + " " + day + "st, " + year + " " + hours + ":" + minutes + ":" + seconds;
    else if (day == 2)
        clock_div.innerHTML = MonthEN[month] + " " + day + "nd, " + year + " " + hours + ":" + minutes + ":" + seconds;
    else if (day == 3)
        clock_div.innerHTML = MonthEN[month] + " " + day + "rd, " + year + " " + hours + ":" + minutes + ":" + seconds;
    else
        clock_div.innerHTML = MonthEN[month] + " " + day + "th, " + year + " " + hours + ":" + minutes + ":" + seconds;
    setTimeout("js_clock('" + lng + "')", 1000);
}
function getWindowHeight() {
    var windowHeight = 0;
    if (typeof (window.innerHeight) == 'number')
        windowHeight = window.innerHeight;
    else {
        if (document.documentElement && document.documentElement.clientHeight)
            windowHeight = document.documentElement.clientHeight;
        else if (document.body && document.body.clientHeight)
            windowHeight = document.body.clientHeight;
    }
    return windowHeight;
}
function setFooterAndContent() {
    if (IsMobileClient() || IsIE6Client())
        return;

    if (document.getElementById) {
        var windowHeight = getWindowHeight() - 50;

        if (windowHeight > 0) {
            var mframe = document.getElementById('ctl00_MframeDiv');
            var contentHeight = mframe.offsetHeight - 50;
            var mainTab = document.getElementById('mainTab');
            var mainTabHeight = mainTab.offsetHeight;
            var footerElement = document.getElementById('footer');
            var footerHeight = footerElement.offsetHeight;

            if(contentHeight < windowHeight)
                document.getElementById('MainContent').style.height = (windowHeight - footerHeight - 100) + 'px';
            else
                document.getElementById('MainContent').style.height = (mainTabHeight - footerHeight - 10) + 'px';

            footerElement.style.top = '30px';
        }

        footerElement.width = window.innerWidth + 'px';
    }
}
function IsMobileClient(){return (navigator.userAgent.toLowerCase().indexOf('iphone') > -1 || navigator.userAgent.toLowerCase().indexOf('mobile') > -1);}
function IsIE6Client() { return (navigator.appName.toLowerCase().indexOf('microsoft') > -1 && (navigator.appVersion.toLowerCase().indexOf('msie 5') > -1 || navigator.appVersion.toLowerCase().indexOf('msie 6') > -1)); }
window.onload = function() {
    var lng;
    if (navigator.appName.toLowerCase().indexOf("explorer") > -1)
        lng = navigator.browserLanguage.toLowerCase().indexOf("de") > -1 ? "de" : "en";
    else
        lng = navigator.language.toLowerCase().indexOf("de") > -1 ? "de" : "en";
    js_clock(lng);
setFooterAndContent();
}
window.onresize = function() {
//setFooterAndContent();
}