﻿<!-- 2010-5-7	wangxiang	81535    英文租车界面取消三亚租车服务-->

Date.prototype.addDate=function(day){
	return new Date(this.getFullYear(),this.getMonth(),this.getDate()+day);
};

Date.prototype.toStdString=function(){
	return this.getFullYear()+"-"+(this.getMonth()+1)+"-"+this.getDate();
};

var cityData1={
	1:"Beijing",
	2:"Shanghai",
	4:"Chongqing",
	7:"Qingdao",
	12:"Nanjing",
	14:"Suzhou",
	17:"Hangzhou",
	25:"Xiamen",
	28:"Chengdu",
	30:"Shenzhen",
	32:"Guangzhou",
	477:"Wuhan"
	//43:"Sanya"
};
var cityData2={
	2:"Shanghai",
	4:"Chongqing",
	7:"Qingdao",
	12:"Nanjing",
	14:"Suzhou",
	17:"Hangzhou",
	30:"Shenzhen"
};
var cityDateAdd={
	1:1,
	2:1,
	4:1,
	7:2,
	12:2,
	14:2,
	17:2,
	25:2,
	28:2,
	30:2,
	32:1,
	43:2,
	477:2
};
var airportData={
	1:{"PEK":"Beijing Capital International Airport"},
	2:{"PVG":"Shanghai Pudong International Airport","SHA":"Shanghai Hongqiao International Airport"},
	4:{"CKG":"Chongqing Jiangbei International Airport"},
	7:{"TAO":"Qingdao Liuting Airport"},
	12:{"NKG":"Nanjing Lukou International Airport"},
	17:{"HGH":"Hangzhou Xiaoshan International Airport"},
	25:{"XMN":"Xiamen Gaoqi International Airport"},
	28:{"CTU":"Chengdu Shuangliu International Airport"},
	30:{"SZX":"Shenzhen Bao'an International Airport"},
	32:{"CAN":"Guangzhou New Baiyun International Airport"},
	43:{"SYX":"Fenghuang International Airport"},
	477:{"WUH":"Wuhan Tianhe Airport"}
};
airportData[14]=airportData[2];
var districtData={
	1:{
		138:"Asian and Olympic Games Village Area",
		32:"Qianmen (The Front Gate) / Chongwenmen Area",
		44:"Beijing Capital International Airport Area",
		137:"China International Exhibition Center Area",
		40:"Xizhimen and Beijing Exhibition Center Area",
		135:"Beijing Station / Jianguomen / Guomao CBD",
		136:"Beijing West Railway Station Area",
		133:"Dong'erhuan Workers' Stadium Area",
		41:"Xidan and Jinrongjie Area",
		652:"Houhai Area",
		650:"Madian Area",
		36:"Princess Tomb and Wanshou Road Commercial Area",
		147:"Jinsong and Panjiayuan Area",
		651:"Shangdi and Zhonguancun Area",
		31:"Tiananmen Square and Wangfujing Area",
		654:"Wangjing Area",
		37:"Yansha Business District",
		653:"Yizhuan Area",
		47:"Yongdingmen and South Railway Station Area"
	},
	2:{
		466:"Pudong International Airport Area",
		364:"Caohejing Development District",
		365:"Caoyang and Zhenru Area",
		366:"Hutai and Pengpu Area",
		367:"Jiangwan and Dabaishu Area",
		363:"Shanghai South Railway Station Area",
		369:"The North Bund Area",
		4:"Hongqiao Area",
		14:"Huaihai Road Area",
		16:"Jing'an Temple Area",
		22:"Lujiazui Commercial Area",
		19:"New Railway Station Area",
		26:"North Sichuan Road Commercial Area",
		28:"People's Square",
		359:"Pudong Jinqiao District",
		379:"Pudong New International Expo Center",
		361:"Pudong Tangqiao and Changli Commercial District",
		358:"Pudong Waigaoqiao District",
		360:"Pudong Zhangjiang District",
		118:"The Bund Area",
		368:"Wujiaochang Commercial Area",
		7:"Xujiahui District ",
		362:"Yuyuan and Daxingjie Commercial District"
	},
	4:{
		328:"Jiangbei Region",
		100:"Jiefangbei Central Shopping Square",
		213:"People's Square (Surrounding Area)",
		214:"Shapingba Region",
		104:"The High-tech Development Zone",
		215:"Yangze River (District at South River Bank)"
	},
	7:{
		228:"Huangdao Hi-tech District",
		83:"Municipal Government District",
		84:"No.1 Bathing Beach",
		85:"Old Man Stone Resort",
		87:"Sifang District",
		86:"Zhanqiao Bridge District"
	},
	12:{
		71:"Fuzi Temple District",
		70:"Gulou District",
		181:"Shanxi Road District",
		72:"Sun Yatsen Mausoleum District",
		316:"East District",
		67:"Railway Station District",
		68:"Xinjiekou District"
	},
	14:{
/*
		212:"Panmen Area",
		211:"Guanqianjie Commercial District",
		209:"Suzhou Industrial District",
		210:"Suzhou New District",
		208:"Railway Station District"
*/
		"-1406":"Downtown"
	},
	17:{
		171:"Cultural and Educational District",
		146:"Railway Chengzhan Station",
		170:"Huanglong Stadium",
		305:"Riverside District",
		95:"East Railway Station",
		93:"West Lake Area",
		94:"Wulin Square Area",
		96:"Xiaoshan District"
	},
	25:{
		175:"Bailuzhou Area",
		173:"Gulangyu Area",
		501:"Haicang District",
		176:"Huli Industrial District",
		174:"Old Urban Area (Ferry Station)",
		178:"Railway Station Area",
		177:"Songbai Area (the new city centre)"
	},
	28:{
		187:"Chunxi Road Commercial Area",
		189:"City Cultural Center",
		188:"Luomashi Commercial Area",
		190:"The Railway Station Area"
	},
	30:{
		128:"China Hi-Tech Fair/Huanggang Port Area",
		157:"Huaqiangbei District",
		159:"Luohu District",
		127:"Shekou (Nanshan) Area",
		126:"Huaqiaocheng (Overseas Chinese Town)",
		320:"Yantian (Dameisha and Xiaomeisha)"
	},
	32:{
		120:"Beijing Road (Walking Street) and Haizhu Square",
		371:"Dongpu Economy Development District",
		55:"Guangzhou Railway Station and China Import and Export Fair Complex",
		56:"East Huanshi Road",
		74:"Shamian, Shangxiajiu Walking Street",
		150:"South of Zhujiang River",
		151:"Tian He Stadium and Guangzhou East Railway Station"
	},
	43:{
		163:"Dadonghai Beach",
		164:"Sanya Bay",
		165:"Urban Disrict",
		162:"Yalong Bay"
	},
	477:{
		199:"Donghu Hi-tech Development Area",
		51:"Hanyang",
		195:"Hankou Business and Finance District",
		196:"Hankou Railway Station Area",
		198:"Hongshan Square and Donghu Lake Area",
		197:"Wuchang Railway Station Area"
	}
};
var timeDate=[];
//service1 pickuptime
timeDate[0]={
	1:"6:00-23:30",
	2:"0:00-23:30",
	4:"6:30-23:30",
	7:"6:00-22:30",
	12:"0:00-23:30",
	14:"0:00-23:30",
	17:"0:00-23:30",
	25:"6:00-23:00",
	28:"7:30-22:00",
	30:"0:00-23:30",
	32:"0:00-23:30",
	43:"0:00-23:30",
	477:"0:00-23:30"
};
//service2 pickuptime
timeDate[1]={
	1:"6:00-23:30",
	2:"0:00-23:30",
	4:"6:30-23:30",
	7:"6:00-22:30",
	12:"0:00-23:30",
	14:"0:00-23:30",
	17:"0:00-23:30",
	25:"6:00-23:00",
	28:"7:30-22:00",
	30:"0:00-23:30",
	32:"0:00-23:30",
	43:"0:00-23:30",
	477:"0:00-23:30"
};
//service2 dropofftime
timeDate[2]={
	1:"6:00-23:30",
	2:"0:00-23:30",
	4:"6:30-23:30",
	7:"6:00-22:30",
	12:"0:00-23:30",
	14:"0:00-23:30",
	17:"0:00-23:30",
	25:"6:00-23:00",
	28:"7:30-22:00",
	30:"0:00-23:30",
	32:"0:00-23:30",
	43:"0:00-23:30",
	477:"0:00-23:30"
};
//service1 pickupdate
timeDate[3]={
	1:"2008-7-1,2008-7-2,2008-7-3,2008-7-4,2008-7-5,2008-7-6,2008-7-7,2008-7-8,2008-7-9,2008-7-10,2008-7-11,2008-7-12,2008-7-13,2008-7-14,2008-7-15,2008-7-16,2008-7-17,2008-7-18,2008-7-19,2008-7-20,2008-7-21,2008-7-22,2008-7-23,2008-7-24,2008-7-25,2008-7-26,2008-7-27,2008-7-28,2008-7-29,2008-7-30,2008-7-31,2008-8-1,2008-8-2,2008-8-3,2008-8-4,2008-8-5,2008-8-6,2008-8-7,2008-8-8,2008-8-9,2008-8-10,2008-8-11,2008-8-12,2008-8-13,2008-8-14,2008-8-15,2008-8-16,2008-8-17,2008-8-18,2008-8-19,2008-8-20,2008-8-21,2008-8-22,2008-8-23,2008-8-24,2008-8-25,2008-8-26,2008-8-27,2008-8-28,2008-8-29,2008-8-30,2008-8-31,2008-9-1,2008-9-2,2008-9-3,2008-9-4,2008-9-5,2008-9-6,2008-9-7,2008-9-8,2008-9-9,2008-9-10,2008-9-11,2008-9-12,2008-9-13,2008-9-14,2008-9-15,2008-9-16,2008-9-17,2008-9-18,2008-9-19,2008-9-20,2008-9-21,2008-9-22,2008-9-23,2008-9-24,2008-9-25,2008-9-26,2008-9-27,2008-9-28,2008-9-29,2008-9-30",
	2:"2008-1-2",
	4:"",
	7:"2008-1-3",
	12:"2008-1-1",
	14:"2008-1-1",
	17:"2008-1-1",
	25:"2008-1-1",
	28:"2008-1-1",
	30:"2008-1-1",
	32:"2008-1-1",
	43:"2008-1-1",
	477:"2008-1-1"
};
//service2 pickupdate
timeDate[4]={
	1:"2008-1-2",
	2:"2008-1-2",
	4:"",
	7:"2008-1-3",
	12:"2008-1-1",
	14:"2008-1-1",
	17:"2008-1-1",
	25:"2008-1-1",
	28:"2008-1-1",
	30:"2008-1-1",
	32:"2008-1-1",
	43:"2008-1-1",
	477:"2008-1-1"
};
//service1 dropoffdate
timeDate[5]={
	1:"2008-1-3",
	2:"2008-1-2",
	4:"",
	7:"2008-1-3",
	12:"2008-1-1",
	14:"2008-1-1",
	17:"2008-1-1",
	25:"2008-1-1",
	28:"2008-1-1",
	30:"2008-1-1",
	32:"2008-1-1",
	43:"2008-1-1",
	477:"2008-1-1"
};

