<!-- 

var listing_style = "states";

var states = new Array(); 
states["AZ"] = "Arizona";
states["CA"] = "California";
states["CT"] = "Connecticut";
states["DC"] = "District of Columbia";
states["DE"] = "Delaware";
states["FL"] = "Florida";
states["GA"] = "Georgia";
states["IL"] = "Illinois";
states["MA"] = "Massachusetts";
states["MD"] = "Maryland";
states["NC"] = "North Carolina";
states["NH"] = "New Hampshire";
states["NJ"] = "New Jersey";
states["NV"] = "Nevada";
states["NY"] = "New York";
states["OH"] = "Ohio";
states["PA"] = "Pennsylvania";
states["VA"] = "Virginia";
states["WA"] = "Washington";
states["BC"] = "British Columbia";
 
 //-->

<!--
var b_cities = new Array('Albany, NY', 'Alexandria, VA', 'Amherst, NY', 'Anaheim, CA', 'Arlington, VA', 'Atlanta, GA', 'Baltimore, MD', 'Bellingham Airport, WA', 'Bethesda, MD', 'Boston, MA', 'Carlisle, PA', 'Chicago, IL', 'Cincinnati, OH', 'Cupertino, CA', 'Elizabeth, NJ', 'Fairfax, VA', 'Greensboro, NC', 'Hagerstown, MD', 'Harrisburg, PA', 'Hartford, CT', 'Irvington, NJ', 'JFK Airport, NY', 'Jersey City, NJ', 'John Wayne Airport, CA', 'King of Prussia, PA', 'Kingston, NY', 'LAX Airport or Hotels, CA', 'LGA Airport, NY', 'Lancaster, PA', 'Las Vegas, NV', 'Liverpool, NY', 'Los Angeles, CA', 'Miami, FL', 'New Castle, DE', 'New York, NY', 'Newark, DE', 'Newark, NJ', 'Norfolk, VA', 'Oakland, CA', 'Orlando, FL', 'Philadelphia, PA', 'Phoenix, AZ', 'Raleigh, NC', 'Richmond, VA', 'Rochester, NY', 'Rockville, MD', 'San Diego, CA', 'San Francisco, CA', 'Seattle Airport, WA', 'Seattle Downtown, WA', 'Silver Spring, MD', 'Springfield, VA', 'State College, PA', 'Syracuse, NY', 'Tulalip, WA', 'Union City, NJ', 'Vancouver, BC', 'Virginia Beach, VA', 'Washington, DC', 'Wheaton, MD', 'White Flint, MD', 'Willow Grove, PA', 'Wilmington, DE', 'Woodbury Outlets, NY', 'York, PA');
var g_bus = new Object;
var total_cities = b_cities.length;
for (i=0; i<total_cities; i++)
  g_bus[b_cities[i]] = new Array;

