<!--

var tcities = new Array("Anaheim", "Boston", "Chicago", "Hawaii", "Key West", "Los Angeles", 
						"Las Vegas", "Miami", "New Orleans", "New York", "Orlando", "Salt Lake City", "San Diego",  
						"San Francisco", "Savannah", "Seattle", "St Augustine", "Washington DC", 
						"Vancouver");
var tgroup = new Object;
var tour_length = tcities.length;

for (i=0; i<tour_length; i++)
  tgroup[tcities[i]]=new Array();

tgroup["Anaheim"][0] = new Option("No preference", "");
tgroup["Anaheim"][1] = new Option("Los Angeles", "Angeles");
tgroup["Anaheim"][2] = new Option("Sea World", "Sea");
tgroup["Anaheim"][3] = new Option("San Diego Zoo", "Zoo");
tgroup["Anaheim"][4] = new Option("Six Flags Magic Mountain", "Flags");
tgroup["Anaheim"][5] = new Option("Universal Studios", "Universal");
tgroup["Anaheim"][6] = new Option("Mexico", "Tijuana");

tgroup["Boston"][0] = new Option("No preference", "");
tgroup["Boston"][1] = new Option("City Tours", "duration");
tgroup["Boston"][2] = new Option("Canada", "Canada");
tgroup["Boston"][3] = new Option("Cape Cod", "Cape");
tgroup["Boston"][4] = new Option("Fall Foliage", "Foliage");
tgroup["Boston"][5] = new Option("Montreal", "Montreal");
tgroup["Boston"][6] = new Option("Newport", "Newport");
tgroup["Boston"][7] = new Option("Niagara Falls", "Niagara");
tgroup["Boston"][8] = new Option("Plimoth Plantation", "Plimoth");
tgroup["Boston"][9] = new Option("Plymouth", "Plymouth");
tgroup["Boston"][10] = new Option("Salem", "Salem");
tgroup["Boston"][11] = new Option("Toronto", "Toronto");
tgroup["Boston"][12] = new Option("Tennessee", "Tennessee");
tgroup["Boston"][13] = new Option("Washington DC", "Washington");

tgroup["Chicago"][0] = new Option("No preference", "");
tgroup["Chicago"][1] = new Option("City Tours", "duration");
tgroup["Chicago"][2] = new Option("Wine TOur", "wine");

tgroup["Hawaii"][0]=new Option("No preference", "");
tgroup["Hawaii"][1]=new Option("City Tours", "duration");
tgroup["Hawaii"][2]=new Option("Dinner Cruise ", "cruise");
tgroup["Hawaii"][3]=new Option("Luau Shows", "luau");
tgroup["Hawaii"][4]=new Option("Outter Island Tour", "maui");
tgroup["Hawaii"][5]=new Option("Polynesian Show", "Polynesian");
tgroup["Hawaii"][6]=new Option("Snorkeling", "Snorkeling ");
tgroup["Hawaii"][7]=new Option("Submarine Tour ", "submarine");

tgroup["Key West"][0] = new Option("No preference", "");

tgroup["Los Angeles"][0]=new Option("No preference", "");
tgroup["Los Angeles"][1]=new Option("City Tours","duration");
tgroup["Los Angeles"][2]=new Option("Bryce Canyon","Bryce");
tgroup["Los Angeles"][3]=new Option("Sequoia","Sequoia");
tgroup["Los Angeles"][4]=new Option("Disneyland California", "Disneyland");
tgroup["Los Angeles"][5]=new Option("Grand Canyon","Canyon");
tgroup["Los Angeles"][6]=new Option("Hollywood Tour","Hollywood");
tgroup["Los Angeles"][7]=new Option("Lake Tahoe","Tahoe");
tgroup["Los Angeles"][8]=new Option("Napa Valley","Napa");
tgroup["Los Angeles"][9]=new Option("Las Vegas","Vegas");
tgroup["Los Angeles"][10]=new Option("Mexico","Mexico");
tgroup["Los Angeles"][11]=new Option("Mt Rushmore","Rushmore");
tgroup["Los Angeles"][12]=new Option("San Francisco","Francisco");
tgroup["Los Angeles"][13]=new Option("Sea World","Sea");
tgroup["Los Angeles"][14]=new Option("Petrifield Forest","Petrifield");
tgroup["Los Angeles"][15]=new Option("Monument Valley","Monument");
tgroup["Los Angeles"][16]=new Option("Yellowstone","Yellowstone");
tgroup["Los Angeles"][17]=new Option("Yosemite","Yosemite");
tgroup["Los Angeles"][18]=new Option("Zion National Park","Zion");
tgroup["Los Angeles"][19]=new Option("Grand Teton National Park","Teton");

