$(document).ready(function () {
	if ($('div#seajet-world').length!=0){
		$('div#seajet-world').mapbox({pan:true,mousewheel: true,layerSplit:3, afterZoom: function(layer, xcoord, ycoord, viewport) { checkPositions(); }, callAfter: function(layer, xcoord, ycoord, viewport) { checkPositions(); }   }); //clickZoom:true, doubleClickZoomOut:true,
		$('div#seajet-world').mousemove(function(){ checkPositions(); });
		checkPositions();
		markerInfo();
		
		$('div#seajet-worldtips a').click(function(){
	               	if (this.className!=""){ 
	               		$('div#seajet-world').mapbox(this.className, 2);
		               	checkPositions(); 
	      			return false;}
		});
	}
	$(document).pngFix();
	$('div#product-thumbnail a').lightBox();
	$('div.lightboxthumb a').lightBox();
});


function checkPositions(){
	seajetLayer = $('div#seajet-world').find(".current-map-layer");	
	breedtemin = 970; hoogtemax = 473;
	breedte = Math.round(seajetLayer.width());
	factor = breedte/breedtemin-1;  
	positie = seajetLayer.position();
	links = positie.left; boven = positie.top; 
	if (factor>0) $('div#seajet-world').css('cursor','move'); else $('div#seajet-world').css('cursor','auto');
	
	$('.marker').each(function(i){
		marginleft = parseFloat($(this).css('margin-left').replace('px',''));
		nieuwlinks = factor*marginleft+links; 
		nieuwlinks = Math.round(nieuwlinks-10); 	
		$(this).css({left:nieuwlinks+'px'}); 	
		margintop = parseFloat($(this).css('margin-top').replace('px','')); 
		nieuwboven = factor*margintop+boven; 
		nieuwboven = Math.round(nieuwboven-7); 
		$(this).css({top:nieuwboven+'px'}); 
	});
	$('.markerinfo').each(function(i){
		breedte = $(this).width();
		hoogte = $(this).height(); 
		$(this).width(breedte+'px');
	});
}

function markerInfo(){
	$('div.marker').hover(function() {
	    var fade = $('> div', this);    
    if (fade.is(':animated')) {
      fade.stop().fadeTo(150, 1);
    } else {
      fade.fadeIn(150);
    }
  }, function () {
    var fade = $('> div', this);
    if (fade.is(':animated')) {
      fade.stop().fadeTo(250, 0);
    } else {
      fade.fadeOut(250);
    }
  });
}