g_bus['Albany, NY'][0] = 'New York, NY';
g_bus['Alexandria, VA'][0] = 'New York, NY';
g_bus['Amherst, NY'][0] = 'New York, NY';
g_bus['Anaheim, CA'][0] = 'John Wayne Airport, CA';
g_bus['Anaheim, CA'][1] = 'LAX Airport or Hotels, CA';
g_bus['Anaheim, CA'][2] = 'Las Vegas, NV';
g_bus['Anaheim, CA'][3] = 'Los Angeles, CA';
g_bus['Anaheim, CA'][4] = 'San Diego, CA';
g_bus['Anaheim, CA'][5] = 'Universal Studios, CA';
g_bus['Arlington, VA'][0] = 'New York, NY';
g_bus['Atlanta, GA'][0] = 'Greensboro, NC';
g_bus['Atlanta, GA'][1] = 'New York, NY';
g_bus['Atlanta, GA'][2] = 'Washington, DC';
g_bus['Baltimore, MD'][0] = 'New York, NY';
g_bus['Bellingham Airport, WA'][0] = 'Vancouver, BC';
g_bus['Bethesda, MD'][0] = 'New York, NY';
g_bus['Boston, MA'][0] = 'Hartford, CT';
g_bus['Boston, MA'][1] = 'Mohegan Sun Casino, CT';
g_bus['Boston, MA'][2] = 'New York, NY';
g_bus['Carlisle, PA'][0] = 'New York, NY';
g_bus['Chicago, IL'][0] = 'New York, NY';
g_bus['Cincinnati, OH'][0] = 'New York, NY';
g_bus['Cupertino, CA'][0] = 'Los Angeles, CA';
g_bus['Elizabeth, NJ'][0] = 'Philly Park Casino, PA';
g_bus['Fairfax, VA'][0] = 'Atlantic City, NJ';
g_bus['Greensboro, NC'][0] = 'Atlanta, GA';
g_bus['Greensboro, NC'][1] = 'New York, NY';
g_bus['Greensboro, NC'][2] = 'Washington, DC';
g_bus['Hagerstown, MD'][0] = 'New York, NY';
g_bus['Harrisburg, PA'][0] = 'New York, NY';
g_bus['Hartford, CT'][0] = 'Boston, MA';
g_bus['Hartford, CT'][1] = 'New York, NY';
g_bus['Irvington, NJ'][0] = 'Philly Park Casino, PA';
g_bus['JFK Airport, NY'][0] = 'New York, NY';
g_bus['JFK Airport, NY'][1] = 'Newark, NJ';
g_bus['JFK Airport, NY'][2] = 'Union City, NJ';
g_bus['John Wayne Airport, CA'][0] = 'Anaheim, CA';
g_bus['King of Prussia, PA'][0] = 'New York, NY';
g_bus['Kingston, NY'][0] = 'New York, NY';
g_bus['LAX Airport or Hotels, CA'][0] = 'Anaheim, CA';
g_bus['LAX Airport or Hotels, CA'][1] = 'Las Vegas, NV';
g_bus['LAX Airport or Hotels, CA'][2] = 'San Diego, CA';
g_bus['LGA Airport, NY'][0] = 'New York, NY';
g_bus['Lancaster, PA'][0] = 'New York, NY';
g_bus['Las Vegas, NV'][0] = 'Anaheim, CA';
g_bus['Las Vegas, NV'][1] = 'LAX Airport or Hotels, CA';
g_bus['Las Vegas, NV'][2] = 'Los Angeles, CA';
g_bus['Las Vegas, NV'][3] = 'San Diego, CA';
g_bus['Liverpool, NY'][0] = 'New York, NY';
g_bus['Los Angeles, CA'][0] = 'Anaheim, CA';
g_bus['Los Angeles, CA'][1] = 'Cupertino, CA';
g_bus['Los Angeles, CA'][2] = 'Las Vegas, NV';
g_bus['Los Angeles, CA'][3] = 'Oakland, CA';
g_bus['Los Angeles, CA'][4] = 'Phoenix, AZ';
g_bus['Los Angeles, CA'][5] = 'San Diego, CA';
g_bus['Los Angeles, CA'][6] = 'San Francisco, CA';
g_bus['Miami, FL'][0] = 'Orlando, FL';
g_bus['New Castle, DE'][0] = 'Atlantic City, NJ';
g_bus['New York, NY'][0] = 'Albany, NY';
g_bus['New York, NY'][1] = 'Alexandria, VA ';
g_bus['New York, NY'][2] = 'Amherst, NY';
g_bus['New York, NY'][3] = 'Arlington, VA';
g_bus['New York, NY'][4] = 'Atlanta, GA';
g_bus['New York, NY'][5] = 'Baltimore, MD';
g_bus['New York, NY'][6] = 'Bethesda, MD';
g_bus['New York, NY'][7] = 'Boston, MA';
g_bus['New York, NY'][8] = 'Carlisle, PA';
g_bus['New York, NY'][9] = 'Chicago, IL';
g_bus['New York, NY'][10] = 'Cincinnati, OH';
g_bus['New York, NY'][11] = 'Greensboro, NC';
g_bus['New York, NY'][12] = 'Hagerstown, MD';
g_bus['New York, NY'][13] = 'Harrisburg, PA';
g_bus['New York, NY'][14] = 'Hartford, CT';
g_bus['New York, NY'][15] = 'JFK Airport, NY';
g_bus['New York, NY'][16] = 'King of Prussia, PA';
g_bus['New York, NY'][17] = 'Kingston, NY';
g_bus['New York, NY'][18] = 'LGA Airport, NY';
g_bus['New York, NY'][19] = 'Lancaster, PA';
g_bus['New York, NY'][20] = 'Liverpool, NY';
g_bus['New York, NY'][21] = 'Norfolk, VA';
g_bus['New York, NY'][22] = 'Philadelphia, PA';
g_bus['New York, NY'][23] = 'Philly Park Casino, PA';
g_bus['New York, NY'][24] = 'Raleigh, NC';
g_bus['New York, NY'][25] = 'Richmond, VA';
g_bus['New York, NY'][26] = 'Rochester, NY';
g_bus['New York, NY'][27] = 'Rockville, MD';
g_bus['New York, NY'][28] = 'Silver Spring, MD';
g_bus['New York, NY'][29] = 'State College, PA';
g_bus['New York, NY'][30] = 'Syracuse, NY';
g_bus['New York, NY'][31] = 'Virginia Beach, VA';
g_bus['New York, NY'][32] = 'Washington, DC';
g_bus['New York, NY'][33] = 'White Flint, MD';
g_bus['New York, NY'][34] = 'Willow Grove, PA';
g_bus['New York, NY'][35] = 'Wilmington, DE';
g_bus['New York, NY'][36] = 'Woodbury Outlets, NY';
g_bus['New York, NY'][37] = 'York, PA';
g_bus['Newark, DE'][0] = 'Atlantic City, NJ';
g_bus['Newark, NJ'][0] = 'Philly Park Casino, PA';
g_bus['Norfolk, VA'][0] = 'New York, NY';
g_bus['Oakland, CA'][0] = 'Los Angeles, CA';
g_bus['Orlando, FL'][0] = 'Miami, FL';
g_bus['Philadelphia, PA'][0] = 'Elizabeth, NJ';
g_bus['Philadelphia, PA'][1] = 'Irvington, NJ';
g_bus['Philadelphia, PA'][2] = 'Jersey City, NJ';
g_bus['Philadelphia, PA'][3] = 'New York, NY';
g_bus['Philadelphia, PA'][4] = 'Newark, NJ';
g_bus['Philadelphia, PA'][5] = 'Union City, NJ';
g_bus['Philadelphia, PA'][6] = 'Washington, DC';
g_bus['Phoenix, AZ'][0] = 'Los Angeles, CA';
g_bus['Raleigh, NC'][0] = 'New York, NY';
g_bus['Richmond, VA'][0] = 'New York, NY';
g_bus['Richmond, VA'][1] = 'Washington, DC';
g_bus['Rochester, NY'][0] = 'New York, NY';
g_bus['Rockville, MD'][0] = 'New York, NY';
g_bus['San Diego, CA'][0] = 'Anaheim, CA';
g_bus['San Diego, CA'][1] = 'LAX Airport or Hotels, CA';
g_bus['San Diego, CA'][2] = 'Las Vegas, CA';
g_bus['San Diego, CA'][3] = 'Los Angeles, CA';
g_bus['San Francisco, CA'][0] = 'Los Angeles, CA';
g_bus['San Francisco, CA'][1] = 'Reno, NV';
g_bus['Seattle Airport, WA'][0] = 'Vancouver, BC';
g_bus['Seattle Downtown, WA'][0] = 'Vancouver, BC';
g_bus['Silver Spring, MD'][0] = 'New York, NY';
g_bus['Springfield, VA'][0] = 'Atlantic City, NJ';
g_bus['State College, PA'][0] = 'New York, NY';
g_bus['Syracuse, NY'][0] = 'New York, NY';
g_bus['Tulalip, WA'][0] = 'Vancouver, BC';
g_bus['Union City, NJ'][0] = 'Philly Park Casino, PA';
g_bus['Vancouver, BC'][0] = 'Bellingham Airport, WA';
g_bus['Vancouver, BC'][1] = 'Seattle Airport, WA';
g_bus['Vancouver, BC'][2] = 'Seattle Downtown, WA';
g_bus['Vancouver, BC'][3] = 'Tulalip, WA';
g_bus['Virginia Beach, VA'][0] = 'New York, NY';
g_bus['Washington, DC'][0] = 'Atlanta, GA';
g_bus['Washington, DC'][1] = 'Atlantic City, NJ';
g_bus['Washington, DC'][2] = 'Greensboro, NC';
g_bus['Washington, DC'][3] = 'New York, NY';
g_bus['Washington, DC'][4] = 'Philadelphia, PA';
g_bus['Washington, DC'][5] = 'Richmond, VA';
g_bus['Wheaton, MD'][0] = 'Atlantic City, NJ';
g_bus['White Flint, MD'][0] = 'New York, NY';
g_bus['Willow Grove, PA'][0] = 'New York, NY';
g_bus['Wilmington, DE'][0] = 'Atlantic City, NJ';
g_bus['Wilmington, DE'][1] = 'New York, NY';
g_bus['Woodbury Outlets, NY'][0] = 'New York, NY';
g_bus['York, PA'][0] = 'New York, NY';


