$(document).ready(function(){
    /* slideshow */
    if($('.slideshow').length > 0) {
        $('.slideshow').cycle({
            fx: 'fade',
            speed: 3000,
            timeout: 6000
        });
    }

    // some fixing up for the Mac
    if($.client.os == 'Mac') {
        $('span.spinner_up').addClass('mac');
        $('span.spinner_down').addClass('mac');
        $('td.quantity input.qty').addClass('mac');
    }

    $('span.spinner_up').bind('click',function(){
        var min_max = $(this).prev().attr('rel').split(':');
        var current_qty = $(this).prev().val();
        var new_qty = parseInt(current_qty)+1;
        if(new_qty <= min_max[1]) {
            $(this).prev().val(new_qty);
        }
    });
    $('span.spinner_down').bind('click',function(){
        var min_max = $(this).prev().prev().attr('rel').split(':');
        var current_qty = $(this).prev().prev().val();
        var new_qty = parseInt(current_qty)-1;
        if(new_qty >= min_max[0]) {
            $(this).prev().prev().val(new_qty);
        }
    });
})
