function showEndzeit(){
	$('#startzeit').slideUp();
	$('#endzeit').slideDown();
	$('#endzeit_td').text('Endzeitpunkt:');
	$('#end_datum').val($('#datum').val());
	
	if($('#datum').val()!="")
		$('#end_datum').dpSetDisplayedMonth($('#datum').val().substr(3,2)-1,$('#datum').val().substr(6,4));

}

function showEndzeitWarning(){
	check = confirm("Mit Eingabe einer Endzeit wird die Serienterminfunktionalität deaktiviert");
	if(check == true){
		showEndzeit();
	}
}

//Popup für Video

function popupVideo(videoID){
	popup("",480,320);
	$.post("../../tutorials/showVideoAjax.php",{ videoID: videoID }, function cb(data){
														   		document.getElementById('PopupDialog').innerHTML = data;
														   } );
}


//Popup für Gruppe einladen
function popupGroupAdd(spieleID, gruppenID, sb, plz, u, katID){
	popup("",300,300);
	$.post("../../meine_events/gruppenAddAjax.php",{ spieleID: spieleID, gruppenID: gruppenID, sb: sb, plz: plz, u: u, katID: katID }, function cb(data){
														   		document.getElementById('PopupDialog').innerHTML = data;
														   } );
}

function popup_cb(data, dialog){
	dialog = data;	
}
/**
 * Erstellt das Grundgerüst für ein Popup und fügt einen übergebenen Dialog ein. Optional mit 'Schliessen [x]'-Option.
 * 
 * @param string dialog Dialog in HTML 
 * @param bool close Flag für Schliessen-Option
 */
function popup(dialog, width, height, close, xOff, yOff)
{
	// Standardhöhe und -breite
	if (!width) width = 200;
	if (!height) height = 100;

	
	// HTML-Grundgerüst für Hintergrund und Popup
	var popup =
		'<div id="PopupBg" style="width:0px;height:0px;z-index:10" onclick="popdown()"></div>' +
		'<div id="Popup" style="width:0px;height:0px;z-index:11">' +
			(close ? '<a href="javascript:popdown()">[x] Schlie&szlig;en</a><br /><br />' : '') +
			'<div id="PopupDialog">' + dialog + '</div>' +
	'</div>';
	
	if(!isNaN(dialog) && dialog>0){
		$.post("../../start/startboxen/suchende_optionen.inc.php",{ suchID: dialog }, function cb(data){
														   		document.getElementById('PopupDialog').innerHTML = data;
														   } );
		
		//$.post("../../start/startboxen/suchende_optionen.inc.php",{ suchID: dialog }, popup_cb(data,dialog));
		
	}
	
	
	$("body").prepend(popup);
	$("#PopupDialog").hide();
	
	// Hintergrund für Browser jeweils mit/ohne Scroll-Leiste anpassen
	var bgWidth;
	var bgHeight;
	var hOff = document.body.offsetHeight;
	var wOff = document.body.offsetWidth;
	//console.log("hOff: "+hOff);
	switch (browser())
	{
		// ab Opera 9.5 verhält sich Opera wie Firefox
		case "opera_old":
		{
			bgWidth = document.body.clientWidth;
			hOff += 16;
			
			var h = document.body.clientHeight;
			if (h < hOff) bgHeight = hOff;
			else bgHeight = h;
			
			break;
		}
		
		case "opera":
		case "firefox":
		{
			var h = window.innerHeight;
			var w = window.innerWidth;
			hOff += 16;
			wOff += 16;
			//console.log("h: "+h);
			// rechte Scrollbar sichtbar (17px)
			if(hOff>16){
				bgHeight = hOff + h;	
			}
			if (hOff > h)
			{
				//bgHeight = hOff + h;
				bgWidth = window.innerWidth - 17;
			}
			
			// keine rechte Scrollbar
			else
			{
				bgHeight = h;
				bgWidth = window.innerWidth;
			}
			
			break;
		}
		
		case "msie":
		{
			
			var h = document.documentElement.clientHeight;
			var w = document.documentElement.clientWidth;
			//alert("MSIE, w: " + w + ", h: " + h + "hOff: " + hOff + "wOff: " + wOff);
			
			if(hOff > 0){
				bgHeight = hOff + h + 30;
			}
			//if (hOff > h)
				//bgHeight = hOff + 30;
			else bgHeight = h;
			bgWidth = w;
			
			$("#PopupBg").css("filter", "Alpha(opacity=35)");
			
			break;
		}
		
		case "safari":
		{
			var h = window.innerHeight;
			var w = window.innerWidth;
			
			// rechte Scrollbar sichtbar (16px)
			if (hOff > 0)
			{
				bgHeight = hOff + h + 16;
				bgWidth = window.innerWidth - 16;
			}
			
			// keine rechte Scrollbar
			else
			{
				bgHeight = h;
				bgWidth = window.innerWidth;
			}
			
			break;
		}
		
		default:
		{
			bgHeight = hOff + 16;
			bgWidth = wOff + 16;
			
			break;
		}
	}
	
	$("#PopupBg").hide();
	$("#Popup").hide();
	
	//console.log(bgHeight);
	
	$("#PopupBg").css("width", bgWidth);
	$("#PopupBg").css("height", bgHeight);
	
	$("#Popup").css("width", width);
	$("#Popup").css("height", height);
	
	//if (!xOff) var xOff = (1000 - width) % 2 == 0 ? ((1000 - width) / 2) : ((1000 - width - 1) / 2);
	if(browser()!="msie"){
		if (!xOff) var xOff = Math.round(bgWidth/2) - Math.round(width/2);
	}
	else{
		if (!xOff) var xOff = (1000 - width) % 2 == 0 ? ((1000 - width) / 2) : ((1000 - width - 1) / 2);	
	}
	$("#Popup").css("margin-left", xOff + "px");
	if (yOff) $("#Popup").css("margin-top", yOff + "px");
	
	$("#PopupBg").fadeIn(200);
	$("#Popup").show(500, function(){$("#PopupDialog").fadeIn(200)});
}