///////////// function
function update_bus_from()
{

	var bf_obj = get_bus_from_obj();

	while(bf_obj.hasChildNodes())
	{
		bf_obj.removeChild(bf_obj.lastChild);

	}
	bf_obj.options[0] = new Option("Departure City","");

	if(listing_style == 'states')
	{
		bus_listing_states(bf_obj);
	}
	else
	{
		//document.getElementById("listing_style").checked = false;
		bus_listing_cityes(bf_obj);
	}
}

function bus_listing_cityes(bf_obj)
{


	for (var i=0; i<b_cities.length; i++)
	{
		var j = i+1;
		bf_obj.options[j] = new Option(b_cities[i], b_cities[i]);
	}
}

function bus_listing_states(bf_obj)
{
	var opg_arr = new Array();

	for (var opg in states )
	{
		opg_arr[opg] = document.createElement("optgroup");

		opg_arr[opg].label = states[opg];
	}

	for (var i=0; i<b_cities.length; i++)
	{
		var j = i+1;

		var o = document.createElement("option");

		var arr = b_cities[i].split(/,\s+/);

		o.value = b_cities[i];

		o.innerHTML = arr[0];

		var short_state = arr[1];

		if(opg_arr[short_state])
			opg_arr[short_state].appendChild(o);

	}

	for(var opg in opg_arr) {

		opg_arr[opg].label = states[opg];

		if(opg_arr[opg].hasChildNodes())
			bf_obj.appendChild(opg_arr[opg]);

	}
}

