﻿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 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);
};
window.onresize = function() {
//setFooterAndContent();
};

///<reference path="~/JS/jquery-vsdoc.js" /> 
///<reference path="~/JS/jquery.ad-gallery.js" />

var DiashowController = {
    Timer: undefined,
    IsPause: undefined,
    CyclesCount: undefined,
    Counter: 0,
    GalleryContents: undefined,
    Texts: undefined,
    ContentsCount: undefined,
    PlayImage: undefined,
    PauseImage: undefined,
    ElementCount: undefined,
    Ready: function (delay, elementCount, cyclesCount) {

        this.Counter = 0;
        this.ElementCount = elementCount;
        var contents = $("#diashowContents");
        this.GalleryContents = contents.children('div');
        this.ContentsCount = this.GalleryContents.length;

        var textsDiv = $("#diashowTexts");
        this.Texts = textsDiv.children('.modBox');

        this.PlayImage = $("#diashowPlay");
        this.PauseImage = $("#diashowPause");

        this.Timer = window.setTimeout("DiashowController.Process(" + delay + ")", delay);

        this.IsPause = false;
        this.CyclesCount = cyclesCount;

        $("#diashow").click(function () {
            DiashowController.PlayOrPause(delay);
        });
    },
    Process: function (delay) {
        for (var i = 0; i < this.ElementCount; i++) {
            var currentContent = $(this.GalleryContents[i]);
            var currentText = $(this.Texts[i]);

            var nextIndex = i + 1;
            var prevIndex = i - 1;
            if (i == (this.ElementCount - 1))
                nextIndex = 0;

            var nextContent = $(this.GalleryContents[nextIndex]);
            var nextText = $(this.Texts[nextIndex]);

            if (currentContent.is('.hidden') == false) {

                currentContent.css("z-index", "0");
                nextContent.css("z-index", "1");
                currentContent.fadeOut(700);
                nextContent.fadeIn(700);

                currentContent.removeClass("visible").addClass("hidden");

                currentText.children(".ui-ds-i").addClass("dottedTop");
                $(this.Texts[prevIndex - 1]).children(".ui-ds-i").addClass("dottedTop");
                $(this.Texts[prevIndex]).removeClass("curvedLeft");

                currentText.removeClass("curvedLeft borderBoldTop borderBoldLeft borderBoldBottom shadowBottom borderColorGray30");
                currentText.removeClass("ui-ds-i-a" + (i + 1));
                currentText.children(".ui-ds-i").children(".modBox").removeClass("ui-ds-i-a");
                currentText.children(".ui-ds-i").addClass("ui-ds-i-ia");

                nextText.addClass("curvedLeft borderBoldTop borderBoldLeft borderBoldBottom shadowBottom borderColorGray30");
                nextText.addClass("ui-ds-i-a" + (nextIndex + 1));
                nextText.children(".ui-ds-i").children(".modBox").addClass("ui-ds-i-a");
                nextText.children(".ui-ds-i").removeClass("ui-ds-i-ia dottedTop");

                $(this.Texts[nextIndex + 1]).children(".ui-ds-i").removeClass("dottedTop");

                nextContent.addClass('visible').removeClass('hidden');
                this.Counter++;
                break;
            }
        }

        if (this.Counter == this.CyclesCount * this.ContentsCount) {
            this.Counter = 0;
            this.Pause();
        }
        else {
            this.Timer = window.setTimeout("DiashowController.Process(" + delay + ")", delay);
        }
    },
    Pause: function () {
        this.IsPause = true;
        this.PauseImage.hide();
        this.PlayImage.show();
        clearTimeout(this.Timer);
    },
    Play: function (delay) {
        this.IsPause = false;
        this.PlayImage.hide();
        this.PauseImage.show();
        this.Timer = window.setTimeout("DiashowController.Process(" + delay + ")", delay);
    },
    PlayOrPause: function (delay) {
        if (this.IsPause) {
            this.Play(delay);
        }
        else {
            this.Pause();
        }
    }

};