var pkgData={
	1:{
		1:{"A":"15818","H":"15819"},
		2:{"A":"0","L":"0"}
	},
	2:{
		1:{"A":"15807","H":"15809"},
		2:{"A":"15803","L":"15803"}
	},
	4:{
		1:{"A":"22882","H":"22883"},
		2:{"A":"22884","L":"22884"}
	},
	32:{
		1:{"A":"15820","H":"15823"},
		2:{"A":"0","L":"0"}
	},
	28:{
		1:{"A":"15825","H":"15827"},
		2:{"A":"0","L":"0"}
	},
	30:{
		1:{"A":"15828","H":"15829"},
		2:{"A":"15830","L":"15830"}
	},
	25:{
		1:{"A":"15832","H":"15834"},
		2:{"A":"0","L":"0"}
	},
	12:{
		1:{"A":"15835","H":"15836"},
		2:{"A":"15838","L":"15838"}
	},
	17:{
		1:{"A":"15840","H":"15841"},
		2:{"A":"15843","L":"15843"}
	},
	477:{
		1:{"A":"15844","H":"15845"},
		2:{"A":"0","L":"0"}
	},
	7:{
		1:{"A":"15846","H":"15848"},
		2:{"A":"15849","L":"15849"}
	},
	14:{
		1:{"A":"15850","H":"15851"},
		2:{"A":"15852","L":"15852"}
	},
	43:{
		1:{"A":"17243","H":"17254"},
		2:{"A":"0","L":"0"}
	}
};