function change_r_date(d)
{
    if (document.bus_search)
    {
		if (document.bus_search.b_roundtrip.checked == false)
		{
			document.bus_search.return_date.value = '';
		}
		else
		{
			if (d == "")
			{
				d = "N/A";
			}
			var f_count = document.forms.length;
			for (var i=0; i<f_count; ++i)
			{
				if (document.forms[i].r_date)
				{
					document.forms[i].r_date.value = d;
				}
			}
		}
    }
}

function change_passengers(n)
{
    if (document.bus_search)
    {
        var f_count = document.forms.length;
        for (var i=0; i<f_count; ++i)
        {
            if (document.forms[i].vol)
            {
                document.forms[i].vol.value = n;
            }
        }
    }
}

function select_oneway(no_update)
{
	if (document.bus_search)
	{
		document.bus_search.return_date.value = '';
		conditional_update();
	}
}

function select_roundtrip(d)
{
	if (document.bus_search)
	{
		var rd_obj = document.bus_search.return_date;
		if (d == null)
		{
			d = document.bus_search.filter_date.value;
			var darray = d.split("-");
			var start_d = new Date(darray[0], darray[1]-1, darray[2]);
			var r_d = new Date(start_d.valueOf() + 172800000);
			var m = r_d.getMonth() + 1;
			if (m < 10)
			{
				m = "0" + m;
			}
			var dt = r_d.getDate();
			if (dt < 10)
			{
				dt = "0" + dt;
			}
			rd_obj.value = r_d.getFullYear() + '-' + m + '-' + dt;
		}
		conditional_update();
	}
}

function enable_roundtrip()
{
        if (document.bus_search)
        {
			document.bus_search.b_roundtrip.checked = true;
			var t_obj = document.getElementById("timeList");
			var silent = (t_obj && t_obj.innerHTML != "");
			select_roundtrip('');
			if (silent != true)
			{
				br_cal.select(document.bus_search.return_date,'br_date','yyyy-MM-dd');
			}
		}
}

function select_preset()
{
	if (document.bus_search && document.bus_search.sbus_from)
	{
		document.bus_search.sbus_from.disabled = true;
		document.bus_search.sbus_to.disabled = true;
		document.bus_search.bus_from.disabled = false;
		document.bus_search.bus_to.disabled = false;
	}
}

