var activeItem = false;
var myInterval;


function closeTourSpecial() {
	 //$('header').style.height="235px";
	 //$('header').style.overflow="show";
	 document.getElementById('header').removeChild(close_link);
	 $('link_tour').removeChild($('subnavigrundierung'));
	 $('flashcontent').removeChild($('flashcontent_inner'));
	 //new Effect.SlideUp('flashcontent', {duration: 1.3});
	 myInterval = setInterval(function () {
	 	$('flashcontent').style.height=  String(parseInt($('flashcontent').style.height)-20)+'px';
		if (parseInt($('flashcontent').style.height)<=0) {
			clearInterval(myInterval);

	 		if ($('introanimation')) new Effect.Opacity('introanimation', {queue:'end', from: 0.0, to: 1.0, duration: 0.2})
                        $('content_hide').style.display = 'block';
			if ($('content')) new Effect.Opacity('content', {queue:'end', from: 0.0, to: 1.0, duration: 0.3});
	 		if ($('snippets')) new Effect.Opacity('snippets', {queue:'end', from: 0.0, to: 1.0, duration: 0.2})

                        $('link_tour').removeChild($('subnavi_dynamic'));
			if ($('subnavi')) $('subnavi').style.display = "block";

		 	listItems = $('mainnavi').select('li');
		 	listItems[0].firstChild.style.color = "#850207"
		 	if (activeItem) listItems[activeItem].firstChild.style.color = '#fff';

			if (allItemsActive) {
			 listItems = $('mainnavi').select('li');
			 for (i = 0; i < listItems.length; i++) {
			 	 listItems[i].firstChild.style.color = "#fff"
			 }
   			}

			flashcontent_inner = document.createElement("div");
		 	flashcontent_inner.id = "flashcontent_inner";
		 	flashcontent_inner.innerHTML = "&nbsp;";

		 	$('flashcontent').appendChild(flashcontent_inner);
	 		document.getElementById('flashcontent').style.display = "none";
	 		document.getElementById('flashcontent').style.height = "600px";
	 		if ($('hausflash')) $('hausflash').style.display = "block";
  		 }
	 },15);
	 //return false;
}


function openTourSpecial() {

	if (typeof count_page === 'function') {
		_ePAGE='/special.swf';
		_eBU='eon-energiesparen';
		count_page();
  	}

	$('flashcontent').innerHTML = '';
	flashcontent_inner = document.createElement("div");
	flashcontent_inner.id = "flashcontent_inner";
	flashcontent_inner.innerHTML = "&nbsp;";
	$('flashcontent').appendChild(flashcontent_inner);

	 if ($('introanimation')) new Effect.Opacity('introanimation', {from: 1.0, to: 0.0, duration: 0.2});
	 if ($('content')) new Effect.Opacity('content', {from: 1.0, to: 0.0, duration: 0.6, afterFinish: function () {$('content_hide').style.display = 'none';} });
	 if ($('snippets')) new Effect.Opacity('snippets', {from: 1.0, to: 0.0, duration: 0.6});
	 if ($('hausflash')) $('hausflash').style.display = "none";
	 //new Effect.Appear('flashcontent', {queue:'end', duration: 0.3});
	 new Effect.BlindDown('flashcontent', {queue:'end', duration: 1.3, afterFinish: embedFlash});


	 listItems = $('mainnavi').select('li');
	 for (i = 0; i < listItems.length; i++) {
	 	 if (listItems[i].firstChild.className == 'active') activeItem = i;
	 	 listItems[i].firstChild.style.color = "#850207"
	 }
	 listItems[0].firstChild.style.color = '#fff';

	 if ($('subnavi')) $('subnavi').style.display = "none";

	 subnavi_grundierung = document.createElement("div");
	 subnavi_grundierung.innerHTML ="&nbsp;";
	 subnavi_grundierung.id ="subnavigrundierung";

	 subnavi_tour = document.createElement("ul");
	 subnavi_tour.id = "subnavi_dynamic";

	 li_warum = document.createElement("li");
	 a_warum = document.createElement("a");
	 a_warum.innerHTML = "Die Idee";
	 a_warum.href = "energiespartour.htm";
	 li_warum.appendChild(a_warum);
	 subnavi_tour.appendChild(li_warum);

	 li_mobil = document.createElement("li");
	 a_mobil = document.createElement("a");
	 a_mobil.className = "active";
	 a_mobil.innerHTML = "EnergieSpar-Mobil";
	 a_mobil.href = "javascript:openTourSpecial();";
	 li_mobil.appendChild(a_mobil);
	 subnavi_tour.appendChild(li_mobil);

	 li_tourdaten = document.createElement("li");
	 a_tourdaten = document.createElement("a");
	 a_tourdaten.innerHTML = "Tourdaten";
	 a_tourdaten.href = "tourdaten.htm";
	 li_tourdaten.appendChild(a_tourdaten);
	 subnavi_tour.appendChild(li_tourdaten);

	 //li_messe = document.createElement("li");
	 //a_messe = document.createElement("a");
	 //a_messe.innerHTML = "Regionale Messen";
	 //a_messe.href = "regionale_messen.htm";
	 //li_messe.appendChild(a_messe);
	 //subnavi_tour.appendChild(li_messe);
	 
	 //li_gewinnspiel = document.createElement("li");
	 //a_gewinnspiel = document.createElement("a");
	 //a_gewinnspiel.innerHTML = "Gewinnspiel";
	 //a_gewinnspiel.href = "gewinnspiel.htm";
	 //li_gewinnspiel.appendChild(a_gewinnspiel);
	 //subnavi_tour.appendChild(li_gewinnspiel);

	 li_150euro = document.createElement("li");
	 a_150euro = document.createElement("a");
	 a_150euro.innerHTML = "150 Euro sparen";
	 a_150euro.href = "150euro.htm";
	 li_150euro.appendChild(a_150euro);
	 subnavi_tour.appendChild(li_150euro);


	 $('link_tour').appendChild(subnavi_grundierung);
	 $('link_tour').appendChild(subnavi_tour);

	 window.setTimeout(function() {
              close_link = document.createElement("a");
              close_link.style.position = "absolute";
              close_link.style.top = "105px";
              close_link.style.color = "white";
              close_link.style.fontSize = "10px";
              close_link.style.fontWeight = "bold";
              close_link.style.left = "910px";
              close_link.style.zIndex = "920";
              close_link.onclick = function() { closeTourSpecial() };
              close_link.href = '#';
              close_link.innerHTML = 'Tour schließen';
              document.getElementById('header').appendChild(close_link);
         }, 300);
	 //return false;

}

