var galImages = new Array();
var currentImage = -1;
function resizePage() {
    var _1 = window.innerWidth || document.documentElement.clientWidth;
    var _2 = window.innerHeight || document.documentElement.clientHeight;
    _1 = _1 - 60;
    if (_2 <= 644) {
        _2 = 644;
    }
    if (_1 > 1280) {
        _1 = 1280;
    }
    if (_1 < 984) {
        _1 = 984;
    }
    setPrefix("header").style.marginLeft = (0 - ((_1 + 40) / 2)) + "px";
    setPrefix("navigation").style.width = (_1 + 20) + "px";
    setPrefix("mainimage").style.width = _1 + "px";
    setPrefix("imageholder").style.width = (_1 - 10) + "px";
    setPrefix("mainimage").style.marginLeft = (0 - (_1 / 2)) + "px";
    setPrefix("calendar").style.marginLeft = (0 - (_1 / 2) - 15) + "px";
    setPrefix("calendar_content").style.marginLeft = (0 - (_1 / 2) - 15) + "px";
    setPrefix("weather").style.marginLeft = ((_1 / 2) - 217) + "px";
    setPrefix("weather_content").style.marginLeft = ((_1 / 2) - 217) + "px";
    setPrefix("announcements").style.marginLeft = ((_1 / 2) - 231 + 10) + "px";
    setPrefix("video").style.marginLeft = ((_1 / 2) - 231 + 10) + "px";
	setPrefix("webcamPop").style.marginLeft = ((_1 / 2) - 231 + 10) + "px";
	setPrefix("webcamPop").style.marginTop = (_2 - 160 - 5 - 164 - 71 - 36 - 36 - 5 - 40) + "px";
    setPrefix("bottommenu").style.marginLeft = ((_1 / 2) - 231 + 10) + "px";
    setPrefix("footer").style.width = _1 + "px";
    setPrefix("footer").style.marginLeft = (0 - ((_1) / 2)) + "px";
    setPrefix("mainimage").style.height = (_2 - 120 - 160) + "px";
    setPrefix("middle").style.height = (_2 - 120 - 160) + "px";
    setPrefix("imageholder").style.height = (_2 - 120 - 160 - 16 + 5) + "px";
    setPrefix("leftside").style.height = (_2 - 120 - 160 - 16 + 5) + "px";
    setPrefix("rightside").style.height = (_2 - 120 - 160 - 16 + 5) + "px";
    setPrefix("imgleft").style.height = (_2 - 120 - 160 - 16 + 5) + "px";
    setPrefix("imgright").style.height = (_2 - 120 - 160 - 16 + 5) + "px";
    setPrefix("imgbottomleft").style.top = (_2 - 120 - 160 - 16 + 10) + "px";
    setPrefix("imgbottom").style.marginTop = (_2 - 120 - 160 - 16 + 5) + "px";
    setPrefix("imgbottomright").style.top = (_2 - 120 - 160 - 16 + 10) + "px";
    setPrefix("calendar").style.marginTop = (_2 - 160 - 5 - 309) + "px";
    setPrefix("calendar_content").style.marginTop = (_2 - 160 - 5 - 309) + "px";
    setPrefix("weather").style.marginTop = (_2 - 160 - 5 - 164 - 71 - 36 - 36 - 10) + "px";
    setPrefix("weather_content").style.marginTop = (_2 - 160 - 5 - 164 - 71 - 36 - 36 - 10) + "px";
    setPrefix("announcements").style.marginTop = (_2 - 160 - 5 - 164 - 71 - 36 - 36 - 5) + "px";
    setPrefix("video").style.marginTop = (_2 - 160 - 5 - 164 - 71 - 36 - 36 - 5 - 40) + "px";
    setPrefix("bottommenu").style.marginTop = (setPrefix("weather_button").style.display == "block") ? (_2 - 160 - 11 - 5 - setPrefix("bottommenu").offsetHeight) + "px": (_2 - 160 + 20 - 5 - setPrefix("bottommenu").offsetHeight) + "px";
    setPrefix("footer").style.marginTop = (_2 - 150) + "px";
};
var imagesLoaded = 0;
var imagesToLoad = ["../gallery/gallery1.jpg", "../gallery/gallery3.jpg", "../gallery/gallery4.jpg", "../gallery/gallery5.jpg", "../gallery/gallery6.jpg"];
window.onload = function() {
    resizePage();
    var ip = new ImagePreloader([imagesToLoad[0]], onImageLoad);
    setPrefix("nav_home").setAttribute("class", "nav_home_hover");
    setPrefix("container").style.visibility = "visible";
};
function onImageLoad(_4, _5) {
    for (i = 0; i < _5; i++) {
        setOpacity(_4[i], 0);
        _4[i].style.position = "absolute";
        galImages.push([setPrefix("imageholder").appendChild(_4[i]), 0]);
        imagesLoaded++;
    }
    setPrefix("imageloader").style.display = "none";
    resizeImages();
    if (imagesLoaded == 1) {
        onPreload();
    }
    if (imagesLoaded < imagesToLoad.length) {
        var ip = new ImagePreloader([imagesToLoad[imagesLoaded]], onImageLoad);
    }
};
window.onresize = function() {
    resizePage();
    resizeImages();
};
var fadeInInt,
fadeOutInt;
function onPreload() {
    getWeatherInfo(setPrefix("weather_content"));
    runGallery();
    setInterval("runGallery()", 12000);
};
function resizeImages() {
    var _7 = window.innerWidth || document.documentElement.clientWidth;
    var _8 = window.innerHeight || document.documentElement.clientHeight;
    _7 = _7 - 60;
    var _9,
    _a;
    var _b = _7 - 10;
    var _c = 0;
    var _d;
    for (i = 0; i < galImages.length; i++) {
        _c = galImages[i][0].height;
        if (galImages[i][0].width > galImages[i][0].height) {
            if (galImages[i].width > _b) {
                _d = _b / galImages[i][0].width;
                _9 = _b;
                _a = galImages[i][0].height * (_d);
            } else {
                _9 = galImages[i][0].width;
                _a = galImages[i][0].height;
            }
            if (_a > _c) {
                _d = _c / _a;
                _a = _c;
                _9 = _9 * (_d);
            }
        } else {
            if (galImages[i][0].height > _c) {
                _d = _c / galImages[i].height;
                _a = _c;
                _9 = galImages[i][0].width * _d;
            } else {
                _a = galImages[i][0].height;
                _9 = galImages[i][0].width;
            }
            if (_9 > _b) {
                _d = _b / _9;
                _9 = _b;
                _a = _a * _d;
            }
        }
        galImages[i][0].width = _9;
        galImages[i][0].height = _a;
        galImages[i][0].style.top = "50%";
        galImages[i][0].style.marginTop = (0 - (_a / 2)) + "px";
        galImages[i][0].style.left = "50%";
        galImages[i][0].style.marginLeft = (0 - (_9 / 2)) + "px";
    }
};
function runGallery() {
    if (currentImage != -1) {
        fadeOutInt = setInterval("fadeOut(" + currentImage + ")", 1);
    }
    advanceImage();
    fadeInInt = setInterval("fadeIn(" + currentImage + ")", 1);
};
function advanceImage() {
    currentImage += 1;
    if (currentImage > galImages.length - 1) {
        currentImage = 0;
    }
};
function fadeIn(_e) {
    if (galImages[_e][1] < 100) {
        galImages[_e][1] += 15;
        setOpacity(galImages[_e][0], galImages[_e][1]);
    } else {
        clearInterval(fadeInInt);
        setOpacity(galImages[_e][0], 100);
    }
};
function fadeOut(_f) {
    if (galImages[_f][1] > 0) {
        galImages[_f][1] -= 15;
        setOpacity(galImages[_f][0], galImages[_f][1]);
    } else {
        clearInterval(fadeOutInt);
        setOpacity(galImages[_f][0], 0);
    }
};
function setOpacity(obj, _11) {
    if (obj.style.MozOpacity != null) {
        obj.style.MozOpacity = (_11 / 100) - 0.001;
    } else {
        if (obj.style.opacity != null) {
            obj.style.opacity = (_11 / 100) - 0.001;
        } else {
            if (obj.style.filter != null) {
                obj.style.filter = "alpha(opacity=" + _11 + ")";
            }
        }
    }
};