$(function() {
    var that = this;
    $('.shadow, .simple').append('<div class="stl"></div><div class="str"></div><div class="sbr"></div><div class="sbl"></div>');
    $('.white').append('<div class="wtl"></div><div class="wtr"></div><div class="wbr"></div><div class="wbl"></div>');
    $('.menu ul, .button').append('<div class="rtl"></div><div class="rtr"></div><div class="rbr"></div><div class="rbl"></div>');

    $('.cp').append('1');
    $("#present").scrollable({
        size: 1,
        clickable: false,
        onSeek: function() {
            var a = this.getStatus();
            if (a.index == 0) {
                this.seekTo(a.total-2, 1);
                a = this.getStatus();
                $(".cp").text(this.getStatus().index);
            } else if (a.total-1 == a.index) {
                this.seekTo(1, 1);
                $(".cp").text(this.getStatus().index);
            } else {
                $(".cp").text(this.getStatus().index);
            }
        }
    });
    this.present_auto = function() {
        that.present_auto_stop();
        $("#present").everyTime(10000, function(){
           $("#present .next").click();
        });
    }
    this.present_auto_stop = function() {
        $("#present").stopTime();
    }
    $("#present").bind("mouseout", function() { that.present_auto(); cancelBubble = true; });
    $("#present").bind("mouseover",  function() { that.present_auto_stop(); cancelBubble = true; });
    if ($("#present").length > 0)
        $("#present").data('scrollable').seekTo(1,1);
    $("#present span").css('visibility', 'visible');
        var num = $('#present .__scrollable').children().length;
        $('#present .cp').after('<span class="op">/' + (num-2) + ' </span>');
    this.present_auto();

    $("#noveltyMain .items").mscroll({inside: 'a'});
    $("#noveltyMain .prev").bind("click", function(){
        $(this).parent().find('.items').data('mscroll').moveback();
    });
    $('#noveltyMain .next').click(function(){
        $(this).parent().find('.items').data('mscroll').move();
    });
    $("#noveltyMain .prev").bind("mouseover", function(){
        $(this).parent().find('.items').data('mscroll').pauseauto();
    });
    $("#noveltyMain .prev").bind("mouseout", function(){
        $(this).parent().find('.items').data('mscroll').startauto();
    });
    $("#noveltyMain .next").bind("mouseover", function(){
        $(this).parent().find('.items').data('mscroll').pauseauto();
    });
    $("#noveltyMain .next").bind("mouseout", function(){
        $(this).parent().find('.items').data('mscroll').startauto();
    });

    $("#novelty .items").mscroll({inside: 'a', axis: 'ver'});
    $("#novelty .prev").click(function(){
        $(this).parent().find('.items').data('mscroll').moveback();
    });
    $('#novelty .next').click(function(){
        $(this).parent().find('.items').data('mscroll').move();
    });
    $("#novelty .prev").bind("mouseover", function(){
        $(this).parent().find('.items').data('mscroll').pauseauto();
    });
    $("#novelty .prev").bind("mouseout", function(){
        $(this).parent().find('.items').data('mscroll').startauto();
    });
    $("#novelty .next").bind("mouseover", function(){
        $(this).parent().find('.items').data('mscroll').pauseauto();
    });
    $("#novelty .next").bind("mouseout", function(){
        $(this).parent().find('.items').data('mscroll').startauto();
    });

//  $("#novelty").scrollable({size: 3, vertical: true, clickable: false});
    $("#address").scrollable({size: 1, naviItem:'p', clickable: false});
    $("#catalog").scrollable({size: 6, clickable: false});
    $("#shopIn").scrollable({size: 1, clickable: false});
    
    $('#address .navi').jScrollPane();
    $('.jScrollPaneDrag').css({'width':'7px'})
    
    $('.items .new').append('<img src="img/new.png" alt="" width="51" height="51" class="new png24" />');
    $('.items .hot').append('<img src="img/hot.png" alt="" width="51" height="51" class="hot png24" />');
    $('.items .modno').append('<img src="img/modno.png" alt="" width="51" height="51" class="modno png24" />');
    $('.items .recomend').append('<img src="img/recomend.png" alt="" width="51" height="51" class="recomend png24" />');
    $('.items .best').append('<img src="img/best.png" alt="" width="51" height="51" class="best png24" />');

    $("input:submit").addClass("submit");
    $("input:text").addClass("text");
    $("input:file").addClass("file");
    $("input.file").filestyle({image: "img/file.gif", imagewidth: 102, imageheight: 20, width: 200});
    $("select").jdrop();
    
    $('a.go').after(' <span class="go">></span>');

    $(".catPage:nth-child(4n+2)").addClass("no_margin");
    $(".top:nth-child(even)").css({"float":"right"});
});