/**
 * Liefert den Browser des Betrachters. 'opera_old' bezieht sich auf Opera-Versionen !=9.50.
 * 
 * @return Gibt einen der Strings 'opera', 'opera_old', 'msie', 'safari' oder 'firefox' zurück.
 */
function browser()
{
	var ua = navigator.userAgent.toLowerCase();
	
	if (ua.indexOf("msie") != -1) return "msie";
	else if (ua.indexOf("firefox") != -1) return "firefox";
	else if (ua.indexOf("opera") != -1)
	{
		if (ua.indexOf("9.50") != -1) return "opera";
		else return "opera_old";
	}	
	else if (ua.indexOf("safari") != -1) return "safari";
	else return "";
}

/**
 * Schließt das Popup.
 */
function popdown()
{
	document.body.style.cursor = "default";
	
	$("#PopupDialog").fadeOut(200, function()
	{
		$("#Popup").hide(200, function()
		{
			$("#Popup").remove();
			$("#PopupBg").fadeOut(200, function()
			{
				$("#PopupBg").remove();
			});
		});
	});
}

/* trim funktion für Javascrupt*/
function trim (s) {
  return s.replace (/^\s+/, '').replace (/\s+$/, '');
}




//Tags einer Gruppe mittels Ajax speichern
function addtags(url, gID){
	$.post(url,{ gruppenID: gID, text: document.getElementById('tagsfeld').value }, function cb(data){
														   //data = data.replace(",",", ");
														   document.getElementById('tagsfeld').value=data.replace(/,/g,", ");
														   alert("Tags gespeichert");
												} );
}

//Boxen speichern
function saveBoxStatus(box){
	$.post("../../start/startboxen/save_box.php",{ sb: box });
}

/*
	Hier die Nachladefunktionen auf der Startseite
*/

