﻿// JScript File
$(document).ready(function(){
   
    var heightRatio = 0.1602083;    
    $("#bandspacer").css("height",screen.height * heightRatio);    

    $("#hypVehicleEnergy").mouseover(function(){             
        $("#divPop").css("background-image","url(images/" + getCookie("lang") + "/VehiclePop.png)");  
        ContentCreator(getCookie("lang") + this.id);       
        DivHelper();  
             
    });
    
    $("#hypHomeEnergy").mouseover(function(){ 
        $("#divPop").css("background-image","url(images/" + getCookie("lang") + "/HomePop.png)");        
        ContentCreator(getCookie("lang") + this.id); 
        DivHelper();
    });  
    
    $("#hypBusinessEnergy").mouseover(function(){ 
        $("#divPop").css("background-image","url(images/" + getCookie("lang") + "/BusinessPop.png)");
        ContentCreator(getCookie("lang") + this.id); 
        DivHelper();
    });
    
    $("#hypAlternativeEnergy").mouseover(function(){ 
        $("#divPop").css("background-image","url(images/" + getCookie("lang") + "/AlternativePop.png)");
        ContentCreator(getCookie("lang") + this.id); 
        DivHelper();
    });
    
    $("#hypCoopInfo").mouseover(function(){ 
        $("#divPop").css("background-image","url(images/" + getCookie("lang") + "/CoopInfoPop.png)");
        ContentCreator(getCookie("lang") + this.id); 
        DivHelper();
    });
    
    $(".SectionLinks").mouseout(function(){        
        $("#divPop").hide();              
    });
    
    //Helper for showing the popup. We determine if browser is IE6 and display as inline element
    function DivHelper(){
        $("#divPop").fadeIn();
        
        //IE6 requires the popup to be displayed as an inline element
        $.each(jQuery.browser, function(i) {
            if($.browser.msie){
                if($.browser.version=="6.0"){
                    $("#divPop").css("display","inline");
                }
            }
        }); 
    }
    
    //Helper for writing content in popup
    function ContentCreator(elem){
        var content = $("#" + elem + "").html();              
        $("#divPopText").html(content);
    }
    
    function getCookie(c_name){
        if (document.cookie.length>0){
            c_start=document.cookie.indexOf(c_name + "=");
            if (c_start!=-1){
                c_start=c_start + c_name.length+1;
                c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
                return unescape(document.cookie.substring(c_start,c_end));
            }
        }
        return "e";
    }
    
});
