//***********************************
function evalInputFields(feld){
//***********************************
	var text=""
	var text2=""
	
	switch (feld)
	{
		case 'undefined':
			alert("Parameter zur Überprüfung fehlt!");

		case 'anfrage':
			if (document.getElementsByName("vorname")[0].value=="debug" || document.getElementsByName("name")[0].value=="debug" || document.getElementsByName("text")[0].value=="debug")
			{
				return (true);
			}

			text += (document.getElementsByName("vorname")[0].value=="") ? "\n\tVorname" : "";
			text += (document.getElementsByName("name")[0].value=="") ? "\n\tFamilienname" : "";
			text += (document.getElementsByName("text")[0].value=="") ? "\n\tNachrichtentext" : "";
			
			if (document.getElementsByName("email")[0].value==""){
				text +="\n\teMail-Adresse";
			} else {
				text +=checkEmail(document.getElementsByName("email")[0].value)
			}

			if (!text=="")
			{
				text = "Folgende Angaben brauchen wir um Ihre Anfrage bearbeiten zu koennen:" + text + "\n";
				alert (text);
				return (false);
			}
			else{
				return (true);
			}
	}
}

//***********************************
function checkEmail(eMail){
//***********************************

	//Format: Teil1[.Teil2]@Teil3.Teil4 pruefen
	suche = /^([_a-zA-z0-9-])+(\.[_a-zA-z0-9-]+)*@([_a-zA-z0-9-]+\.)+([a-zA-Z]{0,})/;
	text=""
	ergebnis=suche.test(eMail)

	if (!ergebnis){
		text +="\n\n\tDie eMailadresse entspricht nicht dem Format:\n\tTeil1[.Teil2]@Teil3.Teil4 ([] = optional)\n\tTeile1-3 d?rfen nur \"A-Z\", \"a-z\", \"_\" oder \"-\" enthalten.\n\tTeil 4 darf nur \"A-Z\" und \"a-z\" enthalten."
	}
	
	//teil hinter dem @
	teile=eMail.split("@")
	//durch '.' getrennte segmente holen
	teile=teile[teile.length-1].split(".")

	//auf mehr als 3 segmente pruefen
	if (teile.length>3){
		text +="\n\n\tZuviele Punkte in der eMail-Adresse hinter dem \"@\""
	}

	if (teile){
		//letztes segment = TLD holen
		teil=teile[teile.length-1]

		//länge und A-Z pruefen
		suche=/[a-zA-Z]{2,4}/
		if (suche.exec(teil) != teil){
		text +="\n\n\tDer letzte Teil der eMail-Adresse (Top Level Domain) ist\n\tkleiner als 2 oder größer als 4 Zeichen lang,\n\toder er enthält andere Zeichen als \"A-Z\" und \"a-z\"."
		}
	}

	return(text)
}

//***********************************
function writeFlash(file, breite, hoehe, id, wmode, myClass){
//***********************************
	if (typeof id =="undefined"){
		id="mainFlash";
	}
	//alert(id);
	document.write('<OBJECT id="'+id+'" class="'+myClass+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="'+breite+'" height="'+hoehe+'">\n');
	document.write('<PARAM name="movie" value="'+file+'">\n');
	document.write('<PARAM name="quality" value="high">\n');
	document.write('<PARAM name="menu" value="false">\n');
	document.write('<PARAM name="allowScriptAccess" value="always" />\n');
	document.write('<PARAM name="wmode" value="'+wmode+'">\n');

	document.write('<EMBED NAME="'+id+'" src="'+file+'" width="'+breite+'" height="'+hoehe+'" TYPE="application/x-shockwave-flash" QUALITY="high" MENU="false" WMODE="'+wmode+'" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always" swliveconnect="true" >\n');
	document.write('</OBJECT>\n');
}

//***********************************
function doPassVar(args){
//***********************************
/*
	if(parent.document.mainFlash){
	alert("doPassVar IE: "+args+"-@-");
		parent.document.mainFlash.SetVariable("debugVars.myVar", args);
	}
	if(parent.window.mainFlash) {
*/

    var flashMovie=getFlashMovieObject("mainFlash");
	alert(flashMovie);
     
	 
	flashMovie.SetVariable("debugVars.myVar", "test");
	//flashMovie.SetVariable("1", "2");

		
		
		alert(parent.window.document.flash.embeds[mainFlash]   )
		obj=parent.document.getElementById("mainFlash");
		obj.SetVariable("debugVars.myVar", "test");
		//parent.document.mainFlash.debugVars.myVar=args;
		//parent.document.embeds[mainFlash].SetVariable("debugVars.myVar", "test");
		//parent.document.mainFlash.setvalue("debugVars.myVar","test");
/*
	}
	if(window.sample) window.document["sample"].SetVariable("myText", str);
	if(document.sample) document.sample.SetVariable("myText", str);
*/

}

/*
function getFlashMovieObject(movieName){
	if (window.document[movieName]) 
	{
	  return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
	if (document.embeds && document.embeds[movieName])
	  return document.embeds[movieName]; 
	}
	else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	{
	return document.getElementById(movieName);
	}
}
function getFlashMovieObject(movieName){
	if (parent.window.document[movieName]) 
	{
	  return parent.window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1)
	{
	if (parent.document.embeds && parent.document.embeds[movieName])
	  return parent.document.embeds[movieName]; 
	}
	else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	{
	return parent.document.getElementById(movieName);
	}
}

*/
function containerToFlash(str) {
	findSWF("mainFlash").containerToFlash(str);
	alert(findSWF("mainFlash")+" "+str);
}

function findSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft")!= -1) {
		return parent.window[movieName];
	} else {
		return parent.document[movieName];
	}
}

function flashToContainer(str) {
	document.fromFlash.flashMessage.value = str;
}

