
/* дополнительные изображения для товаров */
function load_image(id, size, img_type, n){
    $('#main_photo a').attr('href', '/images/items/'+id+((typeof n != 'undefined')?('-'+n):'')+img_type+'x');
    $('#main_photo img').attr('src', '/images/items/'+id+((typeof n != 'undefined')?('-'+n):'')+'_'+size+img_type+'x');
    $('.jqPreload0 img').attr('src', '/images/items/'+id+((typeof n != 'undefined')?('-'+n):'')+img_type+'');
    $('.jqzoom img').attr('jqimg', '/images/items/'+id+((typeof n != 'undefined')?('-'+n):'')+img_type+'');	
    
}
function load_color_image(id,color, size, img_type, n){
    var js ="add_to_basket("+id+", 1,"+color+");return false";
    var newclick = eval("(function(){"+js+"});");   
    $('#add_to_basket').get(0).onclick  = newclick;
    
    $('#main_photo a').attr('href', '/images/colors/'+id+'-'+color+((typeof n != 'undefined')?('-'+n):'')+img_type+'x');
    $('#main_photo img').attr('src', '/images/colors/'+id+'-'+color+((typeof n != 'undefined')?('-'+n):'')+'_'+size+img_type+'x');
    $('.jqPreload0 img').attr('src', '/images/colors/'+id+'-'+color+((typeof n != 'undefined')?('-'+n):'')+img_type+'');
    $('.jqzoom img').attr('jqimg', '/images/colors/'+id+'-'+color+((typeof n != 'undefined')?('-'+n):'')+img_type+'');	
    $('.color_pix').css({
        border : "0px"
    });
    $('#color_pix_'+color+'').css({
        border : "1px solid black"
    });
}
function load_color_image2(id, color, size, img_type, n){
    $('#main_photo a').attr('href', '/images/colors/'+id+'-'+color+((typeof n != 'undefined')?('-'+n):'')+img_type+'x');
    $('#img_'+id+'').attr('src', '/images/colors/'+id+'-'+color+((typeof n != 'undefined')?('-'+n):'')+'_'+size+img_type+'x');
return false; 
}
/* корзина заказа */
var basket=new Array;

function add_to_basket(id, n, color_id,pricelist_pos){
    $.get('/ajax.php?show=basket&act=add&id='+id+(color_id!=undefined?'-'+color_id:'')+'&n='+(n!=undefined?n:'1')+(pricelist_pos!=undefined?'&pricelist_pos='+pricelist_pos:''), function (html){
        $('#message_box').html(html);
        show_basket_dialog();
        refresh_basket_prew();
    });
}

function show_basket_dialog(){
    $('#curtain').show('slow');
    $('#message_box').show('slow');
}

function hide_basket_dialog(){
    $('#curtain').hide('slow');
    $('#message_box').hide('slow');
}

function refresh_basket_prew(){
    $.get('/ajax.php?show=basket_prew_js', function(html){
        eval(html);
    });
}
$(document).ready(function() {
    $(".contentnav a:first").addClass("active");
    $("#addEdu > input").attr('disabled', 'true');

    $(".contenttext div").hide();
    $(".contenttext div:first").show();

    var contentwidth = $(".contentholder").width();

    var totalcontent = $(".content").size();

    var allcontentwidth = contentwidth * totalcontent;

    $(".contentslider").css({
        'width' : allcontentwidth
    });

    rotate = function(){
        $(".contenttext div").hide();
        var slideid = $active.attr("rel") - 1;
        var textid = $active.attr("rel");
        var slidedistance = slideid * contentwidth;
        $(".contentnav a").removeClass('active');
        $("#img"+textid+"").show();
        $active.addClass('active');

        $(".contentslider").animate({
            left: -slidedistance
        }, 500 );
    };


    rotation = function(){
        play = setInterval(function(){
            $active = $('.contentnav a.active').next();

            if ( $active.length === 0) {
                $active = $('.contentnav a:first');
            }

            rotate();
        }, 7000);
    };

    rotation();

    $("#slider").mouseover(function(){
        clearInterval(play);
    }).mouseout(function(){
        rotation();
    });

    $(".contentnav a").click(function() {
        $active = $(this);
        clearInterval(play);
        rotate();
        return false;
    });
});