tgroup["Las Vegas"][0]=new Option("No preference", "");
tgroup["Las Vegas"][1]=new Option("City Tours","duration");
tgroup["Las Vegas"][2]=new Option("Grand Canyon","Canyon");
tgroup["Las Vegas"][3]=new Option("Grand Teton National Park","Teton");
tgroup["Las Vegas"][4]=new Option("Hoover Dam","Hoover");
tgroup["Las Vegas"][5]=new Option("Lake Mead Boat Cruise","Cruise");
tgroup["Las Vegas"][6]=new Option("Mount Charleston Tour","Charleston");
tgroup["Las Vegas"][7]=new Option("River Rafting","Rafting");
tgroup["Las Vegas"][8]=new Option("Yellowstone","Yellowstone");
tgroup["Las Vegas"][9]=new Option("Zion National Park","Zion");
tgroup["Las Vegas"][10]=new Option("Grand Teton National Park","Teton");

tgroup["Miami"][0] = new Option("No preference", "");
tgroup["Miami"][1] = new Option("City Tours", "duration");
tgroup["Miami"][2] = new Option("Everglade", "Everglade");
tgroup["Miami"][3] = new Option("Key West", "Ket");
tgroup["Miami"][4] = new Option("Orlando", "Orlando");
tgroup["Miami"][5] = new Option("Parrot Jungle Island", "Parrot");
tgroup["Miami"][6] = new Option("Seaquarium", "Seaquarium");
tgroup["Miami"][7] = new Option("Snorkeling Tours", "Snorkeling");

tgroup["New Orleans"][0]=new Option("No preference", "");
tgroup["New Orleans"][1]=new Option("City Tours", "duration");

tgroup["New York"][0]=new Option("No preference", "");
tgroup["New York"][1]=new Option("Boston","Boston");
tgroup["New York"][2]=new Option("Canada","Canada");
tgroup["New York"][3]=new Option("Catskills","Catskills");
tgroup["New York"][4]=new Option("City Tours","Duration");
tgroup["New York"][5]=new Option("Cruise Tour","Cruise");
tgroup["New York"][6]=new Option("Finger Lakes","Finger");
tgroup["New York"][7]=new Option("Foxwood Casino","Foxwood");
tgroup["New York"][8]=new Option("Helicopters Tour","Helicopter");
tgroup["New York"][9]=new Option("Hershey Park","Hershey");
tgroup["New York"][10]=new Option("Hudson Valley","Hudson");
tgroup["New York"][11]=new Option("Lake George","Lake");
tgroup["New York"][12]=new Option("Niagara Falls","Niagara");
tgroup["New York"][13]=new Option("Philadelphia","Philadelphia");
tgroup["New York"][14]=new Option("Poconos","Poconos");
tgroup["New York"][15]=new Option("Shenandoah Cavern","Shenandoah");
tgroup["New York"][16]=new Option("Tennessee","Tennessee");
tgroup["New York"][17]=new Option("Washington DC","Washington");
tgroup["New York"][18]=new Option("Woodbury Shopping","Woodbury");

