/*
elp.js: JavaScript-Datei fuer die E-Learning-Plattform mit
allen allgemeinen Funktionen

© 2003 ars navigandi GmbH       http://www.arsnavigandi.de
Erstellt: 14-Oct-2003           Geaendert: 13-Oct-2005
*/



// ------------------------------------------------------------------------------------------------
// Preload-Funktion fuer MouseOver-Bilder
// ------------------------------------------------------------------------------------------------
// Ueberpruefen, ob Preload-Funktionen vorhanden sind
function preload_images() {
	// Funktionen vorhanden? Wenn ja, einbinden
	try {
		// Plattformspezifisch
		preload_images_ecademy();
		// Sprachpezifisch
		preload_images_de_DE();
	}
	// Wenn nicht, Fehler unterdruecken
	catch(ex) {
		//alert(ex);
	}
}


// ------------------------------------------------------------------------------------------------
// Tauscht per MouseOver zwei Bilder aus
// ------------------------------------------------------------------------------------------------
function mark(imgName, num, status) {
	// Bilder vorhanden? Wenn ja, einbinden
	try {
		if (document.images) {
			imgMark = eval(imgName + num + ".src");
			document [imgName].src = imgMark;
		}
		window.status = statustext[status];
	}
	// Wenn nicht, Fehler unterdruecken
	catch(ex) {}
}

// ------------------------------------------------------------------------------------------------
// 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();
}

// Funktion wird nur noch in alten Flash-Kursen verwendet!!!
// Diese Funktion nicht mehr einsetzten!!!
function NeuFensterpl(Datei,InternTitel,Breite,Hoehe,XPos,YPos) {
	NeuFenster(Datei,InternTitel,Breite,Hoehe,XPos,YPos);
}

/* 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();
}


// ------------------------------------------------------------------------------------------------
// Routinen fuer Popup-Window; erzeugt ein neues Fenster, in dem das definierte Bild geladen wird
// ------------------------------------------------------------------------------------------------
function bild(datei, titel, breite, hoehe, text) {
	if (isNav6) {
		fbreite = breite + 50; fhoehe = hoehe + 95;
	} else if (isNav4) {
		fbreite = breite + 50; fhoehe = hoehe + 65;
	} else {
		fbreite = breite + 50; fhoehe = hoehe + 95;
	}
	Fenster = window.open('','Bild','width='+fbreite+',height='+fhoehe+',screenX=20,screenY=20,resizable=no,scrollbars=no,dependent=yes');
	Fenster.moveTo(20,20);
	Fenster.resizeTo(fbreite,fhoehe);
	Fenster.focus();
	Fenster.document.open();
	Fenster.document.write("<HTML><HEAD>\n");
	Fenster.document.write("<TITLE>"+titel+"</TITLE><SCRIPT LANGUAGE=\"JavaScript\" src=\"/js/austria.js\" type=\"text/javascript\"></SCRIPT>\n");
	Fenster.document.write("</HEAD>\n\n");
	Fenster.document.write("<BODY TOPMARGIN=0 LEFTMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0 BGCOLOR=\"#FFFFFF\">\n");
	Fenster.document.write("<TABLE WIDTH=\""+breite+"\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" ALIGN=\"CENTER\" BGCOLOR=\"#FFFFFF\">\n");
	Fenster.document.write("<TR><TD ALIGN=\"CENTER\"><BR></TD></TR>\n");
	Fenster.document.write("<TR><TD ALIGN=\"CENTER\"><IMG SRC=\""+datei+"\" WIDTH=\""+breite+"\" HEIGHT=\""+hoehe+"\" BORDER=\"1\" ALT=\""+titel+"\"></TD></TR>\n");
	Fenster.document.write("<TR><TD ALIGN=\"CENTER\"><BR><FORM><INPUT TYPE=\"button\" VALUE=\"Fenster schließen\" onClick=\"javascript:self.close();\"></FORM</TD></TR>\n");
	Fenster.document.write("</TABLE>\n");
	Fenster.document.write("</BODY></HTML>\n");
	Fenster.document.close();
}

// ------------------------------------------------------------------------------------------------
// Noch eine Browser-Detection (sollte später die einzige JS-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;
	}
}

// ------------------------------------------------------------------------------------------------
// Flash-Detection
// ------------------------------------------------------------------------------------------------
function flashDetect(){
	var divcontainer = "flashDetect";
	if(!document.getElementById(divcontainer)){
		var divholder = document.createElement("div");
		divholder.id = divcontainer;
		document.body.appendChild(divholder);
	}
	document.getElementById(divcontainer).innerHTML = "";
	var divinfo = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width=1 height=1>'+
		'<param name=movie value="/flashDetect.swf">'+
		'<param name=quality value=high>'+
		'<param name=bgcolor value=#FFFFFF>'+
		'<embed src="/flashDetect.swf" quality=high bgcolor=#FFFFFF width=1 height=1 type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" swLiveConnect="true"></embed>'+
	'</object>';
	document.getElementById(divcontainer).innerHTML = divinfo;
}

function setFlashVersion(majorVersion, minorVersion, os, resX, resY) {
	document.getElementById("flashMajorVersion").value = majorVersion;
	document.getElementById("flashMinorVersion").value = minorVersion;
	document.getElementById("flashOS").value = os;
	document.getElementById("flashResX").value = resX;
	document.getElementById("flashResY").value = resY;
	document.getElementById("jsColorDepth").value = screen.colorDepth;
}

// ------------------------------------------------------------------------------------------------
// Function "confirm submit of a formular " 
// ------------------------------------------------------------------------------------------------
function confirmFormSubmit(theForm, message)
{
	var b = confirm(message);
	if (b == true)	
		theForm.submit();
} 