function embedFlash() {
	 document.getElementById('flashcontent').style.height = "600px";
	 swfobject.embedSWF("preload.swf", "flashcontent_inner", "1000", "600", "9.0.0","expressInstall.swf", {}, {wmode: "transparent"}, {} );
}


function htmlspecialchars (string, quote_style) {
    // Convert special characters to HTML entities  
    // 
    // version: 812.3017
    // discuss at: http://phpjs.org/functions/htmlspecialchars
    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Nathan
    // +   bugfixed by: Arno
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlspecialchars("<a href='test'>Test</a>", 'ENT_QUOTES');
    // *     returns 1: '&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;'
    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}

function get_html_translation_table(table, quote_style) {
    // Returns the internal translation table used by htmlspecialchars and htmlentities  
    // 
    // version: 903.1614
    // discuss at: http://phpjs.org/functions/get_html_translation_table
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // +   bugfixed by: Alex
    // +   bugfixed by: Marco
    // +   bugfixed by: madipta
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // %          note: Table from http://www.the-art-of-web.com/html/character-codes/
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    useTable      = (table ? table.toUpperCase() : 'HTML_SPECIALCHARS');
    useQuoteStyle = (quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT');
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
    
    // Map numbers to strings for compatibilty with PHP constants
    if (!isNaN(useTable)) {
        useTable = constMappingTable[useTable];
    }
    if (!isNaN(useQuoteStyle)) {
        useQuoteStyle = constMappingQuoteStyle[useQuoteStyle];
    }

    if (useTable == 'HTML_SPECIALCHARS') {
        // ascii decimals for better compatibility
        entities['38'] = '&amp;';
        if (useQuoteStyle != 'ENT_NOQUOTES') {
            entities['34'] = '&quot;';
        }
        if (useQuoteStyle == 'ENT_QUOTES') {
            entities['39'] = '&#039;';
        }
        entities['60'] = '&lt;';
        entities['62'] = '&gt;';
    } else if (useTable == 'HTML_ENTITIES') {
        // ascii decimals for better compatibility
	    entities['38']  = '&amp;';
        if (useQuoteStyle != 'ENT_NOQUOTES') {
            entities['34'] = '&quot;';
        }
        if (useQuoteStyle == 'ENT_QUOTES') {
            entities['39'] = '&#039;';
        }
	    entities['60']  = '&lt;';
	    entities['62']  = '&gt;';
	    entities['160'] = '&nbsp;';
	    entities['161'] = '&iexcl;';
	    entities['162'] = '&cent;';
	    entities['163'] = '&pound;';
	    entities['164'] = '&curren;';
	    entities['165'] = '&yen;';
	    entities['166'] = '&brvbar;';
	    entities['167'] = '&sect;';
	    entities['168'] = '&uml;';
	    entities['169'] = '&copy;';
	    entities['170'] = '&ordf;';
	    entities['171'] = '&laquo;';
	    entities['172'] = '&not;';
	    entities['173'] = '&shy;';
	    entities['174'] = '&reg;';
	    entities['175'] = '&macr;';
	    entities['176'] = '&deg;';
	    entities['177'] = '&plusmn;';
	    entities['178'] = '&sup2;';
	    entities['179'] = '&sup3;';
	    entities['180'] = '&acute;';
	    entities['181'] = '&micro;';
	    entities['182'] = '&para;';
	    entities['183'] = '&middot;';
	    entities['184'] = '&cedil;';
	    entities['185'] = '&sup1;';
	    entities['186'] = '&ordm;';
	    entities['187'] = '&raquo;';
	    entities['188'] = '&frac14;';
	    entities['189'] = '&frac12;';
	    entities['190'] = '&frac34;';
	    entities['191'] = '&iquest;';
	    entities['192'] = '&Agrave;';
	    entities['193'] = '&Aacute;';
	    entities['194'] = '&Acirc;';
	    entities['195'] = '&Atilde;';
	    entities['196'] = '&Auml;';
	    entities['197'] = '&Aring;';
	    entities['198'] = '&AElig;';
	    entities['199'] = '&Ccedil;';
	    entities['200'] = '&Egrave;';
	    entities['201'] = '&Eacute;';
	    entities['202'] = '&Ecirc;';
	    entities['203'] = '&Euml;';
	    entities['204'] = '&Igrave;';
	    entities['205'] = '&Iacute;';
	    entities['206'] = '&Icirc;';
	    entities['207'] = '&Iuml;';
	    entities['208'] = '&ETH;';
	    entities['209'] = '&Ntilde;';
	    entities['210'] = '&Ograve;';
	    entities['211'] = '&Oacute;';
	    entities['212'] = '&Ocirc;';
	    entities['213'] = '&Otilde;';
	    entities['214'] = '&Ouml;';
	    entities['215'] = '&times;';
	    entities['216'] = '&Oslash;';
	    entities['217'] = '&Ugrave;';
	    entities['218'] = '&Uacute;';
	    entities['219'] = '&Ucirc;';
	    entities['220'] = '&Uuml;';
	    entities['221'] = '&Yacute;';
	    entities['222'] = '&THORN;';
	    entities['223'] = '&szlig;';
	    entities['224'] = '&agrave;';
	    entities['225'] = '&aacute;';
	    entities['226'] = '&acirc;';
	    entities['227'] = '&atilde;';
	    entities['228'] = '&auml;';
	    entities['229'] = '&aring;';
	    entities['230'] = '&aelig;';
	    entities['231'] = '&ccedil;';
	    entities['232'] = '&egrave;';
	    entities['233'] = '&eacute;';
	    entities['234'] = '&ecirc;';
	    entities['235'] = '&euml;';
	    entities['236'] = '&igrave;';
	    entities['237'] = '&iacute;';
	    entities['238'] = '&icirc;';
	    entities['239'] = '&iuml;';
	    entities['240'] = '&eth;';
	    entities['241'] = '&ntilde;';
	    entities['242'] = '&ograve;';
	    entities['243'] = '&oacute;';
	    entities['244'] = '&ocirc;';
	    entities['245'] = '&otilde;';
	    entities['246'] = '&ouml;';
	    entities['247'] = '&divide;';
	    entities['248'] = '&oslash;';
	    entities['249'] = '&ugrave;';
	    entities['250'] = '&uacute;';
	    entities['251'] = '&ucirc;';
	    entities['252'] = '&uuml;';
	    entities['253'] = '&yacute;';
	    entities['254'] = '&thorn;';
	    entities['255'] = '&yuml;';
    } else {
        throw Error("Table: "+useTable+' not supported');
        return false;
    }
    
    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal);
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}


