﻿
function GetObj(objName){
			if(document.getElementById){
				return eval('document.getElementById("' + objName + '")');
			}else if(document.layers){
				return eval("document.layers['" + objName +"']");
			}else{
				return eval('document.all.' + objName);
			}
		}
var waittime
function search_sh(n){
	clearTimeout(waittime);
	waittime=window.setTimeout("search_sh1("+n+");",300);}
function search_sh2(){	clearTimeout(waittime);}
function search_sh1(n){
		for(var i=1;i<=5;i+=1){
		if( i == n ){
			GetObj("ts"+i).className = "selected";
		}else{GetObj("ts"+i).className = "";}}
var text_key,search_action,sou_v
	switch(n){
		case 1:
			search_action = "/peruser/scenery_more.asp?action=search";
			text_key="keyword"
			sou_v="景区搜索"
			break;
		case 2:
			search_action = "/quoteprice.htm";
			text_key="title"
			sou_v="线路搜索"
			break;
		case 3:
			search_action = "/peruser/tra_article.asp";
			text_key="title"
			sou_v="游记搜索"
			break;
		case 4:
			search_action = "/peruser/BlogSearch.asp?action=All&blogtype=1";
			text_key="BLOGKEY"
			sou_v="博文搜索"
			break;
		case 5:
			search_action = "/more_sou/more_news.asp";
			text_key="keyw"
			sou_v="新闻搜索"
			break;
			//case 5:
			//search_action = "/peruser/askprice.asp";
			//text_key="title"
			//sou_v="询价搜索"
		//	break;
	}
	GetObj("form_top").action = search_action;
	GetObj("keyword").name = text_key;
	//GetObj("bu_sou").value = sou_v;
	}
   
var Browser = new Object();
Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
Browser.isIE = window.ActiveXObject ? true : false;
Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);
if (Browser.isFirefox) { // entend Event Mod for FireFox
	extendEventObject();
}
function extendEventObject() {
	Event.prototype.__defineGetter__("srcElement", function () {
		var node = this.target;
		while (node.nodeType != 1) node = node.parentNode;
		return node;
	});

	Event.prototype.__defineGetter__("fromElement", function () {
		var node;
		if (this.type == "mouseover")
			node = this.relatedTarget;
		else if (this.type == "mouseout")
			node = this.target;
		if (!node) return;
		while (node.nodeType != 1) node = node.parentNode;
		return node;
	});

	Event.prototype.__defineGetter__("toElement", function () {
		var node;
		if (this.type == "mouseout")
			node = this.relatedTarget;
		else if (this.type == "mouseover")
			node = this.target;
		if (!node) return;
		while (node.nodeType != 1) node = node.parentNode;
		return node;
	});
}
function IsChild(cNode,pNode){
	while(cNode!=null){
		cNode=cNode.parentNode;
		if(cNode==pNode) return true; 
	}
	return false;
}

var ajccache=new Object();
var waitInterval;
var tempref;
var MouseDelayTime=150;//鼠标感应延迟300毫秒
function getTBprefixName(str,sta){
	if(str.indexOf("active")!=-1 || str.indexOf("normal")!=-1) str=str.substr(6);
		else if(str.indexOf("over")!=-1) str=str.substr(4);
			else str="";
	return sta+str;
}
function travelajaxtabs(){
	//alert(arguments);
	for(var i=0;i<arguments.length;i++)
	{
		var ulobj=document.getElementById(arguments[i]);
			ulist=ulobj.getElementsByTagName("li");			
			for(var j=0;j<ulist.length;j++)
			{
				var thelist=ulist[j];
				if(thelist.parentNode.parentNode!=ulobj) continue;//只有第一层li有效 fixed 2006.9.29
				var ulistlink=thelist.getElementsByTagName("a")[0];
				var ulistlinkurl=ulistlink.getAttribute("urn");
				var ulistlinktarget=ulistlink.getAttribute("rel");
				thelist.setActive=function(bactive){
					if(bactive){
						this.status="active";
						this.className=getTBprefixName(this.className,"active");
					}else{
						this.status="normal";
						this.className=getTBprefixName(this.className,"normal");
					}
				}
				thelist.LoadTab=function(){
					this.setActive(true);
					//alert(this.parentNode.parentNode.tagName);
					this.parentNode.parentNode.activetab.setActive(false);
					this.parentNode.parentNode.activetab=this;					
					var ulistlink=this.getElementsByTagName("a")[0];
					loadAJAXTab(ulistlink.getAttribute("urn"),ulistlink.getAttribute("rel"));
				}
				thelist.onmouseover=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var fm=myEvent.fromElement;
					if(IsChild(fm,this) || fm==this) return;//过滤子元素event
					if(this.status=="active") return;
					tempref=this;
					clearTimeout(waitInterval);
					//alert('sdfdf');
					waitInterval=window.setTimeout("tempref.LoadTab();",MouseDelayTime);
				}

				thelist.onmouseout=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var em=myEvent.toElement;
					if(IsChild(em,this) || em==this) return; //过滤子元素event
					if(this.status=="active") return;
					clearTimeout(waitInterval);
				}

				if(ulistlinkurl.indexOf("#default")!=-1){
					thelist.setActive(true);
					ulobj.activetab=thelist;
					ajccache[ulistlinkurl]=getElement(ulistlinktarget).innerHTML;
				}else{
					thelist.setActive(false);
				}

			}
		if(ulobj.activetab==null) ulobj.activetab=ulist[0];
	}
}