function zeigenStartseite(elID, bild){
//	alert("in zeigen"+elID);
			
	if(document.getElementById(elID).style.display == "none"){ // || document.getElementById(elID).visibility=="hidden"){
		
		//Holen, wenn noch kein Inhalt
		if(trim(document.getElementById(elID).innerHTML)==""){
			//document.getElementById(elID).innerHTML = "<img src=\"../../img/loading.gif\" alt=\"Bitte warten\" title=\"Bitte warten\" />";
			$.post("../../start/startboxen/startseite_ajax.php",{type: elID}, function cb(data){
																						 
														   //data = data.replace(",",", ");
														   document.getElementById(elID).innerHTML=data;
														   $("#"+elID+":hidden").slideDown("fast");
															if(bild!=null)
																bild.src = "../../img/up.gif";
												} );
			
		}else{
			$("#"+elID+":hidden").slideDown("fast");
			if(bild!=null)
				bild.src = "../../img/up.gif";
		}
	}
	else{
		$("#"+elID+":visible").slideUp("fast");
		if(bild!=null)
			bild.src = "../../img/down.gif";
	}
}



//Prüft, ob die Eingabe numerisch ist
function zahlen_test(feld){
	for(var i=0;i<feld.value.length;i++){
		if(isNaN(feld.value.charAt(i)) || feld.value.charAt(i) == " "){
			feld.value = feld.value.substring(0,i);
			break;
		}
	}
}

function warten(){
	document.formular.sub1.value = "Bitte warten...";
	document.formular.sub1.disabled = true;
	document.formular.sub2.value = "Bitte warten...";
	document.formular.sub2.disabled = true;
}

//"Make Pixel Numeric"
function mpxn(pixel){
	return parseInt(pixel.substr(0,pixel.length-2));
}



//Zählt die Zeichen einer Nachricht und gibt die Verbliebenen aus
function zaehlen(sender, empf){
	var lange = 160;		//max anzahl an zeichen
	anz = sender.value.length;
	if(anz>lange){
		sender.value = sender.value.substring(0,lange);
		anz = lange;
	}
	empf.value = lange-anz;
}


function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


function ubertrag_min(element){
	//alert(document.getElementById('reminder_min').value);
	document.getElementById("reminder_min").value = element.value;
	document.getElementById("best_min").value = element.value;
}

//Reiht die Namen der Empfänger einer mail aneinander und kürzt diese zur Anzeigen
function ubertrag()
{
 var text = "";
 for(var i=0;i<document.sendmail.eingeladene.length;i++){
	 	text = text + " - " + document.sendmail.eingeladene.options[i].text;
 }
 
 if(text.length>3)
 	text = text.substring(3,text.length);
 if(text.length > 80)
 	text = text.substring(0,78) + "...";
 document.sendmail.an.value = text;
 if (document.sendmail.eingeladene.length == 0)
 {
  document.sendmail.an.value = "Keine Empfänger";
 }
 if(text == " - ")
  document.sendmail.an.value = "Keine Empfänger";
}

//siehe ubertrag() nur für sms
function ubertragsms()
{
 var text = "";
 for(var i=0;i<document.sendmail.eingeladene.length;i++){
	 	text = text + " - " + document.sendmail.eingeladene.options[i].text;
 }
 
 if(text.length>3)
 	text = text.substring(3,text.length);
 if(text.length > 45)
 	text = text.substring(0,43) + "...";
 document.sendmail.an.value = text;
 if (document.sendmail.eingeladene.length == 0)
 {
  document.sendmail.an.value = "Keine Empfänger";
 }
 if(text == " - ")
  document.sendmail.an.value = "Keine Empfänger";
}



//öffnet und schliesst das div id
function zeigen(id)
{
 if(document.getElementById(id).style.display == 'none')
 {
  document.getElementById(id).style.display = 'block';
 }
 else
 {
  document.getElementById(id).style.display = 'none';
 }
}


var aktiv;
var zaehler;
var schrittweite = 10;

//prüft, ob der Browser ein Internet Explorer ist
function isIE(){
	if(navigator.appName.indexOf("Microsoft") != -1)
		return true;
	else
		return false;
}

function changeOpacity(objekt, opac){
	if(navigator.appName.indexOf("Microsoft") != -1)
		objekt.style.filter = "alpha(opacity=" + (opac*100)+")";
	else
		objekt.style.opacity = opac;
}

