///////// XML CONFIG ///////////////
//     /travel/trips/xml/config.php

var site_url = "https://webservices.admin.cam.ac.uk/alumni_travel_admin/trips/";

$(document).ready(function() {
// get the input field
	$.get('/travel/xml/trips.php',
		function parseXML(xml) {
		var results = [];
		$(xml).find('trip').each(function() {
			var text = $.trim($(this).find('title').text());
			var value = $.trim($(this).find('id').text());
			results[results.length] = {'result': value, 'value': text
		};
	});
	
	var input = $('#form1 input#txtResourceFinder');
	input.autocomplete(results, {
		delay:10,
		minChars: 0,
		matchContains: true,
		width:300,
		formatItem: function(data) {
			return $(data).val() ;
		}
		
		}).result(function(event, data) {
			location.href = "/travel/?gotoTrip="+$(data).attr('result');
		});
	});
	
	$.get('/travel/xml/leaders.php',
		function parseXML(xml) {
		var results = [];
		$(xml).find('leader').each(function() {
			var text = $.trim($(this).find('scholar_full_name').text());
			var value = $.trim($(this).find('trip_id').text());
			
			text += " <br /> <small> ( ";

			text += $(this).find('trip_title').text() + " ";
			
			text += " </small> ) ";
			
			
			results[results.length] = {'result': value, 'value': text
		};
	});
	
	var input = $('input#txtResourceFinder2');
	input.autocomplete(results, {
		delay:10,
		minChars: 0,
		matchContains: true,
		width:300,
		formatItem: function(data) {
			return $(data).val() ;
		}
	
		}).result(function(event, data) {
			location.href = "/travel/?gotoTrip="+$(data).attr('result');
		});
	});
	
	$.get('/travel/xml/trips.php',
		function parseXML(xml) {
		var results = [];
		$(xml).find('trip').each(function() {
			var text = $.trim($(this).find('start_date').text());
			var value = $.trim($(this).find('id').text());
				text += " <br /> <small> ( ";

			text += $(this).find('title').text() + " ";
			
			text += " </small> ) ";
			results[results.length] = {'result': value, 'value': text
		};
	});
	
	var input = $('input#txtResourceFinder3');
	input.autocomplete(results, {
		delay:10,
		minChars: 0,
		matchContains: true,
		width:300,
		formatItem: function(data) {
			return $(data).val() ;
		}
	
		}).result(function(event, data) {
			location.href = "/travel/?gotoTrip="+$(data).attr('result');
		});
	});
	
});

function clearText(thefield) {
	if (thefield.defaultValue == thefield.value)
		thefield.value = ""
}