function getXmlhttp()
{
	var http_request;
	
	if(window.XMLHttpRequest) { 
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType("text/xml");
		}
	}
	else if (window.ActiveXObject) { 
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) { 
		window.alert("can't create XMLHttpRequest object.");
		return null;
	}	
	return http_request;
}

function loadAJAXTab(url,contentid){
	var ocontent=getElement(contentid);
	if(ajccache[url]==null) {
		var xhttp=getXmlhttp();		
			xhttp.onreadystatechange=function(){
				if(xhttp.readyState == 4 && (xhttp.status==200 || window.location.href.indexOf("http")==-1))
				{					
					ocontent.innerHTML=xhttp.responseText;
					ajccache[url]=ocontent.innerHTML;
				}
			}
		xhttp.open("GET",url,true);
		xhttp.send(null);
	}else{
		ocontent.innerHTML=ajccache[url];
	}
}
window.onerror=function(){return true}
///////////////////////////////////////////////////////////////////////////////
function getElement(aID)
{
  return (document.getElementById) ? document.getElementById(aID): document.all[aID];
}
function keyform(){
	if(document.getElementById("keyword").value==""){
		alert('请输入要查询的关健字');
		document.getElementById("keyword").focus();
		return false;
	}
}
//省
document.onmousedown=function(aEvent){
	var myEvent = window.event ? window.event : aEvent;
	var lo=getElement("locListDiv");
	if(!IsChild(myEvent.srcElement,lo))hideLocSelect();
}
window.onerror=function(){return true}
function showLocSelect()
{var locdiv=getElement("locListDiv");
	if(locdiv.style.display=="block"){
		locdiv.style.display="none";
		return;	}
	locdiv.style.display="block";
	var locs=locdiv.getElementsByTagName("li");
	for(var i=0;i<locs.length;i++)
	{var theloc=locs[i];
			theloc.onmouseover=function(){
				this.style.backgroundColor="#A0AAC8"
			}
			theloc.onmouseout=function(){
				this.style.backgroundColor="#2D80E0"
			}
			theloc.onclick=function(){
				var locstr=this.innerHTML;
				if (locstr.indexOf(" ")!=-1) locstr=locstr.substr(0,locstr.indexOf(" ")); 
				hideLocSelect();
				var l=getElement("locbar");
			}}}
function hideLocSelect()
{	getElement("locListDiv").style.display="none";
}
function IsChild(cNode,pNode){
	while(cNode!=null){
		cNode=cNode.parentNode;
		if(cNode==pNode) return true; 
	}
	return false;
}
document.onmousedown=function(aEvent){
	var myEvent = window.event ? window.event : aEvent;
	var lo=getElement("locListDiv");
	if(!IsChild(myEvent.srcElement,lo))hideLocSelect();
}

	var marqueeContent=new Array();  
	var marqueeInterval=new Array(); 
	var marqueeId=0;
	var marqueeDelay=2000;
	var marqueeHeight=15;
	//接下来的是定义一些要使用到的函数
	function initMarquee() {
		var str=marqueeContent[0];
		document.write('<div id=marqueeBox style="overflow:hidden;height:'+marqueeHeight+'px" onmouseover="clearInterval(marqueeInterval[0])" onmouseout="marqueeInterval[0]=setInterval(\'startMarquee()\',marqueeDelay)"><div>'+str+'</div></div>');
		marqueeId++;
		marqueeInterval[0]=setInterval("startMarquee()",marqueeDelay);
		}
	function startMarquee() {
		var str=marqueeContent[marqueeId];
			marqueeId++;
		if(marqueeId>=marqueeContent.length) marqueeId=0;
		if(marqueeBox.childNodes.length==1) {
			var nextLine=document.createElement('DIV');
			nextLine.innerHTML=str;
			marqueeBox.appendChild(nextLine);
			}
		else {
			marqueeBox.childNodes[0].innerHTML=str;
			marqueeBox.appendChild(marqueeBox.childNodes[0]);
			marqueeBox.scrollTop=0;
			}
		clearInterval(marqueeInterval[1]);
		marqueeInterval[1]=setInterval("scrollMarquee()",20);
		}
	function scrollMarquee() {
		marqueeBox.scrollTop++;
		if(marqueeBox.scrollTop%marqueeHeight==(marqueeHeight-1)){
		clearInterval(marqueeInterval[1]);
		}
	}
