var active = false;
var zoomInterval = null;
var status = 'zoomedIn';
var minWidth = 200;
var minHeight = 126;
var maxWidth = 698;
var maxHeight = 413;
var aspect_ratio = maxWidth / maxHeight;
var speed = 30;
var marginLeftStart = 0;
var marginTopStart = -131;
var marginRightCurrent = 0;
var marginTopCurrent = -131;
var ContentBackup = '';
var topCorrection = 15;
/*
   margin-left: 780px;
   margin-top: -131px;
*/

/*Browserweiche IE6*/
var browser = navigator.userAgent.toLowerCase();
var ganzzahl = parseInt(navigator.appVersion);
var explorer = ((browser.indexOf("msie") != -1) && (browser.indexOf("opera") == -1));
var explorer6 = (explorer && (ganzzahl == 4) && (browser.indexOf("msie 6.0") !=-1));

function zoomOutActivate(){
   if(!active && status == 'zoomedIn'){
      zoomInterval = window.setInterval("zoomOut()",50);
      /*ContentBackup = document.getElementById('mainContentContainer').innerHTML;*/
      /*document.getElementById('mainContentContainer').innerHTML = '';*/
      document.getElementById('country_name').innerHTML = '';
      document.getElementById('mainContentContainer').style.visibility = 'hidden';
      document.getElementById('karten_container').style.cursor = 'auto';
      document.getElementById('minimap_title').style.display='none';
      document.getElementById('close_map').style.display = 'block';
      
      if(explorer6){
         document.getElementById('img_karte').src = '862_DE.gif?exp=24552665187500';
      }
      else{
         document.getElementById('img_karte').src = '463_DE.png?exp=24552665186800';
      }
      
   }
}

function zoomInActivate(){
   if(!active && status == 'zoomedOut'){
      zoomInterval = window.setInterval("zoomIn()",50);
      document.getElementById('karten_container').style.cursor = 'pointer';
      /*document.getElementById('mainContentContainer').innerHTML = ContentBackup;*/
      document.getElementById('mainContentContainer').style.visibility = 'visible';
      document.getElementById('close_map').style.display = 'none';
      document.getElementById('imageMap_container').style.display = 'none';
      document.getElementById('img_karte').style.display = 'block';
      document.getElementById('country_name').innerHTML = '';
   }
}

function zoomOut(){
   var karte = document.getElementById('img_karte');
   var container = document.getElementById('karten_container');

   if(karte.height>= maxHeight || karte.width>= maxWidth){
      karte.height =maxHeight;
      karte.width = maxWidth;
      window.clearInterval(zoomInterval);
      active = false;
      status = 'zoomedOut';
      document.getElementById('img_karte').style.display = 'none';
      document.getElementById('imageMap_container').style.display = 'block';
   }
   else{
      active = true;
      karte.width = karte.width + (Math.floor(aspect_ratio * speed));
      container.width = container.width + speed;

      if((marginRightCurrent + speed) < 250) {
         marginRightCurrent = marginRightCurrent + speed;
         container.style.marginRight = marginRightCurrent + "px";
      }

      karte.height = karte.height + speed;
      container.height = container.height + speed;
      marginTopCurrent = marginTopCurrent - (speed +topCorrection);
      container.style.marginTop = marginTopCurrent + "px";

   }
}

function zoomIn(){
   var karte = document.getElementById('img_karte');
   var container = document.getElementById('karten_container');

   if(karte.height<= minHeight || karte.width<= minWidth){
      karte.height = minHeight;
      karte.width = minWidth;
      container.style.marginRight = 0 + "px";
      window.clearInterval(zoomInterval);
      active = false;
      status = 'zoomedIn';
      document.getElementById('karten_container').style.cursor = 'pointer';
      document.getElementById('minimap_title').style.display='block';
      
      if(explorer6){
         document.getElementById('img_karte').src = '869_DE.gif?exp=24552665183800';
      }
      else{
         document.getElementById('img_karte').src = '464_DE.png?exp=24552665184500';
      }
   }
   
   else{
      active = true;
      karte.width = karte.width - (Math.floor(aspect_ratio * speed));
      container.width = container.width - speed;

      if((marginRightCurrent - speed) > 0) {
         marginRightCurrent = marginRightCurrent - speed;
         container.style.marginRight = marginRightCurrent + "px";
      }

      karte.height = karte.height - speed;
      container.height = container.height - speed;
      marginTopCurrent = marginTopCurrent + (speed +topCorrection);
      container.style.marginTop = marginTopCurrent + "px";
   }
}