var testzeich = /\S.+/;
var testmail = /(@)/;
function pruef(inhalt)
{

if(!testzeich.exec(inhalt)) return  false; else return true;

}

function pruef_mail(inhalt)
{
if(!testmail.exec(inhalt)) return  false; else return true;


}

function pruef_zahl(inhalt)
{

if(!Number(inhalt)) return  false; else return true;

}

function kat_wahl(){

if(document.kat.kat.value== "0"){
	alert("Bitte erst eine Kategorie wählen");
	return;
}

document.kat.submit();

}

function lo_kat(name){

	testen = confirm("Beim Löschen einer Kategorie werden alle dazugehörigen Bilder ebenfalls gelöscht.\n Möchtest du dieses? Dann bestätige mit OK!");
if (testen == true){


		document.forms[''+name].was.value = 'lo';
		document.forms[''+name].submit();
		
		}
	

}

function kat_neu(){
	if(!pruef(document.katneu.katname.value)) {alert("Bitte die Kategorie ausfüllen"); return;}
	
	document.katneu.submit();
	
}

function uebertragen(){
	
	if(!pruef(document.wahl.bild.value)) {alert("Bitte ein Bild auswählen"); return;}
	
	document.wahl.kateigen.value= document.kateigen.kateigen.value;
	
	document.wahl.submit();
}	

function aendern(){
	
		
	document.wahl.kateigen.value= document.kateigen.kateigen.value;
	
	document.wahl.submit();
}	

function kat_wechsel(){
	
	
	if(document.kateigen.kateigen.value != "0")	document.kateigen.submit();
	
	
	
}

function kat_frei(){
	
	
	document.kateigen.submit();
	
	
	
}

function bild(bild,breite,hoehe,profil)
{
breite = 600;
hoehe = 600;
fff = open("bild.php?bild="+bild+"&profil="+profil,"Bilder","width="+breite+", height="+ hoehe+ ",left=400,top=100,status=yes ,scrollbars=yes, resizable=no");
}

function ko_zu(){
	
	if(!pruef(document.kommentar.kommentar.value)) {alert("Bitte einen Text eingeben"); return;}
	document.kommentar.submit();
}

function bewert(){
	
document.voting.submit();
	
}	

function mms(profil){
	
	testen = confirm("Du möchtest diese Bild als MMS bekommen? Bestätige bitte mit OK oder brich den Vorgang ab.");
if (testen == true){


		location.href= 'bild.php?was=mms&profil='+profil;
		
		}
	
	
	
}

function gast_ein(){
	
	if(!pruef(document.gast.bn.value)) {alert("Bitte einen Benutzernamen eingeben"); return;}
	if(!pruef(document.gast.pw.value) || !pruef(document.gast.pww.value)) {alert("Bitte beide Passwortfelder ausfüllen"); return;}
	
	if(document.gast.pw.value != document.gast.pww.value) {alert("Die Passwörter sind nicht identisch"); return;}
	
	if(document.gast.mitmail.checked == true){
			
			if(!pruef_mail(document.gast.email.value)) {alert("Bitte eine gültige E-Mailadresse eingeben!"); return;}
	}
	
	
		if(document.gast.telbuch.checked == true){
			
			if(document.gast.vorwahl.value==0 || !pruef_zahl(document.gast.handy.value) || !pruef(document.gast.vorname.value) || !pruef(document.gast.nachname.value)) {alert("Bitte Vorname, Nachname,eine Vorwahl und gültige Handynummer eingeben!"); return;}
			
		}
	
	//if(document.gast['katzuord[]'].options.length == 0){alert("Es ist nötige mindestens eine Kategorie dem User zuzuordnen"); return;}
	
	document.gast['katzuord[]'].multiple = true;
	for(i = 0; i <= document.gast['katzuord[]'].options.length-1; i++){
		
		document.gast['katzuord[]'].options[i].selected = true;
	}
	
	document.gast.submit();
	
}

function g_login(){
	
	if(!pruef(document.glogin.gbn.value)) {alert("Bitte einen Benutzernamen eingeben"); return;}
	if(!pruef(document.glogin.gpw.value)) {alert("Bitte ein Passwort eingeben"); return;}
	
	document.glogin.submit();
}

