var richtig=1;

function checkuser(){
	var str=""+document.f1.username.value;
	var reg=new RegExp("^[a-zöäüA-ZÖÄÜ0-9]+([a-zöäüA-ZÖÄÜ0-9]{1,49})$");
	var pos=str.search(reg);
	if(pos>=0)	document.f1.username.style.backgroundColor="#cfcfcf";
	else document.f1.username.style.backgroundColor="#FF4242";
	
		if(str==""){
			richtig=0;
			document.f1.username_F.value="Bitte einen Benutzernamen angeben."
		}else if(pos<0){
		richtig=0;
		document.f1.username_F.value="Darf nur aus Buchstaben und Zahlen bestehen.";
		}else document.f1.username_F.value="";		
	
}

function checkmail(){
	var strReg = "^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$";
	var rege = new RegExp(strReg);
	var str=""+document.f1.email.value;
	var boo = (rege.test(str)); 
	if(boo==true)document.f1.email.style.backgroundColor="#cfcfcf";
	else document.f1.email.style.backgroundColor="#FF4242";
	
		if(str==""){
			richtig=0;
			document.f1.mail_F.value="Bitte eine E-mail Adresse angeben."
		}else if(boo==false){
			richtig=0;
			document.f1.mail_F.value="Bitte geben sie eine gültige E-mail Adresse an.";
		}else document.f1.mail_F.value="";		
		
}

function checkphone(){
	var str=document.f1.telefon.value;
	var check="^[- /+()0-9]*$";
	var reg=new RegExp(check);
	var pos=str.search(reg);
	if(pos>=0 && str!="")	document.f1.telefon.style.backgroundColor="#cfcfcf";
	else document.f1.telefon.style.backgroundColor="#FF4242";
	
		if(str==""){
			richtig=0;
			document.f1.telefon_F.value="Bitte eine Telefonnummer angeben."
		}else if(pos<0){
			richtig=0;
			document.f1.telefon_F.value="Darf nur aus folgenden Zeichen bestehen: 0-9 + - / ( )";
		}else document.f1.telefon_F.value="";	
	
}

function checkvorname(){
	var str=document.f1.vorname.value;
	var check="^[a-zäöüA-ZÖÄÜ -]*$";
	var reg=new RegExp(check);
	var pos=str.search(reg);
	if(pos>=0 && str != 0)	document.f1.vorname.style.backgroundColor="#cfcfcf";
	else document.f1.vorname.style.backgroundColor="#FF4242";
	
		if(str==""){
			richtig=0;
			document.f1.uservorname_F.value="Bitte geben sie Ihren Vornamen an."
		}else if(pos<0){
			richtig=0;
			document.f1.uservorname_F.value="Darf nur aus Buchstaben, Leerzeichen und - bestehen.";
		}else document.f1.uservorname_F.value="";	
		
}
function checkfamilienname(){
	var str=document.f1.familienname.value;
	var check="^[a-zäöüA-ZÖÄÜ -]*$";
	var reg=new RegExp(check);
	var pos=str.search(reg);
	if(pos>=0 && str != 0)	document.f1.familienname.style.backgroundColor="#cfcfcf";
	else document.f1.familienname.style.backgroundColor="#FF4242";
	
		if(str==""){
			richtig=0;
			document.f1.userfamilienname_F.value="Bitte geben sie Ihren Familiennamen an."
		}else if(pos<0){
			richtig=0;
			document.f1.userfamilienname_F.value="Darf nur aus Buchstaben, Leerzeichen - bestehen.";
		}else document.f1.userfamilienname_F.value="";	
		
}