//Klappt ein Menü auf
function zeigen2(id, hoehe){
	element = document.getElementById(id);
	
	if(element.style.display == 'none'){
		changeOpacity(element, 0); 
		if(isIE())
			element.style.height = 0;
		else
			element.style.height = '0px';
		element.style.display = 'block';
		element.style.overflow = 'hidden';
		var hv = "height_max(element,"+hoehe+")";
		zaehler = 0;
		aktiv = window.setInterval(hv, 5);
	}
	else{
		if(isIE())
			element.style.height = hoehe;
		else
			element.style.height = hoehe+'px';
		element.style.overflow = 'hidden';
		var hv = "height_min(element,"+hoehe+")";
		zaehler = 100;
		changeOpacity(element,1);
		aktiv = window.setInterval(hv, 5);
	}
}

function height_min(el, hoehe){
	if(isIE()){
		el.style.height = (parseInt(el.style.height) - schrittweite);
		zaehler = zaehler - 1000/hoehe;
		if(zaehler < 0)
			zaehler = 0;
		changeOpacity(el, zaehler/100);
		if(parseInt(el.style.height)==0 || parseInt(el.style.height) < 0){
			window.clearInterval(aktiv);
			changeOpacity(el, 0);
			el.style.display = 'none';
		}
	}
	else{
		akt = parseInt(el.style.height.substr(0,el.style.height.length-2))
		if(akt < schrittweite)
			el.style.height = "0px";
		else
			el.style.height = (akt - schrittweite) + "px";
		zaehler = zaehler - 1000/hoehe;
		
		if(zaehler < 0)
			zaehler = 0;
		changeOpacity(el, zaehler/100);
		if(mpxn(el.style.height)==0 || mpxn(el.style.height) < 0){
			window.clearInterval(aktiv);
			changeOpacity(el, 0);
			el.style.display = 'none';
		}
	}
}

function height_max(el, hoehe){
	if(isIE()){
		el.style.height = parseInt(el.style.height) + schrittweite;
		zaehler = zaehler + 1000/hoehe;
		if(zaehler > 100)
			zaehler = 100;
		changeOpacity(el, zaehler/100);
		if(parseInt(el.style.height) == hoehe || parseInt(el.style.height) > hoehe){
			window.clearInterval(aktiv);
			changeOpacity(el, 1);
		}
	}
	else{
		akt = parseInt(el.style.height.substr(0,el.style.height.length-2))
		el.style.height = (akt + schrittweite) + "px";
		zaehler = zaehler + 1000/hoehe;
		
		if(zaehler > 100)
			zaehler = 100;
		changeOpacity(el, zaehler/100);
		if(mpxn(el.style.height)==hoehe || mpxn(el.style.height)>hoehe){
			window.clearInterval(aktiv);
			changeOpacity(el, 1);
		}
	}
}


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top+'');
}

function showTable(id)
{
	var bereich = document.getElementById(id);
		
	if (bereich.style.display == 'none')
	{
		bereich.style.display = 'inline';
	}
	else
	{
		bereich.style.display = 'none';
	}

}


function termin_wiederholung()
{
	document.testForm.enddatum.options[0].selected=true;
	document.getElementById('kalender').style.display='none';
	
	for(i=0;i<document.testForm.serientermin.length;++i)
	{
		var bereich = document.getElementById(document.testForm.serientermin.options[i].value);
		if (document.testForm.serientermin.options[i].value!='') 
		{	
			bereich.style.display = 'none';
			document.getElementById('div_enddatum').style.display='inline';
		}
		
	}
	
	
	for(i=0;i<document.testForm.serientermin.length;++i)
	{
		if(document.testForm.serientermin.options[i].selected == true)
		{
			var bereich = document.getElementById(document.testForm.serientermin.options[i].value);
			if (document.testForm.serientermin.options[i].value!='')
			{
				bereich.style.display = 'inline';
				//enddatum2.style.display = 'inline';
			}
			else 
			{
				document.getElementById('div_enddatum').style.display='none';
			}
		}
	}
	
}

