	// globals
	home_country = null;
	dest_country = null;
	map_open = false;
	
	// defines
	var CH = {
		name:'China',
		code:'ch',
		left:659,
		top:206,
		size:'small',
		link_name:'china'
	};
	var KH = {
		name:'Cambodia',
		code:'kh',
		left:651,
		top:245,
		size:'small',
		link_name:'cambodia-laos'
	};
	var BR = {
		name:'Brazil',
		code:'br',
		left:347,
		top:315,
		size:'small',
		link_name:'brazil'
	};
	var AR = {
		name:'Argentina',
		code:'ar',
		left:312,
		top:383,
		size:'small',
		link_name:'argentina'
	};
	var EC = {
		name:'Galapagos Islands',
		code:'ec',
		left:312,
		top:383,
		size:'small',
		link_name:'go-go-galapagos'
	};
	var SV = {
		name:'El Salvador',
		code:'sv',
		left:280,
		top:258,
		size:'small',
		link_name:'el-salvador'
	};
	var CR = {
		name:'Costa Rica',
		code:'cr',
		left:290,
		top:265,
		size:'small',
		link_name:'costa-rica'
	};
	var KE = {
		name:'Kenya',
		code:'ke',
		left:520,
		top:273,
		size:'small',
		link_name:'project-kenya-safari'
	};
	var NP = {
		name:'Nepal',
		code:'np',
		left:607,
		top:221,
		size:'small',
		link_name:'nepal'
	};
	var PE = {
		name:'Peru',
		code:'pe',
		left:295,
		top:311,
		size:'small',
		link_name:'peru'
	};
	var ZA = {
		name:'South Africa',
		code:'za',
		left:487,
		top:336,
		size:'small',
		link_name:'overland-south-africa'
	};
	var TZ = {
		name:'Tanzania',
		code:'tz',
		left:516,
		top:280,
		size:'small',
		link_name:'tanzania'
	};
	var ZM = {
		name:'Zambia',
		code:'zm',
		left:502,
		top:307,
		size:'small',
		link_name:'zambia'
	};
	var IN = {
		name:'India',
		code:'in',
		left:597,
		top:234,
		size:'small',
		link_name:'project-rajasthan'
	};
	
	
	// list of countries
	var countries = [CH,KH,BR,AR,EC,SV,CR,KE,NP,PE,ZA,TZ,ZM,IN];
	
	
	$().ready(function() {
		init_map();
	});
	
	
	/////////////////////////////////////////////////////////////
	// close map
	function toggle_map() {
		speed = 1000;
		if (map_open) {
			
			$('#map_holder').animate({
				height: '-=425'
			}, speed, function() {});
			
			$('#map').animate({
				top: '-=425'
			}, speed, function() {});
			
			map_open = false;
		} else {
			
			$('#map_holder').animate({
				height: '+=425'
			}, speed, function() {});
			
			$('#map').animate({
				top: '+=425'
			}, speed, function() {});
			
			map_open = true;
		}
	}
	
	
	/////////////////////////////////////////////////////////////
	// initilise map
	function init_map() {
		for (i in countries) {
			add_home_marker(countries[i]);
		}
	}
	
	
	
	/////////////////////////////////////////////////////////////
	// select a home
	function toggle_home(country) {
		
		if (!home_country && country) {
			
			// save selection
			home_country = country;
			
			// change icon
			$('#map #H_'+country.code).attr('src','/images/resources/map/map_pin_dest_'+country.size+'.png');
			
			// hide all other homes
			$('#map .Home').each(function(index) {
				if ($(this).attr('id')!='H_'+country.code) $(this).fadeTo('fast',0);
			});
			
			// update instructions
			$('#info_heading').html(country.name);
			$('#info_body').html('Click here to find out more about volunteering in <span class="dest">'+country.name+'</span><a id="info_button" href="/voluntour/'+home_country.link_name+'/"><img src="/images/resources/map/learn_more.png" /></a>');
			$('#info_flag').html('<img src="/images/resources/map/flags/'+country.code+'.png" width="32" height="32" />');
			
			// update flag
			$('#map_menu_dest').html('<img src="/images/resources/map/flags/'+country.code+'.png" width="32" height="32" />');
			
		} else {
			// deselect everything
			
			// remove selection
			home_country = null;
			
			// change icon
			if (country)
				$('#map #H_'+country.code).attr('src','/images/resources/map/map_pin_default_'+country.size+'.png');
					
			// show all homes
			$('#map .Home').each(function(index) {
				$(this).fadeTo('fast',1);
			});
			
			// update instructions
			$('#info_heading').html('Instructions');
			$('#info_body').html('Where would you like to volunteer? Select a <span>Country</span>.');
			$('#info_flag').html('<img src="/images/resources/map/map_flatpin_grey.png" />');
			
			// update flag
			$('#map_menu_dest').html('<img src="/images/resources/map/flags/unselected.png" width="32" height="32" />');
			
		}
		
		
	}
	
	
	/////////////////////////////////////////////////////////////
	// add a home marker
	function add_home_marker(country) {
		
		// image source
		src = '/images/resources/map/map_pin_default_'+country.size+'.png';
		
		// adjust for image offsets
		if (country.size=='small') {		// small
			x = country.left-10;
			y = country.top-22;
		} else {							// normal
			x = country.left-13;
			y = country.top-30;
		}
		
		// add marker
		$('#map').append('<img id="H_'+country.code+'" class="Marker Home" style="top:'+y+'px; left:'+x+'px" src="'+src+'" />');
		
		// add actions to marker
		$('#map #H_'+country.code).hover(
			function() {
				// show home lines if home hasn't been chosen yet
				if (!home_country) {
					// hide all other homes
					$('#map .Home').each(function(index) {
						if ($(this).attr('id')!='H_'+country.code) $(this).stop().fadeTo('fast', 0.3);
					});
				}
			},
			function() {
				// hide home lines if home hasn't been chosen yet
				if (!home_country) {
					// show all homes
					$('#map .Home').each(function(index) {
						$(this).stop().fadeTo('fast',1);
					});
				}
			}
		).click(function() {
			toggle_home(country);
		});
		
	}
	
