// ################################################################################
// Name:         Javascript Library 
// Beschreibung: Bibliothek mit Javascript-Grundfunktionen fuer Browser ab Version 3.0
// Version:      1.3
// Autor:        Roland Brueggemann, via one! multimedia GmbH
// Benoetigt:    -
// ################################################################################


// ################################################################################
// Funktionsliste
//
//   Grafiken
//     imgNew()
//     imgPreload()
//     imgChange()
//     imgChangeFade()
//
//   Fenster
//     newWindow()
//     ab 1.4 newCenteredWindow()
//     ab 1.4 newFullscreenWindow()
//     windowMaximize()
// 
//   URL
//     gotoUrl()
//     selectUrl()
//
//   etc.
//     getRidOfFrames()
// ################################################################################


// ##################################################
// Funktion:     imgNew()
// Beschreibung: Interne Funktion zur Erstellung ein neues Image-Objekts fuer die uerbergebene Grafikdatei
// Autor:        Roland Brueggemann
// Parameter:    
//    file       Dateiname des Bildes (vollstaendiger Pfad)
// Rueckgabe:    Inhalt des Image-Objektes
// Aufruf:       imgNew("bilder/test.gif");
// ##################################################

function imgNew(file) {
	if (document.images) {
		imgNewTmp = new Image();
		imgNewTmp.src = file;
		return imgNewTmp;
	}
}

// ##################################################
// Funktion:     imgPreload()
// Beschreibung: Laedt Bild in den Speicher, um verzoegertes Nachladen zu verhindern
// Autor:        Roland Brueggemann
// Parameter:
//    file       Dateiname des Bildes (vollstaendiger Pfad)
// Rueckgabe:    -
// Aufruf:       imgPreload("bilder/test.gif");
// ##################################################

var imgPreloadCount = 0;
imgPreloadName = new Array();

function imgPreload(file) {

	if (document.images) {
		imgPreloadName[imgPreloadCount] = imgNew(file);
		imgPreloadCount ++;
	}
}

// ##################################################
// Funktion:     imgChange()
// Beschreibung: Tauscht Inhalt einer Grafik aus (Bildwechsel)
// Autor:        Roland Brueggemann
// Parameter (abwechselnd):
//               Bild-"Name" der zu aendernen Grafik
//               Dateiname des Bildes (vollstaendiger Pfad)
// Rueckgabe:    -
// Aufruf:       imgChange("button","bilder/button.gif");
// ##################################################

function imgChange() {

	if (document.images) {
		for (var i=0; i<imgChange.arguments.length; i+=2) {
			if (document.images[imgChange.arguments[i]]) {
				document.images[imgChange.arguments[i]].src = imgChange.arguments[i+1];
			}
		}
	}
}

// ##################################################
// Funktion:     imgChangeFade()
// Beschreibung: Tauscht Inhalt einer Grafik mit IE Fade-Filter aus (Bildwechsel)
// Autor:        Roland Brueggemann
// Parameter:
//    id         Bild-"Name" der zu aendernen Grafik
//    file       Dateiname des Bildes (vollstaendiger Pfad)
// Rueckgabe:    -
// Aufruf:       imgChangeFade("button","bilder/button.gif");
// ##################################################

function imgChangeFade(id, file) {
	if (document.images && document.all && document.all[id].filters.blendTrans) {
		document.all[id].filters.blendTrans.Apply();
		document.all[id].src = file;
		document.all[id].filters.blendTrans.Play();
	} else {
		imgChange(id,file);
	}	
}

// ##################################################
// Funktion:     newWindow()
// Beschreibung: Oeffnet neues Browserfenster mit angegebener URL
// Autor:        Roland Brueggemann
// Parameter:
//    url        Adresse, die aufgerufen werden soll
//    width      Breite des Fensters
//    height     Hoehe des Fensters
//    options    Fenster-Eigenschaften
//    name       Name des Fensters
//    posX       X-Position des neuen Fensters
//    posY       Y-Position des neuen Fensters
// Rueckgabe:    -
// Aufruf:       newWindow("http://www.viaone.de",780,450);
// ##################################################

