//2011-3-11

function click() {
  if (event.button==2) {alert('右键被禁用!')}
}
document.onmousedown=click;
document.onselectstart= function(){return false}
document.oncopy= function(){return false}
document.oncut=function(){return false}

function Tabs(id){
    $('#'+id+' .'+id+'-box').each(function(i){
        $(this).attr('id',id+'-box-'+i);
        if (i==0){ $(this).fadeIn('slow')}
    });
    $('#'+id+" .tabs li").each(function(i){
        $(this).attr('id',id+'_li_'+i);
        if (i==0){ $(this).addClass('current')}
        $(this).click(function(){
          $('#'+id+' .tabs li').removeClass('current');
          $(this).addClass('current');
          $('#'+id+' .'+id+'-box').hide();
          $('#'+id+'-box-'+i).show();
        })
    })
};


function setStyle(){
  var MaxW = $('body').outerWidth();
  if(MaxW>1240){
    switchStylestyle('styles2');
  }else{
    switchStylestyle('styles1');
  }
}

function switchStylestyle(t){
  $('link[rel*=style][title]').each(function (i){
    this.disabled = true;
    if( $(this).attr('title') == t) this.disabled = false;
  });
}

$(function(){
  setStyle();
  window.onresize = function(){
    setStyle();
    try{setSwf();}catch(e){}}
  //去除链接虚线
  $('a,li').bind('focus',function(){
    if(this.blur){ this.blur() };
  });

/*
  //头部延长背景
  $('#header').wrap('<table width="100%" border="0" cellpadding="0" cellspacing="0" class="table"><tr id="hd_wrap"><td class="hd_c"></td></tr></table>');
  $('#hd_wrap').prepend('<td class="hd_l">&nbsp;</td>');
  $('#hd_wrap').append('<td class="hd_r">&nbsp;</td>');
*/
  //底部延长背景
  $('#footer').wrap('<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="table"><tr id="ft_wrap"><td class="ft_c"></td></tr></table>');
  $('#ft_wrap').prepend('<td class="ft_l">&nbsp;</td>');
  $('#ft_wrap').append('<td class="ft_r">&nbsp;</td>');

/*
  $("#nav>li").mousemove(function(){
      if($(this).attr('class')!='nav_li_7'){
        $("#nav>li>ul").hide();
        $("#nav>li>a").removeClass("over");
        $(this).find("ul").show();
        $(this).find("a").eq(0).addClass("over");
      }
  });

  $("#nav>li").mouseout(function(){
    if($(this).attr('class')!='nav_li_7'){
      $("#nav>li>ul").hide();
      $("#nav>li>a").removeClass("over");
    }
  })
*/

  $("#nav>li").hover(function(){
      if($(this).attr('class')!='nav_li_7'){
        $("#nav>li>ul").hide();
        $("#nav>li>a").removeClass("over");
        $(this).find("ul").show();
        $(this).find("a").eq(0).addClass("over");
      }
  },function(){
    if($(this).attr('class')!='nav_li_7'){
      $("#nav>li>ul").hide();
      $("#nav>li>a").removeClass("over");
    }
  });

  $("#nav .nav_li_7 a").eq(0).click(function(){
    $("#nav>li>ul").hide();
    $("#nav>li>a").removeClass("over");
    $(this).next("ul").show();
    $(this).addClass("over");
  })

  $("#cVideo").click(function(){
    $("#nav>li>a").removeClass("over");
    $('#nav_li_7_ul').hide();
  })


});


function $Dhide(id){
  $(id+'>li').hover(
    function(){
      $(this).find('span').animate({
        width:'toggle', opacity: 'toggle'
      }, "slow");
    },
    function(){
      $(this).find('span').show();
    }
  )
}

function $setHeight(){
  if($("#setLeft")[0] && $('#setRight')[0]){
    $('#setLeft,#setRight').attr('style',' ');
    var maxH=Math.max($('#setLeft').height(),$('#setRight').height());
    $('#setLeft').height(maxH);
    $('#setRight').height(maxH);
  }
}


function onKey(t,txt,s){
  if(s==1){
    t.value = t.value == '' ? txt : t.value;
  }else{
    t.value = t.value == txt ?'':t.value;
  }
}

//向上
function DoTop(a){
  var sTop = $(a).scrollTop() -120;
  if (sTop<0) sTop=0
  //alert(sTop);
  $(a).animate({scrollTop: sTop+'px'}, 300);
}
//向下
function DoBottom(a,b){
  var sBottom = $(a).scrollTop() +120;
  var maxHeight = $(b).height();
  if (sBottom>maxHeight) sBottom = maxHeight;
  $(a).animate({scrollTop: sBottom+'px'}, 300);
}



//公司简介滚动

var left;
$().ready(function(){
    left = parseInt($("#list").css("left"));
    $(".btn").click(function(){
        move(this.id);
    });

});
function move(sign)
{
    var tleft = left;
    switch(sign)
    {
        case "right":
        {
            var len = $("#list > li").length * 60;

            if((len - Math.abs(left)) > 900)
            {
                tleft -= 120;
            }
            else
            {
                tleft = left;
            }
            break;
        }
        case "left":
        {
            if (left == 0)
            {
                tleft = 0;
            }
            else
            {
                tleft += 120;
            }
            break;
        }
    }

    if ((tleft - left) != 0)
    {
        $("#list").animate({
            left:tleft + "px"
        },200,function(){
            left = tleft;

        });
    }

}


$(function(){
      var $div_li =$("#list li");
      $div_li.click(function(){
      $(this).addClass("hot")
           .siblings().removeClass("hot");
            var index =  $div_li.index(this);
      $("#roll_content  ul")
          .eq(index).show()
          .siblings().hide();
    })
  })


function autoImgSize(obj, MAX_WIDTH, MAX_HEIGHT, IMG_MARGIN){
  var dImg = new Image();
  dImg.src = obj.src;
  dImg.onload = function (){
    var w = dImg.width;
    var h = dImg.height;
    //对比图片宽高是否超出
    if(w > MAX_WIDTH || h > MAX_HEIGHT){
      if(w > MAX_WIDTH){
        //对比图片宽
        obj.style.width = MAX_WIDTH + 'px';
        obj.style.height = dImg.height * MAX_WIDTH / dImg.width + 'px';
        var h2 = parseInt(obj.style.height);
        //设置完宽,高超出时
        if(h2 > MAX_HEIGHT){
          obj.style.height = MAX_HEIGHT + 'px';
          obj.style.width = parseInt(obj.style.width) * MAX_HEIGHT / h2 + 'px';
        }
      }else{
        //对比图片高
        obj.style.height = MAX_HEIGHT + 'px';
        obj.style.width = dImg.width * MAX_HEIGHT / dImg.height + 'px';
        //设置完高,宽超出时
        var w2 = parseInt(obj.style.width);
        if(w2 > MAX_WIDTH){
          obj.style.width = MAX_WIDTH + 'px';
          obj.style.height = parseInt(obj.style.height) * MAX_WIDTH / w2 + 'px';
        }
      }
    }
    //设置外边距
    //obj.style.marginLeft = IMG_MARGIN + (MAX_WIDTH - obj.width) / 2 + 'px';
    //obj.style.marginTop = IMG_MARGIN + (MAX_HEIGHT - obj.height) / 2 + 'px';
  }
  dImg.src = obj.src;
}
