// JavaScript Document

function tbswap ( passed_tab )
{
	var tabs = new Array ( "flights", "cars", "hotels", "cruises", "maps" )
	
	// disable all tabs
	
	for ( i = 0; i < tabs.length; i++ )
	{
		// icons
		
		this_tab = document.getElementById( tabs[i] + "-icon" );
		this_tab.src = "/Travel/images/tb-" + tabs[i] + ".jpg";

		// tab
		
		this_tab = document.getElementById( "tb-" + tabs[i] + "-form" );
		this_tab.style.display = "none";
	}
	
	// enable active tab
	
		// icons
		
		this_tab = document.getElementById( passed_tab + "-icon" );
		this_tab.src = "/Travel/images/tb-" + passed_tab + "-active.jpg";

		// tab
		
		active_tab = document.getElementById( "tb-" + passed_tab + "-form" );
		active_tab.style.display = "block";
}
function validate_input ( searchtype )
{
	switch ( searchtype )
	{
		case "FLIGHT" :
			format_date ( "tbflightsform", "dep" );
			format_date ( "tbflightsform", "ret" );
			break;
		case "HOTEL" :
			format_date ( "tbhotelsform", "checkin" );
			format_date ( "tbhotelsform", "checkout" );
			break;
		case "CAR" :
			format_date ( "tbcarsform", "pickup" );
			format_date ( "tbcarsform", "dropoff" );
			break;
	}
}
function format_date ( formname, prefix )
{
	months = new Array( 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC' );
	eval ( "theform = document." + formname + ";" );
	eval ( "provided_date = theform." + prefix + "date.value;" );
	eval ( "monthfield = theform." + prefix + "Month;" );
	eval ( "dayfield = theform." + prefix + "Day;" );
	eval ( "yearfield = theform." + prefix + "Year;" );
	splitdate = provided_date.split( "/" );
	month_number = splitdate[0];
	new_day = splitdate[1];
	new_year = splitdate[2];
	month_cast = parseInt(month_number);
	month_cast--;
	month_text = months[month_cast];
	//alert ( "month " + month_text );
	monthfield.value=month_text;
	dayfield.value = new_day;
	yearfield.value = new_year;	
}