tgroup["Orlando"][0]=new Option("No preference", "");
tgroup["Orlando"][1]=new Option("Busch Gardens", "Busch");
tgroup["Orlando"][2]=new Option("City Tours", "Duration");
tgroup["Orlando"][3]=new Option("Cypress Gardens", "Cypress");
tgroup["Orlando"][4]=new Option("Everglades", "Everglades");
tgroup["Orlando"][5]=new Option("Gatorland", "Gatorland");
tgroup["Orlando"][6]=new Option("Gospel Brunch", "Gospel");
tgroup["Orlando"][7]=new Option("Kennedy Space Center", "Space");
tgroup["Orlando"][8]=new Option("Miami", "Miami");
tgroup["Orlando"][9]=new Option("Silver Springs", "Silver");

tgroup["Salt Lake City"][0]=new Option("No preference", "");
tgroup["Salt Lake City"][1]=new Option("Mt Rushmore", "Rushmore");
tgroup["Salt Lake City"][2]=new Option("Yellowstone", "Yellowstone");

tgroup["San Diego"][0]=new Option("No preference", "");
tgroup["San Diego"][1]=new Option("City Tours", "Duration");
tgroup["San Diego"][2]=new Option("Disneyland California", "Disneyland");
tgroup["San Diego"][3]=new Option("Ensenada", "Ensenada");
tgroup["San Diego"][4]=new Option("Legoland", "Legoland");
tgroup["San Diego"][5]=new Option("Rosarito Beach", "Rosarito");
tgroup["San Diego"][6]=new Option("San Diego Zoo", "Zoo");
tgroup["San Diego"][7]=new Option("Sea World", "Sea");
tgroup["San Diego"][8]=new Option("Sycuan Casino", "Sycuan");
tgroup["San Diego"][9]=new Option("Tijuana, Mexico", "Tijuana");
tgroup["San Diego"][10]=new Option("Viejas Casino", "Viejas");
tgroup["San Diego"][11]=new Option("Universal Studios", "Universal");
tgroup["San Diego"][12]=new Option("Wild Animal Park", "Wild");

tgroup["San Francisco"][0]=new Option("No preference", "");
tgroup["San Francisco"][1]=new Option("City Tours", "Duration");
tgroup["San Francisco"][2]=new Option("Camel Valley", "Camel");
tgroup["San Francisco"][3]=new Option("Disneyland California", "Disneyland");
tgroup["San Francisco"][4]=new Option("Grand Canyon","Canyon");
tgroup["San Francisco"][5]=new Option("Hearst Castle","Hearst");
tgroup["San Francisco"][6]=new Option("Las Vegas","Vegas");
tgroup["San Francisco"][7]=new Option("Los Angeles","Angeles");
tgroup["San Francisco"][8]=new Option("Mexico","Mexico");
tgroup["San Francisco"][9]=new Option("Muir Woods","Muir");
tgroup["San Francisco"][10]=new Option("Oregon","Oregon");
tgroup["San Francisco"][11]=new Option("Reno","Reno");
tgroup["San Francisco"][12]=new Option("Sausalito","Sausalito");
tgroup["San Francisco"][13]=new Option("Universal Studios", "Universal");
tgroup["San Francisco"][14]=new Option("Yosemite","Yosemite");

tgroup["Savannah"][0]=new Option("No preference", "");

tgroup["Seattle"][0]=new Option("No preference", "");
tgroup["Seattle"][1]=new Option("Boeing Factory", "Boeing");
tgroup["Seattle"][2]=new Option("City Tours", "Duration");
tgroup["Seattle"][3]=new Option("Harbor Cruise", "Cruise");
tgroup["Seattle"][4]=new Option("Mt Rainier", "Rainier");
tgroup["Seattle"][5]=new Option("Mt St Helens", "Helens");

tgroup["St Augustine"][0]=new Option("No preference", "");
tgroup["St Augustine"][1]=new Option("Bus Tours","bus tour");
tgroup["St Augustine"][2]=new Option("Helicopter Tours","Helicopter");