function newWindow(url,width,height,options,name,posX,posY) {

	if (!url) return false;
	if (!width) width = 900;
	if (!height) height = 300;
	if (!options) options = "scrollbars=yes,menubar=yes,toolbar=no,location=no,status=yes,resizable=yes";
	if (!posX && posX != "0") posX = 20;
	if (!posY && posX != "0") posY = 20;
	if (!name) name = "extWindow";

	window.open( url, name, "width=" + width + ",height=" + height + ",screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",top=" + posY + "," + options );
}



// ##################################################
// Funktion:     windowMaximize()
// Beschreibung: Maximiert das Broserfenster, in dem die Funktion aufgerufen wurde
// Autor:        Roland Brueggemann
// Parameter:    -
// Rueckgabe:    -
// Aufruf:       windowMaximize()
// ##################################################

function windowMaximize() {

	if (window.screen){
		if (document.all || document.layers) { 
			self.moveTo(0,0); 
			self.resizeTo(screen.availWidth,screen.availHeight)
		}
	}
}

// ##################################################
// Funktion:     gotoUrl()
// Beschreibung: Wechselt zur angegebenen URL (immer im href, nicht als onclick angeben!)
// Autor:        Roland Brueggemann
// Parameter (abwechselnd):
//               URL, die aufgerufen werden soll
//               Framename, in welchem die URL aufgerufen werden soll
//                  "this","": 	   Seite wird in aktuellem Frame geoeffnet
//                  "top":         Seite wird in aktuellem Fenster geoeffnet
//                  "blank","new": Seite wird in neuem Fenster geoeffnet
//                  sonst:         Seite wir in angegebem Frame geoeffnet (gleiches Frameset!)
// Rueckgabe:    -
// Aufruf:       gotoUrl("http://www.viaone.de","top");
// ##################################################

function gotoUrl() {

	for (var i=0; i<gotoUrl.arguments.length; i+=2) {
		url = gotoUrl.arguments[i];
		target = gotoUrl.arguments[i+1];

		if (url) {
			if (!target || target == "this") {
				this.location.href = url;
			}
			else if (target == "top") {
				top.location.href = url;
			}
			else if (target == "blank" || target == "new") {
				window.open(url);
			}
			else if (parent.frames[target]) {
				parent.frames[target].location.href = url;
			}
			else {
				alert("Der angegebene Frame " + target + " existiert nicht!");
			}
		} else {
			alert("Bitte geben Sie eine URL an!");
		}
	}
}

// ##################################################
// Funktion:     selectUrl(formname,selectname)
// Beschreibung: Wechselt zur ausgwaehlten Url einer beliebigen Selectbox
// Autor:        Roland Brueggemann
// Parameter: 
//    formname   Name des Formulares der Selectbox
//    selectname Name der Selectbox
// Rueckgabe:    -
// Aufruf:       selectUrl("meinFormular","meineSelectbox");
// ##################################################

function selectUrl(formname,selectname) {

	index = document[formname][selectname].selectedIndex; 
	url = document[formname][selectname].options[index].value; 

	if (url != "") {
		this.location.href = url; 
	}
}

// ##################################################
// Funktion:     getRidOfFrames()
// Beschreibung: Oeffnet aktuelle URL im Top-Frame
// Autor:        Roland Brueggemann
// Parameter:    -
// Rueckgabe:    -
// Aufruf:       getRidOfFrames()
// ##################################################

function getRidOfFrames() {

	if(top.frames.length > 0) {
		top.location.href = self.location;
	}
}


// ##################################################
// Funktion:     visible/invisible(lelayer)
// Beschreibung: Oeffnet aktuelle URL im Top-Frame
// Autor:        Roland Brueggemann
// Parameter:    -
// Rueckgabe:    -
// Aufruf:       getRidOfFrames()
// ##################################################
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
var ns = (browserName == "Netscape" && browserVer <5);
var ns6 = (browserName == "Netscape" && browserVer == 5);
var ie = (browserName == "Microsoft Internet Explorer");
var mac = (navigator.userAgent.indexOf("Mac") != -1);

function visible(lelayer){
if (ns){document.layers[lelayer].visibility = "show";}
else if (ie){document.all[lelayer].style.visibility = "visible";}
else if (ns6){document.getElementById(lelayer).style.visibility = "visible";}
}
function invisible(lelayer){
if (ns){document.layers[lelayer].visibility = "hide";}
else if (ie){document.all[lelayer].style.visibility = "hidden";}
else if (ns6){document.getElementById(lelayer).style.visibility = "hidden";}
}


// ##################################################
// Funktion:     open popup Team
// ##################################################

photoWindow = null;

function openWindowFr( slettre, stitre, photoWidth, photoHeight,snom,stel,sgsm,smail)
{
	 extraHeight = 15;
	 winWidth = photoWidth;
	 winHeight = photoHeight + extraHeight;
	 if (photoWindow == null) photoWindow = window.open('','photoWindow','toolbar=no,location=no,directories=no,status,scrollbars=no,Width=' + winWidth + ',Height=' + winHeight + ',left=5,top=5,resizable=yes,left=50,top=50')
	   else
		 if (!photoWindow.closed) photoWindow.window.resizeTo (winWidth,winHeight+15)
		  else photoWindow = window.open('','photoWindow','toolbar=no,location=no,directories=no,status,scrollbars=no,Width=' + winWidth + ',Height=' + winHeight + ',left=5,top=5,resizable=yes');
			  
	 photoWindow.document.writeln ('<HTML><HEAD>');
	 photoWindow.document.writeln ('<TITLE>Coordonnees</TITLE>');
	 photoWindow.document.writeln ('<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">');
	 photoWindow.document.writeln ('<link rel="StyleSheet" type="text/css" href="stylesheets/site.css">');
	 photoWindow.document.writeln ('</HEAD>');
	 photoWindow.document.writeln ('<BODY TEXT="#003366" BGCOLOR="#9BB1C3" LINK="#ffffff" VLINK="#ffffff" ALINK="#555555" LEFTMARGIN="0" TOPMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" SCROLL=NO>');
	 photoWindow.document.writeln ('<TABLE Height=16 Width=370 BGCOLOR="#43576F"><TR><TD colspan="2"><img src="images/common/all/spacer.gif" width="370" height="1" alt="" border="0"></td></tr><tr><td><span class=letterTeam>'+slettre+'</span></TD><TD Width=270><span class=titlewhite>'+stitre+'</span></TD></TR></TABLE>');
	 photoWindow.document.writeln ('<TABLE Width=350><TR Width=350><TD Width=80><BR><span class=txtwhitepop>Nom: </span></TD><TD Width=270><BR><span class=txtwhitepop>'+snom+'</span><br></TD></TR>');
	 if(stel!=''){
		photoWindow.document.writeln ('<TR Width=350><TD Width=80><span class=txtwhitepop>Tél.: </span></TD><TD Width=270><span class=txtwhitepop>'+stel+'</span><br></TD></TR>');
	 }
	 if(sgsm!=''){
		photoWindow.document.writeln ('<TR Width=350><TD Width=80><span class=txtwhitepop>Portable: </span></TD><TD Width=270><span class=txtwhitepop>'+sgsm+'</span><br></TD></TR>');
	 }
	 photoWindow.document.writeln ('<TR Width=350><TD Width=80><span class=txtwhitepop>E-mail : </span></TD><TD Width=270><a href="mailto:'+smail+'"  class=txtwhitepop>'+smail+'</a><br></TD></TR></TABLE>');
	 photoWindow.document.writeln ('</BODY></HTML>');
	 photoWindow.document.close ();
	 photoWindow.window.focus();
};

function openWindowNl( slettre, stitre, photoWidth, photoHeight,snom,stel,sgsm,smail)
{
	 extraHeight = 15;
	 winWidth = photoWidth;
	 winHeight = photoHeight + extraHeight;
	 if (photoWindow == null) photoWindow = window.open('','photoWindow','toolbar=no,location=no,directories=no,status,scrollbars=no,Width=' + winWidth + ',Height=' + winHeight + ',left=5,top=5,resizable=yes,left=50,top=50')
	   else
		 if (!photoWindow.closed) photoWindow.window.resizeTo (winWidth,winHeight+15)
		  else photoWindow = window.open('','photoWindow','toolbar=no,location=no,directories=no,status,scrollbars=no,Width=' + winWidth + ',Height=' + winHeight + ',left=5,top=5,resizable=yes');
			  
	 photoWindow.document.writeln ('<HTML><HEAD>');
	 photoWindow.document.writeln ('<TITLE>Gegevens</TITLE>');
	 photoWindow.document.writeln ('<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">');
	 photoWindow.document.writeln ('<link rel="StyleSheet" type="text/css" href="stylesheets/site.css">');
	 photoWindow.document.writeln ('</HEAD>');
	 photoWindow.document.writeln ('<BODY TEXT="#00529C" BGCOLOR="#9BB1C3" LINK="#ffffff" VLINK="#ffffff" ALINK="#555555" LEFTMARGIN="0" TOPMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0" SCROLL=NO>');
	photoWindow.document.writeln ('<TABLE Height=16 Width=370 BGCOLOR="#43576F"><TR><TD colspan="2"><img src="images/common/all/spacer.gif" width="370" height="1" alt="" border="0"></td></tr><tr><td><span class=letterTeam>'+slettre+'</span></TD><TD Width=270><span class=titlewhite>'+stitre+'</span></TD></TR></TABLE>');
	 photoWindow.document.writeln ('<TABLE Width=350><TR Width=350><TD Width=80><BR><span class=txtwhitepop>Naam: </span></TD><TD Width=270><BR><span class=txtwhitepop>'+snom+'</span><br></TD></TR>');
	 if(stel!=''){
		photoWindow.document.writeln ('<TR Width=350><TD Width=80><span class=txtwhitepop>Tel.: </span></TD><TD Width=270><span class=txtwhitepop>'+stel+'</span><br></TD></TR>');
	 }
	 if(sgsm!=''){
		photoWindow.document.writeln ('<TR Width=350><TD Width=80><span class=txtwhitepop>GSM: </span></TD><TD Width=270><span class=txtwhitepop>'+sgsm+'</span><br></TD></TR>');
	 }
	 photoWindow.document.writeln ('<TR Width=350><TD Width=80><span class=txtwhitepop>E-mail : </span></TD><TD Width=270><a href="mailto:'+smail+'" class=txtwhitepop>'+smail+'</a><br></TD></TR></TABLE>');
	 photoWindow.document.writeln ('</BODY></HTML>');
	 photoWindow.document.close ();
	 photoWindow.window.focus();
};