

function setUpPageLayout()
{
	try
	{
		Drupal.behaviors.myModuleBehavior = function (context) {

			//$('#navigation li:eq(0) a:hover').addClass('background_menu');
			setMouseOverOnMenuItem(0,'menu_green');
			setMouseOverOnMenuItem(1,'menu_blue');
			setMouseOverOnMenuItem(2,'menu_yellow');
			setMouseOverOnMenuItem(3,'menu_purple');
			setMouseOverOnMenuItem(4,'menu_brown');
			setMouseOverOnMenuItem(5,'menu_red');
			setUpChangeLocationButton();
			if(user_location)
			{
			$('#top_right').animate({right:'2px'},0); 			
			}
			else
			{
			$('#top_right').animate({right:'2px'},2000); 			
			}

			$('#section-top-boxes_left p:eq(2)').remove();
 		
			if($('#travelToFromBolivia').length > 0)
			{
				setUpGettingTooAndFromBolivia();
			}
			if($('#backPackInBoliviaPage').length > 0)
			{
				setUpBackPackInBoliviaPage();
			}			

		};
		


		
	}
	catch(error)
	{
	
	}
	
	
	//#navigation   li.menu-114 a:hover { background: black; }
	//#navigation   li.menu-114 a:hover { background: black; }
	//#navigation   li.menu-114 a:hover { background: black; }
	//#navigation   li.menu-114 a:hover { background: black; }

}

	function setUpBackPackInBoliviaPage()
	{
		$('#backPackInBoliviaPage .backPackInBoliviaPageContent').addClass('hidden');
		$('#backPackInBoliviaPage h2').click(function(){		
		
			var the_header = $(this);
			var the_content = $(this).next('.backPackInBoliviaPageContent');
			var the_content_id = the_content.attr('id');

			//$(".main_content:not(#"+the_content_id+")").addClass('hidden');
			
				if(the_content.is(":visible"))
				{
					the_content.slideUp();
					the_content.addClass('hidden');				

				}
				else
				{
					the_content.slideDown();
					the_content.removeClass('hidden');
				}		
			});
	}

     function setUpGettingTooAndFromBolivia()
	 {
		$('.main_content').addClass('hidden');
			$('.bolivia_by_road_div').prepend('<h2> By Land Road </h2>');
			$('.bolivia_by_water_div').prepend('<h2> By Water </h2>');
			$('.bolivia_by_flight_div').prepend('<h2> By Plane </h2>');
			$('.bolivia_by_railroad_div').prepend('<h2> By Plane </h2>');			

		$('.main_header').click(function(){
		
		
			var the_header = $(this);
			var the_content = $(this).next();
			var the_content_id = the_content.attr('id');

			//$(".main_content:not(#"+the_content_id+")").addClass('hidden');
			
				if(the_content.is(":visible"))
				{
					the_content.slideUp();
					the_content.addClass('hidden');				

				}
				else
				{
					the_content.slideDown();
					the_content.removeClass('hidden');
				}			
		
		
		});
	  
	  }





function editWeatherBox()
{

}
function openHowToGetToBolivia()
{
	openPopUp({url:'12/popup',name:'Getting To And From Bolivia',width:'600',height:'600'});
}

