function MM_swapImgRestore() {
//	for (var i = 0; i < topElem; i++) MM_swapImage('pic_m_'+i,'','/pics/clipart/blk0_off.gif',1);
	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() {
	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) {
	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() {
	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];
		}
	}
}

//wechselt auf die englische Version der aktuellen Webseite
function englishVersion() {
	var navigURL_de = parent.navig.document.URL;
	var navigURL_en = navigURL_de.replace(/.php/, "_en.php");
	var contentURL_de = parent.content.document.URL;
	var contentURL_en = contentURL_de.replace(/.php/, "_en.php");
	var menubarURL_de = parent.menubar.document.URL;
	var menubarURL_en = menubarURL_de.replace(/.php/, "_en.php");

	parent.navig.location.href = navigURL_en;
	parent.content.location.href = contentURL_en;	
	parent.menubar.location.href = menubarURL_en;
}
function englishVersion2() {
	var navigURL_de = parent.navig.document.URL;
	var navigURL_en = navigURL_de.replace(/.php/, "_en.php");
	var contentURL_de = parent.content.document.URL;
	var contentURL_en = contentURL_de.replace(/de/, "/en/");
	var menubarURL_de = parent.menubar.document.URL;
	var menubarURL_en = menubarURL_de.replace(/.php/, "_en.php");

	parent.navig.location.href = navigURL_en;
	parent.content.location.href = contentURL_en;	
	parent.menubar.location.href = menubarURL_en;
}

//wechselt auf die deutsch Version der aktuellen Webseite
function deutscheVersion() {
	var navigURL_en = parent.navig.document.URL;
	var navigURL_de = navigURL_en.replace(/_en.php/, ".php");
	var contentURL_en = parent.content.document.URL;
	var contentURL_de = contentURL_en.replace(/_en.php/, ".php");
	var menubarURL_en = parent.menubar.document.URL;
	var menubarURL_de = menubarURL_en.replace(/_en.php/, ".php");

	parent.navig.location.href = navigURL_de;
	parent.content.location.href = contentURL_de;	
	parent.menubar.location.href = menubarURL_de;
}
function deutscheVersion2() {
	var navigURL_en = parent.navig.document.URL;
	var navigURL_de = navigURL_en.replace(/_en.php/, ".php");
	var contentURL_en = parent.content.document.URL;
	var contentURL_de = contentURL_en.replace(/en/, "/de/");
	var menubarURL_en = parent.menubar.document.URL;
	var menubarURL_de = menubarURL_en.replace(/_en.php/, ".php");

	parent.navig.location.href = navigURL_de;
	parent.content.location.href = contentURL_de;	
	parent.menubar.location.href = menubarURL_de;
}

//  blank Zeichen
var whitespace = " \t\n\r";
var umbruch = "\n\r\f";

//  Prüfe, ob string s leer ist
function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}

//  Gibt true zurück, wenn string s leer oder blank ist 
function isWhitespace(s) {
var i;

	if (isEmpty(s)) return true;
    	for (i = 0; i < s.length; i++)  {
			var c = s.charAt(i);
			if (whitespace.indexOf(c) == -1) return false;
    	}
    return true;
}

//  Gibt true zurück, wenn string s ein Datum XX.XX.XXXX ist 
function isDatum(s) {
	if (s.length != 10) return false; //10 Zeichen
	var teile = s.split(".");
	if (teile.length != 3) return false;  //drei Elemente
	if (isNaN(teile[0]) || isNaN(teile[1]) || isNaN(teile[2])) return false; //3x Zahlen
	if ((teile[0].length != 2) || (teile[1].length != 2) || (teile[2].length != 4)) return false; //3x richtige Länge
    return true;
}


function checkEMail(s) {
	if (EMail(s)) return true;
	else {
		alert("Bitte geben Sie eine korrekte E-Mail Adresse an");
		return false;
	}
}

//Überprüft ob es sich um eine korrekte E-Mail Adresse handelt.
function EMail(s) {
	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);
	return res;
}

// liefert den ausgewählten Inhalt der Radiobuttons mit dem Namen "radioName"
function getRadioValue(radioName) {
   var objFormField = document.forms[0].elements[radioName]
   intControlLength = objFormField.length
   if (intControlLength > 0) strValue = -1;
   else strValue = document.forms[0].elements[radioName].value;
   for (i=0;i<intControlLength;i++) {
        if (objFormField[i].checked) strValue = objFormField[i].value;
   }     
   return strValue;
}

// für Textfelder: einfügen und upload einer beliebigen Datei
// fn = Form Name
// ta = Text Area Name
function bbcodefile(fn,ta,typ) {
	//ls nummer aus Feld Lehrstuhl suchen
	ls = eval("document."+fn+".Lehrstuhl.value");
	
	//Importbox öffnen
	open("/intern/extra/file_imp.php?ls="+ls+"&fn="+fn+"&ta="+ta+"&typ="+typ,"file_imp","width=400,height=450,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,left=0,top=0");
}

