﻿$(document).ready(function () {

    $("#menu li").hover(function () {
        if (!$(this).hasClass("hold") && !$(this).hasClass("left")) {
            $(this).addClass("hover");
        }
    }, function () {
        if (!$(this).hasClass("hold") && !$(this).hasClass("left")) {
            $(this).removeClass("hover");
        }
    });

    var url = window.location.href;
    $("#menu a").each(function () {
        var thisURL = $(this).attr("href").toLowerCase();
        if (url.toLowerCase().indexOf(thisURL) > 0) {
            $(this).parent().addClass("hold");
        }
    });

    $('#images').cycle();
    $('#images').removeClass("hide");

    $("#submenu li").hover(function () {
        if (!$(this).hasClass("hold")) {
            $(this).addClass("hover");
        }
    }, function () {
        if (!$(this).hasClass("hold")) {
            $(this).removeClass("hover");
        }
    });

    $("#submenu li").click(function () {
        $("#submenu li").removeClass("hold").removeClass("hover");
        $(".servicepanel").fadeOut(300);

        var id = $(this).attr("id");
        $("#" + id + "panel").animate({ opacity: 1.0 }, 301).fadeIn(300);
        $(this).addClass("hold");

        $("#" + id + "panel li:first").click();
    });


    $(".servicepanel li").hover(function () {
        if (!$(this).hasClass("hold")) {
            $(this).addClass("hover");
        }
    }, function () {
        if (!$(this).hasClass("hold")) {
            $(this).removeClass("hover");
        }
    });

    $(".servicepanel li").click(function () {
        $(".itempanel").fadeOut(300);
        $(".servicepanel li").removeClass("hold").removeClass("hover");

        var id = $(this).attr("id");
        $("#" + id + "item").animate({ opacity: 1.0 }, 300).fadeIn(300);
        $(this).addClass("hold");

        if (id == "hydro" || id == "lastone" || id == "mas") {
            $(".serviceimages").fadeOut(300);
            $("#" + id + "image").animate({ opacity: 1.0 }, 300).fadeIn(300);
        }

        if (id == "face" || id == "correct" || id == "enzyme" || id == "circadia" || id == "rejuv") {
            $(".skincare").fadeOut(300);
            $("#" + id + "image").animate({ opacity: 1.0 }, 300).fadeIn(300);
        }


    });

    if ($("#ctl00_ContentPlaceHolder1_hdnPanel").val() != null && $("#ctl00_ContentPlaceHolder1_hdnPanel").val() != "") {
        var id = $("#ctl00_ContentPlaceHolder1_hdnPanel").val();
        $("#" + id).click();
        //$("#" + id + "panel li:first").click();
        if ($("#ctl00_ContentPlaceHolder1_hdnSubPanel").val() != null && $("#ctl00_ContentPlaceHolder1_hdnSubPanel").val() != "") {
            var subid = $("#ctl00_ContentPlaceHolder1_hdnSubPanel").val();
            $("#" + subid).click();
        }

    } else {
        $("#massage").click();
    }

    if ($("#ctl00_ContentPlaceHolder1_hdnPanel2").val() != null && $("#ctl00_ContentPlaceHolder1_hdnPanel2").val() != "") {
        var id = $("#ctl00_ContentPlaceHolder1_hdnPanel2").val();
        $("#" + id).click();

    } else {
        $("#danne").click();
    }




});