$r(_,"onload",function(){
	var service1=$("service1"),service2=$("service2");
	var flag1=$("flag1"),flag2=$("flag2");
	var city=$("city"),fromTxt=$("fromTxt");
	var time1=$("time1"),time2=$("time2");
	var date1=$("date1"),date2=$("date2");
	var dateBak1=date1.cloneNode(true);
	var dateBak2=date2.cloneNode(true);
	var airportSelelct=$("airportSelelct");
	var districtSelelct=$("districtSelelct");
	var from1=$("from1"),from2=$("from2"),to=$("to");
	var fromAirport=$("airport");
	var fromDistrict=$("district");
	var fromLocation=$("location");
	$r(service1,"onclick",service1Click);
	$r(service2,"onclick",service2Click);
	$r(from1,"onchange",from1Change);
	$r(from2,"onchange",from2Change);
	$r(city,"onchange",cityChange);

	_.search={};
	_.search.city=city;
	_.search.from1=from1;
	_.search.from2=from2;
	_.search.airportSelelct=airportSelelct;
	_.search.districtSelelct=districtSelelct;
	_.search.to=to;

	function service1Click(){
		city.options.length=0;
		for (var cityId in cityData1)
			city.options.add(new Option(cityData1[cityId],cityId));
		flag1.style.display="none";
		from1.style.display="";
		from2.style.display="none";
		fromTxt.innerHTML="From";
		from1Change();
		cityChange(false);
	}
	_.service1Click=service1Click;
	function service2Click(){
		city.options.length=0;
		for (var cityId in cityData2)
			city.options.add(new Option(cityData2[cityId],cityId));
		flag1.style.display="";
		from1.style.display="none";
		from2.style.display="";
		fromTxt.innerHTML="Pick-up location";
		from2Change();
		cityChange(false);
	}
	_.service2Click=service2Click;
	function from1Change(){
		var i=from1.selectedIndex;
		fromAirport.style.display=i==0?"":"none";
		fromDistrict.style.display=i==1?"":"none";
		flag2.style.display="";
		fromLocation.style.display="none";
		airportInit();
		districtInit();
		toInit();
	}
	_.from1Change=from1Change;
	function from2Change(){
		var i=from2.selectedIndex;
		fromAirport.style.display=i==0?"":"none";
		fromDistrict.style.display="none";
		fromLocation.style.display=i==1?"":"none";
		flag2.style.display="none";
		airportInit();
	}
	_.from2Change=from2Change;
	function cityChange(flag){
		if (flag!==false){
			airportInit();
			districtInit();
			toInit();
		}
		if (service1.checked){
			timeInit(0,time1);
			date1=dateInit(3,date1,dateBak1);
		}else{
			timeInit(1,time1);
			timeInit(2,time2);
			date1=dateInit(4,date1,dateBak1);
			date2=dateInit(5,date2,dateBak2);
		}
	}
	_.cityChange=cityChange;

	function airportInit(){
		airportSelelct.options.length=0;
		for (var airportId in airportData[city.value])
			airportSelelct.options.add(new Option(airportData[city.value][airportId],airportId));

	}
	_.airportInit=airportInit;
	function districtInit(){
		districtSelelct.options.length=0;
		districtSelelct.options.add(new Option("",""));
		for (var districtId in districtData[city.value])
			districtSelelct.options.add(new Option(districtData[city.value][districtId],districtId));
	}
	_.districtInit=districtInit;
	function toInit(){
		if (service1.checked){
			to.options.length=0;
			if (from1.selectedIndex==0){
				to.options.add(new Option("",""));
				for (var districtId in districtData[city.value])
					to.options.add(new Option(districtData[city.value][districtId],districtId));
			}
			if (from1.selectedIndex==1)
				for (var airportId in airportData[city.value])
					to.options.add(new Option(airportData[city.value][airportId],airportId));
		}
	}
	_.toInit=toInit;
	function timeInit(k,time){
		time.options.length=0;
		time.options.add(new Option("",""));
		var timeRange=timeDate[k][city.value].split("-");
		for (var i=0;i<2;i++){
			timeRange[i]=timeRange[i].split(":");
			for (var j=0;j<2;j++)
				timeRange[i][j]=parseInt(timeRange[i][j],10);
		}
		while(timeRange[0][0]*60+timeRange[0][1]<=timeRange[1][0]*60+timeRange[1][1]){
			var value=(timeRange[0][0]>9?timeRange[0][0]:"0"+timeRange[0][0])+
				":"+
				(timeRange[0][1]>9?timeRange[0][1]:"0"+timeRange[0][1]);
			time.options.add(new Option(value,value));
			timeRange[0][1]+=30;
			timeRange[0][0]+=Math.floor(timeRange[0][1]/60);
			timeRange[0][1]%=60;
		}
	}
	function dateInit(k,date,dateBak){
		var nowDate = new Date();
	
		var newDate=dateBak.cloneNode(true);
		if (date.replaceNode)
			date.replaceNode(newDate);
		else
			date.parentNode.replaceChild(newDate,date);
		newDate.id+="_calender_notice_m";
		
		if (nowDate.getHours()> 11)
			newDate.setAttribute("range_start",today.addDate(cityDateAdd[city.value]+1).toStdString());
		else
			newDate.setAttribute("range_start",today.addDate(cityDateAdd[city.value]).toStdString());
		
		newDate.setAttribute("prohibit",timeDate[k][city.value]);
		$deal_elements(newDate);
		$init();
		return newDate;
	}

/*
	city.options.length=0;
	for (var cityId in cityData)
		city.options.add(new Option(cityData[cityId],cityId));
*/
	if (service1.checked)
		service1Click();
	else
		service2Click();

	//初始化select
	function selectAutoSizeInit(obj){
		if (!operator_.e_IE)
			return;
		var defaultWidth;
		obj.style.position="absolute";
		obj.style.zIndex=9999;
		obj.style.marginTop="-20px";
		obj.parentNode.insertBefore(__.createElement("<div style=\"height:20px;\"></div>"),obj);
		$r(obj,"onmouseover",function(){
			if (!defaultWidth)
				defaultWidth=obj.offsetWidth;
			obj.style.width="auto";
			__.body.title=[defaultWidth,obj.offsetWidth];
			if (defaultWidth<obj.offsetWidth){
				obj.style.width=obj.offsetWidth+"px";
				obj.focus();
			}else
				obj.style.width=defaultWidth+"px";
		});
		$r(obj,"onchange",function(){
			__.body.focus();
		});
		$r(obj,"onfocusout",function(){
			obj.style.width=defaultWidth+"px";
		});
	}
	selectAutoSizeInit(districtSelelct);
	selectAutoSizeInit(to);
	
	//restore
	if (_["restore"])
		restore();
});

