
// telepark.cms 
// (c) by telepark

// open new window
function newWindow(url,name,width,height) {
	fenster = window.open (
	url,
	name, 					// name
	'toolbar=0' 			// tool bar 
	+',location=0' 			// address bar
	+',directories=0' 		// additional bars
	+',status=0' 			// status bar
	+',menubar=0' 			// menu bar
	+',scrollbars=1' 		// scroll bars
	+',resizable=1' 		// window resizable
	+',width=' + width 		// window width in pixels
	+',height=' + height 	// window height in pixels
	);
}

// get focus
function getfocus() {
	self.focus();
}

// create HttpRequest
function createHttpRequest() {
	var xmlhttp;
 	try {
 		xmlhttp = new XMLHttpRequest();
 	} catch (e) {
  		var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0',
  										'MSXML2.XMLHTTP.5.0',
  										'MSXML2.XMLHTTP.4.0',
  										'MSXML2.XMLHTTP.3.0',
  										'MSXML2.XMLHTTP',
  										'Microsoft.XMLHTP'
  										);
  		for (var i = 0; i<XmlHttpVersions.length && !xmlhttp; i++) {
  			try {
  				xmlhttp = new ActiveXObject(XmlHttpVersions[i]);
  			}
  			catch(e) {
  			}
  		}
 	}
 	if (!xmlhttp) {
 		alert('Error creating the XMLHttpRequest object.');
 	} else {
		return xmlhttp;
 	}
}

// disable/enable all form fields
function toggleFormFields(status,target) {
	// status
	if (status == "disable") status = true;
	else status = false;
	// toggle input, select and textarea fields
	if (target != "") {
		var ml = target.document.forms[target.document.forms.length-1];
	}
	else var ml = document.forms[document.forms.length-1];
	var len = ml.elements.length;
	for (var i=0; i<len; i++) {
		var e = ml.elements[i];
		//alert("tagName: " + e.tagName + ", name:" + e.name);
		if (e.tagName == "INPUT" || e.tagName == "SELECT" || e.tagName == "TEXTAREA") {
			e.disabled = status;
		}
	}
}

// loading animation
function loading(f) {
	// hide
	if (f != true) {
		if (document.getElementById('status')) {
			document.getElementById('status').style.display = 'none';
			toggleFormFields("enable","");
		}
		else if (parent.document.getElementById('status')) {
			parent.document.getElementById('status').style.display = 'none';
			toggleFormFields("enable","parent");
		}
	} 
	// show
	else {
		if (document.getElementById('status')) {
			document.getElementById('status').style.display = 'block';
			toggleFormFields("disable","");
		}
		else if (parent.document.getElementById('status')) {
			parent.document.getElementById('status').style.display = 'block';
			toggleFormFields("disable","parent");
		}
	}
}

// input field restriction
MS_restrict_field = function(formname, id_or_name, chars) {
	var obj = (document.getElementById && document.getElementById(id_or_name) != null)
			  ? document.getElementById(id_or_name) : ((document[formname][id_or_name] != null)
			  ? document[formname][id_or_name] : '');

	if(obj.type == "text" || obj.type == "textarea") {
		obj.timer = "";
		obj.chars = chars;
		obj.onkeypress = obj.onkeydown = function() {
			var self = this;
			controll = function() {
				for(var t='',x=0; x<self.value.length; ++x) {
					if(self.chars.indexOf(self.value.charAt(x))>-1) {
						t += self.value.charAt(x);
					}
				}
				self.value = t;
			};
			this.timer = setTimeout(controll,1);
		};
		obj.onkeyup = function() {
			clearTimeout(this.timer);
		};
	}
};

// PRAKTIKA
// ========