function CheckStr(userInput){
 
 var StrLeft = 0;
 // 160 - kuerzen(gruppenname) - termindatum - sonst
 var maxLen = 160 - 14 - 30 - 22;
 StrLen = window.document.testForm.absagetext.value.length;

  if (StrLen > maxLen ){
    window.document.testForm.absagetext.value = window.document.testForm.absagetext.value.substring(0,maxLen);
    StrLeft = 0;
	alert("160 Zeichen Limit erreicht!");

  }
  else{
    StrLeft = maxLen - StrLen;
  }
 var Aussage = window.document.testForm.absagetext.value;

  document.testForm.LEN.value = StrLeft;

}
var req;

function loadXMLDoc(url) 
{
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function checkSubKats(katParentID,katID,domain)
{
	if (katParentID =="") katParentID = 1;
	
		deleteSelect();
		url  =  'http://' + domain + '/include/kats_nachladen.inc.php?katParentID=' + katParentID + '&katID=' + katID;
		loadXMLDoc(url);		
	
}


function processReqChange() 
{
    var go2;
	// only if req shows "complete"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            // ...processing statements go here...
      response  = req.responseXML.documentElement;
      for(i=0;i<response.getElementsByTagName('option').length;++i)
	  {
	  option    = response.getElementsByTagName('option')[i].firstChild.data;
      value    = response.getElementsByTagName('value')[i].firstChild.data;
	  selected    = response.getElementsByTagName('selected')[i].firstChild.data;
      
	  //alert (option + "--" + value);
	  hinzufuegen(option,value,false,selected);
	  
	  if (selected=="true") go2 = value;
	  }
	  
	  if (go2 !="") setSubKat(go2);
     
	 	} else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}

function hinzufuegen(text,value,defaultSelected,selected) 
{
 NeuerEintrag = new Option(text,value,defaultSelected,selected);
 document.gruppe.kategorie1.options[document.gruppe.kategorie1.length] = NeuerEintrag;
	//alert (selected + "-" + text + "-" +value);
	//if (selected=="true") 
	//{ 
	//	alert ("jaja"+ value);
	//	setSubKat(value); 
	//}
}

function deleteSelect()
{
	document.gruppe.kategorie1.length =  0;
}

function setSubKat(katID2)
{
       	for(i=0;i<document.gruppe.kategorie1.length;++i)
        {
                if (document.gruppe.kategorie1.options[i].value == katID2 )
                {
                        document.gruppe.kategorie1.options[i].selected = true;
                        //alert(document.gruppe.kategorie1.options[i].value+"=="+katID2);
                }
        }
}


////////////////////////////////////////////////////////////////////////////////////

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}

function AllMessages()
{
	for(var x=0;x<document.form.elements.length;x++)
	{
		var y=document.form.elements[x];
		if(y.name!='ALLMSGS')
			y.checked=document.form.ALLMSGS.checked;
	}
}

function AllMessages1()
{
	for(var x=0;x<document.getElementsByName('form')[0].elements.length;x++)
	{
		var y=document.getElementsByName('form')[0].elements[x];
		if(y.name!='ALLMSGS')
			y.checked=document.getElementById('ALLMSGS').checked;
	}
	
}

function AllMessagesPart(sym,el){
	var laenge = document.getElementById('form').elements.length;
	for(var x=0;x<laenge;x++){
		var y=document.getElementById('form').elements[x];
		if(y.id.charAt(0)==sym)
			y.checked = el.checked;
	}
	
}