function submitForm()
{
	var sCity;
	var sTaxiType;
	var sFromType;
	var tDate;
	var NumCtrl;
	var iPkg;
	
	sCity = $("city").value;

	if ($("service1").checked)
	{
		sTaxiType = $("service1").value;
	}
	else
	{
		sTaxiType = $("service2").value;
	}

	if (sTaxiType==1)
	{
		sFromType=$("from1").value;
	}
	else
	{
		sFromType=$("from2").value;
	}

	if (sTaxiType==1)
	{
		if(sFromType=="A" && $("to").value=="")
		{
			checkinfo($("to"), "Please select your destination.");
			return false;
		}
		if(sFromType=="H" && $("districtSelelct").value=="")
		{
			checkinfo($("districtSelelct"), "Please select your destination.");
			return false;
		}
	}
	
	NumCtrl = $("date1") || $("date1_calender_notice_m");
	tDate = NumCtrl.value.trim().toUpperCase();
	tDate = tDate==NumCtrl.notice?'':tDate;
	if (tDate=="")
	{
		checkinfo(NumCtrl, "Please provide the correct pick-up date.");
		return false;
	}

	if (! (tDate.parseEngDate()||""))
	{
		checkinfo(NumCtrl, "Please provide the correct pick-up date.");
		return false;
	}
		
	NumCtrl = $("time1");
	if (NumCtrl.value=="")
	{
		checkinfo(NumCtrl, "Please provide the correct pick-up time.");
		return false;
	}
	if (sTaxiType==2)
	{
		NumCtrl = $("date2") || $("date2_calender_notice_m");
		tDate = NumCtrl.value.trim().toUpperCase();
		tDate = tDate==NumCtrl.notice?'':tDate;
		if (tDate=="")
		{
			checkinfo(NumCtrl, "Please provide the correct drop-off date.");
			return false;
		}

		if (! (tDate.parseEngDate()||""))
		{
			checkinfo(NumCtrl, "Please provide the correct drop-off date.");
			return false;
		}
		
	}
	
	NumCtrl = $("cars");
	if (NumCtrl.value=="")
	{
		checkinfo(NumCtrl, "Please provide No. of cars.");
		return false;
	}
	
	NumCtrl = $("TaxiAdultNum");
	if (NumCtrl.value=="")
	{
		checkinfo(NumCtrl, "Please provide No. of Passengers.");
		return false;
	}
	
	NumCtrl = $("date1") || $("date1_calender_notice_m");
	$("TaxiDate1").value = NumCtrl.value.parseEngDate();
	
	NumCtrl = $("date2") || $("date2_calender_notice_m");
	$("TaxiDate2").value = NumCtrl.value.parseEngDate();
	
	if (sTaxiType==2)
	{
		if($("TaxiDate2").value.parseDate() - $("TaxiDate1").value.parseDate() < 0)
		{
			checkinfo($("date2_calender_notice_m"), "The drop-off date cannot be earlier than the pick-up date.")
			return false;
		}
	}
	
	iPkg = "0";
	try
	{
		iPkg = pkgData[sCity][sTaxiType][sFromType];
	}
	catch(e)
	{
		iPkg = "0";
	}
	
	if (iPkg == "0")
	{
		checkinfo($("city"), "Execuse me, we haven't provider the service.");
		return false;
	}
	$("pkg").value = iPkg;
	
	return true;
}

