// JavaScript Document
$(document).ready(function() {	
    var menuItem = $("#menu > ul > li");
    menuItem.each(function(index) {
        $(this).bind("mouseover", function() {
            $(this).addClass("NavOver");
        });
        $(this).bind("mouseout", function() {
            $(this).removeClass("NavOver");
        });
    });
    /*
    var listItem = $("#menu > ul > li > a");
    listItem.each(function(index) {
    if ($(this).hasClass("Active")) {
    $(this).parent().css("z-index", 7);
    //$(this).css("z-index",6);
    if ($(this).parent().attr("id") == "list01") {
    if ((/MSIE\s6\.0/).test(navigator.userAgent))
    $(this).parent().css("margin-left", 12);
    else
    $(this).parent().css("margin-left", 24);
    }
    else
    $(this).parent().css("margin-left", -1);
    }
    });*/
    $(".Login").unbind("click").bind("click", function() {
        if ($(".LoginForm1").css("display") == "none") {
            $(".LoginForm1").css("display", "block");

            $(".Login").css("color", "#FFF");
            $(".Login").css("background-image", "none");
            $(".Login").css("background-color", "#6e9b04");

            $("#forgotPassBlock").hide();

            $(".LoginForm1 span.errorSpan").hide();
            $(".LoginForm1 input.TextBox").val("");
            $(".LoginForm1 a").show();

            $(".Theme_Human .DropListUIContainer").hide();

            $("#" + loginEmailTextboxId)[0].focus();

        }

        return false;
    });
    $(".Cancel").bind("click", function() {
        if ($(".LoginForm1").css("display") == "block") {
            $(".LoginForm1").css("display", "none");
            $(".Login").css("background-color", "#FFFFFF");
            $(".Login").css("color", "#AAA391");
            $(".Login").css("background-image", "");

            $(".LoginForm1 span.errorSpan").hide();
            $(".LoginForm1 input.TextBox").val("");
            // for login form - global variabel
            $("#" + errorMessageBlock1).hide();
            $("#" + errorMessageBlock2).hide();
            errorFound = false;
            isOpenPasswordBlock = false;

        }
    });
    $(".GuideMe > a").bind("click", function() {
		var menuItem = $("#menu > ul > li");
		menuItem.each(function(index) {
			$(this).removeClass("NavOver");
		});
        showAdvisorTool('player', 'GuideMe');
    });
    $(".InspireMe > a").bind("click", function() {
		var menuItem = $("#menu > ul > li");
		menuItem.each(function(index) {
			$(this).removeClass("NavOver");
		});
        showAdvisorTool('player', 'InspireMe');
    });
});

function GetPopupWidth(name) {
    if (name == "SendToFriend" || name == "tellafriend") return 522;
    if (name == "print" || name == "PrintRecipe") return 541;
    if (name == "SaveToMyRecipeBox") return 522;
    if (name == "RemoveFromMyrecipeboxConfirm") return 522;
    if (name == "AddCategory") return 522;
    if (name == "EditCategory") return 540;
    if (name == "deleteCategory") return 522;
    if (name == "RememberMe") return 522;
    if (name == "PrivacyInfomation") return 800;
    if (name == "Confimation") return 522;
    if (name == "TaggingRecipe") return 522;
    if (name == "RecipeZoom") return 300;
    return 522;
}

function GetPopupHeight(name) {
    if (name == "SendToFriend" || name == "tellafriend") return 337;
    if (name == "print" || name == "PrintRecipe") return 250;
    if (name == "SaveToMyRecipeBox") return 273;
    if (name == "RemoveFromMyrecipeboxConfirm") return 153;
    if (name == "AddCategory") return 273;
    if (name == "EditCategory") return 300;
    if (name == "deleteCategory") return 150;
    if (name == "RememberMe") return 200;
    if (name == "PrivacyInfomation") return 600;
    if (name == "Confimation") return 155;
    if (name == "TaggingRecipe") return 155;
    if (name == "RecipeZoom") return 320;
    if (name == "ReviewConfirm") return 210;
    if (name == "ReviewEditConfirm") return 210;
    return 200;
}

function IsScroolAble(name) {
    var isScrool = 0;
    switch (name) {
        case "print":
        case "EditCategory":
            isScrool = 1;
            break;
    }
    return isScrool;
}

function windowPop(url, name) {
    //alert(name + width + ":" + height);
    var width = GetPopupWidth(name);
    var height = GetPopupHeight(name);
    var scrollboolean = IsScroolAble(name);
    var LeftPosition = (screen.width) ? (screen.width - width) / 2 : 0;
    var TopPosition = (screen.height) ? (screen.height - height) / 2 : 0;

    var params;
    if (scrollboolean != "") {
        params = "scrollbars=" + scrollboolean;
    } else {
        params = "scrollbars=0";
    }
    params = params + ",location=0,menubar=0,status=0,toolbar=0,resizable=0,top=" + TopPosition + ",left=" + LeftPosition + ",";
    params = params + "width=" + width + "px,height=" + height + "px";
    window.open(url, name, params);
    
}


function ShowLoginPopup() {
    $(".LoginForm1").show();
    $(".LoginForm1 input.TextBox").val("");
    $("#" + loginEmailTextboxId)[0].focus();
    return false;
}

function ShowLoginPopupAndSaveRecipeWhenPostBack(recipeId) {
    $(".LoginForm1").show();
    $(".LoginForm1 input.TextBox").val("");
    $("#" + loginExtentParametterHidden).val("SaveRecipeId=" + recipeId);
    $("#" + loginEmailTextboxId)[0].focus();
    return false;
}

function ShowLoginPopupInRecipeDetailPage() {
    $(".LoginForm1").show();
    $(".LoginForm1 input.TextBox").val("");
    $("#" + loginExtentParametterHidden).val("tab=review");
    $("#" + loginEmailTextboxId)[0].focus();
    return false;
}