function checkgeschlecht(){
    if(document.f1.geschlecht[0].checked==false && document.f1.geschlecht[1].checked==false){
		richtig=0;
		document.f1.geschlecht_F.value="Bitte geben Sie Ihr Geschlecht bekannt."
	}else document.f1.geschlecht_F.value="";
}
function checkdate(){
	if(document.f1.gebday.selectedIndex==0 || document.f1.gebmonth.selectedIndex==0 || document.f1.gebyear.selectedIndex==0){
		document.f1.geb_F.value="Bitte geben Sie ein gültiges Geburtsdatum an.";
		richtig=0;
	}else{ 
		var monat=document.f1.gebmonth.selectedIndex;
		var tag=document.f1.gebday.selectedIndex;
		var jahr=document.f1.gebyear.selectedIndex;
		var jahr_=document.f1.gebyear.options[document.f1.gebyear.selectedIndex].text;
		
		var tage;
		if(monat==2){
			for(var i=2004; i>1915; i-=4){
				if(i==jahr_){
					tage=29;
					if(!(tag<=tage)){
						document.f1.geb_F.value="Der Februar des Jahres "+jahr_+" hat nur 29 Tage.";
						richtig=0;
					}else document.f1.geb_F.value="";
					break;
				}else{
					tage=28;
					if(!(tag<=tage)){
						document.f1.geb_F.value="Der Februar des Jahres "+jahr_+" hat nur 28 Tage.";
						richtig=0;
					}else document.f1.geb_F.value="";
				}
			}
		}else if(monat==4 || monat==6 || monat==9 || monat==11){
			tage=30;	  
			if(!(tag<=tage)){
				document.f1.geb_F.value="Der Monat "+document.f1.gebmonth.options[document.f1.gebmonth.selectedIndex].text+" hat nur "+tage+" Tage.";
				richtig=0;
			}else document.f1.geb_F.value="";
		}else{
			document.f1.geb_F.value="";
		}
	}
}

function check(){
	richtig=1;
	checkuser();
	checkmail();
	checkphone();
	checkvorname();
	checkfamilienname();
	checkgeschlecht();
	checkdate();
	checkmsn();
	checkicq();
	checkskype();
	if(richtig==0) return false;
	else{ return true; }

}

function checkmsn(){
	var str=""+document.f1.msn.value;
	var reg = new RegExp("^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$");
	var pos=str.search(reg);
	if(pos>=0 || str==""){
		document.f1.msn_F.value="";
		document.f1.msn.style.backgroundColor="#cfcfcf";
	}else if(pos<0){
		document.f1.msn_F.value="Bitte geben Sie eine gültige MSN Adresse an.";
		document.f1.msn.style.backgroundColor="#FF4242";
		richtig=0;
	}	
}	

function checkicq(){
	var str=""+document.f1.icq.value;
	var reg = new RegExp("^[0-9-]*$");
	var pos=str.search(reg);
	if(pos>=0 || str==""){
		document.f1.icq_F.value="";
		document.f1.icq.style.backgroundColor="#cfcfcf";
	}else if(pos<0){
		document.f1.icq_F.value="Bitte geben Sie eine gültige ICQ Nummer an.";
		document.f1.icq.style.backgroundColor="#FF4242";
		richtig=0;
	}	
}	

function checkskype(){
	var str=""+document.f1.skype.value;
	var reg = new RegExp("^[0-9a-zÖÄÜöäüA-z-]*$");
	var pos=str.search(reg);
	if(pos>=0 || str==""){
		document.f1.skype_F.value="";
		document.f1.skype.style.backgroundColor="#cfcfcf";
	}else if(pos<0){
		 document.f1.skype_F.value="Bitte geben Sie einen gültigen Skype Namen an.";
		document.f1.skype.style.backgroundColor="#FF4242";
		richtig=0;
	}	
}




