// FKI
function openCloseRow(id, url) {
	location.href = url+'/id/'+id+'/index.html';
}
function endEvaluationQuick(msg) {
	if (confirm(msg)) {
		document.main.submit();
	}
}


// --- OLD or GENERAL functions

function MM_findObj(n, d) { //v4.01
  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 doMultiselect(o) { for (var t=0; t<document.main.elements.length; t++) { var x = document.main.elements[t]; if (x.name.indexOf(o.name) != -1) { x.checked = o.checked; } } }
// CONFIRM ACTION BEFORE PROCEEDING TO URL
function confirmaction(url, action, jsaction) { if (confirm(action)) { if (jsaction) { eval(jsaction+"()"); } else { location.href = url; } } }
// SHOW BIG IMAGE VERSION OF IMAGE
function showBigImage(image) { image = image.replace('/','-=slash=-'); window_open("/1/1000/2653/image/"+image+"/index.html", "zoom_image", 700, 600, 1, 1, 1); }
// FIRMEN VERWALTEN
function firmen_verwalten() { window_open("/home/willkommen/firmenverwaltung/index.html", "firmen_verwalten", 600, 300, 1, 0, 1); }
// CHANGE FOLDER
function change_folder() { window_open("/home/willkommen/firmenverwaltung/index.html", "change_folder", 600, 300, 1, 0, 1); }
// READ IN NEW FILES
function new_files(num) { window_open("/home/willkommen/newfiles/start/1/num/"+num+"/index.html", "new_files", 600, 300, 1, 0, 1); }
// EDIT CAPTIONS
function edit_captions(type, id, idh) { window_open("/home/willkommen/bearbeiten/type/"+type+"/id/"+id+"/idh/"+idh+"/index.html", "edit_caption", 600, 300, 1, 0, 1); }
// SELECT ALL CHECKBOXES
function selectall(o) { for (var t=0; t<document.main.elements.length; t++) { var x = document.main.elements[t]; if (x.name.indexOf('item') != -1) { x.checked = o.checked; } } }
// SELECT BILD 
function selectItem(id) {}
// GENERAL WINDOW OPEN FUNCTION
function window_open(url, name, width, height, center, resizable, alwaysRaised) {
	var xtra = "";
	if (center) {
		var screenX = screen.width / 2 - width / 2;
		var screenY = screen.height / 2 - height / 2;
		xtra = xtra + ",screenX="+screenX+",screenY="+screenY+",left="+screenX+",top="+screenY;
	}
	if (resizable) {
		xtra = xtra + ",resizable=yes,scrollbars=yes";
	}
	if (!document.all) {
		if (alwaysRaised) {
			xtra = xtra + ",alwaysRaised=yes,dependent=yes";
		}
	} else {
		// IE
	}
	var w = window.open(url, name, "width="+width+",height="+height+xtra);
	w.focus();
}

// IN DATEIVERWALTUNG DIE BILDER ANORDNEN
function anordnen(file, catalog, loc) {
	location.href='/home/willkommen/dateiverwaltung/file/'+file+'/catalog/'+catalog+'/loc/'+loc+'/anordnen/1/index.html';
}

// IM ANORDNEN POPUP EINEN NEUEN ORDNER KREIEREN
function neuerOrdner() {
	var f = document.main;
	var doit = true;
	if (f.location.selectedIndex > 0) {
		// HAS SELECTED ORDNER
	} else {
		if (confirm('Wenn Sie keinen existierenden Ordner auswählen, wir ein neuer Superordner kreiert!')) {
			// IS OKAY
		} else {
			doit = false;
		}
	}
	if (doit) {
		if (f.neu.value.length<3) {
			doit = false;
			alert("Der Ordnername muss mindestens 3 Buchstaben lang sein");
		}
		if (doit) {
			f.todo.value='neuerordner';
			f.submit();
		} else {
			// FAILED
		}
	} else {
		// FAILED
	}
}
// FUNCTIONS FOR ADDING A NEW CONTAINER
// OPEN POPUP TO SELECT CONTAINERS
function mkcms_add_container(element_id, loc, language) { window_open("/1/2/3/element/"+element_id+"/loc/"+loc+"/language/"+language+"/index.html", "mkcms_container", 700, 500, 1, 1, 1); }
// ADD PREDEFINED CONTAINER AND CREATE FIRST ELEMENT
function mkcms_add_container_automatically(url, element_id, loc, language, type, input, output) { location.href=url+"/addautocontainer/1/element/"+element_id+"/loc/"+loc+"/language/"+language+"/type/"+type+"/input/"+input+"/output/"+output+"/index.html"; }
function reload_page(url) { 
	// reload with delay
	if (url.length) {
		//window.setTimeout("location.href = '"+url+"';", 500);
		location.href = url;
	} else {
		//window.setTimeout("location.reload();", 500);
		window.location.reload();
	}
}
