// JavaScript Document
function onLoadMenu()
{
	d=document;
	adr=d.URL;
	if(adr.indexOf("media")>=0)
		show("Menu5",false)
}

function show(divid,boff)
{
	d=document;
	if(boff)
	{
		if(divid!="Menu3")
			d.getElementById("Menu3").style.display="none";
		if(divid!="menu4.1")
			d.getElementById("Menu5").style.display="none";
	}
	if(d.getElementById(divid).style.display=="none")
		d.getElementById(divid).style.display="inline-block";
	else
		d.getElementById(divid).style.display="none";
}

function goBack()
{
	window.history.back()
}

function playSound(_sndObj, sndFile)
{
	var i, method = "", sndObj = eval(_sndObj);

	if (sndObj != null)
	{
		if (navigator.appName == 'Netscape')
			method = "play";
		else
		{
			if (window.MM_WMP == null)
			{
				window.MM_WMP = false;
				for(i in sndObj)
					if (i == "ActiveMovie")
					{
						window.MM_WMP = true;
						break;
					}
			}
      			if (window.MM_WMP)
				method = "play";
      			else
				if (sndObj.FileName)
					method = "run";
		}
	}
  	if (method)
		eval(_sndObj+"."+method+"()");
  	else
		window.location = sndFile;
}

function stopSound(_sndObj, sndFile)
{
	var i, method = "", sndObj = eval(_sndObj);

	if (sndObj != null)
	{
		if (navigator.appName == 'Netscape')
			method = "stop";
		else
		{
			if (window.MM_WMP == null)
			{
				window.MM_WMP = false;
				for(i in sndObj)
					if (i == "ActiveMovie")
					{
						window.MM_WMP = true;
						break;
					}
			}
      			if (window.MM_WMP)
				method = "stop";
      			else
				if (sndObj.FileName)
					method = "stop";
		}
	}
  	if (method)
		eval(_sndObj+"."+method+"()");
}

function openPaintWindow(sTarget,sWidth,sHeight)
{
	var sHelp;
	sHelp="width=";
	sHelp=sHelp+sWidth;
	sHelp=sHelp+",height=";
	sHelp=sHelp+sHeight;
	sHelp=sHelp+",menubar=no,status=no,locationbar=no";
	winPaint=open(sTarget,"ThomasPaint",sHelp);
}

function closePaintWindow()
{
	if(!winPaint)
		return;
	winPaint.close();
}

function openVideoWindow(sTarget)
{
	winVideo=open(sTarget,"ThomasVideo","width=500,height=400,menubar=no,status=no,resizable=no,locationbar=no");
	winVideo.moveTo((screen.width-500)/2,(screen.height-400)/2);
	winVideo.focus();
}

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);
	return x;
}

function ValidateForm()
{
	var i,p,q,nm,test,num,min,max,errors='',args=ValidateForm.arguments;

	for (i=0; i<(args.length-2); i+=3)
	{
		test=args[i+2];
		val=FindObj(args[i]);
		if(val)
		{
			nm=val.name;
			field=val;
			if ((val=val.value)!="")
			{
				if (test.indexOf('isEmail')!=-1)
				{
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1))
					{
						errors+='- '+nm+' muß eine gültige Mail Adresse sein.\n';
						field.focus();
					}
				}
				else
					if (test!='R')
					{
						num = parseFloat(val);
						if (val!=''+num)
						{
							errors+='- '+nm+' muß eine gültige Nummer sein.\n';
							field.focus();
						}
						if (test.indexOf('inRange') != -1) 
						{
							p=test.indexOf(':');
							min=test.substring(8,p);
							max=test.substring(p+1);
							if (num<min || max<num)
							{
								errors+='- '+nm+' muß zwischen '+min+' und '+max+' liegen.\n';
								field.focus();
							}
						}
					}
			}
			else
				if (test.charAt(0) == 'R')
				{
					errors += '- '+nm+' muß angegeben werden.\n';
					field.focus();
				}
		}
	}
	if (errors)
		alert('Folge Fehler sind aufgetreten:\n\n'+errors);
	document.ReturnValue = (errors == '');
}

function jumpMenu(targ,selObj)
{
	var n=selObj.selectedIndex;
	if(selObj.options[n].value!="")
	{
		selObj.selectedIndex=0;
		eval(targ+".location='"+selObj.options[n].value+"'");
	}
}
