$(document).ready(function() {
  $('#g_plus_one').html('<g:plusone size="small" count="true"></g:plusone>');
	$("#emailInput").keyup(function(event){
	  if(event.keyCode == 13){
		location.href='index.php?id=273&email='+$(this).val();
	  }
	});
	$('#amerika, #naherosten, #asien, #europa, #welt').hover(function(e){
		tip = $('body').find('.tip');		
		o_top = $(this).offset().top - 20;
		o_left = $(this).offset().left;
		
		$('#map_amerika area, #map_naherosten area, #map_asien area, #map_europa area, #map_welt area').hover(function(){
			
			coords = $(this).attr('coords').split(",");		
			left_tip = o_left + parseInt(coords[0]) + 10;
			top_tip = o_top + parseInt(coords[1]) - 10;		
			
			
			if($(this).parent().attr('id') == "map_welt"){
				continent = $(this).attr('id').replace(/_/g," ");
				tip.css({'left':left_tip - (tip.width()/2) + 50, 'top': top_tip +30});
				tip.html(continent);
			}
			else{
				land = $(this).attr('id').split("-");
				stadt = land[0].replace(/_/g," ");								if(stadt == "Kuwait Stadt"){					stadt = "Kuwait-Stadt";				}
				land_c = land[1].replace(/_/g," ");
				tip.css({'left':left_tip - (tip.width()/2), 'top': top_tip});
				tip.html(stadt + ", " + land_c);
			}
			
			tip.show();
			
		},function(){
			tip.hide();
		});		
	});
	// Marks the teasercontent images if active.	
	// Active image needs to end on 3.png
	/*
	if($('.teaserContent').length > 0){
		//rege = new RegExp('.*id=(.*)');
		rege = new RegExp('http:\/\/www.exportberatung.de\/(.*)');
		thispage = document.location;
		thispage_id = thispage.match(rege)[0];
		$('.teaserContent').each(function(){
			href = $(this).children('a').attr('href');
			teaser_id = href.match(rege)[0];
			if(teaser_id == thispage_id) {
				pic = $(this).children('a').children('img').attr('src');
				newpic = pic.substr(0, pic.length-5) + '3.png';
				$(this).children('a').children('img').attr('src',newpic);
			} 
		});
	}*/
	
		
		$('.teaserContent').each(function(){
			thispage = document.location;
			href = $(this).children('a').attr('href');
			if(href == thispage) {
				pic = $(this).children('a').children('img').attr('src');
				newpic = pic.substr(0, pic.length-5) + '3.png';
				$(this).children('a').children('img').attr('src',newpic);
			} 
		});
	
	// Translation switch to other page.
	
	// Space for citations
	if( $('.quickrefImg').children('span').length > 0){
		zitat = $('.quickrefImg').children('span').html();
		rege2 = new RegExp('(.*)(<br>)(.*)');
		res = zitat.match(rege2);
		zitatneu = res[1]+'&nbsp;'+res[2]+'&nbsp;'+res[3];
		$('.quickrefImg').children('span').html(zitatneu);
	}
	
	$('#language_switch').children('li').first().children('a').attr('href','index.php?id=302');
	
});

function goMail() {
	location.href='index.php?id=273&email='+document.getElementById('emailInput').value
}