// ===============  MAPS  =======================


var marker = new Array();
var markers = new Array();
var geocoder;
var toDo = new Array();
var searchextra = ", Deutschland";
//var normalProj = G_NORMAL_MAP.getProjection();
var markerInterval = new Array();
var mymarker;

var coordsCache = new Array();
var coordsCacheStr = ''
var myZip;



coordsCache['20357, deutschland']= new Array(53.564431,9.9690496);coordsCache['14471, deutschland']= new Array(52.3767887,13.0057451);coordsCache['80331, deutschland']= new Array(48.1365323,11.5697308);coordsCache['14542, deutschland']= new Array(52.3647941,12.8700716);coordsCache['20359, deutschland']= new Array(53.5511779,9.9641759);coordsCache['95355, deutschland']= new Array(50.2408072,11.5344431);coordsCache['20095, deutschland']= new Array(53.5507515,10.0017259);coordsCache['84453, deutschland']= new Array(48.2428386,12.5056618);coordsCache['14641, deutschland']= new Array(52.631423,12.8120193);coordsCache['37127, deutschland']= new Array(51.4682935,9.7447585);coordsCache['34131, deutschland']= new Array(51.3110759,9.4032861);coordsCache['21335, deutschland']= new Array(53.2142854,10.377885);coordsCache['17358, deutschland']= new Array(53.6223109,14.0136372);coordsCache['37619, deutschland']= new Array(51.9552167,9.5182385);coordsCache['80333, deutschland']= new Array(48.1440989,11.5695525);coordsCache['20095, deutschland']= new Array(53.5507515,10.0017259);coordsCache['16321, deutschland']= new Array(52.6874845,13.5672765);coordsCache['30169, deutschland']= new Array(52.3630935,9.7364049);coordsCache['37688, deutschland']= new Array(51.66014,9.3466097);coordsCache['63924, deutschland']= new Array(49.7212318,9.1851374);coordsCache['95361, deutschland']= new Array(50.0979512,11.5032023);coordsCache['93426, deutschland']= new Array(49.1948314,12.5158691);coordsCache['31848, deutschland']= new Array(52.2184983,9.4374889);coordsCache['14547, deutschland']= new Array(52.2286552,12.9276162);coordsCache['14621, deutschland']= new Array(52.6380767,13.0463426);coordsCache['25335, deutschland']= new Array(53.7543421,9.6058804);coordsCache['39606, deutschland']= new Array(52.7890715,11.7223312);coordsCache['96160, deutschland']= new Array(49.7616213,10.463781);coordsCache['85716, deutschland']= new Array(48.2821764,11.5620402);coordsCache['31832, deutschland']= new Array(52.2048941,9.6049895);coordsCache['38855, deutschland']= new Array(51.8437498,10.7993086);coordsCache['36199, deutschland']= new Array(51.0143636,9.7389246);coordsCache['33102, deutschland']= new Array(51.7359819,8.7446217);coordsCache['31162, deutschland']= new Array(52.0726077,10.0327077);coordsCache['31860, deutschland']= new Array(52.0172656,9.4114239);coordsCache['37079, deutschland']= new Array(51.5346649,9.838804);coordsCache['96138, deutschland']= new Array(49.8285099,10.7474752);coordsCache['20457, deutschland']= new Array(53.5316484,9.9852574);coordsCache['31785, deutschland']= new Array(52.1014352,9.3617441);coordsCache['84072, deutschland']= new Array(48.5555434,11.7086836);coordsCache['30952, deutschland']= new Array(52.297583,9.6518689);coordsCache['22761, deutschland']= new Array(53.5678526,9.9118726);coordsCache['33175, deutschland']= new Array(51.785633,8.8267643);coordsCache['85591, deutschland']= new Array(48.1119561,11.7723469);coordsCache['17139, deutschland']= new Array(53.7305669,12.7694939);coordsCache['92339, deutschland']= new Array(49.005298,11.4919024);coordsCache['35585, deutschland']= new Array(50.6130603,8.5086873);coordsCache['82377, deutschland']= new Array(47.7630977,11.3829463);coordsCache['16244, deutschland']= new Array(52.895392,13.5618816);coordsCache['25436, deutschland']= new Array(53.6833851,9.6710705);coordsCache['18546, deutschland']= new Array(54.5328678,13.6356184);coordsCache['94436, deutschland']= new Array(48.5666165,12.739717);coordsCache['17291, deutschland']= new Array(53.3193989,13.8724781);coordsCache['84453, deutschland']= new Array(48.2428386,12.5056618);coordsCache['22869, deutschland']= new Array(53.5993247,9.8291495);coordsCache['96215, deutschland']= new Array(50.1738979,11.0475145);coordsCache['32547, deutschland']= new Array(52.1965956,8.8245138);coordsCache['17449, deutschland']= new Array(54.0868131,13.8327559);coordsCache['19243, deutschland']= new Array(53.508415,11.0480995);coordsCache['34121, deutschland']= new Array(51.3021767,9.4803861);coordsCache['18273, deutschland']= new Array(53.8000621,12.2159732);coordsCache['37619, deutschland']= new Array(51.9552167,9.5182385);coordsCache['92259, deutschland']= new Array(49.5429364,11.6601327);coordsCache['23968, deutschland']= new Array(53.9078425,11.3531041);coordsCache['17389, deutschland']= new Array(53.8566457,13.7141441);coordsCache['38690, deutschland']= new Array(51.9610743,10.569299);coordsCache['27305, deutschland']= new Array(52.8163226,8.9463465);coordsCache['99610, deutschland']= new Array(51.17087,11.1651487);coordsCache['30880, deutschland']= new Array(52.2812522,9.8482706);coordsCache['91257, deutschland']= new Array(49.7627954,11.5310637);coordsCache['98617, deutschland']= new Array(50.530613,10.3539589);coordsCache['24217, deutschland']= new Array(54.3951262,10.3646553);coordsCache['34314, deutschland']= new Array(51.3947309,9.4806545);coordsCache['37077, deutschland']= new Array(51.5641968,9.9909847);coordsCache['24768, deutschland']= new Array(54.3063359,9.6429685);coordsCache['18528, deutschland']= new Array(54.4117391,13.4258526);coordsCache['96317, deutschland']= new Array(50.2420979,11.3113054);coordsCache['30521, deutschland']= new Array(52.3239015,9.8038578);coordsCache['18276, deutschland']= new Array(53.7099956,12.1279997);coordsCache['37608, deutschland']= new Array(51.6666667,1.6166667);coordsCache['85521, deutschland']= new Array(48.0598428,11.6681224);coordsCache['34131, deutschland']= new Array(51.3110759,9.4032861);coordsCache['16259, deutschland']= new Array(52.798072,14.015775);coordsCache['21365, deutschland']= new Array(53.2842092,10.4498403);coordsCache['18055, deutschland']= new Array(54.0838949,12.1666436);coordsCache['85354, deutschland']= new Array(48.3948737,11.6949987);coordsCache['20146, deutschland']= new Array(53.5688101,9.9819779);coordsCache['36179, deutschland']= new Array(50.9938823,9.8567512);coordsCache['32457, deutschland']= new Array(52.2253083,8.9402185);coordsCache['23730, deutschland']= new Array(54.133637,10.8225089);coordsCache['33098, deutschland']= new Array(51.7113515,8.7542577);coordsCache['97080, deutschland']= new Array(49.8158268,9.9102608);coordsCache['84028, deutschland']= new Array(48.5409477,12.1623342);coordsCache['37077, deutschland']= new Array(51.5641968,9.9909847);coordsCache['35578, deutschland']= new Array(50.549895,8.5162205);coordsCache['33100, deutschland']= new Array(51.7212792,8.8341562);coordsCache['14513, deutschland']= new Array(52.3899573,13.2730408);coordsCache['24768, deutschland']= new Array(54.3063359,9.6429685);coordsCache['37671, deutschland']= new Array(51.7980896,9.3510271);coordsCache['24392, deutschland']= new Array(54.6415512,9.803084);coordsCache['39576, deutschland']= new Array(52.5994148,11.8824717);coordsCache['07545, deutschland']= new Array(50.8805212,12.0805073);coordsCache['33034, deutschland']= new Array(51.7281977,9.1585552);coordsCache['31785, deutschland']= new Array(52.1014352,9.3617441);coordsCache['12529, deutschland']= new Array(52.3690709,13.5016479);coordsCache['35576, deutschland']= new Array(50.5629784,8.4800373);coordsCache['33051, deutschland']= new Array(51.6666667,1.6166667);coordsCache['30521, deutschland']= new Array(52.3239015,9.8038578);coordsCache['31582, deutschland']= new Array(52.6335275,9.21858);coordsCache['18182, deutschland']= new Array(54.1861501,12.3290314);coordsCache['84478, deutschland']= new Array(48.2017152,12.4202162);coordsCache['34125, deutschland']= new Array(51.3331165,9.5223999);coordsCache['31515, deutschland']= new Array(52.4248253,9.407641);coordsCache['82140, deutschland']= new Array(48.2128791,11.3490674);coordsCache['94249, deutschland']= new Array(49.0761781,13.1135022);coordsCache['39288, deutschland']= new Array(52.2978506,11.871638);coordsCache['35398, deutschland']= new Array(50.5615626,8.6404842);coordsCache['37081, deutschland']= new Array(51.5317158,9.9049169);coordsCache['96215, deutschland']= new Array(50.1738979,11.0475145);coordsCache['25704, deutschland']= new Array(54.1040117,9.0622852);coordsCache['18437, deutschland']= new Array(54.3029821,13.0535231);coordsCache['30175, deutschland']= new Array(52.3769996,9.7630649);coordsCache['83022, deutschland']= new Array(47.9558287,12.0862928);coordsCache['37176, deutschland']= new Array(51.6331323,9.9307093);coordsCache['92637, deutschland']= new Array(49.6741448,12.1869797);coordsCache['86668, deutschland']= new Array(48.6800629,11.2792896);coordsCache['81829, deutschland']= new Array(48.1383204,11.6875629);coordsCache['33129, deutschland']= new Array(51.7737127,8.5578667);coordsCache['30659, deutschland']= new Array(52.4181462,9.8176312);coordsCache['80939, deutschland']= new Array(48.201196,11.6145677);coordsCache['32052, deutschland']= new Array(52.0919704,8.6500658);coordsCache['33142, deutschland']= new Array(51.5581888,8.6020547);coordsCache['37671, deutschland']= new Array(51.7980896,9.3510271);coordsCache['37081, deutschland']= new Array(51.5317158,9.9049169);coordsCache['31582, deutschland']= new Array(52.6335275,9.21858);coordsCache['18528, deutschland']= new Array(54.4117391,13.4258526);coordsCache['30521, deutschland']= new Array(52.3239015,9.8038578);coordsCache['31188, deutschland']= new Array(52.0861374,10.1242568);coordsCache['37671, deutschland']= new Array(51.7980896,9.3510271);coordsCache['35708, deutschland']= new Array(50.7864729,8.2051873);coordsCache['97456, deutschland']= new Array(50.1111389,10.2060019);coordsCache['34121, deutschland']= new Array(51.3021767,9.4803861);coordsCache['37079, deutschland']= new Array(51.5346649,9.838804);coordsCache['39104, deutschland']= new Array(52.120502,11.6277055);coordsCache['97737, deutschland']= new Array(50.0558088,9.7051863);coordsCache['16356, deutschland']= new Array(52.6205567,13.6740512);coordsCache['84028, deutschland']= new Array(48.5409477,12.1623342);coordsCache['33142, deutschland']= new Array(51.5581888,8.6020547);coordsCache['93059, deutschland']= new Array(49.0287545,12.1059712);coordsCache['33102, deutschland']= new Array(51.7359819,8.7446217);coordsCache['35039, deutschland']= new Array(50.8324955,8.7927351);coordsCache['97828, deutschland']= new Array(49.8444564,9.5719246);


