﻿$(document).ready(function() {

    $("#LeftMenus ul li a.Selected").parent().find("div").css("opacity", 1);

    $("#LeftMenus ul li a:not(.Selected),#BeforeLink ul li a").hover(function() {
        $(this).parent().find("div").animate({ opacity: 1 }, 200);

    }, function() {
        $(this).parent().find("div").animate({ opacity: 0.8 }, 600);
    });

    $("#RightMenus .Item").hover(function() {

        $(this).children().children(".colourBackground").animate({
            opacity: .9
        }, 230);

        $(this).children()
                    .children(".rhsContent")
                    .children("h4")
                    .children("a")
                   .css("background-image", "url(img/rhs-btns-on.png)")


    }, function() {

        $(this).children().children(".colourBackground").animate({
            opacity: 0.5
        }, 1000);

        $(this).children()
                    .children(".rhsContent")
                    .children("h4")
                    .children("a")
                   .css("background-image", "url(img/rhs-btns-off.png)");

    });

    $(".BeforeImage").click(function(e) {
        e.preventDefault();
    });

    var width = 0;
    var height = 0;

    var imgTimer = null;

    $(".BeforeImage").hover(function() {

        if (height == 0) {

            var imge = $("#imgBeforeImage");
            imge.css("z-index", "2000");
            height = imge.height();
            width = imge.width() + 20 - 9;

            $("#BeforeImagePopUp").css("top", "-" + height / 2 + "px");

            $("#BeforeLink .bmid").css("width", width + "px");
            $("#BeforeLink .crhs").css("height", height + "px");

            $("#BeforeImagePopUp").css("display", "none").css("visibility", "visible");
        }
        // image appears
        clearTimeout(imgTimer);
        $("#BeforeImagePopUp").slideDown();
    }, function() {
        // image disappears
        imgTimer = setInterval(function() { $("#BeforeImagePopUp").slideUp(750) }, 2000);
    });

    $("#BeforeImagePopUp").hover(function() {
        // image appears
        clearTimeout(imgTimer);
    }, function() {
        // image disappears
        imgTimer = setInterval(function() { $("#BeforeImagePopUp").slideUp(750) }, 2000);
    });

    $("#InfoLink a").click(function(e) {
        e.preventDefault();
        $("#RolloverContainer").fadeIn(300);
//    }, function(e) {
//        e.preventDefault();
//        $("#RolloverContainer").fadeOut(600);
    });

    $("#CloseInfo a").click(function(e) {
        e.preventDefault();        
        $("#RolloverContainer").fadeOut(600);
    });    

});
