	function ellipsis(str,len){
		if ((!len)||str.length<=len){
			return str;
		}else{
			return str.substring(0,len)+"..."; 	
		}	
	}
	function topTab(cls,fix){
		if(document.getElementById(cls)){
		  document.getElementById(cls).className = "main_tab_on";
		}
		if(fix){//修复阴影效果
		$("#"+cls).append("<div id='top_tab_bug'></div>");
			//var o=$("#"+cls);
			//var pos = o.offset()
			//var _left=pos.left+'px';
			//var _top=pos.top+o.height()+'px'; 
			//$('#top_tab_bug').css("top",o.height()+'px')
			$('#top_tab_bug').show()
		}

	}
	///speed
	var autourl = new Array(["www1.swufe-online.com", "www2.swufe-online.com", "www3.swufe-online.com","10.10.3.3"], [ "中国电信", "中国移动", "教 育 网","内部网络"]);
	var tim = 1;//十分之一秒
	var url = location.href;
	var did=false;
	function speed(){
	for (var i = 0; i < autourl[0].length; i++) {
		if(url.indexOf(autourl[0][i]) >= 0){
			$("#myline").html("<b class='bg_i'>&nbsp;&nbsp;</b>当前线路：<font class=green>"+autourl[1][i]+"</font> <a href='javascript:changeLine("+i+")'class='bg_i'>测速切换</a>");
		}
	}
	}
	function auto(i,b){
		var ss='un';
		// 1 tim = 0.1 秒  tim=10时,为1ms  500k的文件/ 100k/s =5 s 为快
		if (tim < 50&&b) {
		
			ss = "<font style='color:green' unselectable=on>快（" + tim * 100 + "）</font>"
		}
		if (tim >= 50&&tim<150&&b) {
			ss = "<font style='color:#f99c00' unselectable=on>较快（" + tim * 100 + "）</font>"
		}
		if (tim >= 150&&b) {
			ss = "<font style='color:red' unselectable=on>慢（" + tim * 100 + "）</font>"
		}
		if(!b){
			ss = "<font style='color:red' unselectable=on>线路不可用</font>"
		}
		if (tim > 2000) {
			ss = "<font style='color:red' unselectable=on>超时</font>"
		}//200秒
		document.getElementById("r_" + i).innerHTML = ss;
	}
	function changeLine(n){
		if (!did) {
			$("#myline").append("<ul id='speed_ct' tabindex='1'></ul><span class='none' id='speedimg'></span>");//加tabindex触发焦点事件，子容器unselectable=on屏蔽焦点
				$("#speed_ct").blur(function(){ 
			 		$('#speed_ct').hide("200")
		})
		}
		tim = 1,html="";//复位
		setInterval("tim++", 100)
		document.getElementById("speedimg").innerHTML = '';//复位
		for (var i = 0; i < autourl[0].length; i++) {
			if(!did)$("#speed_ct").append("<li class='spd_li'><a unselectable=on  class='left block' href='"+url.replace(autourl[0][n],autourl[0][i])+"'>"+autourl[1][i]+"</a> <span id='r_"+i+"' class='left block'><img src='/v2010/loading.gif'/ align='absmiddle'></span></li>");
			//html+="<li class='spd_li'><a unselectable=on  class='left block' href='"+url.replace(autourl[0][n],autourl[0][i])+"'>"+autourl[1][i]+"</a> <span id='r_"+i+"' class='left block'><img src='/v2010/loading.gif'/ align='absmiddle'></span></li>";
			document.getElementById("speedimg").innerHTML += ("<img src=http://" + autourl[0][i] + "/speedTest500K.jpg?" + Math.random() + " width=1 height=1 onLoad=auto(" + i +",true) onerror=auto(" + i + ",false)> ")
			if (i == autourl[0].length - 1) {
				did = true;
				//document.getElementById("speed_ct").innerHTML = html;
				$('#speed_ct').show("200"); 
				//$('#speed_ct').slideDown("200"); 
				$('#speed_ct').focus()
			}
		}
		
	}

	function hideAlert(){
	   $('#login_alert').hide("slow"); 	
	}
	//-------------------
	var set,srh,getcode;
	var StringMsg=[];
	StringMsg.keyword="请输入关键字或者快速服务代码检索";
	$(document).ready(function(){
		$("#keyword").val(StringMsg['keyword']);
		$("#keyword").focus(function(){
			hideAlert();
			this.value='';
			this.style.backgroundColor = '#FFC';
			this.style.color = '';
		})
		$("#keyword").blur(function(){
			if (this.value == '') {
				this.style.backgroundColor = '#FFF';
				this.style.color = '#AAAAAA';
				this.value=StringMsg[this.id]
			}
		})
		srh=function(){
			var key=$("#keyword").val()
			if (key.length<1||key==StringMsg['keyword']){
				alert(StringMsg['keyword']);
				$("#keyword").focus();
				return;	
			}//提取新闻
			if(!isNaN(key)){
				window.open("/v2010/read.jsp?id="+key,"_blank");
				return;
			}//搜索新闻
			form1.action="/v2010/search.jsp";
			form1.submit();

		}
		getcode=function(){
			var scode=$("#scode").val()
			if (scode.length<1||scode==StringMsg['scode']){
				alert(StringMsg['scode']);
				$("#scode").focus();
				return;	
			}
			alert("代码："+scode)
		}	
		//--end
	})

