function init(formobj){
year_v="";
b_year_v="";
b_year_v=formobj.back_year.options[formobj.back_year.selectedIndex].value;
year_v=formobj.year.options[formobj.year.selectedIndex].value;
today=new Date();
yearind = today.getFullYear();
if (yearind<=2037 && yearind>=2000){yearind = yearind - 2000;}
else{if (yearind<=1999 && yearind>=1980){yearind = yearind - 1900;}}
if (formobj.year.length > 0){
	for (i=0; i<formobj.year.length; i++){
		if (parseInt(formobj.year.options[i].value,10)==yearind) {
			if (year_v=="non"){formobj.year.options[i].selected=true;}
			if (b_year_v=="non"){formobj.back_year.options[i].selected=true;}	
			break;
		}
	}
}
if (year_v=="non") {	
	formobj.month.options[today.getMonth()+ 1].selected=true;
	formobj.date.options[today.getDate()].selected=true;
}
if (b_year_v=="non") {	
	formobj.back_month.options[today.getMonth()+ 1].selected=true;
	formobj.back_date.options[today.getDate()].selected=true;  
}  
formobj.h_ok.value = "";
kindselect(formobj);
}

function goaction(formobj){
	var actionkind="";
	actionkind = formobj.actionkind.value;
	switch (actionkind) {
	case "oneway": 
		goactiononeway(formobj); 
		break;
	case "airreturn": 
		goactionairreturn(formobj); 
		break;
	case "muti": 
		goactionmuti(formobj); 
		break;
	default: 
		goactiononeway(formobj); 
		break;
	}
}