// reload praktika list (frontend)
function frontendReloadPraktikaList(userid,searchstring) {
	loading(true);
	
	var s = '';
	
	if (!searchstring || searchstring == "undefined" || searchstring == '') {
		if (document.getElementById('searchpraktikum')) {
			s = encodeURI(document.getElementById('searchpraktikum').value);
		}
	}
	else if (searchstring != '') {
		s = encodeURI(searchstring);
	}
	
	var xmlhttp = createHttpRequest();
	xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendReloadPraktikaList.php?userid=" + userid + "&searchstring=" + s, true);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
				eval(xmlhttp.responseText);
				loading();
			}
		}
		catch(e) {
			status = '';
			loading();
		}
	  }
	}
	xmlhttp.send(null);
}

// delete praktikum
function frontendDeletePraktikum(pracid,userid,searchstring,page) {
	loading(true);
	var c = confirm('Möchten Sie dieses Praktikum wirklich löschen?');
	if (c == true) {
		var xmlhttp = createHttpRequest();
		xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendDeletePraktikum.php?pracid=" + pracid + "&searchstring=" + searchstring + "&page=" + page, true);
		xmlhttp.onreadystatechange=function() {
		  // readyState==4 - meaning the load is complete
		  if (xmlhttp.readyState==4) {
			// only if "OK"
			var status = '';
			try {
				status = xmlhttp.status;
				if (status==200) {
				//alert(xmlhttp.responseText);
					eval(xmlhttp.responseText);
					loading();
				}
			}
			catch(e) {
				status = '';
				loading();
				if (page && page > 0) frontendReloadPraktikumSearchResults(page);
				else frontendReloadPraktikaList(userid,searchstring);
			}
		  }
		}
		xmlhttp.send(null);
	}
	else {
		loading();
	}
}

// toggle Kontaktart
function toggleKontaktart(art) {
	if (art == 1) {
		if (document.getElementById('public_contact') && document.getElementById('anonymous_contact')) {
			document.getElementById('public_contact').style.display = "block";
			document.getElementById('anonymous_contact').style.display = "none";
		}
	}
	else if (art == 2) {
		if (document.getElementById('public_contact') && document.getElementById('anonymous_contact')) {
			document.getElementById('public_contact').style.display = "none";
			document.getElementById('anonymous_contact').style.display = "block";
		}
	}
}

// delete praktikum
function frontendSetPraktikumStatus(pracid,searchstring,newstatus,userid) {
	loading(true);
	if (newstatus == 0) var question = 'Möchten Sie dieses Praktikum wirklich inaktiv setzen?';
	else if (newstatus == 1) var question = 'Möchten Sie dieses Praktikum wirklich aktiv setzen?';
	var c = confirm(question);
	if (c == true) {
		var xmlhttp = createHttpRequest();
		xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendSetPraktikumStatus.php?pracid=" + pracid + "&userid=" + userid + "&status=" + newstatus + "&searchstring=" + searchstring, true);
		xmlhttp.onreadystatechange=function() {
		  // readyState==4 - meaning the load is complete
		  if (xmlhttp.readyState==4) {
			// only if "OK"
			var status = '';
			try {
				status = xmlhttp.status;
				if (status==200) {
				//alert(xmlhttp.responseText);
					eval(xmlhttp.responseText);
					loading();
				}
			}
			catch(e) {
				status = '';
				loading();
				frontendReloadPraktikaList(userid,searchstring);
			}
		  }
		}
		xmlhttp.send(null);
	}
	else {
		loading();
	}
}

// reload praktika list
function frontendReloadPraktikumSearchResults(page) {
	loading(true);

	var xmlhttp = createHttpRequest();
	xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendReloadPraktikumSearchResults.php?page=" + page, true);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
				eval(xmlhttp.responseText);
				loading();
			}
		}
		catch(e) {
			status = '';
			loading();
		}
	  }
	}
	xmlhttp.send(null);
}

// toggle praktika search form
function togglePraktikaSearchForm() {
	if (document.getElementById('extendedSearchForm')) {
		if (document.getElementById('extendedSearchForm').style.display == "block") document.getElementById('extendedSearchForm').style.display = "none";
		else document.getElementById('extendedSearchForm').style.display = "block";
	}
}

