function ajaxRequest(url, objekt, methode, pars){
	if(objekt != ''){
		$(objekt).innerHTML = '<div class="ajaxLoader"><img src="fileadmin/templates/img/ajax-loader.gif" border="0" title="Lade Daten ..." alt="Lade Daten ..." /></div>';
	}

	if(methode == ''){
		methode = 'get';
	}

	var myAjax = new Ajax.Updater(objekt, url, {method: methode,
												parameters: pars});

	return false;
}

function showCountrys(object, cell){
	$('countrys0').show();
	$('countrys1').show();
	$('countrys2').show();

	$(object+cell).addClassName('blackBg');
	switch (cell) {
 		case 0:
 			$(object+(cell+1)).removeClassName('blackBg');
 			$(object+(cell+2)).removeClassName('blackBg');
 			$(object+(cell+1)+'Div').hide();
 			$(object+(cell+2)+'Div').hide();
 			$('activeLink1').innerHTML = $('1value').innerHTML;
 			$('activeLink2').innerHTML = $('2value').innerHTML;
    	break;
  		case 1:
  			$(object+(cell-1)).removeClassName('blackBg');
 			$(object+(cell+1)).removeClassName('blackBg');
 			$(object+(cell-1)+'Div').hide();
 			$(object+(cell+1)+'Div').hide();
 			$('activeLink0').innerHTML = $('0value').innerHTML;
 			$('activeLink2').innerHTML = $('2value').innerHTML;
    	break;
  		case 2:
  			$(object+(cell-2)).removeClassName('blackBg');
 			$(object+(cell-1)).removeClassName('blackBg');
 			$(object+(cell-2)+'Div').hide();
 			$(object+(cell-1)+'Div').hide();
 			$('activeLink0').innerHTML = $('0value').innerHTML;
 			$('activeLink1').innerHTML = $('1value').innerHTML;
    	break;
	}

	$(object+cell+'Div').show();
}

function setActiveCountry(continent, countryUid, cityMode, adressData){
	if(!cityMode){
		$('countrys'+continent+'Div').hide();
		$('countrys0').hide();
		$('countrys1').hide();
		$('countrys2').hide();

		$('officeContentRahmenRahmen').show();
		$('officeContent').show();

		if (GBrowserIsCompatible() && adressData[0] && adressData[1]) {
			$('googleEarth').addClassName('googleEarthHeight');
    		var map = new GMap2($('googleEarth'));

    		map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
        	map.setCenter(new GLatLng(adressData[0], adressData[1]), 15, G_SATELLITE_MAP);

        	// Marker hinzufügen
        	var point = new GLatLng(adressData[0], adressData[1]);
    		map.addOverlay(new GMarker(point));

		}else{
			$('googleEarth').innerHTML = '<div class="noGoogleData">Keine Google Map verf&uuml;gbar</div>';
		}
		ajaxRequest('index.php', 'officeData', 'post', 'eID=tx_wmdbneooffice_pi1&uid='+countryUid+'&type=0&id=5');
	}else{
		$(cityMode).show();
	}

}

function closeLayer(){
	$('officeContentRahmenRahmen').hide();
	$('officeContent').hide();
}

function setGoogleMap(daten){
	//
	if (GBrowserIsCompatible()) {
    	var map = new GMap2($('googleEarth'));
        map.setCenter(new GLatLng(daten.lat(), daten.lng()), 13);
        
        // Marker hinzufügen
        var point = new GLatLng(daten.lat(), daten.lng());
    	map.addOverlay(new GMarker(point));
	}
}

/** Typo Funktionen, um die E-Mail-Adresse zurÃ¼ck zu konvertieren **/
// decrypt helper function
function decryptCharcode(n,start,end,offset)	{
	n = n + offset;
	if (offset > 0 && n > end)	{
		n = start + (n - end - 1);
	} else if (offset < 0 && n < start)	{
		n = end - (start - n - 1);
	}
	return String.fromCharCode(n);
}

// decrypt string
function decryptString(enc,offset)	{
	var dec = "";
	var len = enc.length;
	for(var i=0; i < len; i++)	{
		var n = enc.charCodeAt(i);
		if (n >= 0x2B && n <= 0x3A)	{
			dec += decryptCharcode(n,0x2B,0x3A,offset);	// 0-9 . , - + / :
		} else if (n >= 0x40 && n <= 0x5A)	{
			dec += decryptCharcode(n,0x40,0x5A,offset);	// A-Z @
		} else if (n >= 0x61 && n <= 0x7A)	{
			dec += decryptCharcode(n,0x61,0x7A,offset);	// a-z
		} else {
			dec += enc.charAt(i);
		}
	}
	return dec;
}

// decrypt spam-protected emails
function linkTo_UnCryptMailto(s)	{
	location.href = decryptString(s,-1);
}