function gebdatum(){
	for(var i=1; i<32; i++){
		if(i<10) i="0"+i;
		document.f1.gebday.options[i]= new Option(i, i, false, false);
	}
	var month=new Array("Jänner", "Februar", "März","April","Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
	for(var i=1; i<13; i++){
		document.f1.gebmonth.options[i]= new Option(month[i-1], i, false, false);
	} 
	for(var i=91;i>0; i--){
		document.f1.gebyear.options[i]= new Option(2007-i, i, false, false);
	} 
}

function resetcolors(){
	document.f1.username.style.backgroundColor="#cfcfcf";
	document.f1.email.style.backgroundColor="#cfcfcf";
	document.f1.telefon.style.backgroundColor="#cfcfcf";
	document.f1.vorname.style.backgroundColor="#cfcfcf";
	document.f1.familienname.style.backgroundColor="#cfcfcf";
	document.f1.icq.style.backgroundColor="#cfcfcf";
	document.f1.msn.style.backgroundColor="#cfcfcf";
	document.f1.skype.style.backgroundColor="#cfcfcf";
}

function checkpw(a){
	if(a!=1){
		if(document.f9.oldpw.value==""){
			document.f9.oldpw.style.backgroundColor="#FF4242";
			document.f9.oldpw_F.value="Bitte geben sie ihr jetziges Passwort ein.";
			return false;
		}
	}else {
		if(a!=1){
			document.f9.oldpw.style.backgroundColor="#cfcfcf";
			document.f9.oldpw_F.value="";
		}
	
		if(document.f9.neupw.value!=document.f9.neupwwh.value){ 
			document.f9.neupw.style.backgroundColor="#FF4242";
			document.f9.neupwwh.style.backgroundColor="#FF4242";
			document.f9.neupw_F.value="";
			document.f9.neupwwh_F.value="Die Passwörter sind nicht gleich.";
			return false;
		}else if(document.f9.neupw.value==""){
			document.f9.neupw.style.backgroundColor="#FF4242";
			document.f9.neupw_F.value="Bitte geben sie ein neues Passwort ein.";
			return false;
		}else if(document.f9.neupwwh.value==""){
			document.f9.neupwwh.style.backgroundColor="#FF4242";
			document.f9.neupwwh_F.value="Bitte wiederholen sie Ihr neues Passwort.";
			return false;
		}else{
			document.f9.neupw.style.backgroundColor="#cfcfcf";
			document.f9.neupwwh.style.backgroundColor="#cfcfcf";
			document.f9.neupw_F.value="";
			document.f9.neupwwh_F.value="";
		}
	}
	return true;
}


function poppen(elem, anz){
	for(var i=1; i<=anz; i++){
		//alert(elem+i);
		if(document.getElementById(elem+i).style.visibility=="collapse")
			document.getElementById(elem+i).style.visibility="visible";
		else 
			document.getElementById(elem+i).style.visibility="collapse"
	}
}




function resizeimg(img,percent) {
					if (img.width > (screen.width/100*percent)) {
						resizeimgW(img,percent);
						resizeimgH(img,percent);
					}
				}
				
function resizeimgW(img,percent) {
	img.width = (img.width/(img.width/(screen.width/100*percent)));
}

function resizeimgH(img,percent) {
	img.width = (img.height/(img.height/(screen.height/100*percent)));
}

function resizethumb(img){
	
}

function popUpImg(img,height,width) {
	myImg = new Image();
	if(img==null)myImg.src='".$dir."/gross/'+filterZahl(document.getElementById('grosses').src)+'.jpg';
	else myImg.src=img;
	test();
}

function test(){
			if(	myImg.width==0 || myImg.height==0){ setTimeout('test()',100);}
		else{
		var width = myImg.width;
		var height = myImg.height;
		var x=0;
		var y=0;
		if(screen.availWidth > width){
			x = (screen.availWidth - width) / 2;
		}
		else{
			var tmp=(screen.availWidth/width);
			width = width*tmp;
			height = height*tmp;
			x = 0;
		}
	
		if(screen.availHeight > height){
			y = (screen.availHeight - height) / 2;
		}
		else{
		var tmp=(screen.availHeight/height);
			height = height*tmp;
			width = width*tmp;
			y = 0;
		}
			if(screen.availHeight > height){
		y = (screen.availHeight - height) / 2;
		}
			if(screen.availWidth > width){
				x = (screen.availWidth - width) / 2;
		}
		
	   var imgWin = window.open('', 'imgWinName', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=1,width=' + width + ', height=' + height);

		imgWin.resizeTo(width+8 ,height+62);
		imgWin.moveTo(x,y);
   
		imgWin.document.write('<HTML>');
		imgWin.document.write(' <HEAD>');
		imgWin.document.write(' <title>imgWin</title>');
		imgWin.document.write(' </HEAD>');
		imgWin.document.write(' <BODY style=\"margin: 0px;\" onLoad=\"self.focus();\">');
		imgWin.document.write(' <a href=\"\" onClick=\"JavaScript:self.close()\">');
		imgWin.document.write(' <img src=\"' + myImg.src+ '\" height=\"' + height + '\" width=\"' + width + '\" alt=\"vergroessertes Imgage un so\" title=\"Click to close\" border=\"0\"></a>');
		imgWin.document.write(' </BODY>');
		imgWin.document.write('</HTML>');
		imgWin.document.close();
}}
				
function overlay(msg,formid,action,multi){
	showoverlay();
	if(action=="del"){
		if(multi){
			document.getElementsByName("del"+formid)[0].value="del";
		}
		else{ 
			document.getElementsByName("del")[0].value="del";
		}
	}
	if(action!="wait"){
		document.getElementById('overlaycontent').innerHTML=msg+"<br /><br /><p align='center'><input type='button' value='OK - L&ouml;schen' class='buttons' onClick='overlaysubmit(\""+formid+"\",true)' />&nbsp;&nbsp;&nbsp;<input type='button' value='Abbrechen' class='buttons' onClick='overlaysubmit(\""+formid+"\",false)' /><p>";
	}
	else document.getElementById('overlaycontent').innerHTML=msg;
}

function overlaysubmit(formid, boo){
	hideoverlay();
	if(boo){
		document.getElementById(formid).submit();
	}

}

/*function popout(id){
	var attr = (document.all) ? 'inline' : 'table-row';
	//alert(id+' '+document.getElementsByName(id)[0].style.display);

	if(document.getElementsByName(id)[0].style.display != 'none'){
		for(var i=0;i<=document.getElementsByName(id).length;i++){
			document.getElementsByName(id)[i].style.display='none';
			//alert(document.getElementsByName(id)[i].style.display);
		}
	}
	else {
		for(var i=0;i<=document.getElementsByName(id).length;i++){
			document.getElementsByName(id)[i].style.display=attr;
			//alert(document.getElementsByName(id)[i].style.display);
		}
	}
	alert("asd");
}*/

function popout(id,itemname,display){
	//alert($("*[name='"+id+"']:first").css("display"));
	if($("*[name='"+id+"']").length > 0){
		var attr = (document.all) ? 'inline' : 'table-row';
		if(itemname=="" || itemname==null) itemname='img'; 
		if(display!=null){
			attr=display;
		}

	
		if($("*[name='"+id+"']:first").css("display") != "none"){
			//for(var i=0;i<document.getElementsByName(id).length;i++){
				//document.getElementsByName(id)[i].style.display='none';
				//$("*[name='"+id+"']").each(function(){
				//	$(this).hide();
				//});
				$("*[name='"+id+"']").hide();
				//console.log(id+"-"+i+"-"+elem.val()+"-"+elem);
				
			//}
			if(itemname!="link")
				document.getElementById(itemname+id).src='images/+.png';
			document.getElementById(itemname+id).alt='ausklappen';
			document.getElementById(itemname+id).title='ausklappen';
		}
		else {
			//for(var i=0;i<document.getElementsByName(id).length;i++){
				//document.getElementsByName(id)[i].style.display=attr;
			/*	$("*[name='"+id+"']").each(function(){
					$(this).show();
				});
				console.log(id+"-"+i);*/
				$("*[name='"+id+"']").show();
			//}
			if(itemname!="link")
				document.getElementById(itemname+id).src='images/-.png';
			document.getElementById(itemname+id).alt='einklappen';
			document.getElementById(itemname+id).title='einklappen';
		}
	}
}
	
function reposition(boo){
	if(!document.getElementById('content_footer') || !document.getElementById('content')){
		setTimeout("reposition("+boo+")",10);
	}
	else {
		if(document.getElementById('content_footer').offsetTop!=document.getElementById('content').offsetHeight && boo){
			var px=document.getElementById('content').offsetHeight-document.getElementById('content_footer').offsetTop;
			document.getElementById('content_footer').style.top=px+"px";
			//alert("asd");
		}else{
			document.getElementById('content_footer').style.top="0px";
		}
		//alert(document.getElementById('content_footer').offsetTop+":"+document.getElementById('content').offsetHeight);
	}
}