// Liste der hochgeladenen Files
// fn = Form Name
function file_list(fn) {
	//ls nummer aus Feld Lehrstuhl suchen
	ls = eval("document."+fn+".Lehrstuhl.value");
	
	//Importbox öffnen
	open("/intern/extra/file_list.php?ls="+ls,"file_list","width=450,height=450,location=no,menubar=no,scrollbars=yes,name='Dateiliste',status=no,toolbar=no,left=0,top=0");
}

// Liste der angemeldeten Studenten
// fn = Form Name
function email_list(vl) {
	//Importbox öffnen
	open("/intern/extra/email_list.php?vl="+vl,"file_list","width=450,height=450,location=no,menubar=no,scrollbars=yes,name='Dateiliste',status=no,toolbar=no,left=0,top=0");
}


// für Textfelder: einfügen von bbcode
// v = IMG, PDF, DOC, B, I, URL, MAIL
// fn = Form Name
// ta = Text Area Name
// b = Bezeichner für Datei Import
function bbcode(fn,ta,v,w,b)  {
	if (v == "IMG") { //Spezialbehandlung, Bild ist geladen, Bild einfügen
		var input = w;
	}
	else if ((v == "PDF") || (v == "DOC") || (v == "OTH") || (v == "NON")) { //Spezialbehandlung, PDF ist geladen, PDF einfügen + Bezeichner
		var input = w + ":" + b;
	}
	else if ((v == "URL") || (v == "URLi")){
		var url = prompt("Bitte geben Sie die URL / den Link ein","http://www.imtek.de/");
		var url_text = prompt("Bitte geben Sie den Text für den Link ein","");
		var input = url + ":" + url_text;
	}
	else {
		var input = prompt("Bitte geben Sie den Text für die Formatierung ein","");
	}
	if (input != "null") {
		if (document.selection) { // für IE
			var str = document.selection.createRange().text;
			document.forms[fn].elements[ta].focus();
			var sel = document.selection.createRange();
			sel.text = " [" + v + "]" + str + input + "[/" + v + "] ";
			return;
		}
		else if ((typeof document.forms[fn].elements[ta].selectionStart) != 'undefined') { // für Mozilla
			var txtarea = document.forms[fn].elements[ta];
			var selLength = txtarea.textLength;
			var selStart = txtarea.selectionStart;
			var selEnd = txtarea.selectionEnd;
			var s1 = (txtarea.value).substring(0,selStart);
			var s2 = (txtarea.value).substring(selStart, selEnd)
			var s3 = (txtarea.value).substring(selEnd, selLength);
			txtarea.value = s1 + ' [' + v + ']' + s2+ input + '[/' + v + '] ' + s3;
			txtarea.selectionStart = s1.length;
			txtarea.selectionEnd = s1.length + 5 + s2.length + input.length + v.length * 2;
			return;
		}
		else {	// für Netscape
			document.forms[fn].elements[ta].value = document.forms[fn].elements[ta].value + ' [' + v + ']' + input + '[/' + v + '] ';
		}
	}
}