function openPopUp(params)
{
	var the_window = window.open(params.url, params.name, 'width='+params.width+', height=' + params.height + ',scrollbars=yes'); 
	return false;
}
function openAccomDetails(the_id)
{
	openPopUp({url:'2/popup?type=accom&id='+the_id,name:'Accom Details',width:'600',height:'600'});
}
function openCompanyDetails(the_id)
{
	openPopUp({url:'6/popup?type=company&id='+the_id,name:'Getting To And From Bolivia',width:'600',height:'600'});
}
function openActivityDetails(the_id)
{
	openPopUp({url:'6/popup?type=activity&id='+the_id,name:'Activity Details',width:'600',height:'600'});
}


  function setMouseOverOnMenuItem(number,the_class)
  {
 			$('#navigation li a').eq(number).mouseover(function(){
				$(this).addClass(the_class);
			}).mouseout(function(){
				$(this).removeClass(the_class);
			}) 
  }

 function setUpChangeLocationButton()
 {
    $('.location_dropdowns').change(function () {
          var location = $(this).val();	
		  callServerRequest('setUserLocation','location='+ location);
		  $("#location_change_button").attr('value','Click here to go ' + location);
        })

 }
 
 function openPopUpMap()
 {
    html_location = root_location + '/js_css_inc/js/plugins/zoommap/bolivia_map.html';
	openXWindowPopUp({html_page:html_location,height_p: 500,width_p: 500,title_p: "Map",draggable_p: true,resizable_p: true,closable_p: true,maximizable_p: true});
 
 }
 
 	    function openXWindowPopUp(options) {
				window_counter = 0;
	            var d = {
	                html_page: '',
	                height_p: 200,
	                width_p: 200,
	                title_p: "[TITLE]",
	                max_window: false,
	                html_content: '',
	                the_script_to_run: '',
	                type_of_content_p: null,
	                window_menu_p: '',
	                draggable_p: true,
	                resizable_p: true,
	                closable_p: true,
	                maximizable_p: true,
	                scrolling_p: 'auto',
	                closefunction_p: null
	            };
	                var the_html_content = '';
	                if (d.height_p > $(window).height()) {
	                    d.height_p = $(window).height() - 40;

	                }
	                if (d.max_window) {
	                    d.width_p = $(window).width() - 40;
	                    d.height_p = $(window).height() - 40;
	                }				
				
	            $.extend(d, options);
	                $('body').after("<div id= 'box" + window_counter + "'></div>");				
	                var the_window_class = $('#box' + window_counter).xWindow({ html_page: d.html_page, content: d.html_content, width: d.width_p, height: d.height_p, title: d.title_p, counter: window_counter, script_to_run: d.the_script_to_run, type_of_content: d.type_of_content_p, window_menu: d.window_menu_p, draggable: d.draggable_p, resizable: d.resizable_p, closable: d.closable_p, maximizable: d.maximizable_p, scrolling: d.scrolling_p, closefunction: d.closefunction_p });
	                //return the_window_class;
	                return false; // returning false so that if it is called from link then it wouldnt go to the top of the page with a "#" in the url

  }
         function addIframeLoader(the_id) {
            the_title_bar = $('#' + the_id).parents('.xWindow').find('.xWindow-titlebar .title');
            the_title_bar.before("<span class = 'loader_span'><span class = 'loader_span_img'><img src  = 'images/bigrotation2.gif'/></span><span class = 'loader_span_text'>  Loading Page </span></span>");

        }  
		
	function getCurrencyForValue()
	{
		carryOutCurrencyRequest('136|27|51|24',$('#curr_value').val(),$('#currency_selected').val());
	}	
		
	function carryOutCurrencyRequest(currencies,amount,currencyGiven)
	{

		$('#currency_result').html('please wait getting result');
		$.get(root_location + '/target_page.php?ajax_server_function=currencyRequest&currencies='+currencies+'&amount='+amount+'&currency_given='+currencyGiven, function(data) {
						handleCurrencyResponse(data);
		});
	
	}

	
	
	function handleCurrencyResponse(data)
	{
		data = data.replace(/{/gi, "")
		var array=data.split("}");
		var the_final_array = new Array(); 
		var the_counter = 0;
		for (x in array)
		{
			the_value = array[x].replace(/"/gi, "");
			//console.log(the_value);
			var sub_array=the_value.split(",");
			the_final_array[the_counter] = new Array();
			for (y in sub_array)
			{			
				var sub_2_array=sub_array[y].split(":");
				the_final_array[the_counter][sub_2_array[0]] = sub_2_array[1];
			}
			
			the_counter++;
		}
		$html_display = '';
		for (the_details in the_final_array)
		{
			if(typeof(the_final_array[the_details]['currency_list_two']) != 'undefined')
			{
				$html_display = $html_display + "this converts to " + the_final_array[the_details]['currency_list_two'] + " (" + the_final_array[the_details]['converter'] + ")<br />" ;
			}
		}
		flog($html_display);
		
		$('#currency_result').html($html_display);
		
		
	}		
		
	function flog(value)
	{
		try
		{
			console.log(value);
		}
		catch(error)
		{
		
		}
	}
		
		function callServerRequest(type,value)
		{
/*		
		
			$.ajax({
				type: "GET",
				url: root_location + "/target_page.php",

				data: "ajax_server_function="+ type+'&'+ value, 
				success: function(response) {
					handleAjaxResponse(response);
				},
				error: function(res, textStatus, errorThrown) {
					alert('Sorry there was an unexpected error');
				}
			});
			*/
			
		$.get(root_location + '/target_page.php?ajax_server_function='+ type+'&'+ value, function(data) {
						handleAjaxResponse(data);
		});			
			
		}
		
		function setUserLocation(location_id)
		{
		  callServerRequest('setUserLocation','location='+ location_id);		
		
		}
		
		function handleAjaxResponse(response)
		{
			window.location.reload();
		}
	    function windowMinimized(number) {
	        $('.titleSelected').removeClass('titleSelected');
	        $('#window_toolbar_title' + number).addClass('titleMinimized');
	    }

	    function windowMaximized(number) {
	        $('.titleSelected').removeClass('titleSelected');
	        $('#window_toolbar_title' + number).removeClass('titleMinimized');
	    }

	    function closeWindowTitle(number) {	        
	        $('#box' + number).parent().remove();
	    }		
        function removeIframeLoader(the_id) {
            if ($('#the_ws_contact_loader').length > 0) {
                $('#the_ws_contact_loader').remove();
            }
            else {
                $('#' + the_id).parents('.xWindow').find('.xWindow-titlebar .loader_span').remove();
            }
        }		
  function setUpTheMap()
 {


$('#bolivia_map').zoommap({
		// Width and Height of the Map
		width: '400px',
		height: '350px',
			
		//Misc Settings
		blankImage: 'images/blank.gif',
		zoomDuration: 1000,
		bulletWidthOffset: '10px',
		bulletHeightOffset: '10px',
		
		//ids and classes
		zoomClass: 'zoomable',
		popupSelector: 'div.popup',
		popupCloseSelector: 'a.close',
		
		//Return to Parent Map Link
		showReturnLink: true,
		returnId: 'returnlink',
		returnText: 'return to South America map',
		
		//Initial Region to be shown
		map: {
			id: 'southamerica',
			image: 'images/southamerica.gif',
			data: 'popups/southamerica.html',
			maps: [
			{
				id: 'bolivia',
				parent: 'southamerica',
				image: 'images/bolivia.gif',
				data: 'popups/bolivia.html',
				width: '80px',
				height: '80px',
				top: '90px',
				left: '140px'
				/* More maps can be nested
				maps : [ ]
				*/
			}
			]
		}
	});

 }