function select_search()
{
    if (document.bus_search && document.bus_search.sbus_from)
    {
		document.bus_search.sbus_from.disabled = false;
		document.bus_search.sbus_to.disabled = false;
		document.bus_search.bus_from.disabled = true;
		document.bus_search.bus_to.disabled = true;
	}
}
///////////////////////////// list by states //////////

function list_by_states(f) {

	var bt_obj = get_bus_to_obj();
	var f_states = new Array();
	var opg_arr = new Array();

	for (var i=0; i<g_bus[f].length; i++)
	{

		var citys_arr = g_bus[f][i].split(/,\s+/);
		citys_arr.push(g_bus[f][i]);
		opg_arr.push(citys_arr);
		if( f_states.toString().indexOf(citys_arr[1])<0 ){

			f_states.push(citys_arr[1]);
		}

	}

	var opg_obj = new Array();

	for(var st in states ) {

		if(f_states.toString().indexOf(st) > -1){


			var opt = document.createElement("optgroup");

			for(var j=0; j<opg_arr.length; j++) {

				var o = document.createElement("option");
				o.value = opg_arr[j][2];

				o.innerHTML = opg_arr[j][0];

				if(st == opg_arr[j][1]) {

					opt.label = states[st];

					opt.appendChild(o);
				}
			}
			opg_obj.push(opt);

		}
	}

	for(var opg in opg_obj) {

		if(opg_obj[opg].hasChildNodes())
			bt_obj.appendChild(opg_obj[opg]);

	}
}

//////////////////////////////////// list_by_cities
function list_by_cities(f) {

		var bt_obj = get_bus_to_obj();

	if (f)
		{

		for (var i=0; i<g_bus[f].length; i++)
		{
			var j = i+1;
        	bt_obj.options[j] = new Option(g_bus[f][i], g_bus[f][i]);
	}
	}

}

function update_bus_to(f)
{
	var bt_obj = get_bus_to_obj();

	while(bt_obj.hasChildNodes())
	{
		bt_obj.removeChild(bt_obj.lastChild);

	}
	var op = document.createElement("option");
	op.value = "";
	op.style.color = '#555555';
	op.innerHTML = "Arrival City";

	bt_obj.appendChild(op);
	if (f)
    {
		if(g_bus[f].length >10 && listing_style == 'states') 
		{
			list_by_states(f);
		} 
		else 
		{
			list_by_cities(f);
        }
	}
	conditional_clear();
}

function get_bus_from_obj()
{
	return window.document.bus_search.bus_from;
}

function get_sbus_from_obj()
{
       	return window.document.bus_search.sbus_from;
}

function get_bus_to_obj()
{
	return window.document.bus_search.bus_to;
}

function get_sbus_to_obj()
{
	return window.document.bus_search.sbus_to;
}

function set_selected(obj, v)
{
    for (var i=0; i<obj.options.length; i++)
    {
        if (obj.options[i].value == v)
        {
            obj.options.selectedIndex = i;
            return i;
        }
    }
    return -1;
}

function update_bus_from_to(f, t)
{
    var bf_obj = get_bus_from_obj();
    var index = 0;
    if (f)
    {
		if (g_bus[f] instanceof Array)
		{
			index = set_selected(bf_obj, f);
		}
    }
    else
    {
		index = bf_obj.selectedIndex;
		if (index > 0)
		{
			f = bf_obj.options[index].value;
		}
    }
    if (t)
    {
		if (g_bus[f] instanceof Array)
		{
			var bt_obj = get_bus_to_obj();
			update_bus_to(f);
			index = set_selected(bt_obj, t);
		}
    }
    else if (index > 0)
    {
       	update_bus_to(f);
    }
    return 0;
}

