$(document).ready(function(){    
  
  
  
  $('.big_pic a').hide();
  $('.big_pic a:first-child').show();
  
  $('.small_pic a').click(function(){    
    $('.big_pic a').hide();
    
    $( $('.big_pic a').get( $(this).index() )).show();
    return false;
  })
  
  $(".ScrCont").css({
    width: 300*$('.lists').length+1    
  });
  
  var img1_click = function(){      
    if( Math.abs(parseInt($(".ScrCont").css('left'))-294) >  (294*$('.lists').length-1) ){
      
    }else{
      $(".img1").unbind();
      var ileft = parseInt($(".ScrCont").css('left')) - 294 ;        
      $(".ScrCont").stop(true,false).animate( { left: ileft }, 1000, function(){
        $('.img1').bind('click',img1_click);
      } )  
    }
  }
  $('.img1').bind('click',img1_click);
  
  var img2_click = function(){    
    if( parseInt($(".ScrCont").css('left')) != 0 ){
      $(".img2").unbind();
      var ileft = parseInt($(".ScrCont").css('left')) + 294 ;
      $(".ScrCont").stop(true,false).animate( { left: ileft }, 1000 ,function(){
        $('.img2').bind('click',img2_click);
      })
    }
    
  };
  $('.img2').bind('click',img2_click);
  /*
  var x = $('.img1').click(function(){      
    if( Math.abs(parseInt($(".ScrCont").css('left'))-294) >  (294*$('.lists').length-1) ){
      
    }else{
      $(".img1").unbind();
      var ileft = parseInt($(".ScrCont").css('left')) - 294 ;        
      $(".ScrCont").stop(true,false).animate( { left: ileft }, 1000, function(){
        $('.img1').bind('click',x);
        
      } )  
    }
  });
  */
  /*
  $('.img2').click(function(){    
    if( parseInt($(".ScrCont").css('left')) != 0 ){
      var ileft = parseInt($(".ScrCont").css('left')) + 294 ;
      $(".ScrCont").stop(true,false).animate( { left: ileft }, 1000 )
    }
    
  });
  */
  
  $('#nav .nav li').hover(function(){
    $('.sub_nav').hide();    
    $('#'+$(this).attr('data')).css({      
      }).show();    
  },function(){
    
  });
  
  
  function AddFavorite(sURL, sTitle){
    try{
      window.external.addFavorite(sURL, sTitle);
    }catch (e){
      try{
        window.sidebar.addPanel(sTitle, sURL, "");
      }catch (e){
        alert("加入收藏失败，请使用Ctrl+D进行添加");
      }
    }
  }  
  function SetHome(obj,vrl){
    try{                            
      document.body.style.behavior='url(#default#homepage)';
      document.body.setHomePage(vrl); 
    }catch(e){
      if(window.netscape) {
        try {
          netscape.security.PRivilegeManager.enablePrivilege("UniversalXPConnect");
        }catch (e) {
          alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 [signed.applets.codebase_principal_support]设置为'true'");
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage',vrl);
      }
    }
    return false;
  }

  
  $('#set_home').click(function(){
    SetHome(window,window.location.href);
    return false;
  });
  
  $('#add_fav').click(function(){    
    AddFavorite(window.location.href,document.title);
    return false;
    
  });
  //$("#accordionGiftLelo").msAccordion();
  
  $('.notice>ul li:last-child').css({
    'border-bottom': 'none'
  });
  
  $("#nav .nav a ").mouseover(function(){        
    $('.sub_nav_ul').hide();
    if( $(this).attr('data') ) {     
      $('#'+$(this).attr('data')).show();  
    }    
  });
 
 
});

