function swapImgRestore() {
	var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
	var d=document; if(d.images) { 
		if(!d.p) d.p=new Array();
		var i,j=d.p.length,a=preloadImages.arguments; 
		for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0) {
			d.p[j]=new Image; d.p[j++].src=a[i];
		}
	}
}

function findObj(n, d) {
	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=findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n);
	return x;
}

function swapImage() {
	var i,j=0,x,a=swapImage.arguments; document.sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
	if ((x=findObj(a[i]))!=null) {
		document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	}
}

function changeGalleryImage(rang,name) {
	document.getElementById('legende'+document.gallery.actualbildname.value).style.visibility= 'hidden';
    document.getElementById('legende'+document.gallery.actualbildname.value).style.display = 'none';	
	document.getElementById('legende'+name).style.visibility= 'visible';
	document.getElementById('legende'+name).style.display = 'block';
	document.gallery.actualbildname.value=name;
	bild = document.images['vorschau'];
	document.gallery.bild_id.value = rang;
	bild.src = "/gallery/images/th_"+name+".jpg";       
}

function changeGalleryImage2(rang,name)	{
	document.gallery.actualbildname.value=name;
	bild = document.images['vorschau'];
	document.gallery.bild_id.value = rang;
	bild.src = "/gallery/images/th_"+name+".jpg";       
}

function showNextPic() {
	document.gallery.bild_id.value=document.gallery.bild_id.value;
	var actual=parseInt(document.gallery.bild_id.value);
	actual=actual+1;
	if(actual>parseInt(document.gallery.anzahlpics.value))actual=1;
	document.gallery.bild_id.value=actual;
	document.gallery.actualbildname.value=picnames=document.getElementById("picnames"+actual).value;
	bild = document.images['vorschau'];
	bild.src = "/gallery/images/th_"+document.gallery.actualbildname.value+".jpg";       
}

function showBackPic() {
	document.gallery.bild_id.value=document.gallery.bild_id.value;
	var actual=parseInt(document.gallery.bild_id.value);
	actual=actual-1;
	if(actual==0)actual=document.gallery.anzahlpics.value;
	document.gallery.bild_id.value=actual;
	document.gallery.actualbildname.value=picnames=document.getElementById("picnames"+actual).value;
	bild = document.images['vorschau'];
	bild.src = "/gallery/images/th_"+document.gallery.actualbildname.value+".jpg";       
}

function gallery() {
	gallerie = document.gallery.gallery_id.value;
	bild = document.gallery.bild_id.value;
	lang = document.gallery.sprache.value;
	pfad = "/gallery/index.php?gid=" + gallerie + "&nr=" + bild + "&lang=" + lang;
	width = 620;
	height= 535;
	links  = (screen.width-width)/2;
	oben  = (screen.height-height)/2;
	gal = window.open(pfad,"Fotogalerie","width="+width+",height="+height+",left="+links+",top="+oben);
	gal.focus();
}

function gallery2(nr){
	gallerie = document.gallery.gallery_id.value;
	bild = document.gallery.bild_id.value;
	pfad = "/gallery/index.php?gid=" + gallerie + "&nr=" + bild + "&nr="+nr;
	width = 620;
	height= 535;
	links  = (screen.width-width)/2;
	oben  = (screen.height-height)/2;
	gal = window.open(pfad,"Fotogalerie","width="+width+",height="+height+",left="+links+",top="+oben);
	gal.focus();	
}

function changeVis(nr) {
	obj = document.getElementById("antwort_"+nr);
	if(obj.style.display == 'none')
		obj.style.display = 'block';
	else
		obj.style.display = 'none';
}

function startSearch()
 {
 error = "Bitte geben Sie einen Suchbegriff ein.";
 f = document.we_global_form;
 if(f.we_lv_search_0.value=='')
  {
  alert(error);
  f.we_lv_search_0.focus();
  return;  
  }
 f.submit();
 }

function MailChecker(mail)
	{
	
	if(mail.length<7)
		return false;
	
	var punkt = 0;
	var affe = 0;
	for(i=0;i<mail.length;i++)
		{
		if(mail.charAt(i)==".")
			punkt = 1;
		if(mail.charAt(i)=="@")
			affe = 1;			
		}
	if(punkt != 1 || affe != 1)
		return false;
	
	if(mail.lastIndexOf(".")<mail.lastIndexOf("@"))
		return false;
	
	var lastpoint = mail.lastIndexOf(".");
	laenge = mail.substring(lastpoint+1);
	if(laenge.length<2)
		return false;

	return true;		
	}



function Checkform()
	{
	f = document.anmeldung;
	
	// Fehler
	err = new Array();	
	err['name'] 	= 'Bitte geben Sie Ihren Namen an.';
	err['vorname'] 	= 'Bitte geben Sie Ihren Vornamen an.';
	err['strasse'] 	= 'Bitte geben Sie Ihre Strasse an.';
	err['plz'] 	= 'Bitte geben Sie Ihre Postleitzahl an.';
	err['ort'] 	= 'Bitte geben Sie Ihre Ortschaft an.';
	err['tel'] 	= 'Bitte geben Sie Ihre Telefon-Nr. an..';
	err['geb'] 	= 'Bitte geben Sie Ihr Geburtstag an.';

	err['email'] 	= 'Bitte geben Sie Ihre Email-Adresse an.';
	err['email_falsch'] = 'Die angegebene Email-Adresse ist nicht korrekt.';


	// Felder die nur auf Inhalt überprüft werden
	fields = new Array('name','vorname','strasse','plz','ort','tel','geb','email');
	anz = fields.length;
	
	for(i=0;i<anz;i++)
		{
		x = fields[i];
		obj = document.getElementById(x);
		if(obj.value=='' )
			{
			alert(err[x]);
			obj.focus();
			return;			
			}
		}
	
	if(!MailChecker(f.email.value))
		{
		alert(err['email_falsch']);
		f.email.focus();
		f.email.select();
		return;		
		}
	
	f.submit();
	}