function jump_or_clear()
{
    var bf_obj = get_bus_from_obj();
    var bt_obj = get_bus_to_obj();
    var fv = bf_obj.options[bf_obj.selectedIndex].value;
    var tv = bt_obj.options[bt_obj.selectedIndex].value;
    if (tv == "Mohegan Sun Casino, CT")
    {
        if (fv == "Boston, MA")
        {
            return ga("http://www.gotobus.com/sunshine/boston_mohegansuntour/");
        }
    }
    else if (tv == "Atlantic City, NJ")
    {
        if (fv == "Newark, DE" || fv == "Wilmington, DE" || fv == "New Castle, DE")
        {
            return ga("http://www.gotobus.com/creativetravel/");
        }
        if (fv == "Washington, DC" || fv == "Fairfax, VA" || fv == "Springfield, VA" || fv == "Wheaton, MD")
        {
            return ga("http://www.gotobus.com/rexbus/daytriptotajmahalatlanticcity/");
        }
    }
    else if (tv == "Reno, NV")
    {
        if (fv == "San Francisco, CA")
        {
            return ga("http://www.gotobus.com/usasia/sanfrancisco___reno/");
        }
    }
    else if (fv == "San Diego, CA")
    {
        if (tv == "Viejas Casino, CA" || tv == "Sycuan Casino, CA")
        {
            return ga("http://www.gotobus.com/sunfuntours/");
        }
    }
    else if (tv == "Foxwoods Casino, CT")
    {
		return ga("http://www.gotobus.com/shortline/citytour/foxwoodsresortandcasino1_daytour.html");
    }
    else if (tv == "Philadelphia Park Casino, PA" || tv == "Philly Park Casino, PA")    {
        return ga("http://www.gotobus.com/skybus/");
    }
    conditional_clear();
}

function conditional_clear()
{
	var t_obj = document.getElementById("timeList");
	if (t_obj)
	{
	    t_obj.innerHTML = "";
	}
}

function get_departure_date()
{
	return document.bus_search.filter_date;
}

function get_return_date()
{
	return document.bus_search.return_date;
}

function check_bus_data()
{
	if (document.bus_search.option.value == "Select")
	{
		if (document.bus_search.bus_from.value == "")
		{
			alert("Please select a valid Departure City!");
			document.bus_search.bus_from.focus();
			return false;
		}
		if (document.bus_search.bus_to.value == "")
		{
			alert("Please select a valid Arrival City!");
			document.bus_search.bus_to.focus();
			return false;
		}
	}
	else if (document.bus_search.option.value == "Search")
	{
		if (document.bus_search.sbus_from.value == "")
		{
			alert("Please enter a valid Departure City!");
			document.bus_search.sbus_from.focus();
			return false;
		}
		if (document.bus_search.sbus_to.value == "")
		{
			document.bus_search.sbus_to.focus();
			alert("Please enter a valid Arrival City!");
			return false;
		}
	}
    if (document.bus_search.filter_date.value == "")
    {
        alert("Please select a valid Departure Date!");
        document.bus_search.filter_date.focus();
        return false;
    }
    if (document.bus_search.b_roundtrip.checked == true && document.bus_search.return_date.value == "")
    {
        alert("Please select a valid Return Date!");
        document.bus_search.return_date.focus();
        return false;
    }
	return true;
}

function pickdaterange()
{
    var dateObj = document.getElementById("beforethisdate");
    var dateFilter = dateObj.options[dateObj.selectedIndex].value;
    if (document.bus_search && document.bus_search.filter_date)
    {
        document.bus_search.filter_date.value = dateFilter;
    }
    server_update();
    window.document.getElementById("beforethisdate").focus();
}

function conditional_update()
{
	var t_obj = document.getElementById("timeList");
	if (t_obj && t_obj.innerHTML != "")
	{
		server_update();
	}
}