// reset page session variable
function resetSessionPage() {
	//alert("resetSessionPage");
	var xmlhttp = createHttpRequest();
	xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/resetPageSession.php", false);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  //alert(xmlhttp.readyState);
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
			//eval(xmlhttp.responseText);
			}
		}
		catch(e) {
			status = '';
		}
	  }
	}
	xmlhttp.send(null);
}

// MARKTPLATZ
// ==========

// reload marktplatz list (frontend)
function frontendReloadMarktplatzList(userid,searchstring) {
	loading(true);
	
	var s = '';
	
	if (!searchstring || searchstring == "undefined" || searchstring == '') {
		if (document.getElementById('searchmarktplatz')) {
			s = encodeURI(document.getElementById('searchmarktplatz').value);
		}
	}
	else if (searchstring != '') {
		s = encodeURI(searchstring);
	}
	
	var xmlhttp = createHttpRequest();
	xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendReloadMarktplatzList.php?userid=" + userid + "&searchstring=" + s, true);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
				eval(xmlhttp.responseText);
				loading();
			}
		}
		catch(e) {
			status = '';
			loading();
		}
	  }
	}
	xmlhttp.send(null);
}

// delete marktplatz
function frontendDeleteMarktplatz(id,userid,searchstring,page) {
	loading(true);
	var c = confirm('Möchten Sie diesen Marktplatzeintrag wirklich löschen?');
	if (c == true) {
		var xmlhttp = createHttpRequest();
		xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendDeleteMarktplatz.php?id=" + id + "&searchstring=" + searchstring + "&page=" + page, true);
		xmlhttp.onreadystatechange=function() {
		  // readyState==4 - meaning the load is complete
		  if (xmlhttp.readyState==4) {
			// only if "OK"
			var status = '';
			try {
				status = xmlhttp.status;
				if (status==200) {
				//alert(xmlhttp.responseText);
					eval(xmlhttp.responseText);
					loading();
				}
			}
			catch(e) {
				status = '';
				loading();
				if (page && page > 0) frontendReloadMarktplatzSearchResults(page);
				else frontendReloadMarktplatzList(userid,searchstring);
			}
		  }
		}
		xmlhttp.send(null);
	}
	else {
		loading();
	}
}

// set frontend marktplatz status
function frontendSetMarktplatzStatus(markid,searchstring,newstatus,userid) {
	loading(true);
	if (newstatus == 0) var question = 'Möchten Sie diesen Marktplatzeintrag wirklich inaktiv setzen?';
	else if (newstatus == 1) var question = 'Möchten Sie diesen Marktplatzeintrag wirklich aktiv setzen?';
	var c = confirm(question);
	if (c == true) {
		var xmlhttp = createHttpRequest();
		xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendSetMarktplatzStatus.php?markid=" + markid + "&userid=" + userid + "&status=" + newstatus + "&searchstring=" + searchstring, true);
		xmlhttp.onreadystatechange=function() {
		  // readyState==4 - meaning the load is complete
		  if (xmlhttp.readyState==4) {
			// only if "OK"
			var status = '';
			try {
				status = xmlhttp.status;
				if (status==200) {
				//alert(xmlhttp.responseText);
					eval(xmlhttp.responseText);
					loading();
				}
			}
			catch(e) {
				status = '';
				loading();
				frontendReloadMarktplatzList(userid,searchstring);
			}
		  }
		}
		xmlhttp.send(null);
	}
	else {
		loading();
	}
}

// reload marktplatz list
function frontendReloadMarktplatzSearchResults(page) {
	loading(true);

	var xmlhttp = createHttpRequest();
	xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendReloadMarktplatzSearchResults.php?page=" + page, true);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
				eval(xmlhttp.responseText);
				loading();
			}
		}
		catch(e) {
			status = '';
			loading();
		}
	  }
	}
	xmlhttp.send(null);
}

// toggle marktplatz search form
function toggleMarktplatzSearchForm() {
	if (document.getElementById('extendedSearchForm')) {
		if (document.getElementById('extendedSearchForm').style.display == "block") document.getElementById('extendedSearchForm').style.display = "none";
		else document.getElementById('extendedSearchForm').style.display = "block";
	}
}