tgroup["Washington DC"][0]=new Option("No preference", "");
tgroup["Washington DC"][1]=new Option("Alexandria, VA", "Alexandria");
tgroup["Washington DC"][2]=new Option("Arlington Cemetary","Cemetary");
tgroup["Washington DC"][3]=new Option("Busch Gardens", "Busch");
tgroup["Washington DC"][4]=new Option("City Tours", "Duration");
tgroup["Washington DC"][5]=new Option("Colonial Williamsburg","Williamsburg");
tgroup["Washington DC"][6]=new Option("Embassy Row","Embassy");
tgroup["Washington DC"][7]=new Option("Gettysburg", "Gettysburg");
tgroup["Washington DC"][8]=new Option("Monticello", "Monticello");
tgroup["Washington DC"][9]=new Option("Mt Vernon","Vernon");
tgroup["Washington DC"][10]=new Option("Night Tours","Night");
tgroup["Washington DC"][11]=new Option("Thomas Jefferson Country", "Jefferson");
tgroup["Washington DC"][12]=new Option("Williamsburg, VA","Williamsburg");

tgroup["Vancouver"][0]=new Option("No preference", "");
tgroup["Vancouver"][1]=new Option("Butchart Gardens", "Butchart");
tgroup["Vancouver"][2]=new Option("City Tours", "Duration");
tgroup["Vancouver"][3]=new Option("Dinner Cruise", "Dinner");
tgroup["Vancouver"][4]=new Option("Victoria","Victoria");
tgroup["Vancouver"][5]=new Option("Whale Watching","Whale");
tgroup["Vancouver"][6]=new Option("Whistler","Whistler");

function get_tour_from_obj()
{
	return get_tour_depart_obj();
}

function get_tour_to_obj()
{
        return get_tour_attraction_obj();
}

function get_tour_depart_obj()
{
	return document.tour_search.depart;
}

function get_tour_attraction_obj()
{
	return document.tour_search.attraction;
}

function get_tour_days_obj()
{
        return document.tour_search.days;
}

function update_tour(depart, attr, keywords, days, jump)
{
	var depart_obj = get_tour_depart_obj();
	var index;
	if (depart)
	{
		index = set_selected(depart_obj, depart);
	}
	else
	{
		index = depart_obj.options.selectedIndex;
		if (index > 0)
        	{
			depart = depart_obj.options[index].value;
		}
	}
	if (index > 0)
	{
		if (tgroup[depart] instanceof Array && tgroup[depart].length > 1)
		{
			update_tour_to(depart, jump);
			if (attr)
			{
				var attr_obj = get_tour_attraction_obj();
				set_selected(attr_obj, attr);
			}		
		}
	}	
        if (days)
	{
		var days_obj = get_tour_days_obj();
		set_selected(days_obj, days);
	}
	if (keywords && document.tour_search.keywords)
	{
		document.tour_search.keywords.value = keywords;
	}
}

function update_tour_to(city, jump)
{
	if (city != '' && tgroup[city] instanceof Array) 
	{	
		var attr_obj = get_tour_attraction_obj();
		var opt_len = tgroup[city].length;
		if (opt_len == 1 && jump)
		{
			return ga("http://www.ivymedia.com/cgi-bin/tour.cgi?depart=" + city);
		}
  		for (var i=attr_obj.options.length-1; i>0; i--)
		{
       			attr_obj.options[i]=null;
   		}
   		for (var i=0; i<opt_len; i++)
		{
       			attr_obj.options[i] = new Option(tgroup[city][i].text, tgroup[city][i].value);
		}
	}
	tour_clear();
}

function set_tour_dates(obj, selected_date)
{
	var wdays= new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun");
	var d = new Date();
	var aDay=86400000;
	var selected = 0;
	for (var i=0; i<60; i++)
	{
		var m = d.getMonth() + 1;
		if (m < 10)
		{
			m = "0" + m;
		}
		var dt = d.getDate();
		if (dt < 10)
		{
			dt = "0" + dt;
		}
		var fdv = d.getFullYear() + "-" + m + "-" + dt + " " + wdays[d.getDay()];
		var fd = d.getFullYear() + "-" + m + "-" + dt;
		obj.options[i+1] = new Option(fdv, fd, true);
		d = new Date(d.valueOf() + aDay);
		if (selected_date == fd)
		{
			selected = i+1;
		}
	}
	obj.options.selectedIndex = selected;
}