function getMonth(whichMonth) {
	show_loadbox();
        var today = new Date();
        var correct = 1;
        if(whichMonth=="next") correct = 2;
        if(whichMonth=="next2") correct = 3;

        var myMonth = today.getMonth()+correct;
        var nextMonth = myMonth+1;
        var myYear = today.getYear();
        var nextYear = myYear;

        if (myYear<2000) myYear = myYear+1900;
        if (nextYear<2000) nextYear = nextYear+1900;

        if (myMonth<10) myMonth = "0" + myMonth;
        if (nextMonth<10) nextMonth = "0" + nextMonth;
        if (nextMonth>12) { nextMonth = "01"; nextYear = nextYear+1; }


        importSoap(myYear+"-"+myMonth+"-01",nextYear+"-"+nextMonth+"-01", false);
}

function importSoap(fromDate,toDate,onlyBounds) {
	show_loadbox();
	map.clearOverlays();
	countItems = 0;
	marker = new Array();
	toDo = new Array();
	$('eventlist').innerHTML = '';
	if (fromDate=='') fromDate = '2009-01-01';
	if (toDate=='') toDate = '2011-01-01';

	if (onlyBounds==false) {
	    reset_map();
	}
	actualBox = map.getBounds();

	var interval = setInterval(function() {
	    if (typeof(soapRequest) != 'undefined') {
	        clearInterval(interval);
		var CalendarEntries = soapRequest.GetCalendarEntriesResult.CalendarEntry;
		//alert(CalendarEntries.length);
	        maxItems = 200;
                var today = new Date();
                var myYear = today.getYear();
                if (myYear<2000) myYear = myYear+1900;
                var myMonth = today.getMonth()+1;
                if (myMonth<10) myMonth = "0" + myMonth;
                var myDay = today.getDate();
                if (myDay<10) myDay = "0" + myDay;

	        if (CalendarEntries instanceof Array) {

			for (i = 0; i<CalendarEntries.length; i++) {
			    if (maxItems<=0) break;
			    compareDate = CalendarEntries[i].EndDate.substr(0,10);
			    if (CalendarEntries[i].Id != 104 && CalendarEntries[i].Id != 439 && CalendarEntries[i].Id != 371 && (CalendarEntries[i].EventTypeId !=11 || CalendarEntries[i].Id == 372 || CalendarEntries[i].Id == 126 || CalendarEntries[i].Id == 76) && compareDate>=fromDate && compareDate<toDate && (CalendarEntries[i].RoadshowMobileId == 1 || CalendarEntries[i].RoadshowMobileId == 2 || CalendarEntries[i].RoadshowMobileId == 3 || CalendarEntries[i].RoadshowMobileId == 5)) {
                              // DEBUG
                              //$('eventlist').innerHTML += CalendarEntries[i].Id;
				   if (CalendarEntries[i].BeginDate.substr(0,10)>=myYear+'-'+myMonth+'-'+myDay) icon = "mapicon"; else icon = "mapicon_grey";
				   myLocation = CalendarEntries[i].EventLocation;
				   if (myLocation == undefined) myLocation = '';
				   myName = CalendarEntries[i].EventName;
				   if (myLocation == undefined) myName = '';
				   myName = htmlspecialchars(myName,'ENT_QUOTES');

				   myResidence = CalendarEntries[i].EventResidence;
				   if (myResidence == undefined) myResidence = '';

				   myZipCode = CalendarEntries[i].EventZipCode;
				   if (myZipCode == undefined) myZipCode = '';

				   myOpeningHours = CalendarEntries[i].OpeningHours;
				   if (myOpeningHours == undefined) myOpeningHours = '';
				   //if (myOpeningHours!='') myOpeningHours = htmlspecialchars(myOpeningHours,'ENT_QUOTES');

				   myDate = CalendarEntries[i].BeginDate.substr(8,2)+'.'+CalendarEntries[i].BeginDate.substr(5,2)+'.'+CalendarEntries[i].BeginDate.substr(0,4);
				   if (myDate == undefined) myDate = '';

				   myEndDate = CalendarEntries[i].EndDate.substr(8,2)+'.'+CalendarEntries[i].EndDate.substr(5,2)+'.'+CalendarEntries[i].EndDate.substr(0,4);
				   if (myEndDate == undefined) myEndDate = '';

				   myDateString = myDate;
				   if (myEndDate!='' && myEndDate!=myDate) myDateString += " - "+myEndDate;

				   myUnique = CalendarEntries[i].EventZipCode;
  	    			   // CalendarEntries[i].EventStreet+"<br />"+myLocation+"<br />"+
				   // "+CalendarEntries[i].EventResidence+
				   toDo.push(CalendarEntries[i].EventZipCode+", deutschland");
				   toDo.push("x = function (latlng) { if (latlng ) { if ('"+compareDate+"'>='"+myYear+"-"+myMonth+"-"+myDay+"' && actualBox.containsLatLng(latlng)) { countItems++; $('eventlist').innerHTML = $('eventlist').innerHTML + \"<div><a class=\\'arrow\\' href=\\'#\\' onclick=\\'zoomTo2(\\\""+CalendarEntries[i].EventZipCode+"\\\", \\\""+myDate+"\\\");this.blur();return false;\\'><span style='font-weight:normal'>"+myDateString + "<br />"+CalendarEntries[i].EventResidence+"</span><br /><b>" + myName + "</b></div>\"; } coordsCacheStr = coordsCacheStr + 'coordsCache[\\'"+CalendarEntries[i].EventZipCode+", deutschland"+"\\']= new Array('+latlng.lat()+','+latlng.lng()+');';  map.addOverlay(createMarker(latlng, '"+myName+"', '<div class=\\\'popup\\\'><img width=\\\'336\\\' height=\\\'58\\\' src=\\\'_images/titel_google_popup.jpg\\\' alt=\\\'\\\' /><h3>"+myName+"</h3><br />"+myZipCode+" "+CalendarEntries[i].EventResidence+"<br />"+CalendarEntries[i].EventStreet+"<br />"+myDateString+"<br />"+myOpeningHours+"</div>', '', '"+myUnique+"', '"+icon+"', '"+myDate+"')); } if (toDo.length>1) { myZip = toDo.shift(); if (!(coordsCache[myZip] instanceof Array)) {  geocoder.getLatLng(myZip,eval(toDo.shift())); } else { eval(toDo.shift())(new GLatLng(coordsCache[myZip][0],coordsCache[myZip][1])) }                                                                                                                                                           } else { if (countItems>1) { hide_loadbox(); }  else { if  (map.getZoom()>6) { map.setZoom(map.getZoom()-1); importSoap(fromDate,toDate,true); } else { hide_loadbox(); } }} } ");

			    maxItems--;
                            }
			}

			toDo.push('');
			geocoder.getLatLng(toDo.shift(),eval(toDo.shift()));


		}

	    }
	}, 50);
}



