/**/
$(document).ready(function(){
        
        $("div#togglewrap div#technical").hide();
        $("div#togglewrap div#tools").hide();
        $("div#togglewrap div#applications").hide();
        $("div#togglewrap div#packaging").hide();
        $("div#togglewrap div#support").hide();
        $("div#togglewrap div#where").hide();
        
        var showthis = "overview";
        $("div#" + showthis + ", div#" + showthis + " div.addresources").show();
        $('#' + showthis + 'trigger').addClass('currenttab');
        $("div#togglewrap div h3").addClass("hidden");
        
        ZARLINK.resizeBlockDiagrams();
        ZARLINK.enableProfileNav();
        ZARLINK.enableDiagNav();
});

var ZARLINK = new Object();
ZARLINK.resizeBlockDiagrams = function()
{
    $("div#overview div#diagramwrap").show();
    
    var MAXWIDTH = 500;
    var MAXHEIGHT = 500;
    
    //EKO: Fixed javascript error that occurs if there are no diagrams
    var simplifiedblock = document.images["simplifiedblock"];
    if (simplifiedblock)
    {
        var simplifiedratio = MAXWIDTH/simplifiedblock.width;
        simplifiedblock.height = simplifiedblock.height * simplifiedratio;
        simplifiedblock.width = simplifiedblock.width * simplifiedratio;
    }

    var detailedblock = document.images["detailedblock"];
    if (detailedblock)
    {
        var detailedratio = MAXWIDTH/detailedblock.width;
        detailedblock.height = detailedblock.height * detailedratio;
        detailedblock.width = detailedblock.width * detailedratio;
    }
    
}
ZARLINK.enableDiagNav = function()
{
    $("div#diagramwrap a").click(function(){
        //alert(this);
        
        
    })
}

ZARLINK.enableProfileNav = function ()
{
        $("ul#profilenav a").click(function(){
            var hash = this.href;
            if (this.id == "wheretobuylink") return true;
            hash = hash.split("#");
            
            $("ul#profilenav li").removeClass("currenttab");

            $("div#togglewrap div#overview").hide();
            $("div#togglewrap div#technical").hide();
            $("div#togglewrap div#tools").hide();
            $("div#togglewrap div#applications").hide();
            $("div#togglewrap div#packaging").hide();
            $("div#togglewrap div#support").hide();
            $("div#togglewrap div#where").hide();

            $("#" + hash[1] + ", #" + hash[1] + " div.addresources").show();
            
            //createCookie('lastviewed', hash[1], 365);
            
            $(this.parentNode).addClass("currenttab");
            if (hash[1] == "overview") $("div#overview div#diagramwrap").show();
        
            //alert(hash[1]);
            return false;    
        })
}