function tour_clear()
{
	var t_obj = document.getElementById("itemList");
	if (t_obj)
	{
	    t_obj.innerHTML = ""; 
	}
}

function tour_conditional_regen()
{
	var t_obj = document.getElementById("itemList");
	if (t_obj && t_obj.innerHTML != "")
	{
		tour_regen();
	}
}

function tour_regen()
{
	var depart_obj = document.tour_search.depart;
	var depart = "";
	if (depart_obj && depart_obj.value)
	{
		depart = depart_obj.value;
	}
	else
	{
		tour_clear();
		return;
	}
	var attr = "";
	var attr_obj = document.tour_search.attraction;
	if (attr_obj && attr_obj.value)
	{
		attr = attr_obj.value;
	}
	var date_obj = document.tour_search.date;
	var d = "";
	if (date_obj && date_obj.value)
	{
		d = date_obj.value;
	}
	var ignore = "";
	var ignore_obj = document.tour_search.ignore;
	if (ignore_obj && ignore_obj.checked == true)
	{
		ignore = 1;
	}
	var days_obj = document.tour_search.days;
	var days = "";
	if (days_obj && days_obj.value)
	{
		days = days_obj.value;
	}
	var keywords = "";
	var keywords_obj = document.tour_search.keywords;
	if (keywords_obj && keywords_obj.value)
	{
		keywords = keywords_obj.value;
	}
        var order = "";
        var order_obj = document.tour_search.order;
        if (order_obj && order_obj.value)
        {
                order = order_obj.value;
        }
        ga("/cgi-bin/tour.cgi?depart=" + depart + "&attraction=" + attr + "&date=" + d + "&ignore=" + ignore + "&days=" + days + "&keywords=" + keywords + "&order=" + order);
}

function check_tour_input()
{
        var depart_obj = document.tour_search.depart;
        var depart = '';
        if (depart_obj && depart_obj.value)
        {
                depart = depart_obj.value;
        }
        if (depart == '')
        {
                alert("Please select a departure city!");
                depart_obj.focus();
                return false;
        }
        var date_obj = document.tour_search.date;
        var d = '';
        if (date_obj && date_obj.value)
        {
                d = date_obj.value;
        }
        if (d && !d.match(/\d\d\d\d-\d\d-\d\d/))
        {
                alert("Date (" + d + ") must be either empty or in the format: YYYY-MM-DD");
                date_obj.focus();
                return false;
        }
}

function tour_date_clicked(y,m,d)
{
	if (m < 10) m = '0' + m;
	if (d < 10) d = '0' + d;
	document.tour_search.date.value = y + '-' + m + '-' + d;
	if (document.tour_search.ignore.checked == false)
	{
		tour_conditional_regen();
	}
}

function empty_tour_date()
{
        document.tour_search.date.value = '';
        tour_conditional_regen();
}

function check_tour_ignore()
{
        if (document.tour_search.ignore.checked == false)
        {
                document.tour_search.date.disabled = false;
                var timg_obj = document.getElementById('td_img');
                if (timg_obj != null)
                {
                        timg_obj.src = "/images/calendar.gif";
                }
                if (document.tour_search.date.value == '')
                {
                        var t_date = new Date(past_date.valueOf() + 3 * aDay);
                        document.tour_search.date.value = formatDate(t_date, "yyyy-MM-dd");
			return;
                }
        }
        else
        {
                document.tour_search.date.value = "";
                document.tour_search.date.disabled = true;
                var timg_obj = document.getElementById('td_img');
                if (timg_obj != null)
                {
                        timg_obj.src = "/images/calendar_hidden.gif";
                }
        }
        tour_conditional_regen();
}

function sort_tours(order_by)
{
	if (document.tour_search && document.tour_search.order)
	{
		document.tour_search.order.value = order_by;
		tour_conditional_regen();
	}
}

//-->


