// JavaScript Docume
function LTrim(str){var i;for(i=0;i<str.length;i++){if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break;}str=str.substring(i,str.length);return str;} 
function RTrim(str){var i;for(i=str.length-1;i>=0;i--){if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break;}str=str.substring(0,i+1);return str;} 
function trim(str){return LTrim(RTrim(str));} 

String.prototype.trim = function(){return this.replace(/(^\s*)|(\s*$)/g,"");}  //return trim(this);
function $(id){return document.getElementById(id);}
function CheckQA()
{
	$('SubmitYes').readonly=true;
	$('SubmitYes').disabled=true;
	title_=$('title').value.trim();
	reply_=$('reply').value.trim();
	leixing_=$('leixing').options[$('leixing').selectedIndex].value;
	lid_=$('lid').value;
	switch (leixing_){
		case '1':
			Cleixing='邮箱';
			break;
		case '2':
			Cleixing='电话';
			break;
		case '3':
			Cleixing='QQ/MSN';
			break;
	}
	var s=true;
	Rond=Math.round(Math.random()*99999999);
	if(title_=='' || title_=='请输入您要提的问题'){
		alert('请输入您要提的问题!');
		$('title').focus();
		s=false;
		$('SubmitYes').disabled=false;
		$('SubmitYes').readonly=false;
		return false;
	}
	if(reply_==''){
		alert('请输入 '+Cleixing);
		$('reply').focus();
		s=false;
		$('SubmitYes').disabled=false
		;$('SubmitYes').readonly=false;
		return false;
	}
	//Rrsult=loadXMLDoc('/Action/QA.php?title='+encodeURI(title_)+'&reply='+encodeURI(reply_)+'&leixing='+encodeURI(Cleixing)+'回复&lid='+encodeURI(lid_)+'&s='+Rond,'QA_Result');
	if(s){
		window.open('/Action/QA.php','myWin');
		$('form1').action='/Action/QA.php';
		$('form1').submit();
	}
	return false;
//	Rrsult='Error';
//	if(Rrsult=='Error'){window.open('/Action/QA.php?title='+encodeURI(title_)+'&reply='+encodeURI(reply_)+'&leixing='+encodeURI(Cleixing+'回复')+'&R=1&lid='+encodeURI(lid_)+'&s='+Rond);}
}
function CheckOrder(){
	$('SubmitOrderYes').readonly=true;
	$('SubmitOrderYes').disabled=true;
	starttime_=$('starttime').value.trim();
	people_=$('people').value.trim();
	baby_=$('baby').value.trim();

	var r = starttime_.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); 
	if(r==null){alert('请选择有效时间!');$('starttime').focus();$('SubmitOrderYes').disabled=false;$('SubmitOrderYes').readonly=false;return;}
	if(people_=='' || people_=='0'){alert('请输入出发人数!');$('people').focus();$('SubmitOrderYes').disabled=false;$('SubmitOrderYes').readonly=false;return;}
	window.open('/Order/index.php','myWin');
	$('form2').action='/Order/index.php?s=1';
	$('form2').submit();
	$('form2').reset();
	$('SubmitOrderYes').readonly=false;
	$('SubmitOrderYes').disabled=false;
}
function CheckOrderSub(){
	uname_=$('Ouname').value.trim();
	mobile_=$('mobile').value.trim();
	email_=$('email').value.trim();
	if(uname_==''){
		alert('请输入出发联系人!');
		$('Ouname').focus();
		return false;
	}
	if(mobile_==''){
		alert('请输入出发联系电话!');
		$('mobile').focus();
		return false;
	}
//	if(email_==''){
//		alert('请输入出发电子邮箱!');
//		$('email').focus();
//		return false;
//	}
	if(email_!=''){
		var myreg =/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
		if(!myreg.test(email_) || email_.length<8){
			alert("您填写的电子邮件格式不正确!");
			$('email').focus()
			return false;
		}
	}
	return true;
}
function loadXMLDoc(url,ShowID)
{
	var xmlhttp=null;
	if (window.XMLHttpRequest){xmlhttp = new XMLHttpRequest();} 
	if (!xmlhttp&&window.ActiveXObject){
	try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.5.0")} 
	catch(e){try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0")} 
	catch(e){ 
	try{new ActiveXObject("Msxml2.XMLHTTP")} 
	catch(e){try{new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}}}} 
	if(!xmlhttp){$(ShowID).innerHTML='Error';}
	else{
		xmlhttp.open("GET",url,true);
		//xmlhttp.setRequestHeader("Content-Type", "text/html;charset=UTF-8");
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");
		xmlhttp.send(null);
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){
				if(xmlhttp.status==200){$(ShowID).innerHTML=xmlhttp.responseText;}
			 	else{$(ShowID).innerHTML='操作失败!'+xmlhttp.statusText;}
			}else{
				$(ShowID).innerHTML='<img src="/tm_images/loading.gif" border="0"/>正在加载,请稍后......';}
		}
	}
}
function Region_Pxfs(id){
	id=parseInt(id);
	if(id==0){return false;}
	switch(id){
		case 1:
			$("Pxfs_1").style.background="url(/tm_images/Region_pxfs_2.gif)";
			$("Pxfs_2").style.background="url(/tm_images/Region_pxfs_3.gif)";
url="/Action/Region_Pxfs.php?id="+$("inid").value+"&s=order&x="+Math.floor(Math.random()*99999999);
			loadXMLDoc(url,"JYLiaoPxfs");
			break;
		case 2:
			$("Pxfs_2").style.background="url(/tm_images/Region_pxfs_2.gif)";
			$("Pxfs_1").style.background="url(/tm_images/Region_pxfs_3.gif)";
url="/Action/Region_Pxfs.php?id="+$("inid").value+"&s=price&x="+Math.floor(Math.random()*99999999);
			loadXMLDoc(url,"JYLiaoPxfs");
			break;
	}
}
function ShowDiolg(ImgId){ //XCAPIMG_211
	var o=$('XCAPIMG_'+ImgId);
	if(o!=null){
		x=o.offsetLeft;
		y=o.offsetTop;
		while(o=o.offsetParent){
			x+=o.offsetLeft;
			y+=o.offsetTop;
		}
	}
	if($('ShowJDID').value!=ImgId){
		$('ShowJDID').value=ImgId;
//alert(ImgId);
$('ShowJDDiv').style.marginLeft=x+82+'px';
$('ShowJDDiv').style.marginTop=y+'px';
$('ShowJDDiv').style.display='block';
$('ShowJDResult').innerHTML='<img src="/tm_images/loading.gif" border="0"/>正在加载,请稍后......';
Pause(this,1000);
this.NextStep=function(){   //#676767
	loadXMLDoc('/Action/ShowJDIMG.php?ElEmt='+Math.floor(Math.random()*99999999)+'&id='+ImgId,'ShowJDResult');
	return false;
	}
	}
	return false;
}
function CloseDiolg(){
	$('ShowJDDiv').style.display='none';
	$('ShowJDResult').innerHTML='&nbsp;';
	$('ShowJDID').value=0;
}   //ShowTipsLink(this,1206,'这里','入内参观','2小时')
function ShowTipsLink(obj,title,leixing,shijian){
	if($('ShowTipsLink').style.display=='block'){
		return false;
	}
	if(obj!=null){
		obj.onmouseout=function(){
				//alert(0);
				$('ShowTipsLink').style.display='none';
		}
		x=obj.offsetLeft;
		y=obj.offsetTop;
		while(obj=obj.offsetParent){
			x+=obj.offsetLeft;
			y+=obj.offsetTop;
		}
	}
	$('ShowTipsLink').style.marginLeft=x+'px';
	$('ShowTipsLink').style.marginTop=y+20+'px';
	$('ShowTipsLink').style.display='block';
	$('ShowTipsTitle').innerHTML=title;
	$('ShowTipsLeiXing').innerHTML='参观类型:'+leixing;
	$('ShowTipsShiJian').innerHTML='参观时间:'+shijian;
	$('ShowTipsImg').innerHTML='<img src="/tm_images/loading.gif" border="0"/>正在加载,请稍后......';
	//alert(obj.href);	//window.open('/Action/ShowTipsLink.php?ElEmt='+Math.floor(Math.random()*99999999)+'&title='+title);
Pause(this,1000);
this.NextStep=function(){
	loadXMLDoc('/Action/ShowTipsLink.php?ElEmt='+Math.floor(Math.random()*99999999)+'&title='+encodeURIComponent(title),'ShowTipsImg'); //ShowTipsTitle  ShowTipsLeiXing  ShowTipsShiJian
	}
}
function ReCode(){   ///换验证码
	$('Code').src='/Action/Code.php?'+Math.round(Math.random()*99999999);
}

 //js暂停
