$(document).ready(function(){
	$(".ww-callout").children(".ww-heading").click(function(){
		$(this).parent().siblings().children(".ww-info").hide("slow");
		$(this).parent().children(".ww-info").toggle("slow"); // Changed from show to toggle so we can collapse ourself
	});       


	$(".point-na").click(function(){
		$(".info-la").hide("slow");
		$(".info-emea").hide("slow");	
		$(".info-ap").hide("slow");		
		$(".info-na").show("slow");
	});

	$(".point-la").click(function(){
		$(".info-na").hide("slow");
		$(".info-emea").hide("slow");	
		$(".info-ap").hide("slow");	
		$(".info-la").show("slow");
	});

	$(".point-ap").click(function(){
		$(".info-la").hide("slow");
		$(".info-emea").hide("slow");	
		$(".info-na").hide("slow");	
		$(".info-ap").show("slow");
	});

	$(".point-emea").click(function(){
		$(".info-la").hide("slow");
		$(".info-na").hide("slow");	
		$(".info-ap").hide("slow");	
		$(".info-emea").show("slow");
	});

	$("#ww-map li a").css({backgroundImage:"none"}); 
	attachNavEvents("na");
	attachNavEvents("la");
	attachNavEvents("emea");
	attachNavEvents("ap");	
	function attachNavEvents(myClass) {
		$("#" + myClass + ' a').append('<div id="ww-map-' + myClass + '"></div>');
		$("#" + myClass + ' a div').css('opacity', 0)
		$("#" + myClass + ' a').hover(
		function() {
			$("#" + myClass + ' a div').stop().animate({"opacity": "1"}, 300);
		},
		function() {
			$("#" + myClass + ' a div').stop().animate({"opacity": "0"}, 300);
		});
	}
						   
	var hash = window.location.hash.substr(1);
	var href = $('.ww-tablelink').each(function(){
		var href = $(this).attr('href');
		if(hash==href.substr(0,href.length-5)){
			var toLoad = hash+'.html #ww-location-content';
			$('#ww-location-content').load(toLoad)
		}											
	});

	$('.ww-tablelink').click(function(){
								  
		var toLoad = $(this).attr('href')+' #ww-location-content';
		$('#ww-location-content').hide('blind',loadContent);
		$('#load').remove();
		$('#ww-wrapper').append('<span id="load">LOADING...</span>');
		$('#load').hide('clip');
		window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
		function loadContent() {
			$('#ww-location-content').load(toLoad,'blind',showNewContent())
		}
		function showNewContent() {
			$('#ww-location-content').show('blind',hideLoader());
			setTimeout("$('html').animate({scrollTop: '830'});", 400);
		}
		function hideLoader() {
			$('#load').hide('blind');
		}
		return false;
		
	});
	
	//added a hash read to expand the section called when coming from other pages  NA12292
	if (window.location.hash){
		var hash = window.location.hash;				
        hash = hash.replace('#', '');//remove # to use jsut the text
		hash = hash.split('-');//added "-top" to keep it from jumping to bottom of the page and this removes the -top to make it usable for the click below
		click = hash[0]; //set click to hash with out the  "-top"	
		$(".point-"+click).trigger('click');}
});
