var Browser={
	ie:document.all
}

function $(id){
	var obj=document.getElementById(id);
	if (!obj){
		obj=document.getElementsByName(id)[0];
	}
	return obj;
}


xmlHttpGet = function(url){
	if (url==null || url=="")
	{
		return "错误的URL";
	}
	var xmlHttp;
	if(window.ActiveXObject){
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		xmlHttp=new XMLHttpRequest();
	}
	var asynchronous=false;
	var post=false;
	
	if (post){
		alert("error!This method only support GET method.");
	}
	xmlHttp.open("GET",url,asynchronous);
	xmlHttp.send(null);
	var rtn=xmlHttp.responseText;
	xmlHttp=null;
	return rtn;
}

function getYZM(){
	var y = "";
	y = xmlHttpGet("getYZM.asp?rdn="+Math.random());
	document.getElementById("yzm").innerHTML = y;
}

function initHymake(){
	if (Browser.ie){
		return;
	}
	var w = document.body.clientWidth;
	var head = $("head");
	var banner = $("banner");
	var menu = $("menu")
	var foot = $("foot")
	var mainBody = $("mainBody")

	var lh = (w-head.offsetWidth)/2;
	var lb = (w-banner.offsetWidth)/2;
	var lm = (w-menu.offsetWidth)/2;
	var lf = (w-foot.offsetWidth)/2;
	var l = (w-mainBody.offsetWidth)/2;
	
	head.style.marginLeft = lh+"px";
	banner.style.marginLeft = lb+"px";
	menu.style.marginLeft = lm+"px";
	foot.style.marginLeft = lf+"px";
	mainBody.style.marginLeft = l+"px";

}

function lightLi(obj){
	if (obj.className!=""){
		return;
	}
	obj.style.color="#0066cc";
}

function resumeLi(obj){
	if (obj.className!=""){
		return;
	}
	obj.style.color='';
}



function showSoftList(j){
	lis = $("softlist").getElementsByTagName("LI");
	for (var i=0;i<lis.length;i++){
		lis[i].className="";
		lis[i].style.color="";
	}
	lis[j].className="softover";
	data = lis[j].getAttribute("data");
	if (data){
		var str=[];
		str.push("getHomeSoftlist.asp?bc="+data+"&rdn="+Math.random());
	}else{
		var t = lis[j].getAttribute("type");
		var str=[];
		if (t=="case"){
			//str.push("getCase.asp?rdn="+Math.random());
			str.push("getHomeSoftlist.asp?bc=5,6&rdn="+Math.random());
		}else{
			str.push("getHomeSoftlist.asp?rdn="+Math.random());
		}
	}
	var softlist=xmlHttpGet(str.join(""));
	$("softdetal").getElementsByTagName("div")[0].innerHTML = softlist;
	initSoftScroll();

}

function initSoftScroll(){
	var sh = $("softdetal").getElementsByTagName("div")[0].scrollHeight;
	var fh = $("softdetal").offsetHeight;
	var ball = $("scrollball");
	ball.style.top="17px";
	$("softdetal").getElementsByTagName("div")[0].scrollTop=0;
	if(sh<fh){
		ball.style.display="none";	
		return;
	}else{
		ball.style.display="block";	
	}
}

function moveBall(){
	var ball = $("scrollball");
	var ds = $("softdetal").getElementsByTagName("div")[0].scrollTop;
	var sh = $("softdetal").getElementsByTagName("div")[0].scrollHeight;
	var fh = $("softdetal").offsetHeight;
	var x = sh - fh;
	if (x<=0){
		return;
	}
	var top=(ds/x)*148;
	ball.style.top = (top+17)+"px";
}

function scrollDown(evt){
	var dt = $("softdetal").getElementsByTagName("div")[0];
	var acc = .5;
	var speed = 10;
	if (!tmp){
		var tmp = setInterval(function(){
			speed -= acc;
			if (speed<=0){
				clearInterval(tmp);
			}
			dt.scrollTop += speed;
			moveBall();
		},50)
	}
}

function scrollUp(evt){
	var dt = $("softdetal").getElementsByTagName("div")[0];
	var acc = .5;
	var speed = 10;
	if (!tmp){
		var tmp = setInterval(function(){
			speed -= acc;
			if (speed<=0){
				clearInterval(tmp);
			}
			dt.scrollTop -= speed;
			moveBall();

		},50)
	}
}


function scrollToLeft(evt){
	var dt = $("slist");
	var acc = .5;
	var speed = 20;
	if (!tmp){
		var tmp = setInterval(function(){
			speed -= acc;
			if (speed<=0){
				clearInterval(tmp);
			}
			dt.scrollLeft -= speed;

		},50)
	}
}

function scrollRight(evt){
	var dt = $("slist");
	var acc = .5;
	var speed = 20;
	if (!tmp){
		var tmp = setInterval(function(){
			speed -= acc;
			if (speed<=0){
				clearInterval(tmp);
			}
			dt.scrollLeft += speed;

		},50)
	}
}