function Pause(obj,iMinSecond){ 
	if (window.eventList==null) window.eventList=new Array(); 
	var ind=-1; 
	for (var i=0;i<window.eventList.length;i++){ 
		if (window.eventList[i]==null) { 
			window.eventList[i]=obj; 
			ind=i; 
			break;} 
	}
	if (ind==-1){ 
		ind=window.eventList.length; 
		window.eventList[ind]=obj;} 
	setTimeout("GoOn(" + ind + ")",iMinSecond); 
}
function GoOn(ind){ 
	var obj=window.eventList[ind]; 
	window.eventList[ind]=null; 
	if (obj.NextStep) obj.NextStep(); 
	else obj(); 
}
//Pause(this,3000);
//this.NextStep=function(){JS语句}


function OrderLoad2(id){
	var tem=document.getElementById(id); 
	tem.options.length=0;
	var c=1;
	var CPdate=new Date();
	for(var i=1;i<MyPrice.length;i++){
		var Ad=MyDate[i].split("-");
		var PDate=new Date(Ad[0],Ad[1],Ad[2]);
		if(PDate > CPdate)
			tem.options.add(new Option(MyDate[i]+" "+MyPrice[i]+"元/人",MyDate[i]));
	}
	if(tem.options[0]==null)
	tem.options[0]=(new Option("价格实时变动，欢迎垂询","0"));
}

function OrderLoad(id,tcid){
	var tem=document.getElementById(id)+"_"+tcid; 
	tem.options.length=0;
	var c=1;
	var CPdate=new Date();
	for(var i=1;i<MyPrice.length;i++){
		var Ad=MyDate[i].split("-");
		var PDate=new Date(Ad[0],Ad[1],Ad[2]);
		if(PDate > CPdate)
			tem.options.add(new Option(MyDate[i]+" "+MyPrice[i]+"元/人",MyDate[i]));
	}
	if(tem.options[0]==null)
	tem.options[0]=(new Option("价格实时变动，欢迎垂询","0"));
}
