jQuery(document).ready(function($){
    if ($(".verden").length) {
	// if we are in a document with .verden
	var trigger_europa, trigger_afrika, trigger_amerika, trigger_australia, trigger_asia, called_from_trigger;

enlighten_continent = function(continent) {
	var el = continent
	if ($.browser.msie) {
	    $("#sol_" + el).stop(true, true).show();
	}	else {
	    $("#sol_" + el).stop(true, true).fadeIn('fast');
	}
    }
darken_continent = function(continent) {
	var el = continent;
	if ($.browser.msie) {
	    $("#sol_" + el).stop(true, true).hide();
	}	else {
	    $("#sol_" + el).stop(true, true).fadeOut('slow');
	}
    }

	$(document).mousemove(function(e){
	    var half_size = $(window).width()/2;
	    var mouseX = half_size - e.pageX;
	    var mouseY = e.pageY;

	    if (mouseX > 270 && mouseX < 485 && mouseY > 450) {
		trigger_amerika = true;
    enlighten_continent("amerika")
		$("body").css({cursor: "pointer"});
	    } else {
		if (trigger_amerika) {
		    $("body").css({cursor: "auto"});
        darken_continent("amerika");
		    trigger_amerika = false;
		}	
	    }
	    if ((mouseX > 95 && mouseX < 269 && mouseY > 338) || mouseX < 95 && mouseX > -20 && mouseY > 460) {
		trigger_europa = true;
    enlighten_continent("europa")
		$("body").css({cursor: "pointer"});
	    } else {
		if (trigger_europa) {
        darken_continent("europa");
		    $("body").css({cursor: "auto"});
		    trigger_europa = false;
		}
	    }
	    if (mouseX > -170 && mouseX < -19 && mouseY > 338) {
		trigger_afrika = true;
    enlighten_continent("afrika");
		$("body").css({cursor: "pointer"});
	    } else {
		if (trigger_afrika) {
        darken_continent("afrika");
		    $("body").css({cursor: "auto"});
		    trigger_afrika = false;
		}
	    }
	    if (mouseX > -290 && mouseX < -169 && mouseY > 338) {
		trigger_asia = true;
    enlighten_continent("asia");
		$("body").css({cursor: "pointer"});
	    } else {
		if (trigger_asia) {
      darken_continent("asia");
		    $("body").css({cursor: "auto"});
		    trigger_asia = false;
		}
	    }
	    if (mouseX > -486 && mouseX < -330 && mouseY > 438) {
		trigger_australia = true;
        enlighten_continent("australia");
		$("body").css({cursor: "pointer"});
	    } else {
		if (trigger_australia) {
        darken_continent("australia");
		    $("body").css({cursor: "auto"});
		    trigger_australia = false;
		}
	    }

	});
	
	$(document).click(function(e){
	    if (called_from_trigger) {
		called_from_trigger = false;
		return true;
	    }
	    
	    if (trigger_europa) {
		called_from_trigger = true;
		$.colorbox({width:"95%", height:"95%", iframe:true, scrolling:false, href: "/maps?lat=55&lng=10&zoom=4"});
	    }			

	    if (trigger_asia) {
		called_from_trigger = true;
		$.colorbox({width:"95%", height:"95%", iframe:true, scrolling:false, href: "/maps?lat=25.95663505946715&lng=89.22363281250003&zoom=4"});
	    }			
	    
	    if (trigger_australia) {
		called_from_trigger = true;
		$.colorbox({width:"95%", height:"95%", iframe:true, scrolling:false, href: "/maps?lat=-25.723086103329297&lng=134.4921875&zoom=5"});
	    }			
	    
	    if (trigger_afrika) {
		called_from_trigger = true;
		$.colorbox({width:"95%", height:"95%", iframe:true, scrolling:false, href: "/maps?lat=0&lng=20&zoom=4"});
	    }			
	    
	    if (trigger_amerika) {
		called_from_trigger = true;
		$.colorbox({width:"95%", height:"95%", iframe:true, scrolling:false, href: "/maps?lat=31.463512610780818&lng=-85.640869140625&zoom=4"});
	    }			
	    
	});
    } 
});