function kat_zu(){
		
	
			for(i = 0; i <= document.gast.kateigen.options.length -1; i++){
				
					if(document.gast.kateigen.options[i].selected == true && document.gast.kateigen.options[i].disabled == false){
						lang = document.gast['katzuord[]'].options.length + 1;
						document.gast['katzuord[]'].options.length= lang;
						
						document.gast['katzuord[]'].options[lang-1].text = document.gast.kateigen.options[i].text;
						document.gast['katzuord[]'].options[lang-1].value = document.gast.kateigen.options[i].value;
						document.gast.kateigen.options[i].disabled = true;
						document.gast.kateigen.options[i].selected = false;
						
						
				}
				
		}
	
		
	
	
}	

function kat_weg(){
katles_text = new Array;	
katles_value = new Array;	
ii = 0;
var w_da;
	for(i = 0; i <= document.gast['katzuord[]'].options.length-1; i++){
		
		if(document.gast['katzuord[]'].options[i].selected == false){
			
			katles_text[ii] = document.gast['katzuord[]'].options[i].text;
			katles_value[ii] = document.gast['katzuord[]'].options[i].value;
			
						
			ii++;
			
		}
		else
		{
			
			w_da = document.gast['katzuord[]'].options[i].value;
			
		}
		
		
		
	}


	document.gast['katzuord[]'].options.length= katles_text.length;
	
	for(i =0 ; i <= katles_text.length-1; i++){
		
			document.gast['katzuord[]'].options[i].text=	katles_text[i];
			document.gast['katzuord[]'].options[i].value=katles_value[i];
		
		
	}
	
	for(i = 0; i <= document.gast.kateigen.options.length-1; i++){
		
		if(document.gast.kateigen.options[i].value == w_da){
			
			document.gast.kateigen.options[i].disabled = false;
			
		}
		
	}
	
}


function gast_aender(){
	
	if(!pruef(document.gast.bn.value)) {alert("Bitte einen Benutzernamen eingeben"); return;}
	if(!pruef(document.gast.pw.value)) {alert("Bitte das Passwortfeld ausfüllen"); return;}
	
	if(document.gast.telbuch.checked == true){
			
			if(document.gast.vorwahl.value==0 || !pruef_zahl(document.gast.handy.value) || !pruef(document.gast.vorname.value) || !pruef(document.gast.nachname.value)) {alert("Bitte Vorname, Nachname,eine Vorwahl und gültige Handynummer eingeben!"); return;}
			
		}	
	
	if(document.gast.mitmail.checked == true){
			
			if(!pruef_mail(document.gast.email.value)) {alert("Bitte eine gültige E-Mailadresse eingeben!"); return;}
	}
		
	
	//if(document.gast['katzuord[]'].options.length == 0){alert("Es ist nötige mindestens eine Kategorie dem User zuzuordnen"); return;}
	
	document.gast['katzuord[]'].multiple = true;
	for(i = 0; i <= document.gast['katzuord[]'].options.length-1; i++){
		
		document.gast['katzuord[]'].options[i].selected = true;
	}
	
	document.gast.submit();
	
}

function such(){
	
	if(!pruef(document.suche.bn.value) && !pruef(document.suche.email.value) && !pruef(document.suche.handy.value)) {alert("Es muß mindestens ein Suchbegriff eingegeben werden");return;}
	
	document.suche.submit();
}

function bn_aender(){
	
//	if(document.gast['katzuord[]'].options.length == 0){alert("Es ist nötige mindestens eine Kategorie dem User zuzuordnen"); return;}
	
	document.gast['katzuord[]'].multiple = true;
	for(i = 0; i <= document.gast['katzuord[]'].options.length-1; i++){
		
		document.gast['katzuord[]'].options[i].selected = true;
	}
	
	document.gast.submit();
	
	
}

function verstoss(profil){
	
	
	testen = confirm("Du möchtest einen Verstoß melden? Es wird eine E-Mail an den Administrator geschickt und auch dein Benutzername wird übermittelt. Drücke OK für den Versand oder Abbrechen.");
if (testen == true){


		location.href = 'bild.php?verstoss=1&profil='+profil;
		
		}
	
	
	
	
}	
