﻿//ajax include
var rootdomain="http://"+window.location.hostname; function ajaxinclude(url){ var page_request = false; if (window.XMLHttpRequest) page_request = new XMLHttpRequest(); else if (window.ActiveXObject){try{page_request = new ActiveXObject("Msxml2.XMLHTTP")}catch (e){try{page_request = new ActiveXObject("Microsoft.XMLHTTP")}catch (e){}}} else return false;page_request.open('GET', url, false);page_request.send(null);writecontent(page_request);} function writecontent(page_request){if (window.location.href.indexOf("http")==-1 || page_request.status==200) document.write(page_request.responseText)}

//show aux
function at_show_aux(parent, child){var p = document.getElementById(parent);var c = document.getElementById(child );var top = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;for(; p; p = p.offsetParent){top += p.offsetTop;left += p.offsetLeft;}c.style.position = "absolute";c.style.top = top +'px';c.style.left = left+'px';c.style.visibility = "visible";} function at_show(){var p = document.getElementById(this["at_parent"]);var c = document.getElementById(this["at_child" ]);at_show_aux(p.id, c.id);clearTimeout(c["at_timeout"]);} function at_hide(){var p = document.getElementById(this["at_parent"]);var c = document.getElementById(this["at_child" ]);c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);} function at_click() { var p = document.getElementById(this["at_parent"]); var c = document.getElementById(this["at_child" ]); if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden"; return false;} function at_attach(parent, child, showtype, position, cursor) { var p = document.getElementById(parent); var c = document.getElementById(child); p["at_parent"] = p.id; c["at_parent"] = p.id; p["at_child"] = c.id; c["at_child"] = c.id; p["at_position"] = position; c["at_position"] = position; c.style.position = "absolute"; c.style.visibility = "hidden"; if (cursor != undefined) p.style.cursor = cursor; switch (showtype) { case "click": p.onclick = at_click; p.onmouseout = at_hide; c.onmouseover = at_show; c.onmouseout = at_hide; break; case "hover": p.onmouseover = at_show; p.onmouseout = at_hide; c.onmouseover = at_show; c.onmouseout = at_hide; break;}}

//search
function googlesearch(){
	var wq=document.getElementsByName("srchtxt")[0].value;
	var glink="http://www.google.com/search?q="+wq;window.open(glink);}
function baidusearch(){
	var wd=document.getElementsByName("srchtxt")[0].value;
	var clink="http://www.baidu.com/s?ie=UTF-8&word="+wd;window.open(clink);}
function hailiangsearch(){
	if (document.getElementById("srchtxt").value == "" ) {alert ( "关键词不能为空！" );}
	else {
		var clink="http://search.kunming.cn/search.jsp?searchText="+document.getElementsByName("srchtxt")[0].value;
		window.open(clink);}
	}


//select link
function linkin(str){if(str!="#"){window.open(str);}}

//slide line
function scrollUlByControl(ul){try{slideLine(ul,4000,20,26);}catch(e){}}function slideLine(ul,delay,speed,lh){var slideBox=(typeof ul == "string")?document.getElementById(ul):ul;var delay=delay,speed=speed,lh=lh;var tid=null,pause=false;var start=function(){tid=setInterval(slide,speed);};var slide=function(){if (pause) return;var i;slideBox.scrollTop+=1;if (slideBox.scrollTop%lh==0){clearInterval(tid);for (i=0;i<1;i++){slideBox.appendChild(slideBox.getElementsByTagName("li")[0]);}setTimeout(start,delay);slideBox.scrollTop=0;}};slideBox.onmouseover=function(){pause=true;};slideBox.onmouseout=function(){pause=false;};setTimeout(start, delay);}

//show focus
//function showFocus(num){for(var id = 1;id<=3;id++){var fpid="focusPic"+id;var fcid="focusContent"+id;var fnid="focusnav"+id;if(id==num){try{document.getElementById(fpid).style.display="block"}catch(e){};try{document.getElementById(fcid).style.display="block"}catch(e){};try{document.getElementById(fnid).className="active"}catch(e){};}else{try{document.getElementById(fpid).style.display="none"}catch(e){};try{document.getElementById(fcid).style.display="none"}catch(e){};try{document.getElementById(fnid).className="normal"}catch(e){};}}}

//tabs
function ddtabcontent(tabinterfaceid){this.tabinterfaceid=tabinterfaceid;this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a");this.enabletabpersistence=true;this.hottabspositions=[];this.currentTabIndex=0;this.subcontentids=[];this.revcontentids=[];this.selectedClassTarget="link";}ddtabcontent.getCookie=function(Name){var re=new RegExp(Name+"=[^;]+", "i");if (document.cookie.match(re))return document.cookie.match(re)[0].split("=")[1];return "";};ddtabcontent.setCookie=function(name, value){document.cookie = name+"="+value+";path=/";};ddtabcontent.prototype={expandit:function(tabid_or_position){this.cancelautorun();var tabref="";try{if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel"))tabref=document.getElementById(tabid_or_position);else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel"))tabref=this.tabs[tabid_or_position];}catch(err){alert("Invalid Tab ID or position entered!")}if (tabref!="")this.expandtab(tabref);},cycleit:function(dir, autorun){if (dir=="next"){var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1:0;}else if (dir=="prev"){var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1;}if (typeof autorun=="undefined")this.cancelautorun();this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]]);},setpersist:function(bool){this.enabletabpersistence=bool;},setselectedClassTarget:function(objstr){this.selectedClassTarget=objstr || "link";},getselectedClassTarget:function(tabref){return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref;},urlparamselect:function(tabinterfaceid){var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i"));return (result==null)? null : parseInt(RegExp.$1);},expandtab:function(tabref){var subcontentid=tabref.getAttribute("rel");var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : "";this.expandsubcontent(subcontentid);this.expandrevcontent(associatedrevids);for (var i=0; i<this.tabs.length; i++){this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("rel")==subcontentid)? "selected" : "";}if (this.enabletabpersistence)ddtabcontent.setCookie(this.tabinterfaceid, tabref.tabposition);this.setcurrenttabindex(tabref.tabposition);},expandsubcontent:function(subcontentid){for (var i=0; i<this.subcontentids.length; i++){var subcontent=document.getElementById(this.subcontentids[i]);subcontent.style.display=(subcontent.id==subcontentid)? "block" : "none";}},expandrevcontent:function(associatedrevids){var allrevids=this.revcontentids;for (var i=0; i<allrevids.length; i++){document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none";}},setcurrenttabindex:function(tabposition){for (var i=0; i<this.hottabspositions.length; i++){if (tabposition==this.hottabspositions[i]){this.currentTabIndex=i;break;}}},autorun:function(){this.cycleit('next', true);},cancelautorun:function(){if (typeof this.autoruntimer!="undefined");clearInterval(this.autoruntimer);},init:function(automodeperiod){var persistedtab=ddtabcontent.getCookie(this.tabinterfaceid);var selectedtab=-1;var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid);this.automodeperiod=automodeperiod || 0;for (var i=0; i<this.tabs.length; i++){this.tabs[i].tabposition=i;if (this.tabs[i].getAttribute("rel")){var tabinstance=this;this.hottabspositions[this.hottabspositions.length]=i;this.subcontentids[this.subcontentids.length]=this.tabs[i].getAttribute("rel");this.tabs[i].onmouseover=function(){tabinstance.expandtab(this);tabinstance.cancelautorun();return false;};if (this.tabs[i].getAttribute("rev")){this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/));}if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){selectedtab=i;}}}if (selectedtab!=-1)this.expandtab(this.tabs[selectedtab]);else this.expandtab(this.tabs[this.hottabspositions[0]]);if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod);}}}
function linkin(str){if(str!="#"){window.open(str);}}