function getGETParamByName( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function panToUK() {    
   // map.panTo(new GLatLng(53, -2.5));
   map.setCenter(new GLatLng(53, -2.5), 6, G_HYBRID_MAP);
 }
 
 function panToEurope() {    
   // map.panTo(new GLatLng(53, -2.5));
   map.setCenter(new GLatLng(50, 11), 4, G_HYBRID_MAP);
 }

 function panToNorthUSA() {    
   // map.panTo(new GLatLng(53, -2.5));
   map.setCenter(new GLatLng(38.2, -92), 4, G_HYBRID_MAP);
 }
 
  function panToSouthUSA() {    
   // map.panTo(new GLatLng(53, -2.5));
   map.setCenter(new GLatLng(-10.5, -69), 3, G_HYBRID_MAP);
 }


  function panToAfrica() {    
   // map.panTo(new GLatLng(53, -2.5));
   map.setCenter(new GLatLng(0, 20.7), 3, G_HYBRID_MAP);
 }
 
   function panToAsia() {    
   // map.panTo(new GLatLng(53, -2.5));
   map.setCenter(new GLatLng(23.5,101), 3, G_HYBRID_MAP);
 }
    function panToAustralasia() {    
   // map.panTo(new GLatLng(53, -2.5));
   map.setCenter(new GLatLng(-30.7,145), 3, G_HYBRID_MAP);
 }

///////////////// TRIP PAGE ///////////////////////

function calltrip(id) {	
	// get selected trip
	
	$.ajax({
		   type: "GET",
		   url: '/travel/xml/trips.php?id='+id,
		   dataType: "xml",
		   beforeSend: function() {	$(".result").html('<img style="border:0;" src="/global/images/loadingAnimation.gif" alt="loading..." /><br />')},
		  // complete:  function() {	 $(".result").html('') } ,
		   success: function(xml) {					
				$(xml).find('trip').each(function(){  
					var id = $(this).find('id').text();
					var title = $(this).find('title').text();
					var itinerary = $(this).find('itinerary').text();
					var short_description = $(this).find('short_description').text();
					var description = $(this).find('description').text();
					var cost = $(this).find('cost').text();
					var cost_description = $(this).find('cost_description').text();
					var operator_id = $(this).find('operator_id').text();
					var operator_name = $(this).find('operator_name').text();
					var latitude = $(this).find('latitude').text();
					var longitude = $(this).find('longitude').text();
					var start_date = $(this).find('start_date').text();
					var end_date = $(this).find('end_date').text();
					var trip_duration = $(this).find('trip_duration').text();
					var highlighted = $(this).find('highlighted').text();
					var message = $(this).find('message').text();
					var reading_list_link = $(this).find('reading_list_link').text();
					var reading_list_link_label = $(this).find('reading_list_link_label').text();

					//hide current trip
					$('.atrip').hide();
					
					//hide current map
					$('#map').slideUp();
					$('#textOnly').slideUp();
					
					//display current trip
					var trip  = "";
						trip += "<div class='atrip clear' style='display:none;' id='trip"+id+"'>";
						//trip += "<h2 stlye='width:480px'>"+title+"<span style='float:right; font-size:12px;'><a href='/travel/index.shtml?gotoTrip="+id+"'>Link to this trip</a></span></h2>";
						trip += "<span class='directLink'><a href='/travel/index.shtml?gotoTrip="+id+"'>Direct link to this tour</a></span><h2 class='title' stlye='width:480px'>"+title+"</h2>";
						trip += "<div class='clear' style='line-height:0;height:0;'></div>";
							//right column
							trip += "<div class='photosContainer"+id+" photoContainer'>";	
								// Loading Photos
								//trip += "<div class='loading_photos"+id+"'></div>";
								// Photos
								trip += "<div class='photos"+id+"'></div>";	
								// Photos Pager
								trip += "<div id='pagerContainer"+id+"' class='pagerContainer'></div>";
								// Itinerary
								trip += "<div class='messagearea'>";
								//trip += "<h3 class='itinerary'>Itinerary</h3>";
								trip += itinerary;
								trip += "</div>";
							trip += "</div>";
							
							//left column
							//short description
							trip += "<br />";
							trip += "<h3>"+short_description+"</h3>";
							//start date
							trip += "<div class='messagearea'><p>Departing: "+start_date+"<br />";
							//end date
							trip += "Returning: "+end_date+"<br />";
							//duration 
							trip += "Duration: "+trip_duration+"</p>";
							//cost
							trip += "<p>Price from: <b><a href='javascript:void(0);' onclick='$.scrollTo(\"#costDescription"+id+"\");'>"+cost+"</b>*</a></p></div><br />";
							// Loading Scholars
							//trip += "<div class='loading_leaders"+id+"'></div>";
							//scholars 
							trip += "<div class='scholars"+id+"'></div><br />";	
							//description
							trip += "<h3>Description</h3>";
							trip += "<div class='messagearea'><p style='color:red;'>"+message+"</p>"+description+"</div><br />";
							
							trip += "<h3>Reading List</h3>";
							trip += "<div class='messagearea'><p><a href='"+reading_list_link+"'>"+reading_list_link_label+"</a><p></div><br />";
							//operators
							//trip += "<div class='loading_operators"+operator_id+"'></div>";
							trip += "<h3>Operator</h3>";
							trip += "<div class='messagearea'><p><a href='javascript:void(0);' onclick='callOperator("+operator_id+");'>"+operator_name+"</a></p>";
							trip += "<div class='operator"+operator_id+"'></div></div><br />";	
							
							trip += "<div id='costDescription"+id+"'><div style='float:left;display:inline'>*</div>"+cost_description+"</div>";
						
						trip += "<p style='text-align:right'><a targer='_bank' href='"+site_url+id+"'>Edit this tour</a></p>";
					
						trip += "</div>";
					
					// output trip
					$(".result").html(trip);
					// slide open trip info when ready
					$('.atrip').slideDown();
					//change map link to show
					$('.maplink div').toggle();
					//change reset link to hide
					$('.reset').toggle();
				
				});  // end each trip
				
				callPhotos(id, false);
				callLeaders(id);
		  
		  }  // end function
	
	}); // end ajax
	
	} // end calltrip

function callHighlightedTrips() {	
	// get selected trip
	
	$.ajax({
		   type: "GET",
		   url: '/travel/xml/trips.php',
		   dataType: "xml",
		   beforeSend: function() {	 $(".resultHighlight").html('<img style="border:0;" src="/global/images/loadingAnimation.gif"  alt="loading..." /><br />')},
		  // complete:  function() {	 $(".loading").html('') } ,
		   success: function(xml) {					
				
				var trip  = "";
				var photosArray = Array();
				var showHighlightedDiv = false;

				$(xml).find('trip').each(function(){  
												  
					var highlighted = $(this).find('highlighted').text();
					
					if(highlighted=='Yes'){
																	
						showHighlightedDiv = true;

						var id = $(this).find('id').text();
						var title = $(this).find('title').text();
						var itinerary = $(this).find('itinerary').text();
						var short_description = $(this).find('short_description').text();
						var description = $(this).find('description').text();
						var cost = $(this).find('cost').text();
						var cost_description = $(this).find('cost_description').text();
						var operator_id = $(this).find('operator_id').text();
						var operator_name = $(this).find('operator_name').text();
						var latitude = $(this).find('latitude').text();
						var longitude = $(this).find('longitude').text();
						var start_date = $(this).find('start_date').text();
						var end_date = $(this).find('end_date').text();
						var message = $(this).find('message').text();

							
						//display current trip
							trip += "<div class='btrip clear' style='width:290px;height:200px;' id='trip"+id+"'>";
							trip += "<div class='photosHighlight"+id+"'>";
							
							callPhotos(id, true);
							
							//get trip photos							
								trip += "</div>";
								//left column
								//short description
								//trip += "<b>"+short_description+"</b>";
								//start date
								//trip += "<p>Departing: "+start_date+"<br />";
								//end date
								//trip += "Returning: "+end_date+"</p>";
								//cost
								//trip += "<p>Price from: <b>"+cost+"</b>*</p>";
								
								//trip += "<p class='findOutMore'><a href='/travel/index.shtml?gotoTrip="+id+"'>Find out more...</a></p>";
							trip += "<h3 style='width:190px' class='homeSubTitle'><a target='_top' href='/travel/index.shtml?gotoTrip="+id+"'>"+title+"</a></h3>";
							trip += "<p style='width:190px' >"+message+"</p>";
							trip += "</div>";
						
						
					} // end if highlighted
				
				});  // end each trip
					
				if(showHighlightedDiv){
					$(".resultHighlight").html(trip);
					$(".resultHighlight").cycle({
									   cleartype:  1,
									   timeout: 6000
									   });
					
				} else {	
					$('#travelHighlight').hide();
				}
				
		  
		  }  // end function
	
	}); // end ajax
	
	} // end calltrip


function callPhotos(id, highlight) {
   //Photo URL
   var photosDiv = "photos";
   
   if(highlight) {
	photosDiv = "photosHighlight"   
   }
	
	//get trip photos
	$.ajax({
		   type: "GET",
		   url: '/travel/xml/photos.php?trip_id='+id,
		   dataType: "xml",
		   beforeSend: function() {	 $("."+photosDiv+id).html('<img style="border:0;" src="/global/images/loading.gif" alt="loading..." /><br />')},
		  // complete:  function() {	 $(".photos"+id).html('') } ,
		   success: function(photo_xml) {				
		
				var photos  = "";
				
				$(photo_xml).find('photo').each(function(){
					var photo_id = $(this).find('photo_id').text();
					var photo_file_type = $(this).find('filetype').text();
					var photo_content_type = $(this).find('content_type').text();
	
					//display current trip photos
						//photos += "<a class='fancybox' rel='gallery"+id+"' style='width:300px;height:235px;background:#D2E5E5' href='"+photo_url+photo_id+"."+photo_file_type+"' >";
						//photos += "<img style='width:290px;height:225px;' src='"+photo_url+photo_id+"."+photo_file_type+"?thumb=true' />";
						//photos += "</a>";
						if(highlight){
							photos += "<a target='_top' style='display:block;width:180px;height:140px;border:5px solid #2F6161;' href='/travel/index.shtml?gotoTrip="+id+"'>";
							photos += "<img style='width:180px;height:140px;display:block;' src='/travel/xml/photo.php?photo_id="+photo_id+"&amp;photo_type="+photo_file_type+"&amp;photo_content_type="+photo_content_type+"&amp;photo_thumb=true' />";
							photos += "</a>";
							return false; //only grab one photo

							
						} else {
						photos += "<a class='fancybox' rel='gallery"+id+"' href='/travel/xml/photo.php?photo_id="+photo_id+"&amp;photo_type="+photo_file_type+"&amp;photo_content_type="+photo_content_type+"&amp;photo_thumb=false'>";
						
						photos += "<img style='width:290px;height:225px;' src='/travel/xml/photo.php?photo_id="+photo_id+"&amp;photo_type="+photo_file_type+"&amp;photo_content_type="+photo_content_type+"&amp;photo_thumb=true' />";
						
						photos += "</a>"
						
						}							
	
				 });  //end each photo
				
				$("."+photosDiv+id).html(photos);
				
				
				///// this currently breaks when highlight is on same page
				

							
				if(highlight){
					/*$('.photos'+id).cycle({ 
						fx:      'fade', 
						height:	 145,
						pager:   '#pager'+id
					});	*/
				
				} else {
					
					var pager = "<div class='pager' id='pager"+id+"'></div><div class='clear'></div>";
					$('#pagerContainer'+id).html(pager);
					
					$("."+photosDiv+id).cycle({ 
						fx:      'fade', 
						height:	 225,
						pager:   '#pager'+id
					});	
					$('.fancybox').fancybox({
						'type' : 'image'
					});
					
				}		
				
		   } // end sucess fucntion
   }); // end ajax
	
} // end callphotos


function callLeaders(id){
	
	//get trip scholars

	$.ajax({
		   type: "GET",
		   url: '/travel/xml/leaders.php?trip_id='+id,
		   dataType: "xml",
		   beforeSend: function() {	 $(".scholars"+id).html('<img style="border:0;" src="/global/images/loadingAnimation.gif" alt="loading..." /><br />')},
		  // complete:  function() {	 $(".scholars"+id).html('') } ,
		   success: function(leaders_xml) {
			   var leaders  = "";
			   leaders  += "<h3>Scholars</h3><div class='messagearea'>";
			   
			   $(leaders_xml).find('leader').each(function(){
				
					var leader_id = $(this).find('id').text();
					var scholar_id = $(this).find('scholar_id').text();
					var leader_full_name = $(this).find('scholar_full_name').text();
						
					leaders += "<p><b> <a href='javascript:void(0);' onclick='callScholarBio("+scholar_id+");'>"+leader_full_name+"</a></b>";
					//leaders += "<span> <a href='javascript:void(0);' onclick='callScholarBio("+scholar_id+");'> more.. </a> </span>";
					// Loading Scholars
					//leaders += "<span class='loading_scholars"+scholar_id+"'></span></p>";
					leaders += "</p><p style='font-style:italic;' class='scholarBio"+scholar_id+"'></p>";
				
				});  //end each
			   
			   leaders += "</div>";
			   $('.scholars'+id).html(leaders);
			   
			   }  // end function
	});  // end success

} // end call leaders

function callScholarBio(scholar_id) {
	
	$.ajax({
		   type: "GET",
		   url: '/travel/xml/scholars.php?id='+scholar_id,
		   dataType: "xml",
		   beforeSend: function() {	 $(".scholarBio"+scholar_id).html('<img style="border:0;" src="/global/images/loadingAnimation.gif"  alt="loading..." /><br />')},
		  // complete:  function() {	 $(".scholarBio"+scholar_id).html('') } , 
		   success: function(scholars_xml) {
			   
			   var scholars = "";
			   
			   $(scholars_xml).find('scholar').each(function(){

				   var scholar_id = $(this).find('id').text();
				   var scholar_position = $(this).find('position').text();
				   var scholar_university =  $(this).find('university').text();
				   var scholar_college = $(this).find('college').text();
				   var scholar_biography = $(this).find('biography').text();
				   
				   scholars += "<span>"+scholar_position+" "+scholar_university+" "+scholar_college+"<br />"+scholar_biography+"</span>";
				  
			   
			   });
			   
			    $('.scholarBio'+scholar_id).html(scholars);
			   
		   }
	});	
}  // end scholarBio

function callOperator(operator_id) {
	
	$.ajax({
		   type: "GET",
		   url: '/travel/xml/operators.php?id='+operator_id,
		   dataType: "xml",
		   beforeSend: function() {	 $(".operator"+operator_id).html('<img style="border:0;" src="/global/images/loadingAnimation.gif" alt="loading..." /><br />')},
		  // complete:  function() {	 $(".operator"+operator_id).html('') } , 
		   success: function(scholars_xml) {
			   
			   var operators  = "";	
			   
			   $(scholars_xml).find('operator').each(function(){

				   var operator_id = $(this).find('id').text();
				   var operator_name = $(this).find('name').text();
				   var operator_description = $(this).find('description').text();
				   var operator_address = $(this).find('address').text();
				   var operator_email = $(this).find('email').text();
				   var operator_website = $(this).find('website').text();
				   var operator_phone = $(this).find('phone').text();
				   
				   //operators += "<div class='loading_logo"+operator_id+"' style='float:right;'></div>";
				   
				   operators += "<div class='operator_logo"+operator_id+" image-right'></div>";

				   operators += operator_description+"<p>"+operator_address+"<br /><a href='mailto:"+operator_email+"'>"+operator_email+"</a><br/><a href='"+operator_website+"'>"+operator_website+"</a><br />"+operator_phone+"</p>";
					
				 }); // end each operator
			   
			   $('.operator'+operator_id).html(operators);
			   
			   $(scholars_xml).find('operator').each(function(){
															  
					var operator_id = $(this).find('id').text();
					callOperatorLogo(operator_id);

			   });
			   
			   
		   }   // success
   
   }); // ajax
			   
	
}   // end call operator


function callOperators() {
	
	$.ajax({
		   type: "GET",
		   url: '/travel/xml/operators.php',
		   dataType: "xml",
		   beforeSend: function() {	 $(".operators").html('<img style="border:0;" src="/global/images/loadingAnimation.gif" alt="loading..." /><br />')},
		  // complete:  function() {	 $(".operators").html('') } , 
		   success: function(operators_xml) {
			   
			   var operators  = "";	
			   
			   $(operators_xml).find('operator').each(function(){

				   var operator_id = $(this).find('id').text();
				   var operator_name = $(this).find('name').text();
				   var operator_description = $(this).find('description').text();
				   var operator_address = $(this).find('address').text();
				   var operator_email = $(this).find('email').text();
				   var operator_website = $(this).find('website').text();
				   var operator_phone = $(this).find('phone').text();
				   
				   operators += "<h3><b>"+operator_name+"</b></h3>";
				   
				   operators += "<div class='messagearea'>";
				   
				   operators += "<div class='operator_logo"+operator_id+" image-right'></div>";
				   
				   operators += ""+operator_description+"<p>"+operator_address+"<br /><a href='mailto:"+operator_email+"'>"+operator_email+"</a><br/><a href='"+operator_website+"'>"+operator_website+"</a><br />"+operator_phone+"</p>";	
				  // operators += "<div class='loading_operator"+operator_id+"'></div>";
				   operators += "<div class='operator_trips"+operator_id+"'></div>";
				   
				   operators += "</div><br />";
				   
				 }); // end each operator
			   
			   $('.operators').html(operators);
			   
			   $(operators_xml).find('operator').each(function(){

				   var operator_id = $(this).find('id').text();
				   callOperatorLogo(operator_id);
				   callTripsByOperator(operator_id);
				   
			   });
			   
		   }   // success
   
   }); // ajax
			   
	
}   // end call operators

///////////////// LECTURERS PAGE ///////////////////////

function callScholars() {
	
	$.ajax({
		   type: "GET",
		   url: '/travel/xml/scholars.php',
		   dataType: "xml",
		   beforeSend: function() {	 $(".scholars").html('<img style="border:0;" src="/global/images/loadingAnimation.gif" alt="loading..." /><br />')},
		  // complete:  function() {	 $(".scholars").html('') } , 
		   success: function(scholars_xml) {
			   
			   var scholars  = "";//"<div class='messagearea'>";	
			   
			   $(scholars_xml).find('scholar').each(function(){

				   var scholar_id = $(this).find('id').text();
				   var scholar_full_name = $(this).find('full_name').text();
				   var scholar_positions = $(this).find('positions').text();
				   var scholar_university =  $(this).find('university').text();
				   var scholar_college = $(this).find('college').text();
				   var scholar_biography = $(this).find('biography').text();	   
				   
				   scholars += "<h3><b>"+scholar_full_name+"</b></h3>";

				   scholars  += "<div class='messagearea'>";	

				   scholars += "<span><b>Position : </b>"+scholar_positions+"<br /><b>University : </b>"+scholar_university+" <br /><b>College : </b>"+scholar_college+"</span><br /><b>Biography : </b>"+scholar_biography;
				   //scholars += "<div class='loading_scholar"+scholar_id+"'></div>";
				   scholars += "<div class='scholar_trips"+scholar_id+"'></div>";
				   
				   scholars += "</div><br />";	
			   
			   });
			   
			 
			   
			   $('.scholars').html(scholars);
			   
			   $(scholars_xml).find('scholar').each(function(){

				   var scholar_id = $(this).find('id').text();
				   callTripsByScholar(scholar_id);
				   
			   });
		   }
	});	
}  // end scholarBio

function callTripsByScholar(scholar_id){
	
	//get trip scholars

	$.ajax({
		   type: "GET",
		   url: '/travel/xml/leaders.php?scholar_id='+scholar_id,
		   dataType: "xml",
		   beforeSend: function() {	 $(".scholar_trips"+scholar_id).html('<img style="border:0;" src="/global/images/loadingAnimation.gif"  alt="loading..." /><br />')},
		   //complete:  function() {	 $(".scholar_trips"+scholar_id).html('') } ,
		   success: function(leaders_xml) {
			   var leaders  = "";
			   leaders  += "<p><b>Trip(s) : </b>";
			   
			   $(leaders_xml).find('leader').each(function(){
				
					var trip_title = $(this).find('trip_title').text();
					var trip_id = $(this).find('trip_id').text();
					
					// Loading Scholars
					//leaders += "<span><a href='javascript:void(0);' onclick='calltrip("+trip_id+");'>"+trip_title+"</a></span><br />";
					leaders += "<span><a href='/travel/index.shtml?gotoTrip="+ trip_id+"'>"+trip_title+"</a></span><br />";


				});  //end each
			   
			   leaders += "</p>";
			   
			   $('.scholar_trips'+scholar_id).html(leaders);
			   
			   }  // end function
	});  // end success

} // end call trips

function callTripsByOperator(operator_id){
	
	//get trip scholars

	$.ajax({
		   type: "GET",
		   url: '/travel/xml/trips.php?operator_id='+operator_id,
		   dataType: "xml",
		   beforeSend: function() {	 $(".operator_trips"+operator_id).html('<img style="border:0;" src="/global/images/loadingAnimation.gif"  alt="loading..." /><br />')},
		  // complete:  function() {	 $(".operator_trips"+operator_id).html('') } ,
		   success: function(trips_xml) {
			   var trips  = "";
			   trips  += "<p><b>Trips:</b><br />";
			   
			   $(trips_xml).find('trip').each(function(){
				
					var trip_title = $(this).find('title').text();
					var trip_id = $(this).find('id').text();
					
					// Loading Scholars
					//operators += "<span><a href='javascript:void(0);' onclick='calltrip("+trip_id+");'>"+trip_title+"</a></span><br />";
					trips += "<span><a href='/travel/index.shtml?gotoTrip="+ trip_id+"'>"+trip_title+"</a></span><br />";

				});  //end each
			   
			   trips += "</p>";
			   
			   $('.operator_trips'+operator_id).html(trips);
			   
			   }  // end function
	});  // end success

} // end call trips

function callOperatorLogo(operator_id){
	
		$.ajax({
		   type: "GET",
		   url: '/travel/xml/logos.php?operator_id='+operator_id,
		   dataType: "xml",
		   beforeSend: function() {	 $(".operator_logo"+operator_id).html('<img style="border:0;" src="/global/images/loading.gif"  alt="loading..." /><br />')},
		   //complete:  function() {	 $(".operator_logo"+operator_id).html('') } ,
		   success: function(operatorLogo_xml) {
			   var operatorLogos  = "";
			   
			   $(operatorLogo_xml).find('logo').each(function(){
				
					var photo_id = $(this).find('photo_id').text();
					var filetype = $(this).find('filetype').text();
					var photo_content_type = $(this).find('content_type').text();
					
					// Loading Scholars
					operatorLogos += "<img src='/travel/xml/photo.php?photo_id="+photo_id+"&amp;photo_type="+filetype+"&amp;photo_content_type="+photo_content_type+"&amp;photo_thumb=false' />";

				});  //end each
			   
			   operatorLogos += "";
			   
			   $('.operator_logo'+operator_id).html(operatorLogos);
			   
			   }  // end function
	});  // end success
	
} // call operator logo

function callAllTrips(){
	
	//get trip scholars

	$.ajax({
		   type: "GET",
		   url: '/travel/xml/trips.php',
		   dataType: "xml",
		   beforeSend: function() {	 $(".all").html('<img style="border:0;" src="/global/images/loadingAnimation.gif"  alt="loading..." /><br />')},
		  // complete:  function() {	 $(".operator_trips"+operator_id).html('') } ,
		   success: function(trips_xml) {
			   var trips  = "";
			  /* trips  += "<p><b>Trips:</b><br />";*/
			   
			   $(trips_xml).find('trip').each(function(){
				
					var trip_title = $(this).find('title').text();
					var trip_id = $(this).find('id').text();
					
					// Loading Scholars
					//operators += "<span><a href='javascript:void(0);' onclick='calltrip("+trip_id+");'>"+trip_title+"</a></span><br />";
					trips += "<span><a href='/travel/index.shtml?gotoTrip="+ trip_id+"'>"+trip_title+"</a></span><br />";

				});  //end each
			   
			   trips += "</p>";
			   
			   $('.all').html(trips);
			   
			   }  // end function
	});  // end success

} // end call trips

