// JavaScript Document
/*
	set checked
*/
function setChecked(val) {
	var tp = document.form2.tp;
	for(var i=0;i<tp.length;i++) {
		if(i==parseInt(val)) {
			tp[i].checked = true;
		}
	}
}

/*
	set search keywords
*/
function setVal(o,val) {
	if(o) {
		o.value = val;
	}
}

/*
*/
function IsEmptyTxt(o,txt) {
	if(o) {
		if(o.value.replace('From','').replace('To','')=="") {
			alert(txt);
			o.value = "";
			o.focus();
			return true;
		}
		return false;
	}
	return false;
}

/*
*/
function clsSearchTxt(o,txt) {
	if(o.value==txt) o.value = "";
}
/**/
function resSearchTxt(o,txt) {
	if(o.value=="") o.value = txt;
}
/*
	form load
*/
function bus_formload() {
	var frm = document.frm_bus1;
	if (frm) {
//		frm.from.onfocus = function () { clsSearchTxt(this,'From'); }
//		frm.from.onblur = function() { resSearchTxt(this,'From'); }
//		frm.to.onfocus = function() { clsSearchTxt(this,'To'); }
//		frm.to.onblur = function() { resSearchTxt(this,'To'); }
		frm.onsubmit = function() {
			return !IsEmptyTxt(this.from,"Please input your departure bus stops.") && !IsEmptyTxt(this.to,"Please input your arrival bus stops.");
		}
	}
	var frm2 = document.frm_bus2;
	if (frm2) {
		frm2.onsubmit = function() {
			return !IsEmptyTxt(this.q,"Please input a bus stop or route.");
		}
	}
	try {
		setChecked(ss);
		setVal(document.form2.q,kw);
		setVal(document.form1.from,kw_from);
		setVal(document.form1.to,kw_to);
	}
	catch(e) { }
}

/**/
function showalt(flag)
{
	var altstr=document.getElementById("btalt");
	if(flag=="1"){altstr.innerHTML="Search all the buses pass a certain bus stop. ";}
	if(flag=="2"){altstr.innerHTML="Search a certain bus line. ";}
}