function toggleMarktplatzKategorie(id) {
	loading(true);
	for (var i=1; i<=4; i++) {
		if (document.getElementById('angebot_kategorienid_' + i)) {
			document.getElementById('angebot_kategorienid_' + i).style.display = 'none';
		}
	}
	if (document.getElementById('angebot_kategorienid_' + id)) {
		document.getElementById('angebot_kategorienid_' + id).style.display = 'block';
	}
	loading();
}

// BERUFE
// ======

// reload berufe list
function frontendReloadBerufeResults(searchstring) {
	loading(true);
	
	var s = '';
	
	if (!searchstring || searchstring == "undefined" || searchstring == '') {
		if (document.getElementById('searchberuf')) {
			s = encodeURI(document.getElementById('searchberuf').value);
		}
	}
	else if (searchstring != '') {
		s = encodeURI(searchstring);
	}
	
	var xmlhttp = createHttpRequest();
	xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendReloadBerufeList.php?searchstring=" + s, true);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
				eval(xmlhttp.responseText);
				loading();
			}
		}
		catch(e) {
			status = '';
			loading();
		}
	  }
	}
	xmlhttp.send(null);
}

// toggle berufe filter
function frontendToggleBerufeFilter(tid) {
	if (document.getElementById('searchberuf')) var searchstring = document.getElementById('searchberuf').value;
	else var searchstring = "";
	
	var xmlhttp = createHttpRequest();
	xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendToggleBerufeFilter.php?tid=" + tid, true);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
			frontendReloadBerufeResults(searchstring);
			}
		}
		catch(e) {
			status = '';
			frontendReloadBerufeResults(searchstring);
		}
	  }
	}
	xmlhttp.send(null);
}

// toggle search area
function toggleSearchArea(area) {
	if (area == 2) {
		if (document.getElementById('extendedSearchLink')) document.getElementById('extendedSearchLink').href="index.php?extendedmarktplatzsearch";
		if (document.getElementById('searchPlace')) document.getElementById('searchPlace').name="marktplatzsearch";
		if (document.getElementById('extendedsearchlabel')) document.getElementById('extendedsearchlabel').innerHTML="Marktplatz";
	}
	else if (area == 1) {
		if (document.getElementById('extendedSearchLink')) document.getElementById('extendedSearchLink').href="index.php?extendedpraktikasearch";
		if (document.getElementById('searchPlace')) document.getElementById('searchPlace').name="praktikasearch";
		if (document.getElementById('extendedsearchlabel')) document.getElementById('extendedsearchlabel').innerHTML="Praktikums";
	}
}

// toggle gueltigkeit (praktika and marktplatz)
function toggleGueltigkeit(mode) {
	if (mode == "unbegrenzt") {
		if (document.getElementById('angebot_gueltigab')) document.getElementById('angebot_gueltigab').value = '';
		if (document.getElementById('angebot_gueltigbis')) document.getElementById('angebot_gueltigbis').value = '';
		if (document.getElementById('praktikum_zeitraum_start')) document.getElementById('praktikum_zeitraum_start').value = '';
		if (document.getElementById('praktikum_zeitraum_ende')) document.getElementById('praktikum_zeitraum_ende').value = '';
	} else if (mode == "datum") {
		if (document.getElementById('angebot_gueltigunbegrenzt') && (document.getElementById('angebot_gueltigab').value!="" || document.getElementById('angebot_gueltigbis').value!="")) {
			document.getElementById('angebot_gueltigunbegrenzt').checked = false;
		}
		if (document.getElementById('praktikum_zeitraum_unbegrenzt') && (document.getElementById('praktikum_zeitraum_start').value!="" || document.getElementById('praktikum_zeitraum_ende').value!="")) {
			document.getElementById('praktikum_zeitraum_unbegrenzt').checked = false;
		}
	}
}

