$(document).ready(function(){
    var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
    var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
    if (jQuery.browser.msie && (ie55 || ie6)) {
        var t_img = 'info.png';
    } else {
        t_img = 'info_tr.png';
    }
    $('#products div').hover(function() {
        if ( $(this).hasClass('soldout') ) {

        } else {
            $(this).append('<a href="cart_form.php?height=485&width=505&callback=true&poster=' + $(this).attr('id') + '" class="thickbox"><img src="' + t_img + '" class="info" /></a>');
            tb_init('#products div a.thickbox');
        }

    }, function(){
        $('.info').remove();
    }
    );
});
function thickboxCallbackFunction(poster){
    $('.add').bind('click', function(){
        var qty = $('#cart_add_form input').val();
        if(!isNaN(qty)){
            if(qty < 1 || qty > 20){
                qty = 1;
            }
            var s = (qty > 1) ? 's' : '';
            $('#cart_widget').css('background-color', '#7ec80c').animate({
                backgroundColor: '#ffffff'
            }, 1600).html('<span class="cart_label">Added ' + qty +  ' poster' + s + ' to your <a href="show_cart.php?height=485&width=505" class="thickbox">cart</a></span> <span class="cart_image"><a href="show_cart.php?height=485&width=505" class="thickbox image_link"><img src="cart.png" alt="shopping cart" /></a><span>');
            $.post('index.php', {
                action: 'add',
                item: poster,
                quantity: qty
            });
        }
        tb_remove();
        tb_init('#cart_widget a.thickbox');
    });
    $('.cart_thumb').bind('click', function(){
        $('#cart_images img').eq(0).attr('src', 'images/' + $(this).attr('id') + '.png');
        $('.cart_thumb').css('border', 'solid 1px white')
        $(this).css('border', 'solid 1px #7ec80c');
    })
    $('#close_win').bind('click', function(){
        tb_remove();
    });
}
