

$(document).ready(function(){

	var theme_path = "/de/wp-content/themes/vm";

	var south_america = theme_path + "/images/20-worlds/map/map-2";
	var africa = theme_path + "/images/20-worlds/map/map-4";
	var europe = theme_path + "/images/20-worlds/map/map-3";
	var cell_background = theme_path + "/images/20-worlds/cuadro_blanco.png";	


	/* EUROPE -- ONLY SPAIN*/
	$.fn.showEurope = function(){
		var eu_index = arguments[0];
		var eu_country = arguments[1];
		var eu_highlight = europe;

		if(eu_index == 0 || eu_country == "es"){ //guinea
			eu_highlight += "/mundo_3_espana.png";
		}else{ 
			eu_index = -1;
		}	
		if(eu_index != -1){
			$("div#mundo_3 img").attr("src", eu_highlight);
		}
	}

	$.fn.hideEurope = function(){
		//restore original
		var eu_original = europe + "/mundo_3.png";
		$("div#mundo_3 img").attr("src", eu_original);
	}	/* espana es*/
	$("#countries-list tr:eq(0) td:eq(0)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\')");
		$("div#mundo_2 img").showEurope(99999,"es");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideEurope(99999, "es");
	});
	
	/* AFRICA GUINEA ECUATORIAL*/
	
	$.fn.showAfrica = function(){
		var afr_index = arguments[0];
		var afr_country = arguments[1];
		var afr_highlight = africa;

		if(afr_index == 0 || afr_country == "gq"){ //guinea
			afr_highlight += "/mundo_4_guinea.png";
		}else{ 
			afr_index = -1;
		}	
		
		if(afr_index != -1){
			$("div#mundo_4 img").attr("src", afr_highlight);
		}	
	}

	$.fn.hideAfrica = function(){
		var africa_index = arguments[0]; /* use if needed*/
		var africa_country = arguments[1];

		//restore orignal map
		var afr_original = africa + "/mundo_4.png";
		$("div#mundo_4 img").attr("src", afr_original);
		
	}



	/* SOUTH AMERICA */
	$.fn.showSA = function(){ //call when mouse enter img map
		var sa_index = arguments[0];
		var sa_country = arguments[1];
		var sa_highlight = south_america; 
		var afr_highlight = africa;

		if(sa_index == 0 || sa_country == "ar" ){ //argentina - need double map
			sa_highlight += "/mundo_2_argentina_1.png";
			afr_highlight += "/mundo_4_argentina_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);

		}else if(sa_index == 1 || sa_country == "bo"){ //bolivia - need double map
			sa_highlight += "/mundo_2_bolivia_1.png";
			afr_highlight += "/mundo_4_bolivia_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);

		}else if(sa_index == 2 || sa_country == "cl"){ //chile - need double map
			sa_highlight += "/mundo_2_chile_1.png";
			afr_highlight += "/mundo_4_chile_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);

		}else if(sa_index == 3 || sa_country == "pa"){ //panama
			sa_highlight += "/mundo_2_panama.png";

		}else if(sa_index == 4 || sa_country == "gt"){ //guatemala
			sa_highlight += "/mundo_2_guatemala.png";

		}else if(sa_index == 5 || sa_country == "cr"){ // costa rica - need double map
			sa_highlight += "/mundo_2_costarica_1.png";
			afr_highlight += "/mundo_4_costarica_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);			

		}else if(sa_index == 6 || sa_country == "cu"){ //cuba
			sa_highlight += "/mundo_2_cuba.png";

		}else if(sa_index == 7 || sa_country == "ec"){ //ecuador - double map
			sa_highlight += "/mundo_2_ecuador_1.png";
			afr_highlight += "/mundo_4_ecuador_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);

		}else if(sa_index == 8 || sa_country == "co"){ //colombia - double map
			sa_highlight += "/mundo_2_colombia_1.png";
			afr_highlight += "/mundo_4_colombia_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);

		}else if(sa_index == 9 || sa_country == "sv"){ //el salvador
			sa_highlight += "/mundo_2_elsalvador.png";
		
		}else if(sa_index == 10 || sa_country == "hn"){ // honduras - double map
			sa_highlight += "/mundo_2_honduras_1.png";
			afr_highlight += "/mundo_4_honduras_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);

		}else if(sa_index == 11 || sa_country == "mx"){ // mexico
			sa_highlight += "/mundo_2_mexico.png";

		}else if(sa_index == 12 || sa_country == "ni"){ //nicaragua - double map
			sa_highlight += "/mundo_2_nicaragua_1.png"; 
			afr_highlight += "/mundo_4_nicaragua_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);			

		}else if(sa_index == 13 || sa_country == "uy"){ //uruguay - double map
			sa_highlight += "/mundo_2_uruguay_1.png";
			afr_highlight += "/mundo_4_uruguay_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);

		}else if(sa_index == 14 || sa_country == "py"){ // paraguay - double map
			sa_highlight += "/mundo_2_paraguay_1.png";
			afr_highlight += "/mundo_4_paraguay_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);

		}else if(sa_index == 15 || sa_country == "pe"){ //peru
			sa_highlight += "/mundo_2_peru.png";			

		}else if(sa_index == 16 || sa_country == "ve"){ //venezuela - double map
			sa_highlight += "/mundo_2_venezuela_1.png";
			afr_highlight += "/mundo_4_venezuela_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);	

		}else if(sa_index == 17 || sa_country == "do"){ //rep dominicana - double map
			sa_highlight += "/mundo_2_repdominicana_1.png";
			afr_highlight += "/mundo_4_repdominicana_2.png";
			$("div#mundo_4 img").attr("src", afr_highlight);		

		}else{
			sa_index = -1;
		}

		if(sa_index != -1){
			$("div#mundo_2 img").attr("src", sa_highlight);
		}		
	}

	$.fn.hideSA = function(){ //call when mouse leaves img map
		var sa_index = arguments[0];
		var sa_country = arguments[1];

		//restore map without highlights
		var sa_original = south_america + "/mundo_2.png";				
		$("div#mundo_2 img").attr("src", sa_original);
		
		/* 
		argentina bolivia chile 
		costa rica ecuador colombia
		honduras nicaragua uruguay
		paraguay venezuela rep dominicana
		*/
		if((sa_index == 0 || sa_country == "ar") || (sa_index == 1 || sa_country == "bo") ||
			(sa_index == 2 || sa_country == "cl") || (sa_index == 5 || sa_country == "cr") ||
			(sa_index == 7 || sa_country == "ec") || (sa_index == 8 || sa_country == "co") ||
			(sa_index == 10 || sa_country == "hn") || (sa_index == 12 || sa_country == "ni") || 
			(sa_index == 13 || sa_country == "uy") || (sa_index == 14 || sa_country == "py") || 
			(sa_index == 16 || sa_country == "ve") || (sa_index == 17 || sa_country == "do")){ 		
			var afr_original = africa + "/mundo_4.png" ; //restore africa map
			$("div#mundo_4 img").attr("src", afr_original);
		}
	}

	/* FIRST ROW */
	/* espana es*/
	$("#countries-list li:eq(0)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat top left");
		$("div#mundo_2 img").showEurope(99999,"es");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideEurope(99999, "es");
	});

	/* argentina */
	$("#countries-list li:eq(1)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"ar");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "ar");
	});
	/* bolivia*/
	$("#countries-list li:eq(2)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"bo");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "bo");
	});	
	/*chile*/
	$("#countries-list li:eq(3)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"cl");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "cl");
	});

	/* SECOND ROW*/
	/*colombia co*/
	$("#countries-list li:eq(4)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"co");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "co");
	});
	/*costa rica cr*/
	$("#countries-list li:eq(5)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"cr");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "cr");
	});
	/*cuba cu*/
	$("#countries-list li:eq(6)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"cu");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "cu");
	});
	/*ecuador ec*/
	$("#countries-list li:eq(7)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"ec");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "ec");
	});
	/* THIRD ROW*/
	/*el salvador sv */
	$("#countries-list li:eq(8)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"sv");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "sv");
	});

	/*guatemala*/
	$("#countries-list li:eq(9)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"gt");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "gt");
	});
	/* honduras */
	$("#countries-list li:eq(10)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"hn");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "hn");
	});
	/* mexico*/
	$("#countries-list li:eq(11)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"mx");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "mx");
	});
	
	/*FOURTH ROW*/
	/* nicaragua */
	$("#countries-list li:eq(12)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"ni");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "ni");
	});
	/*panama*/
	$("#countries-list li:eq(13)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"pa");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "pa");
	});
	/* paraguay */
	$("#countries-list li:eq(14)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"py");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "py");
	});
	/* peru */
	$("#countries-list li:eq(15)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"pe");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "pe");
	});


	/*FIFTH ROW*/
	/* rep dominicana do*/
	$("#countries-list li:eq(16)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"do");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "do");
	});
	/* uruguay*/
	$("#countries-list li:eq(17)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"uy");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "uy");
	});
	/* venezuela ve*/
	$("#countries-list li:eq(18)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showSA(99999,"ve");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideSA(99999, "ve");
	});
	/* guinea ecuatorial*/
	$("#countries-list li:eq(19)").mouseenter(function(){
		$(this).css("background","url(\'" + cell_background + "\') no-repeat center left");
		$("div#mundo_2 img").showAfrica(99999,"gq");

	}).mouseleave(function(){
		$(this).css("background","none");
		$("div#mundo_2 img").hideAfrica(99999, "gq");
	});	

	/* IMAGE MAPS SA, EUROPE, AFRICA */
	$("map#south-america area").mouseenter(function(){
		var index = $("map#south-america area").index(this);
		$("div#mundo_2 img").showSA(index);
		$("div#output").text(index);
	}).mouseleave(function(){
		var index = $("map#south-america area").index(this);
		$("div#mundo_2 img").hideSA(index);
		$("div#output").text(index);	
	});

	$("map#europe area").mouseenter(function(){
		var index = $("map#europe area").index(this);
		$("div#mundo_3 img").showEurope(index);
		
	}).mouseleave(function(){
		var index = $("map#europe area").index(this);
		$("div#mundo_3 img").hideEurope(index);
	});

	$("map#africa area").mouseenter(function(){
		var index = $("map#africa area").index(this);
		$("div#mundo_4 img").showAfrica(index);
	}).mouseleave(function(){
		var index = $("map#africa area").index(this);
		$("div#mundo_4 img").hideAfrica(index);
	});

});

