// Javascript Document

function FrameRedirect() {
		if(top.frames.length == 0) {
				 document.location.href = "http://www.rudolf-holgerson.de";
		}
}

function PrintDocument(URL) {
	var fenster;
	alert(URL);
	if (screen.height <= 600) {
		fenster = open(URL, "Drucken","height=450,width=400,resizable=yes,scrollbars=yes");
	} 
	else {
		fenster = open(URL, "Drucken","height=500,width=500,resizable=yes");
	}
}



function Show_Layer(ebene) {
		var MLayer = document.getElementById(ebene);
		MLayer.style.visibility = "visible"
}

function Hide_Layer(ebene) {
		var MLayer = document.getElementById(ebene);
		MLayer.style.visibility = "hidden";
}

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

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

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

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



/*************************************************************************
  This code is from Dynamic Web Coding at www.dyn-web.com
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this entire notice is included.
*************************************************************************/
var statLyr;
function initStatLyr(myLayer,topPos) {
	// args: id, left, top, w, h, duration of glide to location onscroll, acceleration factor
  // acceleration factor should be -1 to 1. -1 is full deceleration
	//statLyr = new Glider(myLayer,20,200,null,null,1000,-1);
	statLyr = new Glider(myLayer,428,topPos,null,null,1000,-1);

  //statLyr.show();
}

function Play_Sound(sFile,sName,LayerTPos,LayerLPos) {
		document.getElementById("mp3name").innerHTML = sName;
		document.getElementById("sound").style.top = LayerTPos;
		document.getElementById("sound").style.left = LayerLPos;
		
		if ((document.all) && (window.offscreenBuffering)) {
			document.getElementById("soundspan").innerHTML = "<OBJECT ID=\"MediaPlayer1\" CLASSID=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" CODEBASE=\"http:\//activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab# Version=5,1,52,701\" STANDBY=\"Loading Microsoft Windows® Media Player components...\" TYPE=\"application/x-oleobject\" width=\"280\" height=\"46\"><param name=\"fileName\" value=\"../assets/mp3/"+sFile+"\"><param name=\"animationatStart\" value=\"true\"><param name=\"transparentatStart\" value=\"true\"><param name=\"autoStart\" value=\"true\"><param name=\"showControls\" value=\"true\"><param name=\"Volume\" value=\"-300\"></OBJECT>"
		}
		
		if ((document.getElementById) && (!document.all)) {
			document.getElementById("soundspan").innerHTML = "<embed type=\"application/x-mplayer2\" pluginspage=\"http:\//www.microsoft.com/Windows/MediaPlayer/\" src=\"http:\//www.rudolf-holgerson.de/assets/mp3/"+sFile+"\" name=\"MediaPlayer1\" width=280 height=44 autostart=1 showcontrols=1 volume=-300>";
		}
		else {
			document.getElementById("soundspan").innerHTML = "<embed type=\"application/x-mplayer2\" pluginspage=\"http:\//www.microsoft.com/Windows/MediaPlayer/\" src=\"http:\//www.rudolf-holgerson.de/assets/mp3/"+sFile+"\" name=\"MediaPlayer1\" width=280 height=44 autostart=1 showcontrols=1 volume=-300>";
		}
		//Show_Layer('sound');
		statLyr.show(); //Startet dynamisches Layer
}

function StopPlayer() {
	if ((document.getElementById) && (!document.all)) {
			document.getElementById("soundspan").innerHTML = "<embed type=\"application/x-mplayer2\" pluginspage=\"http:\//www.microsoft.com/Windows/MediaPlayer/\" src=\"\" name=\"MediaPlayer1\" width=280 height=45 autostart=1 showcontrols=1 volume=-300>";
			document.getElementById("soundspan").innerHTML = "";
	}
}

function StopPlayer_Flash() {
			document.getElementById("soundspan").innerHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"390\" height=\"180\"><param name=\"movie\" value=\"\"><param name=\"quality\" value=\"high\"><embed src=\"\" quality=\"high\" pluginspage=\"http:\//www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"390\" height=\"180\"></embed>\"</OBJECT>";
	
}

function gScrollY() {
	var sy = 0;
	if (document.documentElement && document.documentElement.scrollTop)
		sy = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop) 
		sy = document.body.scrollTop; 
	else if (window.pageYOffset)
		sy = window.pageYOffset;
	else if (window.scrollY)
		sy = window.scrollY;
	return sy;
}

