// JavaScript Document
//---------------------------------
/**title效果**/
var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	var w='';
	return{
		show:function(v,vv){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = vv+'<br>&nbsp;&nbsp;&nbsp;&nbsp;'+v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();
//------测试切换
finfinDivFlag=1;//初始化赋值
finfinDivNum=0;//替换层数
frameHeight=50;//层高度
speed=3;//移动速度
contralFlag=1;//运行标记，当Flag=1运行，否则停止
runTime=10000;//运行时间
function finfin_move(n,dayword){
	//先加入预载入
	dayword_array = dayword.split("-");
	dayword_array = ran_Arr(dayword_array);
	for(i=1;i<=20;i++){
		document.getElementById('finfinDiv'+i).innerHTML=dayword_array[i-1];
	}
	finfin_move2(n);
}
function finfin_move2(n){
	finfinDivNum=n;
	if(contralFlag==1)
	{
		scrollup(finfinDivFlag);
		if(finfinDivFlag==finfinDivNum){
			finfinDivFlag=1;
		}else{
			finfinDivFlag++;
		}
	}
	setTimeout("finfin_move2("+n+")",runTime);
}
function scrollup(f){
	mainobj=document.getElementById("main");
	if(mainobj.scrollTop>=frameHeight*(f-1)){
		mainobj.scrollTop=frameHeight*(f-1);
		return;
		}
	else{
		mainobj.scrollTop+=speed;
		setTimeout("scrollup("+f+")",5);
		}
}
function stopFinfin(){
	contralFlag=0;
}
function startFinfin(){
	contralFlag=1;
}
//------测试btn切换
function finfin_chg(i,j){
	if(i==1)$("#finfin_btn"+j).css("background","#F2FCF0");
	if(i==2)$("#finfin_btn"+j).css("background","#FFFFFF");
}	
//------
function chg_menu_bg(i,obj){
	if(i==1){
		obj.style.background='url(/skin/img/index_top_bg2.gif)';
		obj.style.color='#FFFFFF';
	}else{
		obj.style.background='url(/skin/img/index_top_bg.gif)';
		obj.style.color='#F3962F';
	}
}
//-----index
function indexCcontentChg(i,obj){
	if(i==1){
		obj.className="index_left_link_td1";
	}else{
		obj.className="index_left_link_td";
	}
}
function indexRevlue(){
	if($("#searchTitle").val()==''){
		$("#searchTitle").val("请输入查询关键字");	
	}
}
//********oneClass
function oneClass_chgbg(i,obj){
	if(i==1){
		obj.className="oneClassContent1";
	}else{
		obj.className="oneClassContent";
	}	
}
function oneClass_chgbg2(i,obj){
	if(i==1){
		obj.className="oneClassContent3";
	}else{
		obj.className="oneClassContent2";
	}	
}
//********twoClass
function twoClass_chgbg(i,j,obj){
	if(i==1){
		obj.className="twoClassContent_to";
	}else{
		if(j==2){
			obj.className="twoClassContent2";
		}else{
			obj.className="twoClassContent1";
		}
	}	
}
function tool_chgbg(i,obj){
	if(i==1){
		obj.className="toolContent1";
	}else{
		obj.className="tool_content_td2";
	}	
}
function top_chg(i,j,obj){
	if(j==1){
		obj.style.background="url(/skin/img/index_top_menu"+i+i+".jpg)";
		obj.style.color="#FFFFFF";
	}else{
		obj.style.background="url(/skin/img/index_top_menu"+i+".gif)";
		obj.style.color="#FF8F20";
	}
}

//------AJAX
$(document).ready(function(){
	 $("#province").change(function(){
	 //先清掉option
	var opts = document.getElementById("city");   
		for(var i=opts.length-1;i>0;i--){    
			opts.options[i]=null;        
		}  
	//AJAX
     var n = $("#province").attr("value");
	 if(n!=0){
		$.ajax({
			   url:"/ajax/ajax.php",
				type:"POST",
				data:"action=proChg&provinceid="+n+"&rd="+Math.random(),	
				dataType:"html",
				success:function(msg){
						if(msg!=""){	  
						arr = msg.split("|");
						for(n=0;n<arr.length-1;n++){
							arr2 = arr[n].split('-');
							var loption=document.createElement("OPTION");
							loption.text=arr2[1];
							loption.value=arr2[0];
							document.getElementById("city").options.add(loption);
						}
						}
					}
			   });
	 }
	 });
});
function  vchg(i,obj){
	if(i==1){
		obj.style.color="#35A438";
	}else{
		obj.style.color="#999";
	}
}
function navchk(){
	if(document.getElementById('title').value==''){
		alert('站点名不能为空!');
		return false;
	}
	if(document.getElementById('linkurl').value==''){
		alert('网址不能为空!');
		return false;
	}
}
//-----JS随机Function
function ran_Arr(oArr) {
    var temp_x; //临时交换数
    var tArr = oArr.slice(0);//新数组,复制原数组
    var random_x;
    for(var i=oArr.length;i>0;i--) {
        random_x = Math.floor(Math.random()*i); //   取得一个随机数
        temp_x = tArr[random_x];
        tArr[random_x] = tArr[i-1];
        tArr[i-1] = temp_x;
    }
    return tArr; //返回新数组
}
