/*
    Prognoz, prognozFunctions.js
    Misc. Functions

*/
<!--

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function IEDropDownNav(){

    if (document.all&&document.getElementById) {
        navRoot = document.getElementById("main-nav-dropdown");

        for (i=0; i<navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];

            if (node.nodeName=="LI") {
                node.onmouseover=function() {
                    this.className+=" over";
                }
                node.onmouseout=function() {
                    this.className=this.className.replace(" over", "");
                }
            }
        }
    }
    return;
}

var colHeights = new Array();
var prevHeights = new Array();

function setHeights(){
    var tallest;

    if(document.getElementById("sub-content"))          { colHeights[0] = document.getElementById("sub-content").offsetHeight;}
    if(document.getElementById("main-content"))         { colHeights[1] = document.getElementById("main-content").offsetHeight;}
    if(document.getElementById("sub-nav"))              { colHeights[2] = document.getElementById("sub-nav").offsetHeight;}

    prevHeights = colHeights;

    tallest = 0;
    for(var x=0; x<=colHeights.length; x++){
        if(colHeights[x] > tallest){
            tallest = colHeights[x];
        }
    }

    if(document.getElementById("sub-content"))          { colHeights[0] = document.getElementById("sub-content").style.height = tallest+"px"; }
    if(document.getElementById("main-content"))         { colHeights[1] = document.getElementById("main-content").style.height = tallest+"px"; }
    if(document.getElementById("sub-nav"))              { colHeights[2] = document.getElementById("sub-nav").style.height = tallest+"px"; }

    return;
}

function changeBanner(view){
    a = document.getElementsByTagName("link")[0];

    if(a.disabled == false){
        switch(view){
            case 0: document.getElementById("nav-banner").style.backgroundImage = "url('../images/content/home_banner.jpg')"; break;
            case 1: document.getElementById("nav-banner").style.backgroundImage = "url('../images/content/home_banner1.jpg')"; break;
            case 2: document.getElementById("nav-banner").style.backgroundImage = "url('../images/content/home_banner2.jpg')"; break;
            case 3: document.getElementById("nav-banner").style.backgroundImage = "url('../images/content/home_banner3.jpg')"; break;
        }
    }

    return;
}

function showPic(caller, caption, w){
    var img = caller.getAttribute("src");
    var alt = caller.getAttribute("alt");
    var align = caller.getAttribute("align");
    var hspace = caller.getAttribute("hspace");
    var vspace = caller.getAttribute("vspace");

    if(img != null && !document.getElementById("large_image_div")){
        var images = document.getElementsByTagName("img");
        var img_caller = null;
        for(var i=0; i<images.length; i++){
            if(images[i].getAttribute("src") == img){
                img_caller = images[i];
            }
        }

        //create div
        var new_div = document.createElement("div");
        var new_div_hotspot = document.createElement("a");
        var new_div_img = document.createElement("img");
        new_div.setAttribute("id", "large_image_div");

        new_div_hotspot.setAttribute("id", "large_image_div_hotspot");

        /* because IE sucks, use DOM 0 style */
        new_div_hotspot.onmouseout = function() { hidePic(caller); }

        //create img inside
        new_div_img.setAttribute("id", "large_image");
        new_div_img.setAttribute("src", img);
        new_div_img.setAttribute("alt", alt);
        if(w != null){ new_div_img.setAttribute("width", w); }

        //create caption
        if(caption != null){
            var new_div_caption = document.createElement("p");
            var new_div_caption_txt = document.createTextNode(caption);
            new_div_caption.appendChild(new_div_caption_txt);
            new_div_hotspot.appendChild(new_div_caption);
        }
        new_div_hotspot.appendChild(new_div_img);
        new_div.appendChild(new_div_hotspot);

        //insert and align
        if(img_caller != null){
            img_caller.parentNode.insertBefore(new_div, img_caller);

            var pw = document.getElementById("main-content").offsetWidth;
            var divw = new_div.offsetWidth;
            var icw = img_caller.offsetWidth;
            if(hspace != null && hspace != ""){ divw += eval(hspace*2); }

            var divh = new_div.offsetHeight;
            var ich = img_caller.offsetHeight;
            var deltah = Math.abs(divh - ich);
            if(vspace != null && vspace != ""){ deltah -= eval(vspace); }

            new_div.style.marginTop = -(deltah)+"px";

            if(align != null && align != ""){
                if(align == "right" && pw>divw){
                    new_div.style.marginLeft = (pw-divw)+"px";
                } else {
                    /* IE only check */
                    if(typeof(document.all)=='object'){
                        new_div.style.marginLeft = "-"+icw+"px";
                    }
                }
            }
        }
    }
}

function hidePic(caller){

    var r = document.getElementById("large_image_div");
    if (r && r.parentNode && r.parentNode.removeChild) {
        r.parentNode.removeChild(r);
    }
}

function init(){
    MM_preloadImages('../images/content/home_banner1.jpg', '../images/content/home_banner2.jpg', '../images/content/home_banner3.jpg');
    IEDropDownNav();
    setTimeout("setHeights()",50);
}

function openAWindow( pageToLoad, winName, width, height, center){

xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ) &&(center)){
 xposition = (screen.width - width) / 8;
 yposition = (screen.height - height) / 3;
}

args = "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=1,"
+ "scrollbars=1,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "hotkeys=0,"
+ "screenx=" + xposition + "," //NN Only
+ "screeny=" + yposition + "," //NN Only
+ "left=" + xposition + "," //IE Only
+ "top=" + yposition; //IE Only

window.open( pageToLoad, winName, args );

}


window.onload = init;
-->