function load_map() {

   //map.addControl(new GHierarchicalMapTypeControl());
   map.addMapType(G_PHYSICAL_MAP);
   map.addControl(new GScaleControl());
   map.addControl(new GLargeMapControl());

   geocoder = new GClientGeocoder(new GGeocodeCache());
   geocoder.setBaseCountryCode('de');
   geocoder.setViewport(map.getBounds());

   map.enableContinuousZoom();
   map.enableDoubleClickZoom();
   map.enableScrollWheelZoom();
   reset_map();
   importSoap('2009-04-01','2011-01-01', false);
}

function reset_map() {
   map.setCenter(new GLatLng(51.4, 10), 6, G_PHYSICAL_MAP);
}

var loadboxTimeout;

function show_loadbox() {
	$('noconnection').innerHTML='';
        new Effect.Appear('loadbox', { from: '0.0', to: '0.9', duration: '0.2'});
	clearTimeout(loadboxTimeout);
        loadboxTimeout = setTimeout("$('noconnection').innerHTML='Es konnte keine Verbindung zum Tourdatenserver hergestellt werden<br />oder keine Termine im ausgewählten Zeitraum verfügbar.<br/><br/>Bitten klicken Sie um fortzufahren.';",7000);

}
function hide_loadbox() {
	clearTimeout(loadboxTimeout);
	$('noconnection').innerHTML='';
	new Effect.Fade('loadbox', { duration: '0.7'});
	// DEBUG
        //$('coords2').innerHTML = coordsCacheStr;
}