function sortList(order,field,jsfunction,target) {
	var xmlhttp = createHttpRequest();
	target = target + "/toggleSort.php?field=" + field + "&order=" + order;
	xmlhttp.open("GET", target, true);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
			//frontendReloadBerufeResults();
			eval(jsfunction);
			}
		}
		catch(e) {
			status = '';
			eval(jsfunction);
		}
	  }
	}
	xmlhttp.send(null);
}

// PROJEKTBOERSE
// =============

// reload projektboerse list (frontend)
function frontendReloadProjektboerseList(userid,searchstring) {
	loading(true);
	
	var s = '';
	
	if (!searchstring || searchstring == "undefined" || searchstring == '') {
		if (document.getElementById('searchprojektboerse')) {
			s = encodeURI(document.getElementById('searchprojektboerse').value);
		}
	}
	else if (searchstring != '') {
		s = encodeURI(searchstring);
	}
	
	var xmlhttp = createHttpRequest();
	xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendReloadProjektboerseList.php?userid=" + userid + "&searchstring=" + s, true);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
				eval(xmlhttp.responseText);
				loading();
			}
		}
		catch(e) {
			status = '';
			loading();
		}
	  }
	}
	xmlhttp.send(null);
}

// delete projektboerse
function frontendDeleteProjekt(id,userid,searchstring,page) {
	loading(true);
	var c = confirm('Möchten Sie diesen Projekteintrag wirklich löschen?');
	if (c == true) {
		var xmlhttp = createHttpRequest();
		xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendDeleteProjekt.php?id=" + id + "&searchstring=" + searchstring + "&page=" + page, true);
		xmlhttp.onreadystatechange=function() {
		  // readyState==4 - meaning the load is complete
		  if (xmlhttp.readyState==4) {
			// only if "OK"
			var status = '';
			try {
				status = xmlhttp.status;
				if (status==200) {
				//alert(xmlhttp.responseText);
					eval(xmlhttp.responseText);
					loading();
				}
			}
			catch(e) {
				status = '';
				loading();
				if (page && page > 0) frontendReloadProjektboerseSearchResults(page);
				else frontendReloadProjektboerseList(userid,searchstring);
			}
		  }
		}
		xmlhttp.send(null);
	}
	else {
		loading();
	}
}

// set frontend projektboerse status
function frontendSetProjektboerseStatus(projid,searchstring,newstatus,userid) {
	loading(true);
	if (newstatus == 0) var question = 'Möchten Sie diesen Projekteintrag wirklich inaktiv setzen?';
	else if (newstatus == 1) var question = 'Möchten Sie diesen Projekteintrag wirklich aktiv setzen?';
	var c = confirm(question);
	if (c == true) {
		var xmlhttp = createHttpRequest();
		xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendSetProjektboerseStatus.php?projid=" + projid + "&userid=" + userid + "&status=" + newstatus + "&searchstring=" + searchstring, true);
		xmlhttp.onreadystatechange=function() {
		  // readyState==4 - meaning the load is complete
		  if (xmlhttp.readyState==4) {
			// only if "OK"
			var status = '';
			try {
				status = xmlhttp.status;
				if (status==200) {
				//alert(xmlhttp.responseText);
					eval(xmlhttp.responseText);
					loading();
				}
			}
			catch(e) {
				status = '';
				loading();
				frontendReloadProjektboerseList(userid,searchstring);
			}
		  }
		}
		xmlhttp.send(null);
	}
	else {
		loading();
	}
}

// reload projektboerse list
function frontendReloadProjektboerseSearchResults(page) {
	loading(true);

	var xmlhttp = createHttpRequest();
	xmlhttp.open("GET", "admin/modules/sprungbrett/ajax/frontendReloadProjektboerseSearchResults.php?page=" + page, true);
	xmlhttp.onreadystatechange=function() {
	  // readyState==4 - meaning the load is complete
	  if (xmlhttp.readyState==4) {
		// only if "OK"
		var status = '';
		try {
			status = xmlhttp.status;
			if (status==200) {
			//alert(xmlhttp.responseText);
				eval(xmlhttp.responseText);
				loading();
			}
		}
		catch(e) {
			status = '';
			loading();
		}
	  }
	}
	xmlhttp.send(null);
}