/**
 * Reihe einer Tabelle farbig markieren, wenn Maus over, out oder click
 * Anwenden mit:
 *  <tr onmouseover="setPointer(this, XX, 'over', '#DDDDDD', '#CCFFCC', '#FFCC99');" onmouseout="setPointer(this, XX, 'out', '#DDDDDD', '#CCFFCC', '#FFCC99');" onmousedown="setPointer(this, XX, 'click', '#DDDDDD', '#CCFFCC', '#FFCC99');">
 *  wobei XX für die Nummer der Zeile steht
 * 
 * Geklaut von phpMyAdmin
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
 var marked_row = new Array;

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor) {
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the row -> exits
    if ((thePointerColor == '' && theMarkColor == '') || typeof(theRow.style) == 'undefined') return false;

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') theCells = theRow.getElementsByTagName('td');
    else if (typeof(theRow.cells) != 'undefined') theCells = theRow.cells;
	else return false;

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;

    if (typeof(window.opera) == 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
	    currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } 
    if (currentColor == null) currentColor = theDefaultColor;  //wenn keine Farbe gesetzt

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == '' || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') newColor = thePointerColor;
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase() && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') newColor = theDefaultColor;
        else if (theAction == 'click' && theMarkColor != '') {
            newColor = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor = (thePointerColor != '') ? thePointerColor : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum]) ? true : null;
        }
    }
	
    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        if (domDetect) for (c = 0; c < rowCellsCnt; c++) theCells[c].setAttribute('bgcolor', newColor, 0);
        else for (c = 0; c < rowCellsCnt; c++) theCells[c].style.backgroundColor = newColor;
    } 
	
    return true;
}

function Go(URL,val) {
	if (val != 0) {
	   window.location.href = URL+val;
	   document.forms[0].reset();
	   document.forms[0].elements[0].blur();
	}
}

function bbcodePrev(input) {
	//URL Replace
	input = input.replace(/\[URL\]([^\]]+)\:(.*?)\[\/URL\]/gi, "<a href=\"$1\"><img src='/pics/clipart/bl_arrs.gif' width='13' height='6' class='link'>$2</a>");
	input = input.replace(/\[url\]([^\]]+)\:(.*?)\[\/url\]/gi, "<a href=\"$1\"><img src='/pics/clipart/bl_arrs.gif' width='13' height='6' class='link'>$2</a>");
	//Mail Replace
	input = input.replace(/\[MAIL\]([^\]]+)\:(.*?)\[\/MAIL\]/gi, "<a href=\"mailto:$1\"><img src='/pics/clipart/bl_mail.gif' width='15' height='13' class='link'>$2</a>");
	input = input.replace(/\[mail\]([^\]]+)\:(.*?)\[\/mail\]/gi, "<a href=\"mailto:$1\"><img src='/pics/clipart/bl_mail.gif' width='15' height='13' class='link'>$2</a>");
	//PDF Replace
	input = input.replace(/\[PDF\]([^\]]+)\:(.*?)\[\/PDF\]/gi, "<a href=\"$1\">$2<img src='/pics/clipart/file_pdf.gif' width='16' height='16' class='link'></a>");
	input = input.replace(/\[pdf\]([^\]]+)\:(.*?)\[\/pdf\]/gi, "<a href=\"$1\">$2<img src='/pics/clipart/file_pdf.gif' width='16' height='16' class='link'></a>");
	//DOC Replace
	input = input.replace(/\[DOC\]([^\]]+)\:(.*?)\[\/DOC\]/gi, "<a href=\"$1\">$2<img src='/pics/clipart/file_pdf.gif' width='16' height='16' class='link'></a>");
	input = input.replace(/\[doc\]([^\]]+)\:(.*?)\[\/doc\]/gi, "<a href=\"$1\">$2<img src='/pics/clipart/file_pdf.gif' width='16' height='16' class='link'></a>");
	//OTH Replace
	input = input.replace(/\[OTH\]([^\]]+)\:(.*?)\[\/OTH\]/gi, "<a href=\"$1\">$2<img src='/pics/clipart/file_pdf.gif' width='16' height='16' class='link'></a>");
	input = input.replace(/\[oth\]([^\]]+)\:(.*?)\[\/oth\]/gi, "<a href=\"$1\">$2<img src='/pics/clipart/file_pdf.gif' width='16' height='16' class='link'></a>");
	//NON Replace
	input = input.replace(/\[NON\]([^\]]+)\:(.*?)\[\/NON\]/gi, "<a href=\"$1\">$2<img src='/pics/clipart/file_pdf.gif' width='16' height='16' class='link'></a>");
	input = input.replace(/\[non\]([^\]]+)\:(.*?)\[\/non\]/gi, "<a href=\"$1\">$2<img src='/pics/clipart/file_pdf.gif' width='16' height='16' class='link'></a>");
	//Bild Replace
	input = input.replace(/\[IMG\]([^\]]+)\[\/IMG\]/gi, "<img src='/pics/clipart/bl_blk.gif' width='200' height='200' class='border'>");
	input = input.replace(/\[img\]([^\]]+)\[\/img\]/gi, "<img src='/pics/clipart/bl_blk.gif' width='200' height='200' class='border'>");
	//LI Replace
	input = input.replace(/\[LI\]([^\]]+)\[\/LI\]/gi, "&bull; $1");
	input = input.replace(/\[li\]([^\]]+)\[\/li\]/gi, "&bull; $1");
	
	//Kleinzeug Replace
	input = input.replace(/\[I\]/gi, "<em>");
	input = input.replace(/\[\/I\]/gi, "</em>");
	input = input.replace(/\[i\]/gi, "<em>");
	input = input.replace(/\[\/i\]/gi, "</em>");
	input = input.replace(/\[B\]/gi, "<strong>");
	input = input.replace(/\[\/B\]/gi, "</strong>");
	input = input.replace(/\[b\]/gi, "<strong>");
	input = input.replace(/\[\/b\]/gi, "</strong>");
	input = input.replace(/\n/gi, "<br>");
	
	return input;
}

//Bei Seitenaufruf testen, ob die Seite sich in einem Frame mit Namen CONTENT befindet, wenn nicht, weiterleiten an zentrale Seite
function relfile() {
	if ((self.location == top.location)) {
		var URL = window.document.URL;
		var URLpart = URL.split("/");
		var File = URLpart[URLpart.length-1];
		if ((File == "navig.php") || (File == "menubar.php")) {
			window.location.href = IndexFile;
		}
		else if ((File != "index.php") && (File != "index_en.php")) {
			window.location.href = IndexFile+"?page="+URL;
		}
	}
}
relfile();

 

