//  Javascript

// TOOLTIP
var posunY = 10;
var posunX = 20;

function tooltip() {

  if($.browser.msie) {
    $('#manufactory-map area[title]').each( function() {
        var $this = $(this);
        $this.data('title',$this.attr('title'));
        $this.removeAttr('title');
    });
  	$('#manufactory-map area').mouseover(function(e) {
  		var tip = $(this).data('title');
  		$(this).parent().append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');
  		$('#tooltip').css('top', e.pageY + posunY );
  		$('#tooltip').css('left', e.pageX + posunX );
      $('#tooltip').css('opacity', 0 );
  		$('#tooltip').animate({opacity: 0.8}, {queue:false, duration: 'normal'});
  	}).mousemove(function(e) {
  		$('#tooltip').css('top', e.pageY + posunY );
  		$('#tooltip').css('left', e.pageX + posunX );
  	}).mouseout(function() {
  		$(this).parent().children('div#tooltip').remove();
  	});
  }
  else {
  	$('#manufactory-map area').mouseover(function(e) {
  		var tip = $(this).attr('title');
  		$(this).attr('title','');
  		$(this).parent().append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');
  		$('#tooltip').css('top', e.pageY + posunY );
  		$('#tooltip').css('left', e.pageX + posunX );
      $('#tooltip').css('opacity', 0 );
  		$('#tooltip').animate({opacity: 0.8}, {queue:false, duration: 'normal'});
  	}).mousemove(function(e) {
  		$('#tooltip').css('top', e.pageY + posunY );
  		$('#tooltip').css('left', e.pageX + posunX );
  	}).mouseout(function() {
  		$(this).attr('title',$('.tipBody').html());
  		$(this).parent().children('div#tooltip').remove();
  	});
	}
}

// MAP
function map() {
  $('#map-region .map-area')
  .mouseenter(function(){
      css = $(this).attr('rel')
      $('#map-region').addClass(css);
  })
  .mouseleave(function(){
      css = $(this).attr('rel')
      $('#map-region').removeClass(css);
  });
}


//  INIT
$(document).ready(function(){
  tooltip();
  map();
});