var typeOfPlayer;
function Play_Sound_Flash(sFile,sName,LayerTPos,LayerLPos) {
		
		typeOfPlayer = "mp3";
		document.getElementById("soundheader").style.backgroundImage = "url(../assets/bilder/mp3-header2.jpg)";
		var WinHeight = getWinHeight();
		var ScrollTop = gScrollY();
		
		//document.getElementById("sound-flash").style.top = ((ScrollTop+(WinHeight/2)-90));
		document.getElementById("sound-flash").style.top = LayerTPos;
		document.getElementById("sound-flash").style.left = LayerLPos;
		if (window.screen.width == 800) document.getElementById("sound-flash").style.left = 350;
		
		if ((document.all) && (window.offscreenBuffering)) {
			document.getElementById("soundspan").innerHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"390\" height=\"180\"><param name=\"movie\" value=\""+sFile+"\"><param name=\"quality\" value=\"high\"></OBJECT>";
		}
		
		else if ((document.getElementById) && (!document.all)) {
			document.getElementById("soundspan").innerHTML = "<embed src=\""+sFile+"\" quality=\"high\" pluginspage=\"http:\//www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"390\" height=\"180\"></embed>";
		}
		else document.getElementById("soundspan").innerHTML = "<embed src=\""+sFile+"\" quality=\"high\" pluginspage=\"http:\//www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"390\" height=\"180\"></embed>"; 
		//Show_Layer('sound');
		//initStatLyr('sound-flash',10);
		statLyr.show(); //Startet dynamisches Layer
}

function Play_MM_Flash(sFile,sName,LayerTPos,LayerLPos) {
		typeOfPlayer = "mm";
		document.getElementById("soundheader").style.backgroundImage = "url(../assets/bilder/mp3-header3.jpg)";
		var WinHeight = getWinHeight();
		var ScrollTop = gScrollY();
		document.getElementById("sound-flash").style.top = ((ScrollTop+(WinHeight/2)-200));
		document.getElementById("sound-flash").style.left = LayerLPos;
		if (window.screen.width == 800) document.getElementById("sound-flash").style.left = 350;
		
		if ((document.all) && (window.offscreenBuffering)) {
			document.getElementById("soundspan").innerHTML = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http:\//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"360\" height=\"350\"><param name=\"movie\" value=\""+sFile+"\"><param name=\"quality\" value=\"high\"></OBJECT>";
		}
		
		else if ((document.getElementById) && (!document.all)) {
			document.getElementById("soundspan").innerHTML = "<embed src=\""+sFile+"\" quality=\"high\" pluginspage=\"http:\//www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"360\" height=\"350\"></embed>";
		}
		else document.getElementById("soundspan").innerHTML = "<embed src=\""+sFile+"\" quality=\"high\" pluginspage=\"http:\//www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"360\" height=\"350\"></embed>"; 
		//Show_Layer('sound');
		statLyr.show(); //Startet dynamisches Layer
}


function ShowPicture(sFile,sClass,sHeader,LayerTPos,LayerLPos) {
		
		var iLPos;
		var iLNPos;
		Hide_Layer('sound-flash');
		StopPlayer_Flash();
		document.getElementById("viewheader").style.backgroundImage = "url(../assets/bilder/picview-header.jpg)";
		document.getElementById("headspan").innerHTML = sHeader;
		//var WinHeight = getWinHeight();
		//var ScrollTop = gScrollY();
		//document.getElementById("picview").style.top = ((ScrollTop+(WinHeight/2)-50));
		/*if (window.screen.width > 800) {
			iLPos = parseInt(LayerLPos);
			iLPos += 50;
			iLNPos = iLPos.toString() + "px";
			document.getElementById("picview").style.left =  iLNPos;
		}
		else document.getElementById("picview").style.left = LayerLPos;*/
		
		document.getElementById("viewspan").innerHTML = "<img src=\""+sFile+"\" class=\""+sClass+"\">";
		Show_Layer('picview');	
		//statLyr.show(); //Startet dynamisches Layer
}

function ShowPictureNew(sFile,sPic,sHeader,sHeadspan) {
		document.getElementById(sHeadspan).innerHTML = sHeader;
		document.getElementById(sPic).src = sFile;
}

function ShowImpressum() {
		var sp = document.getElementById('impressum').style.visibility;
		if (sp == 'visible') Hide_Layer('impressum');
		else Show_Layer('impressum');
}


function EMail(f)
{
 var s = document.getElementById(f).email.value;
 var a = false;
 var res = false;
 if(typeof(RegExp) == 'function')
 {
  var b = new RegExp('abc');
  if(b.test('abc') == true){a = true;}
  }

 if(a == true)
 {
  reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+'(\\@)([a-zA-Z0-9\\-\\.]+)'+'(\\.)([a-zA-Z]{2,4})$');
  res = (reg.test(s));
 }
 else
 {
  res = (s.search('@') >= 1 && s.lastIndexOf('.') > s.search('@') && s.lastIndexOf('.') >= s.length-5)
 }
 if (!res) alert("Fehler in der eMail-Adresse!       \nBitte folgendes Format:\nname@adresse.de");
 return(res);
}


