﻿//**幻灯片js**//

var timer;
var currentpoint;
currentpoint = 0;
var playId;
centertu = 1;
var MaxPoint = 4;
var imgArr = [];
var isUp=true;


 imgArr[0]=[];
 imgArr[1]=[];
 imgArr[2]=[];
 imgArr[3]=[];
 imgArr[0][0]="http://www.ufida.com.cn/images/pop/20111012.jpg";
 imgArr[1][0]="http://www.ufida.com.cn/images/pop/20111125.jpg";
 imgArr[2][0]="http://www.ufida.com.cn/images/pop/20111219.jpg";
 imgArr[3][0]="http://www.ufida.com.cn/images/pop/20111201.png";
 imgArr[0][1]="/subject/20111011/shanghai";
 imgArr[1][1]="http://www.cellsoft.cc/zhuanti/20111118/";
 imgArr[2][1]="/subject/20111216/";
 imgArr[3][1]="/subject/20111201";

function centertoleft(i) {
    var j;
    j = document.getElementById("centertu");
    centertu = centertu - 1;
    if (centertu == 0) centertu = i;
    j.style.backgroundImage = "url(http://www.ufida.com.cn/images/index/gd_center_tu_" + centertu + ".gif)";
}

function centertoright(i) {
    var j;
    j = document.getElementById("centertu");
    centertu = centertu + 1;
    if (centertu == i + 1) centertu = 1;
    j.style.backgroundImage = "url(http://www.ufida.com.cn/images/index/gd_center_tu_" + centertu + ".gif)";
}

function setTimeer() {
    clearTimer();
    TimerdoClick('tbnav', 'tbsub', MaxPoint, currentpoint);
    //alert(currentpoint);

    timer = setInterval("loadImage(setTimeer)", 5000);
}

function loadImage(callback) {
	
	

if (currentpoint >= MaxPoint) currentpoint = 0;
    callback.call(); //将回调函数的this替换为Image对象

}

function clearTimer() {
    clearInterval(timer);
}



//show
function curShowImg(e){
	 clearTimer();

    var curLeft=-currentpoint *980;
    
    //$(".big_banner_list").animate( { left:curLeft+"px"}, 700 );
     switchBanner(currentpoint);  
     timer = setInterval("loadImage(setTimeer)", 5000);
	
}


function TimerdoClick(navname, subname, idnum, o) {

    if (currentpoint >= MaxPoint) { currentpoint = 0; }
    if (currentpoint < 0) {currentpoint = MaxPoint - 1; }
	
	var curLeft=-currentpoint *980;
    
    switchBanner(currentpoint);
	curBtnDisplay();
	
	currentpoint++;
}


function switchBanner(id){
   playId=id;
   $(".big_banner_list").fadeOut(300,function(){
	   $(".big_banner_list").css("left",(-playId*980)+"px");
	   $(".big_banner_list").fadeIn(500);
   })
}

$(document).ready(function () {
	//最新动态
	myGod('div4',2000);
	//banner显示
    baneermain();
	
	btmNavDsiplay();
	
});

    function baneermain() {
		//底部5个区域的交互
		btmInteractive();
        MaxPoint = imgArr.length;
		
		//加载其他的大图
		bannerdisplay();
		
        loadImage(setTimeer);
		
		
		//按钮交互
		btnclickEvent();
		
		
    }
	
	function btmInteractive(){
	    $(".banner_adv").each(function(i){
			var curLeft=i*(173+18)+5;
			$(this).css("left",curLeft+"px");
			$(this).css("position","absolute");
			$(this).css("top","0px");
		});
		$(".banner_adv").mouseenter(function(){
	
			//$(this).css("display","none");
			
			
			$(this).animate( { top: "-10px"}, 200 );
		})
		
		$(".banner_adv").mouseleave(function(){
	        
			$(this).animate( { top: "0px"}, 200 );
			//$(this).css("display","none");
			//$(this).animate( { top: "10px"}, 50 );
		})
			
	}
	
	
	function btmNavDsiplay(){
		$("#btmNavBtn").click(function(){
			$(".index_bottom_public").slideToggle(500);
			if(isUp){
				$(this).html('<img src="http://www.ufida.com.cn/images/index/ya_btm_arrow.jpg" />');
				isUp=false;
			}else{
				$(this).html('<img src="http://www.ufida.com.cn/images/index/ya_btm_arrow_down.jpg" />');
				isUp=true;
			}
		})

	}
	
	function bannerdisplay(){
		var imghtml=$(".big_banner_list").html();
		for(var i=1;i<MaxPoint;i++){
			imghtml +="<div class='banner_img_box'><a href='"+imgArr[i][1]+"' target='_blank'><img src='"+imgArr[i][0]+"' /></a></div>";
		}
		
		$(".big_banner_list").html(imghtml);
	}
	
	function btnclickEvent(){
	$(".index_banner_btn_bg").click(function(){
		  var id=$(this).attr("rel");
		  
		  var e = document.getElementById('tbsub');
		  currentpoint=id-1;

		  curShowImg(e);

		  curBtnDisplay();
	});
	
	
}

