﻿// JavaScript Document
WebUrl="http://www.piao.sh.cn/";
//设为首页
function $HomePage(obj,Url){obj.style.behavior='url(#default#homepage)';obj.setHomePage(Url);return false}
//加入收藏夹
function $Favorite(Url,Title){
	switch($GetIE()){
		case "IE": window.external.addFavorite(Url,Title);break;
		case "Firefox": window.sidebar.addPanel(Title, Url, "");break;
		case "Opera":
			var Opera = document.createElement('a');Opera.setAttribute('rel','sidebar');
			Opera.setAttribute('href',Url);Opera.setAttribute('title',Title);Opera.click();break;
	};
};
//通用ID获取对象
function $Id(id){return document.getElementById(id);}
//通用Name获取对象
function GetValue(Name,Vle){$Id(Name).value=Vle;}
function $Name(Name){return document.getElementsByName(Name);}
function $href(Url){location.href=Url;}
//刷新页面
function _renovate(){
	location.reload();
}
//通用标签选择
function ShowTags(Name,Max,Num){
	for(var i=1;i<=Max;i++){
		$Id(Name+i).className='';
		$Id(Name+"_"+i).style.display='none';
	}
	$Id(Name+Num).className='nav';
	$Id(Name+"_"+Num).style.display=''
}
//通用显示/隐藏对象
function ShowTag(Name,Num){
	if(Num==0){
		$Id(Name).style.display='none';
	}else{
		$Id(Name).style.display=''
	}
}
function s_queyr(Num){
	if(Num==0){
		$Id("AirQuery").style.display='';
		$Id("HotelQuery").style.display='none';
		$Id("f_btn").className='f_btn_t';
		$Id("h_btn").className='h_btn_d';
	}else{
		$Id("AirQuery").style.display='none';
		$Id("HotelQuery").style.display='';
		$Id("f_btn").className='f_btn_d';
		$Id("h_btn").className='h_btn_t';
	}
}
//通用Radio选择
function TRadio(Name,N){
	var RadioName=$Name(Name);RadioName[N].checked="checked";
}
//判断浏览器
function $GetIE(){ 
   if(navigator.userAgent.indexOf("MSIE")>=0) return "IE"; 
   if(navigator.userAgent.indexOf("Firefox")>=0) return "Firefox"; 
   if(navigator.userAgent.indexOf("Opera")>=0) return "Opera"; 
   return "No"; 
};
//Radio选择
function $Radio(Name,Value){
	var RadioName=$Name(Name);
	for(var i=0;i<RadioName.length;i++){
		if(RadioName[i].value==Value) RadioName[i].checked="checked";
	}
}

//Select选择
function $Select(Name,Value){
	var SelectName=$Id(Name);
	for(var i=0;i<SelectName.options.length;i++){
		if(SelectName.options[i].text==Value) SelectName.selectedIndex = i;
	}
}
//Flash显示
function flash(url,width,height,links){
	document.write("<DIV style=\"POSITION:relative;\">\r\
	<OBJECT codeBase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" height=\""+height+"\" width=\""+width+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">\r\
	<PARAM NAME=\"Movie\" VALUE=\""+url+"\">\r\
	<PARAM NAME=\"Src\" VALUE=\""+url+"\">\r\
	<PARAM NAME=\"WMode\" VALUE=\"Transparent\">\r\
	<embed src=\""+url+"\" quality=\"high\" allowscriptaccess=\"always\" wmode=\"Transparent\" type=\"application/x-shockwave-flash\"  pluginspage=\"http://www.macromedia.com/go/getflashplayer\" height=\""+height+"\" width=\""+width+"\">\r\
	</OBJECT>\r\
	<A href=\""+links+"\" target=\"_blank\"><IMG style=\"width:"+width+"px;position:absolute;top:0;left:0;height:"+height+"px\" src=\"http://WebResource.lvyehudong.com/Images/spacer.gif\"></A>\r\
	</DIV>");
}
function QQMsg(qq,Name){
	try{
		var xmlhttp=new ActiveXObject("TimwpDll.TimwpCheck");
		location.href='Tencent://Message/?menu=yes&exe=&uin='+qq+'&websiteName='+Name+'&info=';
	}catch(e){
		alert("您电脑上还未安装QQ，或者您安装的版本暂不支持本功能，请使用在线客服与我们联系！");
	}
}
// JavaScript Document
function top_login() {
	aa=document.MinLogin ;
	if (aa.UserName.value=="")
	{
			alert("登录帐号没有填写！");
			aa.UserName.focus();
			return false;
	}
	if (aa.PassWord.value.length<6)
	{
			alert("登录密码没有填写或不正确！");
			aa.PassWord.focus();
			return false;
	}
	$.post(WebUrl+'Member/login.php',
		{
			Action:"top_login",
			UserName:aa.UserName.value,
			PassWord:aa.PassWord.value
		},
		function(data){
			if(data=="Yes"){
				alert("登陆成功！");
				_renovate();
			}else{
				alert(data);
			}
		})
	return false;
}
function esc_login(){
	$.post(WebUrl+'Member/login.php',
		{
			Action:"Logout"
		},
		function(data){
			if(data=="Yes"){
				alert("退出成功！");
				_renovate();
			}else{
				alert(data);
			}
		})
}
function forgetpass(){
	aa=document.rpass;
	if (aa.UserName.value=="")
	{
			alert("您的帐号没有填写！");
			aa.UserName.focus();
			return false;
	}
	if (aa.Email.value=="")
	{
			alert("您的电子邮件没有填写！");
			aa.Email.focus();
			return false;
	}
	$.post(WebUrl+'Member/ForgetPass.php',
		{
			Action:"answer",
			UserName:aa.UserName.value,
			Email:aa.Email.value
		},
		function(data){
			if(data=="Yes"){
				alert("密码已发送到您的Email，请注意查收！");
				_renovate();
			}else{
				alert(data);
			}
		})
	return false;
}
function LoadFlight(City_,N) 
{
	$.post('LoadFlight.html',
		{City:City_},
		function(data){
			$Id("flightbox").innerHTML=data;
		})
	for(var i=0;i<10;i++){
		if(i==N){
			$Id("F_T_"+N).className="d";
		}else{
			$Id("F_T_"+i).className="";
		}
	}
}
function LoadHotel(City_,N) 
{
	$.post('LoadHotel.html',
		{City:City_},
		function(data){
			$Id("hotelbox").innerHTML=data;
		})
	for(var i=0;i<10;i++){
		if(i==N){
			$Id("H_T_"+N).className="d";
		}else{
			$Id("H_T_"+i).className="";
		}
	}
}
function  show_time(){   
	
  document.write(time);
}
function LoadWeather() 
{
	var today,year,month,date,time;
	today=new Date();
	year = today.getYear();
	month = today.getMonth()+1;
	date = today.getDate();
	week = today.getDay();
	if(month<10){month="0"+month;}
	if(date<10){date="0"+date;}
	if (week==0){
		week = "星期日";
	}else if (week == 1){
		week = "星期一";
	}else if (week == 2){
		week = "星期二";
	}else if (week == 3){
		week = "星期三";
	}else if (week == 4){
		week = "星期四";
	}else if (week == 5){
		week = "星期五";
	}else if (week == 6){
		week = "星期六";
	}
	time = year + "年" + month + "月" + date +"日 " + week;
	$.post(WebUrl+'weather.php',
		{City:"%E4%B8%8A%E6%B5%B7"},
		function(data){
			$Id("Weather").innerHTML=time+data;
		})
}

