var trips=new Array();
var emptyTripText='--Choose Trip--';

//
//  BEGIN EDIT 
//
//	Edit this area to add/remoave/change trips
//	Format:AddTrip('Trip Name',Array('date 1','Date 2','date 3'));
//
AddTrip('Aconcagua CME',Array('1/4/2012'));
AddTrip('Aconcagua Normal Northeast Route',Array('11/21/2011', '12/5/2012','1/5/2012','2/6/2012'));
AddTrip('Aconcagua Northeast & Plata Range',Array('12/4/11','1/5/12'));
AddTrip('Aconcagua Polish Glacier Expedition',Array('On Request'));
AddTrip('Aconcagua Full Traverse',Array('1/5/12','2/6/12'));
AddTrip('Kilimanjaro and African Safari',Array('2/18/12','7/21/12', '8/11/12', '9/15/12'));
AddTrip('Aguja Guillaumet',Array('On Request'));
AddTrip('Bariloche Backcountry Ski',Array('8/1/11','8/15/11'));
AddTrip('Bariloche Rock & Ice',Array('11/26/11','1/9/12','2/6/12'));
AddTrip('Cerro Gorra Blanca Ascent',Array('11/14/11','12/5/12','1/7/12', '2/6/12'));
AddTrip('Patagonia 2 Summits',Array('On Request'));
AddTrip('Cerro Solo Ascent',Array('On Request'));
AddTrip('Condoriri Valley & Illimani',Array('5/9/11','6/3/11','7/11/10'));
AddTrip('Dagala Thousand Lakes Trek CME',Array('dates coming soon'));
AddTrip('Himalayan Summits CME',Array('dates coming soon'));
AddTrip('Ice Cap Trek',Array('11/14/11','11/5/11','12/6/10','1/9/12', '2/6/12'));
AddTrip('Ice Cap Trek & Gorra Blanca',Array('11/14/11','12/5/11','1/7/12', '2/6/12'));
AddTrip('Ishinca Valley & Chopicalqui',Array('5/30/11','6/27/10','7/25/11'));
AddTrip('North Patagonia Rock Climbing',Array('12/12/11','1/9/12', '1/30/12','2/9/12'));
AddTrip('Paine & Los Glaciares Trek',Array('11/21/11','2/14/12' ));
AddTrip('Rock Climbing Asturias',Array('On Request'));
AddTrip('Patagonia Alpine Trilogy',Array('On Request'));
AddTrip('Trekking the Pyrenees',Array('9/19/11'));
AddTrip('Tupungato and Maipo Expedition',Array('dates coming soon'));
AddTrip('Volcan Tupungato Expedition',Array('dates coming soon'));
AddTrip('Custom or Private Trip',Array('On Request'));

//
// END EDIT
//


function AddTrip(tripname,tripdates)
{
  	if(trips.length==0)		trips[0]='';//reserved.
	index=trips.length;
	trips[index]=new Array();  
	trips[index]['trip']=tripname;  
	trips[index]['dates']=tripdates;  
}

function PopulateSelects(tripid,dateid)
{
	var trip_sel=document.getElementById(tripid);
	var date_sel=document.getElementById(dateid);
	
	
	if(trip_sel)
	{
		trip_sel.options.length=0;

		var opt=new Option(emptyTripText,'');
		trip_sel.options[trip_sel.options.length]=opt;

		for(var i=1;i<trips.length;i++)  
		{
			var opt=new Option(trips[i]['trip'],trips[i]['trip']);
			trip_sel.options[trip_sel.options.length]=opt;
			
		}
	}
	if(date_sel)
	{
		date_sel.options.length=0;

		var opt=new Option(emptyTripText,'');
		date_sel.options[date_sel.options.length]=opt;
	  
	}		

	UpdateSelects(tripid,dateid);
}

function UpdateSelects(tripid,dateid)
{
	var trip_sel=document.getElementById(tripid);
	var date_sel=document.getElementById(dateid);
	var sel_index='';

	if(trip_sel)	
		sel_index=trip_sel.selectedIndex;
	
	if(date_sel)
	{
		date_sel.options.length=0;
		
		if(sel_index)
		{
			for(var i=0;i<trips[sel_index]['dates'].length;i++)  
			{
				var opt=new Option(trips[sel_index]['dates'][i],trips[sel_index]['dates'][i]);
				date_sel.options[date_sel.options.length]=opt;
			}
		}
		else
		{
			var opt=new Option(emptyTripText,'');
			date_sel.options[date_sel.options.length]=opt;
		}
	}	  
}

function ValidateSelects(tripid,dateid)
{
	var trip_sel=document.getElementById(tripid);
	var date_sel=document.getElementById(dateid);

	//something odd, let it pass - safety's sake
	if(!trip_sel || !date_sel)	return true;
	
 	if(!trip_sel.selectedIndex)
	{
	  	alert('Please Select Trip');
		return false
	} 
	
 	if(!date_sel.value)
	{
	  	alert('Please Select Date');
		return false
	} 

	return true;
}