//按钮显示当前的状态；
function curBtnDisplay(){

	 $(".index_banner_btn_bg").each(function(i){
			
			   if(i==currentpoint){
				   if ($.browser.version == "6.0"){
					   $(this).css("background","url(http://www.ufida.com.cn/images/index/banner_img_bg2.png)" );
					   $(this).css("filter","none");
				   }else{
					   

				       if($(this).hasClass("nocur")){
					       $(this).removeClass("nocur");
				       }
				       if(!$(this).hasClass("cur")){
					       $(this).addClass("cur");
				       }
				   
				   }	
					
					
			   }else{
				   
				    if ($.browser.version == "6.0"){
					   $(this).css("background","url(http://www.ufida.com.cn/images/index/banner_img_bg.png)" );
					   $(this).css("filter","alpha(opacity=55)");
				   }else{

				  
				        if($(this).hasClass("cur")){
					        $(this).removeClass("cur");
				       }
				        if(!$(this).hasClass("nocur")){
					       $(this).addClass("nocur");
				       }
				   }

				  
			   }
			   
		 });

}


function menuFix() {
 var sfEls = document.getElementById("index_nav").getElementsByTagName("li");
 for (var i=0; i<sfEls.length; i++) {
  sfEls[i].onmouseover=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onMouseDown=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onMouseUp=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onmouseout=function() {
  this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), 
"");
  }
 }
}
window.onload=menuFix;


//**分公司**//

  function showLink(id){
 
   document.getElementById(id).style.display="block";
   }
    function hiddenLink(id){
   document.getElementById(id).style.display="none";
   }
 function company_show(){
   document.getElementById('all_company_drop_box_id').style.display="block";
   }
   function company_hidden(){
   document.getElementById('all_company_drop_box_id').style.display="none";
   }
   function show_comp_box(num){
   		for(var i=0;i<6;i++){
			document.getElementById('all_company_box'+i).style.display="none";
			document.getElementById('all_company_re_id'+i).className="close";
		}
		document.getElementById('all_company_box'+num).style.display="block";
			document.getElementById('all_company_re_id'+num).className="open";
   }
   
   
   //**行业**//

  function showLink(id){
 
   document.getElementById(id).style.display="block";
   }
    function hiddenLink(id){
   document.getElementById(id).style.display="none";
   }
 function company_showhy(){
   document.getElementById('all_companyhy_drop_box_id').style.display="block";
   }
   function company_hiddenhy(){
   document.getElementById('all_companyhy_drop_box_id').style.display="none";
}
function company_showjtcy() {
    document.getElementById('all_companyjtcy_drop_box_id').style.display = "block";
}
function company_hiddenjtcy() {
    document.getElementById('all_companyjtcy_drop_box_id').style.display = "none";
}
   function showhy_comp_box(num){
   		for(var i=0;i<9;i++){
			document.getElementById('all_companyhy_box'+i).style.display="none";
			document.getElementById('all_companyhy_re_id'+i).className="close";
		}
		document.getElementById('all_companyhy_box'+num).style.display="block";
			document.getElementById('all_companyhy_re_id'+num).className="open";
   }
   
   
   
      
   /*最新动态js*/
   function myGod(id,w,n){
	var box=document.getElementById(id),can=true,w=w||1500,fq=fq||10,n=n==-1?-1:1;
	box.innerHTML+=box.innerHTML;
	box.onmouseover=function(){can=false};
	box.onmouseout=function(){can=true};
	var max=parseInt(box.scrollHeight/2);
	new function (){
		var stop=box.scrollTop%18==0&&!can;
		if(!stop){
			var set=n>0?[max,0]:[0,max];
			box.scrollTop==set[0]?box.scrollTop=set[1]:box.scrollTop+=n;
		};
		setTimeout(arguments.callee,box.scrollTop%18?fq:w);
	};
};

