﻿var __pover = 'menu';



function showNoPcode(ell) {
    //debugger;
    var theLi;
    if (ell.parent()[0].tagName == "LI") theLi = ell.parent();
    else theLi = ell.parent().parent();
    var theP = theLi.find("p");
    $(".enterPostcodeContinue").remove();
    $(theP.children()[theP.children().length - 1]).after("<span class=\"enterPostcodeContinue\"><br />Please enter your postcode to continue!</span>");
}

function hideError() {
    var errorDiv = document.getElementById("errorDiv");
    errorDiv.style.visibility = 'visible';
}

$(document).ready(function() {
    $('#pizzaContainer li a').each(function() {
        if ($.browser.msie)
            $(this).children('img').attr("alt", "");
        $(this).click(function() {
            if ($(this).attr("href").indexOf("noPcode") >= 0) {
                showNoPcode($(this));
                return false;
            }
            
        });

        $("#errorDiv").hide();
        $(".printMenuIcon a").click(function() {
            if ($(this).attr("href") == "#disabled")
                $("#errorDiv").show();

        });
    });

    $('#sidesContainer li a').each(function() {
        if ($.browser.msie)
            $(this).children('img').attr("alt", "");
        $(this).click(function() {
            if ($(this).attr("href").indexOf("noPcode") >= 0) {
                showNoPcode($(this));
                return false;
            }

        });

        $("#errorDiv").hide();
        $(".printMenuIcon a").click(function() {
            if ($(this).attr("href") == "#disabled")
                $("#errorDiv").show();

        });
    });

    $('#dessertsContainer li a').each(function() {
        if ($.browser.msie)
            $(this).children('img').attr("alt", "");
        $(this).click(function() {
            if ($(this).attr("href").indexOf("noPcode") >= 0) {
                showNoPcode($(this));
                return false;
            }

        });

        $("#errorDiv").hide();
        $(".printMenuIcon a").click(function() {
            if ($(this).attr("href") == "#disabled")
                $("#errorDiv").show();

        });
    });

    $('#drinksContainer li a').each(function() {
        if ($.browser.msie)
            $(this).children('img').attr("alt", "");
        $(this).click(function() {
            if ($(this).attr("href").indexOf("noPcode") >= 0) {
                showNoPcode($(this));
                return false;
            }

        });

        $("#errorDiv").hide();
        $(".printMenuIcon a").click(function() {
            if ($(this).attr("href") == "#disabled")
                $("#errorDiv").show();

        });
    });
    



});



function reCalcPrice()
{    
    var id_Crust = 0;
    var id_size = 0
    var id_Firstsize = 0
    var id_Pizza = 0;
    var sToppings = "";
    //find selected curst
    var arrBaseSize = $(".BaseSizeSelect").val().split(",");
    
    if (arrBaseSize.length > 1)
    {
        id_Crust = arrBaseSize[0];
        id_size = arrBaseSize[1];
    }
    
    //find selected pizza
    id_Pizza = $("#hdnPizzaId").val();
    //find selected toppings
    //debugger;
    $(".customizeYourPizzaBox input[@type='checkbox']").each(function()
    {
        var thisCheck = $(this);
        if (thisCheck.is(":checked"))
        {
            if (sToppings != "") sToppings += ",";
            sToppings += thisCheck.val();
        }
    });

    if (id_Crust != 0 && id_size != 0 && id_Pizza != 0)
    {
        //Grey out sizes that are not available


        var params = "id_Crust=" + id_Crust + "&id_size=" + id_size + "&id_Pizza=" + id_Pizza + "&toppings=" + sToppings;

        $.getJSON("/json/getPizzaPrice.aspx?" + params,
                            function(data, status)
                            {
                                if (data.cost == 0)
                                    $("#spnPizzaPrice").html("");
                                else
                                    $("#spnPizzaPrice").html("&pound;" + number_format(data.cost, 2));

                            });

    }

}

			$(function(){
 
	
				
				
	var tabContainers = $('div.tabsContainer > div');
    $('ul.tabNav li a').click(function () {
        tabContainers.hide().filter(this.hash).show();
        $('ul.tabNav li a').removeClass('selected');
        $(this).addClass('selected');
        return false;
    }).filter(':first').click();
	
 
				
			});
	