function callAssistant(fst){
	var ass = $("assdialog");
	ass.style.display="block";
	var pop = xmlHttpGet("getPopConfig.asp?rdn="+Math.random());
	var w = pop.split("|")[1];
	if (fst){
		$("assmsg").innerHTML = "您好！这是您第一次访问本站，请问您需要什么帮助？";
		$("assistant").style.height="150px";
		ass.style.top="-40px";
	}else{
		$("assmsg").innerHTML = "您好！请问您需要什么帮助？";
		$("assistant").style.height="140px";
		ass.style.top="-30px";
	}
	if (w=="W"){
		document.getElementsByName("poptype")[0].checked=true;
	}else{
		document.getElementsByName("poptype")[1].checked=true;
	}
}

function firstComing(){
	var pop = xmlHttpGet("getPopConfig.asp?rdn="+Math.random());
	var fst = pop.split("|")[0];
	if (fst=="1"){
		callAssistant(true);
	};
}



function savePopConfig(v){
	d=xmlHttpGet('savePopConfig.asp?v='+v+'&rdn='+Math.random());
	if (d!="true"){
		alert("通信失败，请您重试");
		return false;
	}
	return true;
}

function closeAss(){
	$("assdialog").style.display="none";
}

function goHeadNewsSch(evt){
	if (evt.keyCode!=13){
		return;
	}
	v = $("headkey").value;
	schNews(v);
}


function goNewsSch(evt){
	if (evt.keyCode!=13){
		return;
	}
	v = $("key").value;
	schNews(v);
}


function schNews(v){
	if (v==""){
		alert("请输入关键字!");
		return;
	}
	var bc = $("bc");
	var sc = $("sc");
	var url = "newsSch.asp?key="+v;
	if (bc){
		url += "&bc="+bc.getAttribute("data");
	}
	if (sc){
		url += "&sc="+sc.getAttribute("data");
	}
	window.location=url;
}


function viewNews(id){
	if (id==""){
		return;
	}
	
}

function viewNewsDetail(id){
	if (id==""){
		return;
	}
	var w = 610;
	var h = 600;
	w = Math.max(610,w);
	var pt = xmlHttpGet("getPopConfig.asp?rdn="+Math.random());
	pt = pt.split("|")[1];
	if (pt=="D"){
		setTimeout(function(){
		Dialog.width=w+120;
		Dialog.height=h-50;
		var str = xmlHttpGet("newsDetail.asp?id="+id+"&rdn="+Math.random());
		Dialog.msg("详细信息",str);
		fillNewsFoot();},10);
	}else{
		var l = (window.screen.width - w -10) / 2;
		var t = (window.screen.height - h) /2;
		window.open("newsDetail.asp?id="+id,"","left="+l+",top="+t+",width="+w+",height="+h+",toolbar=no,menubar=no,scrollbars=yes,resizeable=yes");
	}
}



function fillNewsFoot(){
	if (!document.getElementById("footmsg") || !document.getElementById("foottb")){
		return;
	}
	setTimeout(function(){document.getElementById("footmsg").style.width=Math.max((document.getElementById("foottb").offsetWidth-15),0)+"px";},10);
}

function printNewsDetail(){
	var div = document.getElementById("newsDetailMain");
	if (!div){
		return;
	}
	if(window.opener){
		window.print();
		return;
	};
	var code = div.innerHTML;
	var oldcode = document.body.innerHTML;
	document.body.innerHTML = code;
	window.print();
	document.body.innerHTML = oldcode;
}

function saveNewsDetail(ttl){
	var div = document.getElementById("newsDetailMain");
	if (!div){
		return;
	};
	if(!document.all){
		return;
	}
	if(window.opener){
		document.getElementById("WebBrowser").ExecWB(4,1);
		return;
	};

	var code = "<html><body style='margin:0px;'>"+div.innerHTML+"</body></html>";
	var nw = window.open('','','left=5000,top=5000');
	nw.document.write(code);
	nw.document.execCommand('SaveAs',false,ttl+'.htm');
	nw.close();
}



function viewFAQ(id){
	if (id==""){
		return;
	}
	var w = 475;
	var h = 500;
	Dialog.width=w;
	Dialog.height=h;
	var str = xmlHttpGet("show_faq.asp?id="+id+"&rdn="+Math.random());
	Dialog.msg("FAQ",str);
}

function viewJLZX(id){
	if (id==""){
		return;
	}
	var w = 475;
	var h = 500;
	Dialog.width=w;
	Dialog.height=h;
	var str = xmlHttpGet("show_jlzx.asp?id="+id+"&rdn="+Math.random());
	Dialog.msg("咨询查看",str);
}


function viewLiuyan(id){
	if (id==""){
		return;
	}
	var w = 515;
	var h = 510;
	Dialog.width=w;
	Dialog.height=h;
	var str = xmlHttpGet("liuyan_view.asp?id="+id+"&rdn="+Math.random());
	Dialog.msg("业务咨询查询",str);
}



function viewJobDetail(id){
	if (id==""){
		return;
	}
	window.location="jobDetail.asp?id="+id;
}