$(document).ready(function(){  
        readCookiesAndSetDisplayCurrency();
        readCookiesAndSetFilter();

        if (document.getElementById("featured-box-static") && document.getElementById("featured-box-animated")){
            var d = document.getElementById("featured-box-static");
            d.style.display = "none";
            var d = document.getElementById("featured-box-animated");
            d.style.display = "block";
        }

        $('#myController').jFlow({  
            slides: "#slides",    
            width: 740,  
            height: 185,
            delay: 8000
        });  
        
        $('.TTcenter').tt({
            distanceY:10,
            delay:0,
            timeOut:0
        });

        $('.postRating > a').click(function(e) {
            e.preventDefault();
            var id = $(this).parent().attr('id').substring(6);
            var msg = "";
            var element = $(this).parent().hasClass('vote');
            $.post("/deals/rate/id/" + id, {rating: $(this).html()}, function(xml) {
                if (element == true) {
                    msg = "Thanks for rating! ("+xml+" so far)";
                } else {
                    msg = "("+xml+")";
                }
                $("#rating" + id).html(msg);
            });
        });

        $('#df-reset').click(function(e){
            e.preventDefault();
            cookiejar.crumble('dealfilter');
            $("li[id^='df_']").removeAttr('class');
            $('.df-menu li').removeAttr('class');
            $('#df-reset').removeAttr('class');
            location.reload();
        });
        $('.df-update').click(function(e){
            e.preventDefault();
            location.reload();
        });
        $('.df-menu li').click(function(e){
            e.preventDefault();
            dealFilterItemSelected(this.id, e.target.id);
            location.reload();
        });

        $('#curselect').change(function(){
        	var oldCur = cookiejar.fetch('displaycurrency');
        	var newCur = $('#curselect').val();
        	if (oldCur != newCur) {
                cookiejar.bake('displaycurrency', newCur, 3);
                location.reload();
        	}
        });
});