function server_update()
{
	var from;
	var to;
	var vfrom;
	var vto;
	var vopt;
	if (document.bus_search.option && document.bus_search.option.value == "Hidden")
	{
		from = document.bus_search.bus_from.value;
		to   = document.bus_search.bus_to.value;
		vopt = "option=Hidden";
        vfrom = "&bus_from=";
        vto = "&bus_to=";
	}
	else if (document.bus_search.option.value == "Select")
	{
		var bus_from_obj = get_bus_from_obj();
		if (bus_from_obj && bus_from_obj.value != "")
		{
			from = bus_from_obj.value;
		}
		else
		{
			conditional_clear();
			return;
		}
   		var bus_to_obj = get_bus_to_obj();
		if (bus_to_obj && bus_to_obj.value)
		{
			to = bus_to_obj.value;
		}
		else
		{
			conditional_clear();
			return;
		}
        vfrom = "&bus_from=";
        vto = "&bus_to=";
        vopt = "option=Select";
	}
	else
	{
		from = document.bus_search.sbus_from.value;
		to   = document.bus_search.sbus_to.value;
        vfrom = "&sbus_from=";
        vto = "&sbus_to=";
        vopt = "option=Search";
	}
	var date_obj = window.document.bus_search.filter_date;
	var date = "";
	if (date_obj)
	{
		date = date_obj.value;
	}
	else
	{
		date_obj = window.document.getElementById("beforethisdate");
		if (date_obj)
		{
            date = date_obj.value;
		}
    }
	var op_url = "";
	var operator_obj = window.document.getElementById("operatorList");
	if (operator_obj)
	{
		op_url = "&operator=" + operator_obj.value;
	}
	var q_url = "";
	if (window.document.bus_search.quantity && window.document.bus_search.quantity.value > 1)
	{
		var quantity = window.document.bus_search.quantity.value;
		q_url = "&quantity=" + quantity;
	}
	var rt_url = "";
	var return_url = "";
	var roundtrip = -1;
	if (window.document.bus_search.roundtrip)
	{
	    if (document.bus_search.roundtrip[1].checked == true)
	    {
		roundtrip = 1;
	    }
	    else
	    {
	        roundtrip = 0;
	    }
        }
        if (document.bus_search.option && document.bus_search.option.value != "Hidden")
	{
            var return_obj = window.document.bus_search.return_date;
            if (return_obj)
            {
                var return_date = return_obj.value;
                return_url = "&return_date=" + return_date;
	    }
	    if (roundtrip < 0)
	    {
	       roundtrip = 1;
	    }
	}
	else
	{
	    roundtrip = 0;
	}
	rt_url = "&roundtrip=" + roundtrip;
        var nm_url = "";
        if (window.document.bus_search.nm && window.document.bus_search.nm.value != '')
        {
                var nm = window.document.bus_search.nm.value;
                nm_url = "&nm=" + nm;
        }
        var st_url = "";
        if (window.document.bus_search.st && window.document.bus_search.st.value != '')
        {
                var st = window.document.bus_search.st.value;
                st_url = "&st=" + st;
        }

        ga("/cgi-bin/bus.cgi?" + vopt + vfrom + from + vto + to + "&filter_date=" + date + op_url + q_url + rt_url + return_url + nm_url + st_url);
}

function assignOperator(operator)
{
    var operatorObj = window.document.getElementById("operatorList");
	for (var i=0; i<operatorObj.options.length; i++)
	{
		if (operatorObj.options[i].value == operator)
        {
	        operatorObj.options[i].selected = true;
		    operatorFilter = operator;
		}
		else
		{
			operatorObj.options[i].selected = false;
		}
	}
	server_update();
}

function reverse_from_to()
{
    var option_obj = document.bus_search.option;
    if (option_obj)
    {
        if (option_obj.value == "Select")
		{
		    var to   = document.bus_search.bus_from.value;
			var from = document.bus_search.bus_to.value;
			var need_clear = 0;
			if (from)
			{
				need_clear = 1;
				update_bus_from_to(from, to);
			}
		}
		else
		{
		    if (document.bus_search.sbus_from)
			{
				to   = document.bus_search.sbus_from.value;
				from = document.bus_search.sbus_to.value;
				if (from)
				{
					need_clear = 1;
					document.bus_search.sbus_from.value = from;
					document.bus_search.sbus_to.value = to;
				}
			}
		}
		if (need_clear == 1)
		{
			conditional_clear();
		}
	}
}

function copy_select_to_search()
{
    var f_obj = document.bus_search.bus_from;
    var t_obj = document.bus_search.bus_to;
    var sf_obj = document.bus_search.sbus_from;
    var st_obj = document.bus_search.sbus_to;
    if (t_obj.selectedIndex > 0)
    {
        st_obj.value = t_obj.options[t_obj.selectedIndex].value;
    }

    if (f_obj.selectedIndex > 0)
    {
        sf_obj.value = f_obj.options[f_obj.selectedIndex].value;
    }
}

function copy_search_to_select()
{
    var sf_obj = document.bus_search.sbus_from;
    var st_obj = document.bus_search.sbus_to;
    update_bus_from_to(sf_obj.value, st_obj.value);
}

