function display(what){
	var doc = _ge(what);
	if(doc.style.display == "none"){
		doc.style.display = "inline";
	}
	else if(doc.style.display == "block" || doc.style.display == "inline"){
		doc.style.display = "none";
	}
	else if(doc.style.display == ""){
		doc.style.display = "inline";
	}
}

function displayLayer(layerName){
	var doc = _ge(layerName);
	if(doc){
		if(doc.style.display=="none" || doc.style.display==""){
			doc.style.display="block";
		}else{
			doc.style.display="none";
		}
	}else{
		return false;
	}
}

function emptyValue(what){
	var doc = _ge(what);
	if(doc){
		doc.value="";
	}else{
		return false;
	}
}

function erfrische(wen,mit,wie,was) {
	jQuery.ajax({
		type: "GET",
		url: mit,
		data: 'uni_countryId=' + document.getElementById('Chooser_countryId').value,
		success: function(msg){
			jQuery(wen).html(msg);
		}
	});
}

function installSearchEngine(){
	if(window.external && ("AddSearchProvider" in window.external)){
		window.external.AddSearchProvider("http://www.sesam24.de/searchplugin.xml");
	}else{
		alert("Dieses Feature funktioniert leider nur mit dem Firefox-Browser ab Version 2 und dem Internet Explorer ab Version 7.");
	}
}

function showmap(id){
	window.open('/maps/index.php?opid='+id+'','Fenster','width=640,height=480,toolbar=no,menubar=no');
}

function memorize(what, id){
	if(_ge(what).firstChild.nodeValue == "Merken"){
		jQuery.ajax({
			type: "GET",
			url: "index.php",
			data: "eID=nb_leaflet&opt=add&lid=" + id,
			success: function(msg){
				jQuery('#leafletTeaser').html(msg);
			}
		});
		jQuery("a#" + what).html("Gemerkt");
		return true;
	}
	if(_ge(what).firstChild.nodeValue == "Gemerkt"){
		jQuery.ajax({
			type: "GET",
			url: "index.php",
			data: "eID=nb_leaflet&opt=del&lid=" + id,
			success: function(msg){
				jQuery('#leafletTeaser').html(msg);
			}
		});
		jQuery("a#" + what).html("Merken");
		return true;
	}
	return false;
}

function checkCommentForm(){
	var pflichtfelder = new Array("name","comment");
	var pflichtfelderName = new Array("Name","Kommentar");
	for(var i=0; i<pflichtfelder.length; i++){
		if(_ge(pflichtfelder[i]).value==""){
			alert("Bitte befüllen: " + pflichtfelderName[i]);
			return false;
		}
	}
	return true;
}

function _ge(what){
	return document.getElementById(what);
}

function checkSearchForm(){
	if(_ge('textfield').value!=''){
	    document.forms.searchForm.submit();
	    return true;
	}else{
	    return false;
	}
}

function _addclass(where, what){
    jQuery(where).addClass(what);
}

function isValidURL(url){
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
}

function isValidEmail(email){
    var RegExp = /^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.)[\w]{2,4}|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/
    if(RegExp.test(email)){
        return true;
    }else{
        return false;
    }
}