// toggle marktplatz search form
function toggleProjektboerseSearchForm() {
	if (document.getElementById('extendedSearchForm')) {
		if (document.getElementById('extendedSearchForm').style.display == "block") document.getElementById('extendedSearchForm').style.display = "none";
		else document.getElementById('extendedSearchForm').style.display = "block";
	}
}

// populate textbaustein
function projektboerseTextbausein(text) {
	if (text && text!="" && text!="undefined" && document.getElementById('projekt_text')) {
		document.getElementById('projekt_text').value=decodeURI(text);
	}
}

// home page search
function tippsandtricks(state) {
	var d="block";
	if (state) d="none"
	document.getElementById('search_fields').style.display=d;
}

function checkTippsandtricks() {
	var obj=document.getElementById('search_fields');
	if (obj.style.display=="none") {
		window.location.href="index.php?pageid=742";
		return false;
	} else {
		return true;
	}
}

function centerSearch() {;
	var obj=document.getElementById('contentTable');
	if (obj) {
		var content=obj.offsetWidth;		
		var m=parseInt((570-content)/2);
		if (m<5) m=5;
		var i=570-(m*2);
		var mF=document.getElementById('main_frame');
		mF.style.marginLeft=m+'px';
		mF.style.marginRight=m+'px';
		mF.style.width=i+'px';
		document.getElementById('navigator_top').childNodes[0].style.width=content+'px';
		document.getElementById('navigator_bottom').childNodes[0].style.width=content+'px';
	} else {
		setTimeout('centerSearch()',50);
	}
}

var hiddenSelects=new Array;

function hideSelects() {
	var popup=document.getElementById("popup");
	if (!popup) return;
	var sels=document.getElementsByTagName("select");
	for (var i=0; i<sels.length; i++) {
		sels[i].style.display="none";
		hiddenSelects.push(sels[i]);
	}
}

function hidePopup() {
	var popup=document.getElementById("popup");
	if (!popup) return;
	popup.style.display="none";
	for (var i=0; i<hiddenSelects.length; i++) {
		hiddenSelects[i].style.display="inline";
	}
	hiddenSelects.length=0;
}

var fenster;

function openWindow(modus,itemtype,iid,module) {
	if (iid==-1) iid = 0;
	
	// 'edit' window
		var pre=ROOT_URL+"admin/";
	
	if (modus=='edit') {
		if (itemtype == "art" || itemtype == "far") { 
			url = pre+"pages/editarticle_multilang.php?itemtype=" + itemtype + "&itemid=" + iid;
			if (module!='') url += "&module=" + module;
			width = 750;
			height = 500;
			newArticleWindow(url,iid,width,height);
		}
		else if (itemtype == "fol" || itemtype == "ffo") {
			url = pre+"pages/editfolder.php?itemtype=" + itemtype + "&itemid=" + iid;
			width = 300;
			height = 150;
			newWindow(url,'popup' + iid,width,height);
		}
		else if (itemtype == "mpa") {
			url = pre+"pages/editmenuarticle.php?itemtype=" + itemtype + "&itemid=" + iid;
			width = 360;
			height = 350;
			newWindow(url,'popup' + iid,width,height);
		}
	}
	
}

function newArticleWindow(url,name,width,height) {
	if (typeof(fenster)=="undefined") fenster=new Array;
	fenster[name] = window.open (
	url,
	name, 					// name
	"toolbar=0" 			// tool bar 
	+",dependent=1"			// dependent
	+",location=0" 			// address bar
	+",directories=0" 		// additional bars
	+",status=1" 			// status bar
	+",menubar=0" 			// menu bar
	+",scrollbars=0" 		// scroll bars
	+",resizable=1" 		// window resizable
	+",width=" + width 		// window width in pixels
	+",height=" + height 	// window height in pixels
	);
}

