window.addEvent('domready',function(){
  var stdHeight = 266;
  var mapDots = [

		
  /*{'title':'Dominican Republic','top':'178','left':'169','bg':'america_north'},*/
  {
    'title':'Belgium',
    'top':'105',
    'left':'302',
    'bg':'europe'
  },

  {
    'title':'Croatia',
    'top':'128',
    'left':'329',
    'bg':'europe'
  },

  {
    'title':'Czech Republic',
    'top':'103',
    'left':'323',
    'bg':'europe'
  },

  {
    'title':'Egypt',
    'top':'163',
    'left':'341',
    'bg':'africa'
  },

  {
    'title':'Germany',
    'top':'108',
    'left':'312',
    'bg':'europe'
  },

  {
    'title':'Greece',
    'top':'140',
    'left':'333',
    'bg':'europe'
  },

  {
    'title':'Hong Kong',
    'top':'170',
    'left':'495',
    'bg':'asia'
  },

  {
    'title':'Indonesia',
    'top':'239',
    'left':'487',
    'bg':'asia'
  },

  {
    'title':'Ireland',
    'top':'100',
    'left':'273',
    'bg':'europe'
  },

  {
    'title':'Italy',
    'top':'128',
    'left':'316',
    'bg':'europe'
  },

  {
    'title':'Japan',
    'top':'141',
    'left':'536',
    'bg':'asia'
  },

  {
    'title':'Lebanon',
    'top':'150',
    'left':'355',
    'bg':'asia'
  },

  /*{'title':'China','top':'177','left':'490','bg':'asia'},*/

  {
    'title':'Malaysia',
    'top':'222',
    'left':'487',
    'bg':'asia'
  },

  {
    'title':'Philippines',
    'top':'201',
    'left':'515',
    'bg':'asia'
  },

  {
    'title':'Portugal',
    'top':'134',
    'left':'278',
    'bg':'europe'
  },

  {
    'title':'Singapore',
    'top':'220',
    'left':'475',
    'bg':'asia'
  },

  {
    'title':'Slovakia',
    'top':'107',
    'left':'334',
    'bg':'europe'
  },

  {
    'title':'Slovenia',
    'top':'115',
    'left':'324',
    'bg':'europe'
  },

  {
    'title':'South Africa',
    'top':'293',
    'left':'333',
    'bg':'africa'
  },

  {
    'title':'South Korea',
    'top':'142',
    'left':'515',
    'bg':'asia'
  },

  /*{'title':'Thailand','top':'198','left':'471','bg':'asia'},*/

  {
    'title':'Turkey',
    'top':'136',
    'left':'352',
    'bg':'europe'
  },

  {
    'title':'United Arab Emirates',
    'top':'171',
    'left':'390',
    'bg':'asia'
  },

  {
    'title':'United Kingdom',
    'top':'96',
    'left':'292',
    'bg':'europe'
  }
		
  ];
	
  var i = 0;
	
  // hoverstuff for the map
	
  var mapDiv = $('worldMapDiv');
  var mapImg = $('worldMapImg');
  var mapAreas = $('worldMap').getElements('area');

	
  var mbxUnHover = function(e){
    $$('.mb').each(function(el){
      el.setStyle('background-color','#fab400');
    })
    mapImg.setStyle('background-image','none');
  }
	
  var mbxAreaHover = function(e,i){
    mbxUnHover();
    // highlight the continent
    mapImg.setStyle('background-image','url(/fileadmin/templates/media/img/content/apogepha/world_map_bg_'+mapDots[i].bg+'.gif)');
    // schwarzen böbbl einblenden
    $('marketDot_'+i).setStyles({
      'background-color':'#000'
    });
  }
	
  var mbxAddHover = function(area,i){
    // creating the link for opening the multibox
    if(!$type(mapDots[i])){
      return false;
    }
    var darkDot = new Element('a', {
      'id':'marketDot_'+i,
      'href':window.location.href.replace(/#.*/,'')+'#marketBox_'+i
      });
    darkDot.addClass('mb');
    darkDot.addClass('mb_noprint');
    darkDot.setStyles({
      'top':mapImg.getPosition().y,
      'left':mapImg.getPosition().x,
      'width':'9px',
      'height':'9px',
      'overflow':'hidden',
      'display':'block',
      'position':'absolute',
      'background-color':'#fab400',
      'margin':mapDots[i].top+'px 0 0 '+mapDots[i].left+'px'
    }).injectTop($('mainframe'));
    var heightX = (mapDots[i].height?mapDots[i].height:1);
    darkDot.setProperty('rel','type:element,width:397,height:'+stdHeight*heightX);

    darkDot.setProperty('title',mapDots[i].title);
    darkDot.addEvent('mouseleave', function(e){
      mbxUnHover(e);
    });
    darkDot.addEvent('mouseover', function(e){
      mbxAreaHover(e,i);
    });
    mapImg.addEvent('mouseover', function(e){
      mbxUnHover(e);
    });
		
    area.addEvent('mouseover', function(e){
      mbxAreaHover(e,i);
    }.bind(i));

    return true;
  }

  mapAreas.each(function(el,i){
    mbxAddHover(el,i);
    el.remove();
  });
	
  // end of hoverstuff
	
  // handling da boxes
  var marketBoxes = $$('.market_id');
  marketBoxes.each(function(el,i){
    el.setProperty('id','marketBox_'+i);
    el.setStyles({
      'position':'absolute'
    });
  });
		
  var box = new Object();
  box = new MultiBox('mb',{
    initialWidth: 250,
    initialHeight: 250,
    useOverlay: true,
    movieWidth: 397,
    movieHeight: 266,
    openFromLink: false,
    showControls: false
  });
});