function createMarker(point, title, html, maxurl, uniqueid, my_icon, date) {
	  if (my_icon == '') my_icon ='mapicon';

          var icon = new GIcon();
          icon.image = '_images/'+my_icon+'.png';


          icon.iconSize = new GSize(22,25);
          icon.iconAnchor = new GPoint(11, 25);
	  icon.infoWindowAnchor = new GPoint(11,25);


         if (marker[uniqueid]!=undefined && marker[uniqueid].tabs instanceof Array) {
	 	 myTabs = marker[uniqueid].tabs;
	 	 marker[uniqueid] = new GMarker(point, {title:title, icon:icon});
	 	 marker[uniqueid].tabs = myTabs;
                 myIndex = marker[uniqueid].tabs.push(new GInfoWindowTab(date, html));
	         GEvent.addListener(marker[uniqueid], "click", function() {
			 marker[uniqueid].openInfoWindowTabsHtml(marker[uniqueid].tabs);
		 });

	         GEvent.addListener(marker[uniqueid], "click"+date, function() {
			 marker[uniqueid].openInfoWindowTabsHtml(marker[uniqueid].tabs, {selectedTab: 1});
		 });

         } else {
	 	 marker[uniqueid] = new GMarker(point, {title:title, icon:icon});
 	         marker[uniqueid].tabs = new Array;
		 myIndex = marker[uniqueid].tabs.push(new GInfoWindowTab(date, html));
	         GEvent.addListener(marker[uniqueid], "click", function() {
			 marker[uniqueid].openInfoWindowTabsHtml(marker[uniqueid].tabs);
		 });

	         GEvent.addListener(marker[uniqueid], "click"+date, function() {
			 marker[uniqueid].openInfoWindowTabsHtml(marker[uniqueid].tabs, {selectedTab: 0});
		 });
         }

     return marker[uniqueid];
}


