function regionShow(i){
	if( i == "first") i = $("#land_tabs ul li").length - 1;
	var $tab = $("#land_tabs ul li").removeClass("selected").eq(i).addClass("selected"),
	count = $("#land_tabs ul li").length - 1,
	left = $tab[0].offsetLeft,
	width = $tab.width();
	left = left + (width/2) + 6;

	$("#top_topic img.white_arrow").animate({left : left+'px'},500);
	var x = $("div.region_publications").filter(".selected");
	$("#publications").fadeOut(500,function(){
		x.removeClass("selected");
		$("div.region_publications").eq(count-i).addClass("selected");
		$("#publications").fadeIn(500);
	})
	if (x.length==0){
		$("#publications").hide();
		$("div.region_publications").eq(count-i).addClass("selected");
		$("#publications").fadeIn(500);

	}
}

$(function(){
	var mutex = 0;
	if( ($("#land_tabs ul li").length > 0) && geoloc){
		if(geoloc.name == 'Australia')   regionShow(0);
		else{
			switch(geoloc.region){
			case 'Asia Pacific' : regionShow(1); break;
			case 'Middle East'  : regionShow(2); break;
			case 'Africa'       : regionShow(3); break;
			case 'Europe'       : regionShow(4); break;
			case 'South America': regionShow(5); break;
			case 'North America': regionShow(5); break;
			default : regionShow(6); 
			}

		}
	}


	$('#features .feature').click(function(){
		window.location.href = $(this).find('a').attr('href');
	});

	$("#land_tabs ul li").click(function(){
		var index = $(this).prevAll("li").length;
		regionShow(index);
	}).hover(
			function(){$(this).addClass("hover");},
			function(){$(this).removeClass("hover");}
	);

	$("#center h1:first").remove();


	$("div.area_feature_details h3").click(function(){
		var $l = $(this).nextAll("a.learn_more");
		window.location.href = $l.attr("href");	
	}).hover(
			function(){$(this).css("textDecoration","underline");},
			function(){$(this).css("textDecoration","none");}
	);

	$("div.small_topic h4").click(function(){
		var $l = $(this).nextAll("a.learn_more");
		window.location.href = $l.attr("href");		
	}).hover(
			function(){$(this).css("textDecoration","underline");},
			function(){$(this).css("textDecoration","none");}
	);

	$("div.right_part").height( $("#key_areas").height());


	$("#explore_tabs div.explore_topic:first").hover(
			function(){
				$("#explore_tabs div.explore_topic:first").children("div.explore_popup").show();
			},
			function(){
				$("#explore_tabs div.explore_topic:first").children("div.explore_popup").hide();
			});

	$("#explore_tabs div.explore_topic:eq(1)").hover(
			function(){
				$("#explore_tabs div.explore_topic:eq(1)").children("div.explore_popup").show();
			},
			function(){
				$("#explore_tabs div.explore_topic:eq(1)").children("div.explore_popup").hide();
			});

	///////////flash replacement/////////////////////////////////


});

