﻿// JavaScript Document
var cooo1;
jQuery(function(){
	cooo1 = new reFocus();
	cooo1.create("from1",0);
	cooo1.create("to1",0);
	cooo1.create("tstop",0);
	
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Opera") == -1);
	if(isIE && false){
		cooo1.listDB[0].Obj.div.style.marginTop="13px";
		cooo1.listDB[1].Obj.div.style.marginTop="13px";
		cooo1.listDB[2].Obj.div.style.marginTop="13px";
		
		cooo1.listDB[0].Obj.iframe.style.width="120px";
		cooo1.listDB[1].Obj.iframe.style.width="120px";
		cooo1.listDB[2].Obj.iframe.style.width="120px";
	}

	document.getElementById("tp2").onclick=function(){
		if(this.checked){
			document.getElementById("tstop").style.display="";
			document.getElementById("trainno1").style.display="none";
			$("#idvia").html("Via.");
		}else{
			document.getElementById("tstop").style.display="none";
			document.getElementById("trainno1").style.display="";
			$("#idvia").html("&nbsp;");
		}
	}
	
	document.getElementById("tp3").onclick=function(){
		if(this.checked){
			document.getElementById("tstop").style.display="none";
			document.getElementById("trainno1").style.display="";
			$("#idvia").html("&nbsp;");
		}else{
			document.getElementById("tstop").style.display="";
			document.getElementById("trainno1").style.display="none";
			$("#idvia").html("Via.");
		}
	}
});

function chkform1(){
	var obj1=document.getElementById("from1");
	var obj2=document.getElementById("to1");
	if(obj1.value.trim()=="" && obj2.value.trim()==""){
		alert("Please enter your start and destination first!");
		obj1.focus();
		return false;
	}else if(obj1.value.trim()==""){
		document.getElementById("tp2").checked=true;
		document.getElementById("tstop").value=obj2.value;
		document.getElementById("form3").submit();
		return false;
	}else if(obj2.value.trim()==""){
		document.getElementById("tp2").checked=true;
		document.getElementById("tstop").value=obj1.value;
		document.getElementById("form3").submit();
		return false;
	}
	return true;
}

function chkform2(){
	var obj1=document.getElementById("tstop");
	if(obj1.value.trim()==""){
		alert("Please enter a city first!");
		obj1.focus();
		return false;
	}
	return true;
}

function chkform3(){
	var obj1=document.getElementById("trainno1");
	if(obj1.value.trim()==""){
		alert("Please enter a train no. first!");
		obj1.focus();
		return false;
	}
	return true;
}

function chkFlightform(){
	if(document.getElementById("tp2").checked){
		return chkform2();
	}else{
		return chkform3();
	}
}
