// common.js

function hideMsg() {
	 setTimeout('$("#MessageArea").hide(500)', 3000);
}

//exScroll
$(document).ready(function () {
                  // $(".nav").superfish({pathClass : 'current',speed:'fast',delay:0});
                   $("ul", $(".nav")).bgIframe({ opacity: false });
                   
                   
                  $(".sortNav p").mouseover(function(){
                            $(this).addClass("sortNavTOn").next("ol").slideDown("slow").siblings("ol").slideUp("slow");              
        $(this).siblings("p").removeClass("sortNavTOn");
                   });
                   
                   $("#indTabM0 li").hover(function(){
                            $(this).addClass("indTabMOn1");},
                            function(){
                                     var c=$(this).attr('class');
                                     if(c=='indTabMOn1'){
                                     $(this).removeClass("indTabMOn1");
                                     }
                   });
                   $("#skuM li").hover(function(){
                            $(this).addClass("proCur1");},
                            function(){
                                     var c=$(this).attr('class');
                                     if(c=='proCur1'){
                                     $(this).removeClass("proCur1");
                                     }
                   });
                                     
                   
                   $("dl.proExp:last,#cartHavePro ul.lineDotH3:last,ul.expSecBrand li:last").css("background","none");
         
                   
                   $(".skuTopLogo img").each(function(i){
                            var WskuLogo=260;
                            if($(this).attr("width")*1>WskuLogo) {
                                     $(this).width(WskuLogo);
                                     }                                                                   
                   });
                   $(".brandInfoL img").each(function(i){
                            var WbrandInfoL=246;
                            if($(this).attr("width")*1>WbrandInfoL) {
                                     $(this).width(WbrandInfoL);
                                     }                                                                   
                   });
                   $(".proInfoTopL img").each(function(i){
                            var WbrandInfoL=250;
                            if($(this).attr("width")*1>WbrandInfoL) {
                                     $(this).width(WbrandInfoL);
                                     }                                                                   
                   });     
                   
});

(function($) {
         $.fn.marquee = function(o) {
                   o = $.extend({
                            speed:               parseInt($(this).attr('speed')) || 30, 
                            step:                  parseInt($(this).attr('step')) || 1,
                            direction: $(this).attr('direction') || 'up', 
                            pause:               parseInt($(this).attr('pause')) || 1000 
                   }, o || {});
                   var dIndex = jQuery.inArray(o.direction, ['down']);
                   if (dIndex > -1) {
                            o.direction = ['up'][dIndex];
                            o.step = -o.step;
                   }
                   var mid;
                   var div                = $(this);
                   var divHeight   = div.innerHeight();
                   var ul                           = $("ul", div);
                   var li                            = $("li", ul);
                   var liSize            = li.size();
                   var liHeight      = li.height();
                   var height                  = liHeight * liSize;
                   if (o.direction == 'up' && height > divHeight){
                                     ul.height(2 * liSize * liHeight);
                                     if (o.step < 0) div.scrollTop(height);
                            }
                            ul.append(li.clone()); 
                            mid = setInterval(_marquee, o.speed);
                            div.hover(
                                     function(){clearInterval(mid);},
                                     function(){mid = setInterval(_marquee, o.speed);}
                            );
                   function _marquee() {
                                     var t = div.scrollTop();
                                     if (o.step < 0) {
                                               div.scrollTop((t <= 0 ? height : t) + o.step);
                                     } else {
                                               div.scrollTop((t >= height ? 0 : t) + o.step);
                                     }
                                     if (t % liHeight == 0) _pause();
                            }
                   function _pause() {
                            if (o.pause > 0) {
                                     var tempStep = o.step;
                                     o.step = 0;
                                     setTimeout(function() {
                                               o.step = tempStep;
                                     }, o.pause);
                            }
                   }
         };
})(jQuery);
$(document).ready(function(){  
$("#exScroll").marquee({  
         direction: "down",  
         step: 1, 
         speed:1, 
         pause: 1000
         });  
});