function bus_where_switch()
{
    var option_obj = document.bus_search.option;
    if (option_obj)
    {
        conditional_clear();
        var select = document.getElementById("select_where");
        var search = document.getElementById("search_where");
        if (option_obj.value == "Select")
        {
            option_obj.value = "Search";
	    if (select && search)
            {
                select.className = "ivyDivHidden";
                search.className = "ivyDivShow";
            }
            copy_select_to_search();
            document.getElementById("bus_choice_switch").innerHTML = "Switch to Select";
        }
        else
        {
            option_obj.value = "Select";
            if (select && search)
            {
                select.className = "ivyDivShow";
                search.className = "ivyDivHidden";
            }
            copy_search_to_select();
            document.getElementById("bus_choice_switch").innerHTML = "Switch to Text";
        }
    }
}

function bus_departure_date_clicked(y,m,d)
{
	if (m < 10) m = '0' + m;
	if (d < 10) d = '0' + d;
	document.bus_search.filter_date.value = y + '-' + m + '-' + d;
	conditional_update();
}

function bus_return_date_clicked(y,m,d)
{
	if (m < 10) m = '0' + m;
	if (d < 10) d = '0' + d;
	var dd = y + '-' + m + '-' + d;
	document.bus_search.return_date.value = dd;
	change_r_date(dd);
}

function validate_form_selections(f)
{
    for (var i=0, j=f.elements.length; i<j; i++)
    {
        var t = f.elements[i].type;
        if (t.match(/select/))
		{
		    if (f.elements[i].value == '')
			{
				alert("Please Select " + f.elements[i].name + "!");
                f.elements[i].focus();
				return false;
			}
        }
    }
    if (f.Date != null && f.Date.value == '')
    {
        alert("Please select a valid Date!");
        return false;
    }
    if (f.time != null && f.time.value < 1.01)
    {
        return confirm("Important: It is a new date after passing 12:00am.\nYou have selected a very early schedule on " + f.Date.value + ".  Please confirm.");
    }
}

function onBalloonOver()
{
	var b_obj = document.getElementById('balloon').style;
	b_obj.visibility = "visible";
	b_obj.display = "block";
}

function onBalloonOut()
{
        var b_obj = document.getElementById('balloon').style;
        b_obj.visibility = "hidden";
        b_obj.display = "none";
}

function el_pos(obj)
{
    var xOffset, yOffset, elParent;
    if(obj.offsetTop){
        yOffset = (obj.offsetTop?obj.offsetTop:0);
        xOffset = (obj.offsetLeft?obj.offsetLeft:0);
        elParent = obj.offsetParent;
        while(elParent){
            yOffset += (elParent.offsetTop?elParent.offsetTop:0);
            xOffset += (elParent.offsetLeft?elParent.offsetLeft:0);
            elParent = elParent.offsetParent;
        }
    }else if(typeof obj.y != 'undefined'){
        yOffset = obj.y;
        xOffset = obj.x;
    }else{      //information is not available
        yOffset = -1;
        xOffset = -1;
    }
    return {x:xOffset,y:yOffset};
}

function b_text(obj, text)
{
        var b_obj = document.getElementById('balloon').style;
        var tt = "<table width=150 bgcolor=#aaaaaa cellpadding=4 cellspacing=1><tr><td bgcolor=#ffffff style=\"font-family:ariel,sans-serif\">" + text + "</td></tr></table>";
        document.getElementById('balloon').innerHTML = tt;
        var pos = el_pos(obj);
        b_obj.top = document.documentElement.scrollTop + pos.y + 16 + 'px';
        b_obj.left = pos.x + 16 + 'px';
        b_obj.visibility = "visible";
        b_obj.display = "block";
}

function no_b_text()
{
        var b_obj = document.getElementById('balloon').style;
        b_obj.visibility = "hidden";
        b_obj.display = "none";
}

function check_oneway_image()
{
	if (document.getElementById('b_oneway').checked == true)
	{
		rd_popup.showPopup('r_text_date');
	}
	else
	{
		br_cal.select(document.bus_search.return_date,'br_date','yyyy-MM-dd');
	}
}

function check_oneway_text()
{
	if (document.getElementById('b_oneway').checked == true)
	{
		rd_popup.showPopup('r_text_date');
	}
}

//-->

