
function locationSelector() {

var originalLocationImage = ""
var originalLocation = ""
var thisLocator = ""
var thisLocatorTitle = ""
var imageBeforeHover = ""
var imageOnBeforeHover = false

	
jQuery('#locationSelector').hover(function(){

	jQuery('#locationNames').show(200);
	jQuery('#locationNames ul').show(700);
	jQuery('#locationDetails').hide();
	

}, function(){

	jQuery('#locationNames ul').hide();
	jQuery('#locationNames').hide(200);
	
	//.clearQueue();
	
});


jQuery('#locationNames li').hover(function(){

	 thisLocator = jQuery(this).attr("id");
	
		jQuery(this).css('color','#FFAB3A');


}, function(){

	jQuery(this).css('color','#C8C8D2');
		
});




jQuery('#locationNames li ul li').click(function(){

	// hide any name span tags 
	jQuery('#mapLocations span').hide();
	
	//if the originalLocationImage is not empty, then update the previous clicked pointer src with the appropriate image
	if(originalLocationImage != "") {
		
	jQuery('#' + originalLocation).attr('src',originalLocationImage)	
		
	}
		
	//now update the location of this click from the class of the <li> + the keyword pointer
	thisLocator = jQuery(this).attr("class")+ 'pointer';
	
	//and update the originalLocation and originalLocationImage info
	originalLocation = thisLocator
	originalLocationImage = jQuery('#' + thisLocator ).attr('src')
	
	//finally set the current location with the 'on' image
	jQuery('#' + thisLocator).attr('src','images/locationOn.png');
		
	
	jQuery('#locationNames').hide();

$.ajax({
			type: 'GET',
			url: 'getLocation.asp',
			data: { id: jQuery(this).attr("class") },
			
			
			success: function(data){ 
							
				jQuery('#locationDetails').html(data); 
				jQuery('#locationDetails').show();
				
			}
				

		});	//close ajax call	
			
	});	
	

jQuery('#mapLocations img.pointer').click(function(){

	//Only run the function if we aren't on a selected location	
	if(imageOnBeforeHover == false){

	
	// hide any name span tags 
	jQuery('#mapLocations span').hide();
	jQuery('#locationDetails').hide();
		 	
			
	//if the originalLocationImage is not empty, then update the previous clicked pointer src with the appropriate image
	if(originalLocationImage != "") {
		
	jQuery('#' + originalLocation).attr('src',originalLocationImage)	
		
	}

	//now update the location of this click from the id of the item clicked (this includes the keyword 'pointer')	
	thisLocator = jQuery(this).attr("id");
		
	//and update the originalLocation and originalLocationImage info
	originalLocation = thisLocator
	// the originalLocationImage is copied from the imageBeforeHover as it has changed on the mouseover state
	originalLocationImage = imageBeforeHover
		

	//finally set the current location with the 'on' image
	jQuery('#' + thisLocator).attr('src','images/locationOn.png');
		
	//and set imageOnBeforeHover true as we now display the locationOn image
	imageOnBeforeHover = true
	
	
$.ajax({
			type: 'GET',
			url: 'getLocation.asp',
			data: { id: jQuery(this).attr("id") },
			
			
			success: function(data){ 
							
		
	
				jQuery('#locationDetails').html(data); 
				jQuery('#locationDetails').show();
				
			}
				

		});	//close ajax call	
		
}
			
});	
	
	
	
jQuery('#mapLocations img.pointer').hover(function(){

	 // store our original displayed image first
	 imageBeforeHover = jQuery(this).attr('src')
	 
	 
	 //if its a selected location set the imageOnBeforeHover flag
	 if(imageBeforeHover == "images/locationOn.png"){
		 
		 imageOnBeforeHover = true
	 
 	} 
 	
 	//if not ..... display the locationOn image
 	if(imageOnBeforeHover == false){
	 	
	 	
	 	 	jQuery(this).attr('src','images/locationOn.png')
	
 	}
 	

 	//construct the id of the relevant name tag for this location and then show it
 	thisLocatorTitle = jQuery(this).attr("id")+ 'Name';
 	jQuery('#'+thisLocatorTitle).show();

 	//alert(thisLocator)
 	
		
}, function(){
	
	// if we werent on a selected location - restore the original image 
	if(imageOnBeforeHover == false){
		
		 jQuery(this).attr('src',imageBeforeHover)

  	} else  {
	  	
		//else just reset the imageOnBeforeHover flag ready for the next mouseover event
		imageOnBeforeHover = false

   }
   
 	//hide the relevant name tag for this location	
 	jQuery('#'+thisLocatorTitle).hide();

	
});


	

		
	
		
}

