﻿
var BasketToggled=false;

$(document).ready(function() {
    $('.morelink').click(function() {
        $(this).closest('ul').find('.more').show();
        $(this).closest('li').prevAll().hide();
        $(this).closest('li').hide();
        return false;
    });

    $('.catexp,.catcol').click(togglecat);

    function togglecat(e) {
        if (e.target == this) {
            var sender = $(this);

            if (sender.is(".catexp")) {
                sender.removeClass("catexp");
                sender.addClass("catcol");
                sender.find("ul").slideDown();
            }
            else {

                sender.find("ul").slideUp(function() {
                    sender.addClass("catexp");
                    sender.removeClass("catcol");
                });
            }

            return false;
        }
    }

});

function setBasketUIdefault2()
{
    if(BasketToggled==false)
        {
            //alert('false');
            $("#basketItems").hide(); 
        }
    else
        {
            //alert('true');
            $("#basketItems").show();
        }
}

function doToggle()
{
    if($('#basketItems tbody tr').is(':visible') == false)
    {
        $('#basketController').text('Hide Basket').removeClass("expand").addClass("collapse");
        $('#basketItems thead tr, #basketItems tbody tr').removeClass("hidden");
        BasketToggled = false;
    }
    else
    {
        $('#basketController').text('Show Basket').removeClass("collapse").addClass("expand");
        $('#basketItems thead tr, #basketItems tbody tr').addClass("hidden");
         BasketToggled = true;
    }

    $.cookie('basketState', BasketToggled, { expires: 1 });
}

function basketUpdates()
{
    if($('#basketController').text() == 'Hide Basket')
    {
   
        $('#basketController').text('Hide Basket').removeClass("expand").addClass("collapse");
        $('#basketItems thead tr, #basketItems tbody tr').removeClass("hidden");
    }

}

//Modified by carl 23/feb/2010 
//Code was making the basket rows jump all over..
//Changed so when hover over image it makes image bigger 
//and when mouse out it makes it smaller again 
$(document).ready(function()
{
/*
    $("#basketItems .basketImage").mouseover(function() {
        $(this).attr("style","position:absolute;z-index:201;");
        $(this).animate({"height":"114px","width":"114px"},"slow");
        //$(this).animate({"width":"+=114px"},"slow");
        //$(this).height(114);
        //$(this).width(114);
    }).mouseout(function() {
        
        $(this).animate({"height":"22px","width":"22px"},"slow", function(){
            $(this).attr("style","position:relative;");}
            );
        //$(this).attr("style","position:relative;");
        //$(this).height(22);
        //$(this).width(22);
   });
   */
});

function returnfalse()
{
    return false;
}

function expandAddressSection()
{
  
    $('.newAddressSection').show();
    //_showfindByPostcode == true;
    $("#findByPostcode").show();
   
}