function goactiononeway(formobj){
recstr = "";
	recstr = detectonedate(formobj);
	if (recstr=="成功") {
		recstr = detecttwowhere(formobj,"出发城市","到达城市");
		if (recstr=="成功") {
			formobj.orgyear.value = formobj.year.options[formobj.year.selectedIndex].text;
			if (formobj.h_ok.value == ""){
				formobj.submit();
				formobj.h_ok.value = "ok";
			}
		}
		else{alert(recstr);}	
	}
	else{alert(recstr);}
}
function goactionairreturn(formobj){
recstr = "";
	recstr = detecttwodate(formobj,"出发日期","返程日期");
	if (recstr=="成功") {
		recstr = detecttwowhere(formobj,"出发城市","到达城市");
		if (recstr=="成功") {
			formobj.orgyear.value = formobj.year.options[formobj.year.selectedIndex].text;
			formobj.backyear.value = formobj.back_year.options[formobj.back_year.selectedIndex].text;
			if (formobj.h_ok.value == ""){
				formobj.submit();
				formobj.h_ok.value = "ok";
			}
		}
		else{alert(recstr);}	
	}
	else{alert(recstr);}
}
function goactionmuti(formobj){
recstr = "";
	recstr = detecttwodate(formobj,"第一出发日","第二出发日");
	if (recstr=="成功") {
		recstr = detectthreewhere(formobj,"出发城市","第一到达","第二到达");
		if (recstr=="成功") {
			formobj.orgyear.value = formobj.year.options[formobj.year.selectedIndex].text;
			formobj.backyear.value = formobj.back_year.options[formobj.back_year.selectedIndex].text;
			if (formobj.h_ok.value == ""){
				formobj.submit();
				formobj.h_ok.value = "ok";
			}
		}
		else{alert(recstr);}	
	}
	else{alert(recstr);}
}
function kindselect(formobj){
var kind = "";
var str1 = "";
for (var i=0;i<formobj.elements.length;i++)
{
	var e = formobj.elements[i];
      	str1 = e.name;
       	if (str1=="airkind"){
       		if (e.checked==1){
       			kind = e.value;
       			break;
       		}
	}
}
switch (kind) {
case "oneway": 
                formobj.actionkind.value="oneway";
		formobj.viacity.value ="";
		formobj.via.style.visibility = "hidden";
		formobj.dstcity.value = "到达城市:";
		formobj.fsttime.value = "出发日期:";
		formobj.sectime.value = "";
		formobj.back_year.style.visibility = "hidden";
		formobj.back_month.style.visibility = "hidden";
		formobj.back_date.style.visibility = "hidden";
		//formobj.timergo2.value = "";
		setsectimego(formobj,"hidden");
	        break;
case "airreturn": 
                formobj.actionkind.value="airreturn";
		formobj.viacity.value ="";
		formobj.via.style.visibility = "hidden";
		formobj.dstcity.value = "到达城市:";
		formobj.fsttime.value = "出发日期:";
		formobj.sectime.value = "返程日期:";
		formobj.back_year.style.visibility = "visible";
		formobj.back_month.style.visibility = "visible";
		formobj.back_date.style.visibility = "visible";
		//formobj.timergo2.value = "";
		setsectimego(formobj,"visible");
	        break;
case "muti": 
                formobj.actionkind.value="muti";
		formobj.viacity.value ="第一到达城市:";
		formobj.via.style.visibility = "visible";
		formobj.dstcity.value = "第二到达城市:";
		formobj.fsttime.value = "第一出发日期:";
		formobj.sectime.value = "第二出发日期:";
		formobj.back_year.style.visibility = "visible";
		formobj.back_month.style.visibility = "visible";
		formobj.back_date.style.visibility = "visible";
		//formobj.timergo2.value = "";
		setsectimego(formobj,"visible");
	        break;
default: 
		for (var i=0;i<formobj.elements.length;i++)
		{
			var e = formobj.elements[i];
		      	str1 = e.name;
		       	if (str1=="airkind"){
		       		if (e.value=="oneway"){
		       			e.checked = 1;
		       			break;
		       		}
			}
		}
		formobj.viacity.value ="";
		formobj.via.style.visibility = "hidden";
		formobj.dstcity.value = "到达城市:";
		formobj.fsttime.value = "出发日期:";
		formobj.sectime.value = "";
		formobj.back_year.style.visibility = "hidden";
		formobj.back_month.style.visibility = "hidden";
		formobj.back_date.style.visibility = "hidden";
		//formobj.timergo2.value = "";
		setsectimego(formobj,"hidden");
	        break;
}
}
function setsectimego(formobj,stbs){
var gobs=0;
		for (var i=0;i<formobj.elements.length;i++)
		{
			var e = formobj.elements[i];
		      	str1 = e.name;
		       	if (str1=="timego"){
		       		if (gobs==0){gobs = gobs + 1;}
		       		else{
		       			if (gobs > 0){ e.style.visibility = stbs;break;}
		       		}
			}
		}
}
function goactionxl(action,bookformobj,xlformobj){
	recstr = "";
	recstr = detecttwowhere(bookformobj,"出发地","到达地");
	if (recstr=="成功") {
		xlformobj.origin.value = bookformobj.org.options[bookformobj.org.selectedIndex].value;
		xlformobj.dest.value = bookformobj.dst.options[bookformobj.dst.selectedIndex].value;
		xlformobj.action = action;
		xlformobj.submit();
	}
	else{alert(recstr);}	
}
function goactionbq(bookformobj,bqformobj){
recstr = "";
	recstr = detectonedate(bookformobj);
	if (recstr=="成功") {
		recstr = detecttwowhere(bookformobj,"出发城市","到达城市");
		if (recstr=="成功") {
			bqformobj.org.value = bookformobj.org.options[bookformobj.org.selectedIndex].value;
			bqformobj.dst.value = bookformobj.dst.options[bookformobj.dst.selectedIndex].value;
			bqformobj.year.value = bookformobj.year.options[bookformobj.year.selectedIndex].value;
			bqformobj.month.value = bookformobj.month.options[bookformobj.month.selectedIndex].value;
			bqformobj.date.value = bookformobj.date.options[bookformobj.date.selectedIndex].value;
			bqformobj.airline.value = bookformobj.airline.options[bookformobj.airline.selectedIndex].value;
			formbq.submit();
		}
		else{alert(recstr);}	
	}
	else{alert(recstr);}
}
