﻿var divpP = 20;
var pp = 0;
var first = true;
function sets() {
    var pageH = 0;
    var topH = document.getElementById("divtop").offsetHeight;
    if (typeof window.innerWidth != 'undefined') {
        pageH = window.innerHeight;
    }
    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

    else if (typeof document.documentElement != 'undefined'
             && typeof document.documentElement.clientWidth !=
             'undefined' && document.documentElement.clientWidth != 0) {

        pageH = document.documentElement.clientHeight;
    }

    if (document.getElementById("body").offsetHeight < pageH) {

        var divp = (pageH - topH) / 2;
        divpP = divp;
        pp = pageH;
        if (navigator.userAgent.indexOf("MSIE 7.0") != -1) {
        }
        if (divp > 20) {
            document.getElementById("top").style.height = divp + "px";
            document.getElementById("bot").style.height = divp + "px";
        }
        else {
            document.getElementById("top").style.height = 40 + "px";
            document.getElementById("bot").style.height = 40 + "px";
        }
    }
    else {
        document.getElementById("top").style.height = 40 + "px";
        document.getElementById("bot").style.height = 40 + "px";
    }
    var bg = document.getElementById("bg");
    if (pageH < 781) {
        bg.style.height = 810 + "px";
    }
    else {
        bg.style.height = pageH + "px";
    }
    setTimeout(changebg, 10000);
}
function sets1() {
    if ((navigator.userAgent.indexOf("MSIE 7.0") != -1 || navigator.userAgent.indexOf("MSIE 6.0") != -1) && first) {
        first = false;
        return;
    }
    document.getElementById("top").style.height = 0 + "px";
    document.getElementById("bot").style.height = 0 + "px";
    var pageH = 0;
    var topH = document.getElementById("divtop").offsetHeight;
    if (typeof window.innerWidth != 'undefined') {
        pageH = window.innerHeight;
    }
    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

    else if (typeof document.documentElement != 'undefined'
             && typeof document.documentElement.clientWidth !=
             'undefined' && document.documentElement.clientWidth != 0) {

        pageH = document.documentElement.clientHeight;
    }
    
    if (document.getElementById("body").offsetHeight < pageH) {

        var divp = (pageH - topH) / 2;
        divpP = divp;
        pp = pageH;
        if (navigator.userAgent.indexOf("MSIE 7.0") != -1) {
        }
        if (divp > 20) {
            document.getElementById("top").style.height = divp + "px";
            document.getElementById("bot").style.height = divp + "px";
        }
        else {
            document.getElementById("top").style.height = 40 + "px";
            document.getElementById("bot").style.height = 40 + "px";
        }
    }
    else {
        document.getElementById("top").style.height = 40 + "px";
        document.getElementById("bot").style.height = 40 + "px";
    }
    var bg = document.getElementById("bg");
    if (pageH < 781) {
        bg.style.height = 810 + "px";
    }
    else {
        bg.style.height = pageH + "px";
    }
}
function load() {

    sets();

    var d = document.getElementById("flex__1_hscrollerbarbeg");
    d.onmouseover = over;
    d.onmouseout = out;

    function over() {
        //alert(d.className);
        d.className = "hoverDiv";
        d.setAttribute("class", "hoverDiv");
        //d.style.background-color="#FFFFFF";
        //hscrollerbarbeg scrollgeneric
    }
    function out() {
        d.className = "hscrollerbarbeg";
        d.setAttribute("class", "hscrollerbarbeg");
    }
}

function scrollWidthCounter() {
    var wd = 0;
    var sp = document.getElementById("tempSpan");
    for (var i = 0; i < sp.childNodes.length; i++) {
        if (sp.childNodes[i].offsetWidth != undefined) {
            if (sp.childNodes[i].className == "scrollul")
                if (sp.childNodes[i].offsetWidth > 150) {
                    sp.childNodes[i].style.width = 150 + "px";
                }
                if (navigator.userAgent.indexOf("Opera") != -1)
                    wd += sp.childNodes[i].offsetWidth + 40;
                else
                    wd += sp.childNodes[i].offsetWidth + 25;
        }
    }
    wd -= 25;
    document.getElementById("programa").style.width = wd + "px";
    NowProgram();
    setInterval(NowProgram,4000);
}
function NowProgram() {
    /*d = document.getElementById("flex__1_hscrollerbarbeg")*/
    var d = document.getElementById("spanScroll");
    //alert(d.childNodes[1]);
    //d.childNodes[1].scrollLeft = 190;
    //alert(d.childNodes[1].scrollLeft);
    //d.scrollLeft = 30;
    //730
}

var N = 1;
function changebg() {
    var bg = document.getElementById("bg");
    var opacityTween = new OpacityTween(bg, Tween.regularEaseOut, 100, 0, 3);
    opacityTween.start();
    opacityTween.onMotionFinished = function() { changeClass(bg); };
}
function changeClass(bg) {
    if (N > 5)
        N = 1;
    else
        ++N;
    bg.className = "bg_0" + N;
    bg.setAttribute("class", "bg_0"+N);
    var opacityTween = new OpacityTween(bg, Tween.regularEaseOut, 0, 100, 3);
    opacityTween.start();
    opacityTween.onMotionFinished = function() { setTimeout(changebg, 10000); };
}





function morbenalistriqoni() {
    setInterval(marqee, 100);
    var pos = new Array(0, 0);
    var posmin = new Array(-1600, -3200);
    var posmax = new Array();
    var p = 0;
    var width = document.getElementById("all1").offsetWidth;
    function marqee() {
        for (var i = 1; i < 3; i++) {
            pos[i - 1] -= 4;
            document.getElementById("all" + i).style.left = pos[i - 1] + "px";
            if (pos[i - 1] < posmin[i - 1]) {
                pos[i - 1] = pos[i - 1] + width + width;
            }
        }
    }
}