﻿$(document).ready(function()
{
    sifrInit();

    setTimeout("newHeader()", 8000);

    $("#overlay").fadeIn(1000, function()
    {
        $("#header").css("background", "url(" + RootPath + "resource/images/design/header/" + Header + ".jpg)");
        $(this).hide();
    });
    
    if (typeof EndRequestHandler == "function") Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
});

function pageLoad()
{
    sifrInit();
    
    $("#overlay").css("background", "url(" + RootPath + "resource/images/design/header/" + Header + ".jpg)");

    $("#ctl00_info").mouseover(function()
    {
        $("#infoBg").animate({ width: "400px" }, { queue: false });
    });
    $("#ctl00_info").mouseout(function()
    {
        $("#infoBg").animate({ width: "0px" }, { queue: false });
    });

    $("#top a.menu:eq(" + Menu + ")").addClass("active");


    myQuery();

    if (typeof secondaryLoad == "function") secondaryLoad();
}





function PostBack(sender, key, e)
{
    var keyCode = (window.event) ? event.keyCode : e.keyCode;
    
    if (key == "enter") key = 13;
    else if (key == "escape") key = 27;
    
    if (keyCode == key) __doPostBack(sender, "");
}

function filebrowser(field_name, url, type, win)
{

    var cmsURL = RootPath + "filebrowser";    // script URL - use an absolute path!

    tinyMCE.activeEditor.windowManager.open({
        file: cmsURL,
        title: 'Billeder',
        width: 800,  // Your dimensions may differ - toy around with them!
        height: 500,
        resizable: "yes",
        inline: "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
        close_previous: "no"
    }, {
        window: win,
        input: field_name
    });

    return false;
}


function newHeader()
{
    var image = Header;
    var same = true;

    while (same)
    {
        image = Math.round(Math.random() * HeaderCount);
        if (image != Header)
        {
            same = false;
            Header = image;
        }
    }

    $("#overlay").css("background", "url(" + RootPath + "resource/images/design/header/" + image + ".jpg)");
    $("#overlay").fadeIn(1000, function()
    {
        $("#header").css("background", "url(" + RootPath + "resource/images/design/header/" + image + ".jpg)");
        $(this).hide();
    });

    setTimeout("newHeader()", 8000)
}