function setdv(formobj,v) {
	//	oldv = formobj.options[formobj.selectedIndex].value;
	//	if (oldv=="non") {
	for(i=0;i<formobj.length;i++) {
		if(formobj.options[i].value==v) {
			formobj.options[i].selected=true;
			break;
		}
	}
	//	}
}
function setInitDate(datestr,yearobj,monthobj,dateobj) {
	setdv(yearobj,datestr.substring(2,4));
	var month=datestr.substring(5,7);
	var date=datestr.substring(8,10);
	if(month.indexOf("0")==0) {
		month=month.substring(1);
	}
	if(date.indexOf("0")==0) {
		date=date.substring(1);
	}
	monthobj.options[month].selected=true;
	dateobj.options[date].selected=true;
}
//joly
function setDayNum(datestr_v) {
	//alert(datestr_v.substring(0,4));
	//alert(datestr_v.substring(5,7));
	//alert(datestr_v.substring(5,7));
	var qq1=parseInt(datestr_v.substring(0,4));
	var qq2;
	if(parseInt(datestr_v.substring(5,6))==0) {
		qq2=parseInt(datestr_v.substring(6,7))-1;
	}else {
		qq2=parseInt(datestr_v.substring(5,7))-1;
	}
	var qq3=parseInt(datestr_v.substring(8,10));
	//alert(qq2);
	var selectdate=new Date(qq1,qq2,qq3);
	var qq4=selectdate.getDay();
	if(qq4==0) {
		document.getElementById('dayNum').value="星期日";
	}else if(qq4==1) {
		document.getElementById('dayNum').value="星期一";
	}else if(qq4==2) {
		document.getElementById('dayNum').value="星期二";
	}else if(qq4==3) {
		document.getElementById('dayNum').value="星期三";
	}else if(qq4==4) {
		document.getElementById('dayNum').value="星期四";
	}else if(qq4==5) {
		document.getElementById('dayNum').value="星期五";
	}else if(qq4==6) {
		document.getElementById('dayNum').value="星期六";
	}
	//GetDayOfWeek(datestr_v.substring(0,4),datestr_v.substring(5,7),datestr_v.substring(8,10));
	//alert(ii);
}
//joly
function setReDayNum(datestr_v) {
	//alert(datestr_v.substring(0,4));
	//alert(datestr_v.substring(5,7));
	//alert(datestr_v.substring(5,7));
	var qq1=parseInt(datestr_v.substring(0,4));
	var qq2;
	if(parseInt(datestr_v.substring(5,6))==0) {
		qq2=parseInt(datestr_v.substring(6,7))-1;
	}else {
		qq2=parseInt(datestr_v.substring(5,7))-1;
	}
	var qq3=parseInt(datestr_v.substring(8,10));
	//alert(qq2);
	var selectdate=new Date(qq1,qq2,qq3);
	var qq4=selectdate.getDay();
	if(qq4==0) {
		document.getElementById('dayNum_Back').value="星期日";
	}else if(qq4==1) {
		document.getElementById('dayNum_Back').value="星期一";
	}else if(qq4==2) {
		document.getElementById('dayNum_Back').value="星期二";
	}else if(qq4==3) {
		document.getElementById('dayNum_Back').value="星期三";
	}else if(qq4==4) {
		document.getElementById('dayNum_Back').value="星期四";
	}else if(qq4==5) {
		document.getElementById('dayNum_Back').value="星期五";
	}else if(qq4==6) {
		document.getElementById('dayNum_Back').value="星期六";
	}
	//GetDayOfWeek(datestr_v.substring(0,4),datestr_v.substring(5,7),datestr_v.substring(8,10));
	//alert(ii);
}
function GetDayOfWeek(y_v,m_v,d_v)
{
	var y=parseInt(y_v);
	var m=parseInt(m_v);
	var d=parseInt(d_v);
	alert(y);
	alert(m);
	alert(d);
	if(m==1)m=13;
	if(m==2)m=14;
	var week=(d+2*m+3*Math.round((m+1)/5)+y+Math.round(y/4)-Math.round(y/100)+Math.round(y/400))%7;
	var weekstr="";
	//alert(week);
	switch(week)
	{
		case 1:weekstr="星期一";
		break;
		case 2:weekstr="星期二";
		break;
		case 3:weekstr="星期三";
		break;
		case 4:weekstr="星期四";
		break;
		case 5:weekstr="星期五";
		break;
		case 6:weekstr="星期六";
		break;
		case 7:weekstr="星期日";
		break;
	}
	//alert(weekstr);
	document.getElementById('dayNum').value=weekstr;
}
function mkyearobj(objname) {
	document.write("<select name='",objname,"' size=1 class=itm onChange='setDateDayNum()'>");
	document.write("<option selected value=non>&nbsp</option>");
	yeart=0;
	yearv=0;
	year1="";
	today=new Date();
	yeart=today.getYear();
	if(yeart<=137&&yeart>=100) {
		yeart=yeart+1900;
	}
	if(yeart<=2037&&yeart>=2000) {
		yearv=yeart-2000;
		if(yearv<10) {
			year1="0"+yearv;
		}
		document.write("<option value=",year1,">",yeart,"年</option>");
		yeart=yeart+1;
		if(yeart<=2037&&yeart>=2000) {
			yearv=yearv+1;
			if(yearv<10) {
				year1="0"+yearv;
			}
			document.write("<option value=",year1,">",yeart,"年</option>");
		}
	}
	document.write("</select>");
}
function mkyearobj_r(objname) {
	document.write("<select name='",objname,"' size=1 class=itm onChange='setDateDayNum_r()'>");
	document.write("<option selected value=non>&nbsp</option>");
	yeart=0;
	yearv=0;
	year1="";
	today=new Date();
	yeart=today.getYear();
	if(yeart<=137&&yeart>=100) {
		yeart=yeart+1900;
	}
	if(yeart<=2037&&yeart>=2000) {
		yearv=yeart-2000;
		if(yearv<10) {
			year1="0"+yearv;
		}
		document.write("<option value=",year1,">",yeart,"年</option>");
		yeart=yeart+1;
		if(yeart<=2037&&yeart>=2000) {
			yearv=yearv+1;
			if(yearv<10) {
				year1="0"+yearv;
			}
			document.write("<option value=",year1,">",yeart,"年</option>");
		}
	}
	document.write("</select>");
}
function mkmonthobj(objname) {
	document.write("<select name='",objname,"' size=1 class='itm'  onChange='setDateDayNum()'>");
	document.write("<option value='non' selected>&nbsp</option>");
	document.write("<option value='jan'>1月</option>");
	document.write("<option value='feb'>2月</option>");
	document.write("<option value='mar'>3月</option>");
	document.write("<option value='apr'>4月</option>");
	document.write("<option value='may'>5月</option>");
	document.write("<option value='jun'>6月</option>");
	document.write("<option value='jul'>7月</option>");
	document.write("<option value='aug'>8月</option>");
	document.write("<option value='sep'>9月</option>");
	document.write("<option value='oct'>10月</option>");
	document.write("<option value='nov'>11月</option>");
	document.write("<option value='dec'>12月</option>");
	document.write("</select>");
}
function mkmonthobj_r(objname) {
	document.write("<select name='",objname,"' size=1 class='itm'  onChange='setDateDayNum_r()'>");
	document.write("<option value='non' selected>&nbsp</option>");
	document.write("<option value='jan'>1月</option>");
	document.write("<option value='feb'>2月</option>");
	document.write("<option value='mar'>3月</option>");
	document.write("<option value='apr'>4月</option>");
	document.write("<option value='may'>5月</option>");
	document.write("<option value='jun'>6月</option>");
	document.write("<option value='jul'>7月</option>");
	document.write("<option value='aug'>8月</option>");
	document.write("<option value='sep'>9月</option>");
	document.write("<option value='oct'>10月</option>");
	document.write("<option value='nov'>11月</option>");
	document.write("<option value='dec'>12月</option>");
	document.write("</select>");
}
function mkdayobj(objname) {
	document.write("<select name='",objname,"' size=1 class=itm  onChange='setDateDayNum()'>");
	document.write("<option selected value=non>&nbsp</option>");
	var datei=1;
	for(datei=1;datei<=31;datei++)
	{
		if(datei<10) {
			document.write("<option value=0",datei,">",datei,"日</option>");
		}
		else {
			document.write("<option value=",datei,">",datei,"日</option>");
		}
	}
	document.write("</select>");
}
function mkdayobj_r(objname) {
	document.write("<select name='",objname,"' size=1 class=itm  onChange='setDateDayNum_r()'>");
	document.write("<option selected value=non>&nbsp</option>");
	var datei=1;
	for(datei=1;datei<=31;datei++)
	{
		if(datei<10) {
			document.write("<option value=0",datei,">",datei,"日</option>");
		}
		else {
			document.write("<option value=",datei,">",datei,"日</option>");
		}
	}
	document.write("</select>");
}
function getdatenum(year,mon,day) {
	ret=0;
	year=remkyear(year);
	ret=Date.parse(year+"/"+mon+"/"+day)
	return ret;
}
function detecttoday() {
	daynum=0;
	year_v=0;
	month_v=0;
	day_v=0;
	today=new Date();
	year_v=today.getFullYear();
	month_v=today.getMonth()+1;
	day_v=today.getDate();
	daynum=Date.parse(year_v+"/"+month_v+"/"+day_v)
	return daynum;
}
function getmonthnum(monv) {
	retnum=0;
	switch(monv) {
		case "jan":retnum=1;
		break;
		case "feb":retnum=2;
		break;
		case "mar":retnum=3;
		break;
		case "apr":retnum=4;
		break;
		case "may":retnum=5;
		break;

		case "jun":retnum=6;
		break;
		case "jul":retnum=7;
		break;
		case "aug":retnum=8;
		break;
		case "sep":retnum=9;
		break;
		case "oct":retnum=10;
		break;
		case "nov":retnum=11;
		break;
		case "dec":retnum=12;
		break;
		default:retnum=0;
		break;
	}
	return retnum;
}
function getdaynum(monv) {
	retnum=0;
	if(!parseInt(monv,10)) {
		retnum=0;
	}
	else {
		retnum=parseInt(monv,10);
	}
	return retnum;
}
function detectmondayok(year,mon,day) {
	rec=true;
	year=remkyear(year);
	bufDate=new Date(year,mon,0);
	bufday=bufDate.getDate();
	if(day>bufday) {
		rec=false;
	}
	return rec;
}
function remkyear(year) {
	if(year<1000) {
		if(year<=37&&year>=0) {
			year=year+2000;
		}
		else {
			if(year<=99&&year>=80) {
				year=year+1900;
			}
		}
	}
	return year;
}
function detectonedate(formobj) {
	recstr="成功";
	bdate=0;
	by=0;
	bm=0;
	bd=0;
	by=formobj.year.options[formobj.year.selectedIndex].value;
	bm=formobj.month.options[formobj.month.selectedIndex].value;
	bd=formobj.date.options[formobj.date.selectedIndex].value;
	if(by!="non"&&bm!="non"&&bd!="non"&&detectmondayok(parseInt(by),getmonthnum(bm),getdaynum(bd))) {
		bdate=getdatenum(parseInt(by,10),getmonthnum(bm),getdaynum(bd));
		if(bdate<detecttoday()) {
			recstr="日期应晚于或等于当日 , 请重新填写 ! !";
		}
		else {
			recstr="成功";
		}
	}
	else {
		recstr="日期填写有误, 请重新填写 ! !";
	}
	return recstr;
}
function detecttwodate(formobj,vstr1,vstr2) {
	recstr="成功";
	bdate=0;
	edate=0;
	by=0;
	bm=0;
	bd=0;
	ey=0;
	em=0;
	ed=0;
	by=formobj.year.options[formobj.year.selectedIndex].value;
	bm=formobj.month.options[formobj.month.selectedIndex].value;
	bd=formobj.date.options[formobj.date.selectedIndex].value;
	ey=formobj.back_year.options[formobj.back_year.selectedIndex].value;
	em=formobj.back_month.options[formobj.back_month.selectedIndex].value;
	ed=formobj.back_date.options[formobj.back_date.selectedIndex].value;
	if(by!="non"&&bm!="non"&&bd!="non"&&detectmondayok(parseInt(by),getmonthnum(bm),getdaynum(bd))) {
		if(ey!="non"&&em!="non"&&ed!="non"&&detectmondayok(parseInt(ey),getmonthnum(em),getdaynum(ed))) {
			bdate=getdatenum(parseInt(by,10),getmonthnum(bm),getdaynum(bd));
			if(bdate<detecttoday()) {
				recstr=vstr1+"应晚于或等于当日 , 请重新填写 ! !";
			}
			else {
				edate=getdatenum(parseInt(ey,10),getmonthnum(em),getdaynum(ed));
				if(edate<bdate) {
					recstr=vstr1+"应早于或等于"+vstr2+" , 请重新填写 ! !";
				}
				else {
					recstr="成功";
				}
			}
		}
		else {
			recstr=vstr2+"填写有误, 请重新填写 ! !";
		}
	}
	else {
		recstr=vstr1+"填写有误, 请重新填写 ! !";
	}
	return recstr;
}
function detecttwowhere(formobj,vstr1,vstr2) {
	recstr="成功";
	dw=formobj.org.options[formobj.org.selectedIndex].value;
	rw=formobj.dst.options[formobj.dst.selectedIndex].value;
	if(dw==rw) {
		recstr=vstr1+"与"+vstr2+"不应一致, 请重新填写 ! ! ";
	}
	return recstr;
}
function detectthreewhere(formobj,vstr1,vstr2,vstr3) {
	recstr="成功";
	dw=formobj.org.options[formobj.org.selectedIndex].value;
	vw=formobj.via.options[formobj.via.selectedIndex].value;
	rw=formobj.dst.options[formobj.dst.selectedIndex].value;
	if(dw==vw) {
		recstr=vstr1+"与"+vstr2+"不应一致, 请重新填写 ! ! ";
	}
	if(vw==rw) {
		recstr=vstr2+"与"+vstr3+"不应一致, 请重新填写 ! ! ";
	}
	//if (dw==rw) {recstr = vstr1+"与"+vstr3+"不应一致, 请重新填写 ! ! ";}
	return recstr;
}
function detectfourwhere(formobj,vstr1,vstr2,vstr3,vstr4) {
	recstr="成功";
	dw=formobj.org.options[formobj.org.selectedIndex].value;
	vw=formobj.via.options[formobj.via.selectedIndex].value;
	vw1=formobj.via1.options[formobj.via1.selectedIndex].value;
	rw=formobj.dst.options[formobj.dst.selectedIndex].value;
	if(dw==vw) {
		recstr=vstr1+"与"+vstr2+"不应一致, 请重新填写 ! ! ";
	}
	if(vw1==rw) {
		recstr=vstr3+"与"+vstr4+"不应一致, 请重新填写 ! ! ";
	}
	return recstr;
}
function tktkindset(formobj,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11) {
	formobj.viacity.value=v1;
	formobj.dstcity.value=v2;
	formobj.fsttime.value=v3;
	formobj.sectime.value=v4;
	formobj.go_air.value=v5;
	formobj.back_air.value=v6;
	formobj.via.style.visibility=v7;
	formobj.back_year.style.visibility=v8;
	formobj.back_month.style.visibility=v9;
	formobj.back_date.style.visibility=v10;
	formobj.back_airline.style.visibility=v11;
}
function kindset(formobj) {
	vstr="";
	for(var i=0;i<formobj.elements.length;i++) {
		var e=formobj.elements[i];
		if(e.name=="bookkind1") {
			if(e.checked) {
				vstr=e.value;
				break;
			}
		}
	}
	for(i=0;i<formobj.bookkind.length;i++) {
		if(formobj.bookkind.options[i].value==vstr) {
			formobj.bookkind.options[i].selected=true;
			break;
		}
	}
	//kindselectsch(formobj);
	kindselect(formobj);
}
function initcity(formobj) {
	setdv(formobj.org,"PEK");
	setdv(formobj.via,"SHA");
	setdv(formobj.dst,"CAN");
}
function inter_initcity(formobj) {
	setdv(formobj.org,"PEK");
	setdv(formobj.via,"LAX");
	setdv(formobj.dst,"NYC");
}
function inter_city_dancheng(formobj) {
	setdv(formobj.orgcity,"PEK");
	setdv(formobj.dstcity,"NYC");
}