animate on page load...

animate on page load...

I am trying to animate the overview (a brif descrption) of my shopping basket on a clients website but it doesnt work!

In theory sounds dead easy, however, I want that to happen only when the user adds a new product on the basket, so this is what is happening...

When the user adds a new product on the basket, the page (which is the product details page) reloads its self and it deosnt take the user to the basket detials page.

The user can go to the basket page only if s/he wants to.

So what I want to do is, to animate (slide down / slide up) the basket overview IF the basket quantity has changed AND if the basket button has been clicked.
This is to prevent the basket overview animating while the user navigating through the website.

So I came up with the following which is based on the combination of the existence of a cookie and the content of the basket before and after the button has been clicked. 

This is the idea in words:

shopping basket button click >
check the quantity basket has changed >
check the button has been clicked and create a cookie >
do the animation

$(document).ready(functon(){
   

//declare vars before the button is clicked

var ButtonAction = ""; // button not clicked yet
var Basket = $("#BasketContent").text(); // basket content
var Newbasket = ""; // new basket content



    $("#button").click(function(){ // click of the shopping basket

        ButtonAction = "True"; // set action value of the button to true

        var Newbasket = $("#NewBasketContent").text(); //set the NEW basket content to variable which includes the new item


            // compaire old and new basket values AND button action is set to True
            if ($(Basket) != $(NewBasket) && (ButtonAction == "True")){
           
           
                //if all above three conditions are true then set the cookie
                $.cookie("SetCookie", "OK")
               
   
            };

    });

// if cookie is OK do the animation

if ($.cookie("SetCookie") = "OK"){

    $("#BasketDiv").slideDown("fast");
    $("#BasketDiv").slideUp("fast");
    ($.cookie("SetCookie") = null;   
}

});


Any ideas?

Thanks in advance

Dimitris