function TrainOrder(Str_,M) 
{
	document.BuyForm.StrValue.value=Str_;
	document.BuyForm.model.value=M;
	document.BuyForm.action="train_buy.php";
	document.BuyForm.submit();
}
function FlightOrder(Str_,M) 
{
	if(M=="1"){
		aa=document.BuyForm;
		if(aa.StrValue.value!=""){
			aa.StrValue.value=aa.StrValue.value+"#"+Str_;
		}else{
			aa.StrValue.value=Str_;
		}
		aa.action="flight_buy.php";
		aa.submit();
	}else{
		document.RForm.StrValue.value=Str_;
		document.RForm.action="flight_search.php";
		document.RForm.submit();
	}
}
function f_send_price(Str_) 
{
	if(Str_==""){
		$Id('SendPrice').innerHTML=0;
	}else{
		$Id('SendPrice').innerHTML=Str_;
	}
	count_price();
}
function count_price() 
{
	var send_price=0;
	model_=$Id("model").value;
	amount_=$Id("amount").value;
	var Str_="";
	for (var i=0;i<$Name("SendArea").length;i++){
	var e = $Name("SendArea")[i];
		if (e.checked==true){
			Str_=e.value;
		}
	}
	if(Str_!=""){
		send_price=Str_.split("@")[1];
	}
	pprice=model_.split("@")[1];
	toolprice=eval(eval(pprice+"+"+5)+"*"+amount_+"+"+send_price);
	$Id('SendPrice').innerHTML=send_price;
	$Id('p_price').innerHTML=pprice;
	$Id('amount_str').innerHTML=amount_;
	$Id('tool_price').innerHTML=toolprice;
	$Id('ToolPrice').value=toolprice;
}
function f_type(Str_) 
{
	if(Str_=="1"){
		$Id('hc_rq').style.display='none';
	}else{
		$Id('hc_rq').style.display='';
	}
}
function berth_all(Str_) 
{
	if($Id('berth_'+Str_).style.display=='none'){
		$Id('berth_'+Str_).style.display='';
	}else{
		$Id('berth_'+Str_).style.display='none';
	}
}
function airquerysy() {
	aa=document.flightform;
	StrCity=aa.StrCity.value;
	EndCity=aa.EndCity.value;
	if(StrCity!=""){
		if(StrCity.indexOf('~' != -1)){
			stt= AirCity.split('@');
			for(var i=0;i<stt.length;i++){
				str=stt[i].split("|");
				if(str[2]==StrCity){
					aa.StrCity.value=StrCity+"~"+str[1];
				}
			}
		}
	}
	if(EndCity!=""){
		if(EndCity.indexOf('~' != -1)){
			stt= AirCity.split('@');
			for(var i=0;i<stt.length;i++){
				str=stt[i].split("|");
				if(str[2]==EndCity){
					aa.EndCity.value=EndCity+"~"+str[1];
				}
			}
		}
	}
}