/**
 * Liefert die in der URL eingestellte Sprache.
 * 
 * @return	string	Die eingestellte Sprache als Parameter für eine URL.
 */
function getLanguage() {
	var language = '';
	if (
		document.location.search != '' &&
		/lg=/.test(document.location.search)
	) {
		language = '?' + document.location.search.match(/lg=[a-z]{2}/i);
	}

	return language;
}

function oeffne_fenster(name) {
	document.location.href = 'http://www.' + name + '.city-map.' + country + '/' + getLanguage();
}

  function menu_titel_erstellen(name) {
    if (typeof(name) == 'undefined') {
      name = waehlen_sie;
    } else {
      name += ':'; // ' - '+ihre_regionen;
    }
    var menu_titel = document.getElementById('menu_titel');

    var text = document.createTextNode(name);
    menu_titel.appendChild(text);
  }


  function f(id, status, level) {
    if (typeof(status) == 'undefined') {
      status = 'aktiv';
    }
    if (typeof(level) == 'undefined') {
      level = '0';
    }
    try {
      flash_karten_frame.f(id, status, level);
    } catch (catchevent) {}
  }


  function menu_erstellen(liste) {
    var menu = document.getElementById('menu');
    while (menu.hasChildNodes()) {
      menu.removeChild(menu.firstChild);
    }
    var br;
    var a;
    var text;
    for(i = 0; i < liste.length; i++) {
      a = document.createElement('a');
      a.href = 'http://' + liste[i].link + getLanguage();
      a.target = '_top';
      a.onfocus = new Function('blah', "f('" + liste[i].region + "', 'aktiv', '1')");
      a.onblur = new Function('blah', "f('" + liste[i].region + "', 'normal', '1')");
      a.onmouseover = new Function('blah', "f('" + liste[i].region + "', 'aktiv', '1')");
      a.onmouseout = new Function('blah', "f('" + liste[i].region + "', 'normal', '1')");
      a.className = 'menu';
      text = document.createTextNode(liste[i].name);
      a.appendChild(text);
      menu.appendChild(a);
      br = document.createElement('br');
      menu.appendChild(br);
    }
    br = document.createElement('br');
    menu.appendChild(br);
    a = document.createElement('a');
    a.href = 'javascript:zoom_out(0);';
    a.target = '_parent';
    a.className = 'menu';
    text = document.createTextNode(zurueck);
    a.appendChild(text);
    menu.appendChild(a);
  }



  function zoom(region, name) {
    try {
      flash_karten_frame.zoom(region, name, tlg, country);
    } catch (catchevent) {
      region.toString().length < 2 ? region = '0' + region.toString() : void(0);
      parent.document.location.href = './?lg='+tlg+'&amp;p=' + region;
    }
    return void(0);
  }


  function hauptmenu_erstellen(liste) {
    if (country!='dk' && country!='pl') {
    var menu = document.getElementById('menu');
    while (menu.hasChildNodes()) {
      menu.removeChild(menu.firstChild);
    }
    var a;
    var text;
    var br;
    for(i = 0; i < liste.length; i++) {
      if (liste[i].link == '05') {
        for(var j = 0; j < 2; j++) {
          a = document.createElement('a');
          if (j == 0) {
            a.href = 'http://www.bremen.city-map.de/';
            text = document.createTextNode('Bremen /');
          } else {
            a.href = 'http://www.bremerhaven.city-map.de/';
            text = document.createTextNode(' Bremerhaven');
          }
          a.href += getLanguage();
          a.onfocus = new Function('blah', "f('" + liste[i].link + "')");
          a.onblur = new Function('blah', "f('" + liste[i].link + "', 'normal')");
          a.onmouseover = new Function('blah', "f('" + liste[i].link + "')");
          a.onmouseout = new Function('blah', "f('" + liste[i].link + "', 'normal')");
          a.target = '_top';
          a.className = 'menu';
          a.appendChild(text);
          menu.appendChild(a);
          br = document.createElement('br');
          j != 0 ? menu.appendChild(br) : void(0);
        }
      } else {
        a = document.createElement('a');
        if (liste[i].link == '03') {
          a.href = 'http://www.hamburg.city-map.de/' + getLanguage();
          a.target = '_top';
        } else if (liste[i].link == '07') {
          a.href = 'http://www.berlin.city-map.de/' + getLanguage();
          a.target = '_top';
        } else {
          a.href = "javascript:zoom('" + liste[i].link + "', '" + liste[i].name + "');";
          a.target = '_parent';
        }
        a.onfocus = new Function('blah', "f('" + liste[i].link + "')");
        a.onblur = new Function('blah', "f('" + liste[i].link + "', 'normal')");
        a.onmouseover = new Function('blah', "f('" + liste[i].link + "')");
        a.onmouseout = new Function('blah', "f('" + liste[i].link + "', 'normal')");
        a.className = 'menu';
        text = document.createTextNode(liste[i].name);
        a.appendChild(text);
        menu.appendChild(a);
        br = document.createElement('br');
        menu.appendChild(br);
      }
    }
   } // country not ok
  }


  function zoom_out() {
    try {
      flash_karten_frame.zoom_out(tlg);
    } catch (catchevent) {
      parent.document.location.href = './?lg='+tlg;
    }
    return void(0);
  }



  function change_region(region, name) {
    document.getElementById('regionen').src = 'regionen2.php?country='+country+'&region=' + region;

    var menu_titel = document.getElementById('menu_titel');
    while (menu_titel.hasChildNodes()) {
      menu_titel.removeChild(menu_titel.firstChild);
    }
    menu_titel_erstellen(name);
  }



function flash_karte_laden(name_film) {
  if ( MM_FlashCanPlay ) {
    document.getElementById('iframeflashkarte').src = 'flash_karte.php?x=' + x + '&y=' + y + '&flashfilm=' + name_film.replace(/www.city-map.de/, document.domain).split('.').join('\\.');
  }
}


var x=616;
var y=Math.floor(x*350/450);
var MM_contentVersion = 5;
var plugin = (navigator.mimeTypes &&
navigator.mimeTypes["application/x-shockwave-flash"]) ?
navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
var i;
if (plugin) {
  var words=navigator.plugins["Shockwave Flash"].description.split(" ");
     for (i=0; i<words.length; ++i) {
	if (isNaN(parseInt(words[i]))) continue;
	var MM_PluginVersion=words[i];
     }
 var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
  for (i = MM_contentVersion; i <= 9; i++) {
    eval('var flash'+i+'Installed = false;');
  }
  document.write('<SCR'+'IPT LANGUAGE=VBScript> \n');
  document.write('on error resume next \n');
  for (i = MM_contentVersion; i <= 9; i++) {
    document.write('flash'+ i+'Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.' + i + '"))) \n');
  }
  document.write('<'+'/SCR'+'IPT> \n');
  for (i = MM_contentVersion; i <= 9; i++) {	
    if (eval("flash"+i+"Installed")==true) {
      MM_FlashCanPlay=true;
      break;
    }
  }
}



