﻿
$(document).ready(function() {
    var options = { to: { width: 200, height: 60} };
    $("#homepanel").show("fold");
    $("#lifepanel").hide();
    $("#opinionpanel").hide();
    $("#aboutpanel").hide();
    $("#contactpanel").hide();
    $("#workpanel").hide();
    $("#lifepanel").addClass("show");
    $("#opinionpanel").addClass("show");
    $("#aboutpanel").addClass("show");
    $("#contactpanel").addClass("show");
    $("#workpanel").addClass("show");
    $links = $(".topCont > ul > li > a");
    $bottomlinks = $(".BottomLinks > p > a");
    var isSLInstalled = Silverlight.isInstalled(null);
    var currentSelected = "home";
    changeStyles();
    $(window).resize(function() {
        changeStyles();
    });


    $("#work").click(function(event) {
        if (currentSelected != "work") {
            $("#" + currentSelected + "panel").hide("fold", {}, "slow", function() {
                $("#workpanel").show("fold");
            });
        } else {

        }
        $links.removeClass("on");
        $bottomlinks.removeClass("on");
        $(this).addClass("on");
        currentSelected = "work";
        return false;
    });

    $("#life").click(function(event) {
        if (currentSelected != "life") {
            $("#" + currentSelected + "panel").hide("fold", {}, "normal", function() {
                $("#lifepanel").show("fold")
            });
        } else {

        }
        $links.removeClass("on");
        $bottomlinks.removeClass("on");
        $(this).addClass("on");
        currentSelected = "life";
        return false;
    });

    $("#opinion").click(function(event) {
        if (currentSelected != "opinion") {
            $("#" + currentSelected + "panel").hide("fold", {}, "normal", function() {
                $("#opinionpanel").show("fold")
            });
        } else {

        }
        $links.removeClass("on");
        $bottomlinks.removeClass("on");
        $(this).addClass("on");
        currentSelected = "opinion";
        return false;
    });

    $("#about").click(function(event) {
        if (currentSelected != "about") {
            $("#" + currentSelected + "panel").hide("fold", {}, "normal", function() {
                $("#aboutpanel").show("fold")
            });
        } else {

        }
        $links.removeClass("on");
        $bottomlinks.removeClass("on");
        $(this).addClass("on");
        currentSelected = "about";
        return false;
    });

    $("#contact").click(function(event) {
    if (currentSelected != "contact") {
            $("#" + currentSelected + "panel").hide("fold", {}, "normal", function() {
            $("#contactpanel").show("fold")
            });
        } else {

        }
        $links.removeClass("on");
        $bottomlinks.removeClass("on");
        $(this).addClass("on");
        currentSelected = "contact";
        return false;
    });

    $("#home").click(function(event) {
    if (currentSelected != "work") {
            $("#" + currentSelected + "panel").hide("fold", {}, "normal", function() {
            $("#workpanel").show("fold")
            });
        } else {

        }
        $links.removeClass("on");
        $bottomlinks.removeClass("on");
        currentSelected = "work";
        return false;
    });

    $("#nosl").click(function(event) {
        if (currentSelected != "work") {
            $("#" + currentSelected + "panel").hide("fold", {}, "normal", function() {
                $("#workpanel").show("fold")
            });
        } else {

        }
        $links.removeClass("on");
        $bottomlinks.removeClass("on");
        $("#work").addClass = ("on");
        currentSelected = "work";
        return false;
    });

    function changeStyles() {
        if ($(window).height() < "600") {
            //$("#silverlightControlHost").css("position", "relative");
            //$("#silverlightControlHost").css("margin-top", "0");
            //$("#silverlightControlHost").css("top", "0");
            $("#silverlightControlHost").css("height", "575px");
            $("#SL").css("height", "575px");
        }
        else {
            //$("#silverlightControlHost").css("position", "absolute");
            //$("#silverlightControlHost").css("margin-top", "-287px");
            //$("#silverlightControlHost").css("top", "50%");
            $("#silverlightControlHost").css("height", "100%");
            $("#SL").css("height", "100%");

        }

        if ($(window).width() < "1000") {
            $("#silverlightControlHost").css("width", "1000px");
            $("#SL").css("width", "1000px");
            $("#body").css("width", "1000px");

        }
        else {
            $("#silverlightControlHost").css("width", "100%");
            $("#SL").css("width", "100%");

        }

        if ($(window).height() < "600" || $(window).width() < "1000") {
            $("body").css("overflow", "visible");
        }
        else {
            if (isSLInstalled) {
                $("body").css("overflow", "hidden");
            }
        }

    }



});