function loeschen(i)
{

	if (confirm("Wollen Sie wirklich löschen?") == true) {
		document[i].hilfe.value = 'Löschen';
		document[i].submit();
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


var alreadyIn = new Array();

	function add(opt)
	{
		if (document.einladungen.eingeladene.length > 0 && document.einladungen.eingeladene.options[0].value == "")
		{
			document.einladungen.eingeladene.options[0] = opt;
		}
		else
		{
			document.einladungen.eingeladene.options[document.einladungen.eingeladene.length] = opt;
		}

		alreadyIn[opt.value] = 1;
	}
	
	function addUser()
	{
		if (document.einladungen.user.selectedIndex == -1) return;
		
		for (i=0; i<document.einladungen.user.length; i++)
		{
			if (document.einladungen.user.options[i].selected)
			{
				if (isInList(document.einladungen.user.options[i].value)) continue;
				
				entry = new Option(document.einladungen.user.options[i].text,
				                   document.einladungen.user.options[i].value);
				add(entry);
			}
		}
	}
	
	function addRec1(opt)
	{
		if (document.sendmail.eingeladene.length > 0 && document.sendmail.eingeladene.options[0].value == "")
		{
			document.sendmail.eingeladene.options[0] = opt;
		}
		else
		{
			document.sendmail.eingeladene.options[document.sendmail.eingeladene.length] = opt;
		}

		alreadyIn[opt.value] = 1;
	}
	
	function addRec()
	{
		if (document.sendmail.user.selectedIndex == -1) return;
		
		for (i=0; i<document.sendmail.user.length; i++)
		{
			if (document.sendmail.user.options[i].selected)
			{
				if (isInList(document.sendmail.user.options[i].value)) continue;
				
				entry = new Option(document.sendmail.user.options[i].text,
				                   document.sendmail.user.options[i].value);
				addRec1(entry);
			}
		}
		
	}
	
	function addNeuUser()
	{
		
		eintrag = document.einladungen.name.value + ', ' + document.einladungen.vorname.value + ' [' + document.einladungen.email.value + ']';
		value = document.einladungen.name.value + ',' + document.einladungen.vorname.value + ',' + document.einladungen.email.value;

		if (!document.einladungen.email.value || document.einladungen.email.value =="E-Mail" ){ alert("Bitte eine korrekte Emailadresse angeben"); return; }
		if (!isValidEmail(document.einladungen.email.value)){ alert("Bitte eine korrekte Emailadresse angeben"); return; }
		if (!document.einladungen.name.value || document.einladungen.name.value =="Name" ){ alert("Bitte einen Namen angeben"); return; }

		if (isInList(eintrag)) return; 

		entry = new Option( eintrag, value );

		add(entry);
		document.einladungen.email.value = "E-Mail";
		document.einladungen.name.value = "Name";
		document.einladungen.vorname.value = "Vorname";
	}
	
	
	function addNeuUserRec(){
		if(!isNaN(document.sendmail.eigene.value.charAt(0)) && document.sendmail.eigene.value!=""){
			eintrag = document.sendmail.eigene.value;
		
			eintrag = check_nr(eintrag);
			if (isInList(eintrag)) return;
			entry = new Option( check_nr(eintrag), check_nr(eintrag) );

			addRec1(entry);
			
			document.sendmail.eigene.value = "weitere Mobilfunknummer";
		}
		
	}
	
	//Prüft die Nummer
	function check_nr(nr){
		if(nr.charAt(0)=="0" && nr.charAt(1)!="0")
			return "0049"+nr.substring(1)
		if(nr.substr(0,2)=="00" && nr.substr(2,2)!="49")
			return "0049"+nr.substring(2);
		if(nr.substr(0,2)=="00" && nr.substr(2,2)=="49" && nr.length>4)
			return nr;
			
		return "0049"+nr;
	}
	
	function submitMe()
	{
		/*document.einladungen.import_outlook.value = "";
		document.einladungen.userliste.value = ""; */
		for (i=0; i<document.einladungen.eingeladene.length; i++)
		{
			document.einladungen.userliste.value += document.einladungen.eingeladene.options[i].value;
			document.einladungen.userliste.value += ";";
		}
		document.einladungen.submit();
	}
	
	function submitMeRec(){
		/*document.einladungen.import_outlook.value = "";
		document.einladungen.userliste.value = ""; */
		for (i=0; i<document.sendmail.eingeladene.length; i++)
		{
			document.sendmail.userliste.value += document.sendmail.eingeladene.options[i].value;
			document.sendmail.userliste.value += ";";
		}
		document.sendmail.submit();
	}
	
	//SMS versenden
	function submitMeRecSMS(){
		if(document.sendmail.nachricht.value==""){
			alert("Bitte einen Text eingeben");
			return false;
		}
		else{
			for (i=0; i<document.sendmail.eingeladene.length; i++)
			{
				document.sendmail.userliste.value += document.sendmail.eingeladene.options[i].value;
				document.sendmail.userliste.value += ";";
			}
			document.sendmail.submit();
		}
	}
	
	
	function entfernen()
	{
		for (i=0; i<document.einladungen.eingeladene.length; i++)
		{
			if (document.einladungen.eingeladene.options[i] && document.einladungen.eingeladene.options[i].selected)
			{
				alreadyIn[document.einladungen.eingeladene.options[i].value] = 0;
				document.einladungen.eingeladene.options[i] = null;
				entfernen();
			}
		}
	}
	
	function entfernenRec()
	{
		for (i=0; i<document.sendmail.eingeladene.length; i++)
		{
			if (document.sendmail.eingeladene.options[i] && document.sendmail.eingeladene.options[i].selected)
			{
				alreadyIn[document.sendmail.eingeladene.options[i].value] = 0;
				document.sendmail.eingeladene.options[i] = null;
				entfernenRec();
			}
		}
	}

	function isInList(invitee)
	{
		return alreadyIn[invitee];
	}
	
	
	//aktuailisert das Feld, welches die verbleibenden SMS bekommt
	function getLeftSMS(){
			var anzopt = document.sendmail.eingeladene.length;
			if(anzopt > anz1){
					document.sendmail.eingeladene.options[anzopt-1] = null;
					alert("Sie können keine SMS mehr versenden");
					anzopt -= 1;
			}
			//document.sendmail.smscounter.value = anz1-anzopt;
			document.getElementById('smscounter').value = anz1-anzopt;
	}
	
	
	
	function isValidEmail(email) {
		
		ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
		
		for(i=0; i < email.length ;i++)
		{
			if(ok.indexOf(email.charAt(i))<0)
			{ 
				return (false);
			}	
		}	 

		AtPos = email.indexOf("@")
		StopPos = email.lastIndexOf(".")
		
		if (email == "") return false;
		if (AtPos == -1 || StopPos == -1) return false;		
		if (StopPos < AtPos) return false;
		if (StopPos - AtPos == 1) return false;
		if (AtPos == 0) return false;
		return true;
		
		
	}
	
function zeigen3(elID, bild){
	if(document.getElementById(elID).style.display == "none"){ // || document.getElementById(elID).visibility=="hidden"){
		$("#"+elID+":hidden").slideDown("fast");
		if(bild!=null)
			bild.src = "../../img/up.gif";
	}
	else{
		$("#"+elID+":visible").slideUp("fast");
		if(bild!=null)
			bild.src = "../../img/down.gif";
	}
}
function haken(elID, cbox){
	if(document.getElementById(elID).style.display == "none" && cbox.value!="0"){ // || document.getElementById(elID).visibility=="hidden"){
		$("#"+elID+":hidden").slideDown("fast");
	}
	else{
		$("#"+elID+":visible").slideUp("fast");
		
	}
}

function checkOptions(checkID, editID){
	if(document.getElementsByName(checkID)[0].checked == true){
		document.getElementById(editID).checked = false;
		document.getElementById(editID).disabled = true;
		$("#ubem:visible").slideUp("fast");
	}
	else
		document.getElementById(editID).disabled = false;
		//document.getElementById(editID).disabled = true;
	//else
		//document.getElementById(editID).disabled = false;
}

function changeBild(bild, src){
	bild.src = src;	
}

function gruppe_loeschen(zlink,gruppenID, katID){
	if(confirm("Wollen Sie die Gruppe wirklich löschen?")){
		location.href = zlink+"meine_gruppen/gruppe.php?gruppenID="+gruppenID+"&func=gruppe_loeschen&katID="+katID;
	}
}



function showImage(bild, e){
	posx = 0;
	posy = 0;
	if(document.all){	//IE
		posx = window.event.clientX + 10;
		posy = window.event.clientY + 10;
	}
	else{	//FF
		posx = document.pageX;
		posy = document.pageY;
	}
	//alert(layer.parent);
	
	//alert(posx + " " + posy);
	el = document.getElementById('bildLayer');
	document.getElementById('bildID').src = bild;
	el.style.top = posy;
	el.style.left = posx;
	el.style.display = "block";
}

function hideImage(){
	document.getElementById('bildLayer').style.display = "none";
}

//initShowImage();