function zoomTo2(uniqueid,date) {
   var my_marker = marker[uniqueid];
   GEvent.trigger(my_marker, 'click'+date);
   var koords = my_marker.getPoint();
   map.panTo(koords);
/*   map.setMapType(G_SATELLITE_MAP);
   map.setCenter(koords,17);*/
}

function zoomTo3(uniqueid) {
   var my_marker = marker[uniqueid];
   GEvent.trigger(my_marker, 'click');
   var koords = my_marker.getPoint();
   map.panTo(koords);
}



function showAddress(address) {
  if (geocoder) {
    geocoder.getLatLng(
      address,
      function(point) {
        if (!point) {
          alert(address + " nicht gefunden");
        } else {
		/*
            if (mymarker) map.removeOverlay(mymarker);

          var icon = new GIcon();
          icon.image = '_images/mapicon.png';


          icon.iconSize = new GSize(23,19);
          icon.iconAnchor = new GPoint(11.5, 19);
	  icon.infoWindowAnchor = new GPoint(8,8);

            mymarker = new GMarker(point, {icon:icon});
	    */
            var zoomlevel=10;
            zoomlevel = 11;

            map.setCenter(point, zoomlevel);
	    //map.addOverlay(mymarker);
            map.setCenter(point, zoomlevel);
            importSoap('2009-04-01','2011-01-01', true);



        }
      }
    );
  }
}



function areasearch(form) {
    show_loadbox()
    var searchstring = document.forms.area_zoom.elements.fm_areasearch.value;

    showAddress(searchstring + searchextra);
    return false;
}

