﻿/// <reference path="../jquery-1.5.1-vsdoc.js" />

$(document).ready(function ()
{
    // Header social links hover images
    $("#hs_rss").hover(
        function ()
        {
            this.src = $("#sociallocation").val() + "rss_colour.png";
        },
        function ()
        {
            this.src = $("#sociallocation").val() + "rss_white.png";
        }

    );

    $("#hs_twit").hover(
        function ()
        {
            this.src = $("#sociallocation").val() + "twitter_colour.png";
        },
        function ()
        {
            this.src = $("#sociallocation").val() + "twitter_white.png";
        }
    );

    $("#hs_face").hover(
        function ()
        {
            this.src = $("#sociallocation").val() + "facebook_colour.png";
        },
        function ()
        {
            this.src = $("#sociallocation").val() + "facebook_white.png";
        }
    );
    // END Header social links hover images
    
    /*if ($("#content").css("height") > $("#sidebar").css("height"))
    {
        $("#sidebar").css("height", $("#content").css("height"));
    }*/

    NewsletterBoxCookie();
});

function CloseNewsletterBox()
{
    $("#newspop").fadeOut("fast");
    $("#windowblind").fadeOut();
}

function NewsletterBox()
{    
    $("#newspop").fadeIn();
    $("#windowblind").fadeIn("fast");    
}

function NewsletterBoxCookie()
{
    var cvalue = GetCookie("newspop");

    if (cvalue == "")
    {
        SetCookie("newspop", "kittens", 3);
        $("#newspop").fadeIn();
        $("#windowblind").fadeIn("fast");
    }
}

function SetCookie(c_name, value, exdays)
{
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString()) + "; path=/";
    document.cookie = c_name + "=" + c_value;
}

function GetCookie(c_name)
{
    var i, x, y, ARRcookies = document.cookie.split(";");
    for (i = 0; i < ARRcookies.length; i++)
    {
        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
        x = x.replace(/^\s+|\s+$/g, "");
        if (x == c_name)
        {
            return unescape(y);
        }
    }

    return "";
}

function DisplayInfoMessage(message, importance)
{
    var disappearTime = 3000;
    $("#notice div span").text(message);
    switch (importance)
    {
        case "normal":
            $("#notice").fadeIn("fast");
            break;
        case "high":
            $("#notice div span").css("background-color", "#CC0000");
            $("#notice").show();
            disappearTime = 12000;
            break;
        default:
            break;
    }

    $("body").bind("mousemove", function ()
    {
        $("body").unbind("mousemove");
        setTimeout("HideInfoMessage()", disappearTime);
    });
}
function HideInfoMessage()
{
    $("#notice").fadeOut("slow", function ()
    {
        $("#notice div span").css("background-color", $("#notice").data("originalColour"));
    });
}
