// JavaScript Document
	var mouseX;
	var mouseY;
	var mouseOverPuff = false;
$(document).ready(function (){
	$('#puffCont').hide();
	
	
	$('#productPuffCont').mouseenter(function() { 
		mouseOverPuff = true;
	
	});
	$('#productPuffCont').mouseleave(function() { 
		mouseOverPuff = false;

	});
	
	var activeLand;// = 'sweden';
	
	$('#'+activeLand+'_hover').show();
	$('#'+activeLand+'_hover').css('zIndex',0);
	var htmls = $('#'+activeLand+'_html').html();
	$('#puffContent').html(htmls);
	
	
	$('.land').mouseover(function() {
		var thisId=$(this).attr('id');
		
		
		//$('.hidden').hide();
		jQuery.each($('.hidden'), function() {
     		var thisId=$(this).attr('id');
			var i = thisId.indexOf('_');
			var land = thisId.substring(0,i);
			if(land != activeLand) {
				$(this).hide();	
			}
			
  		});
		
		//$('.hidden').hide();
		$('#'+thisId+'_hover').show();
	});
	$('.land').mouseleave(function() {
		
	/*	if(mouseOverPuff == false) {$('#puffCont').hide();
		}*/
		
		
		var thisId=$(this).attr('id');
		//var i = thisId.indexOf('_');
		//var land = thisId.substring(0,i);
		
		if(thisId != activeLand) {
			$('#'+thisId+'_hover').hide();
			
			
		}
	});
	
	$('#close').click(function() { 
	$('#puffCont').hide();
	});
	
	$('.land').click(function() {
		
		var name = $(this).attr('id');
		var pos_top = $('#'+name+'_hover').css('top');
		var pos_left = $('#'+name+'_hover').css('left');
		var top_position = pos_top.substring(0, pos_top.length - 2);
		var left_position = pos_left.substring(0, pos_left.length - 2);
		//alert(top_position);
		if(top_position < 150) {top_position = 150;}
	
		var thisId=$(this).attr('id');
		//var i = thisId.indexOf('_');
		//var land = thisId.substring(0,i);
		if(thisId != activeLand) {
		$('#'+activeLand+'_hover').hide();
		activeLand = thisId;
	
		var htmls = $('#'+thisId+'_html').html();
		
		$off = $('#mapWrapper').offset();
		$('.puffContent').html(htmls);
	
		$('#puffCont').css('top',mouseY - $off.top -  $('#puffCont').height());
		$('#puffCont').css('left',mouseX - $off.left - 100) ;
		
		$('#puffCont').show();
		
		
		}
	});
	
	$('.item').click(function() {
		
		var name = $(this).attr('id');
		var topPos = 570 - $('#productPuffCont').height();
		
	
		var htmls = $('#'+name+'_html').html();
		
		var off = $('#iconWrapper').offset();
		var thisOff = $(this).offset();
		var total =  thisOff.left - off.left;
		
		$('.productPuffContent').html(htmls);
	
		$('#productPuffCont').css('bottom',170);
		$('#productPuffCont').css('left',total - 40);
		
		$('#productPuffCont').show();

	});
	/*$('.item').mouseout(function() {
		
		if(mouseOverPuff == false) {
			$('#productPuffCont').hide();
		}
	});*/
	
	$('#productClose').click(function() { 
		$('#productPuffCont').hide();
	});
	
	
	
});
 $(document).mousemove(function(e){
      mouseX = e.pageX;
	  mouseY = e.pageY;
   }); 
