function selectCallback1(s) 
{  
// This function gets called when selection changes  
	if( s.selectedIndex == -1 ) return;  
	var source_city = s.options[s.selectedIndex].value;
	var destination_city = document.getElementById("destination_city").options[document.getElementById("destination_city").selectedIndex].value;
	var destination_station = document.getElementById("destination_station").options[document.getElementById("destination_station").selectedIndex].value;
	var page = document.getElementById("page").value;
	document.location.href= page + '.php?section=search1'
	+ '&source_city=' + encodeURIComponent(source_city)
	+ '&destination_city=' + encodeURIComponent(destination_city)
	+ '&destination_station=' + destination_station
	;
} 

function selectCallback2(s) 
{  
// This function gets called when selection changes  
	if( s.selectedIndex == -1 ) return;  
	var destination_city = s.options[s.selectedIndex].value;
	var source_station = document.getElementById("source_station").options[document.getElementById("source_station").selectedIndex].value;
	var source_city = document.getElementById("source_city").options[document.getElementById("source_city").selectedIndex].value;
	var page = document.getElementById("page").value;
	document.location.href=page + '.php?section=search1'
	+ '&source_city=' + encodeURIComponent(source_city)
	+ '&source_station=' + source_station
	+ '&destination_city=' + encodeURIComponent(destination_city)
	;
} 

function attachBehaviors() 
{  
// Attach event handler to your select object  
	var source_city = document.getElementById("source_city");  
	if( source_city )  
	{  
		source_city.onchange = function(){selectCallback1(source_city);};  
	}
	
	var destination_city = document.getElementById("destination_city");  
	if( destination_city )  
	{  
		destination_city.onchange = function(){selectCallback2(destination_city);};  
	}	
}

window.onload = attachBehaviors;