// JavaScript Document

function switchImage(imgName, imgSrc) 
{
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}

// ------------------------------------------------------------------------------------------------
// Noch eine Browser-Detection (sollte später die einzige Detection werden!)
// ------------------------------------------------------------------------------------------------
// Variablen global erzeugen
var isNav4, isNav6, isIE4;
// Bestimmung des Browsers
setBrowser();

// Bestimmt den Browser
// Abfrage durch: if (isNav6) { ... } else if (isNav4) { ... } else { ... }
function setBrowser() {
	if (navigator.appVersion.charAt(0) == "4") {
		if (navigator.appName.indexOf("Explorer") >= 0) {
			isIE4 = true;
		} else {
			isNav4 = true;
		}
	}
	else if (navigator.appVersion.charAt(0) > "4") {
		isNav6 = true;
	}
}


// ------------------------------------------------------------------------------------------------
// Routinen fuer Popup-Windows
// ------------------------------------------------------------------------------------------------
/* Erzeugt ein neues Fenster mit bestimmbarer Zieldatei, Internem Titel, Breite, Hoehe, 
   relative X-Position und Y-Position */
function NeuFenster(Datei,InternTitel,Breite,Hoehe,XPos,YPos,windowOptions) {
	// set position to 0,0 if screen-resolution => 800x600 px
	if (screen.width < 1000 && Breite > 700) {
		XPos = 0; YPos = 0;
		if (Breite > 800) {
			Breite = 800;
		}
	}
	
	if (isNav6) {
		fbreite = Breite + 8; fhoehe = Hoehe + 27;
	} else if (isNav4) {
		fbreite = Breite + 8; fhoehe = Hoehe + 15;
	} else {
		fbreite = Breite + 12; fhoehe = Hoehe + 31;
	}
	var Fenster3;
	if (arguments.length >=7) {
		if (windowOptions == "editor") {
			fbreite=920; Hoehe=540; XPos=2; YPos=2;
			if (isNav6) {
				fhoehe = Hoehe + 27;
			} else if (isNav4) {
				fhoehe = Hoehe + 15;
			} else {
				fhoehe = Hoehe + 31;
			}
		}
		Fenster3= open(Datei,InternTitel,'width='+fbreite+',height='+fhoehe+',screenX='+XPos+',screenY='+YPos+','+windowOptions);
	} else {
		Fenster3= open(Datei,InternTitel,'width='+fbreite+',height='+fhoehe+',screenX='+XPos+',screenY='+YPos+',dependent=no,scrollbars=yes,resizable=yes');
	}
	Fenster3.moveTo(XPos,YPos);
	Fenster3.resizeTo(fbreite,fhoehe);
	Fenster3.self.focus();
}


// ------------------------------------------------------------------------------------------------
// Function for Backend
// ------------------------------------------------------------------------------------------------

// Function "normalize Password"
function normPasswd(sid, userID, groupID)
{
	var callBack = confirm('Passwort wirklich normieren?');
	if(callBack == true) {
		NeuFenster('/cgi-bin/verwaltung/benutzer_verwaltung.pl?sid='+sid+'&action=normPasswd&ben_id='+userID+'&grp_id='+groupID,'Passwd',600,300,100,100);
	} else {
		// do nothing
	}
}


/* Function newWindow
   Creates a new popup-window width defined width and height on a defined position
   myFile: a URL
   internTitle: the internal JS-Title
   the rest should be clear */
function newWindow(myFile,internTitle,myWidth,myHeight,xPos,yPos) {
	this[internTitle]= open(myFile,internTitle,'width='+myWidth+',height='+myHeight+',screenX='+xPos+',screenY='+yPos+',dependent=no,scrollbars=yes,resizable=yes');
	this[internTitle].moveTo(xPos,yPos);
	this[internTitle].resizeTo(myWidth,myHeight);
	this[internTitle].self.focus();
}



