/*
blendet ein div ein oder aus
optional kann das focusfield angegeben werden
welches nach dem aufklappen focussiert wird.
*/

var contor = '/contor';


function part(elementname, focusfield) {
	obj = $(elementname);
	if(obj.style.display == 'none' || obj.style.display == '' ) {
		obj.style.display='block';
		if(focusfield) {
			obj = $(focusfield).focus();
		}
	} else {
		obj.style.display='none';
	}
}

/** generate unix timetamp */
function time() {
	return parseInt(new Date().getTime().toString().substring(0, 10));
}



/* 
	Optionsbox
	kombinationsfunktion mit der part() funktion
	tauscht aber das kleine optionsbildchen (pfeil)	aus
*/
function changenode(name) {
	var status = document.images[name+"_node"].src == "/contor/images/n_open.gif" ? "close" : "open";
	document.images[name+"_node"].src = "/contor/images/n_"+status+".gif";
	part(name);
}


var url = "";
var changes = "";


function setloc (location,file,updatebody,updatetop) {
	if (location) url += "location="+location+"&";
	if (file) url += "file="+file+'&';
	if (updatetop) url+='updatetop=true';
	
	if (changes) {
		if(!confirm("Achtung! Sie haben Ihre Änderungen noch nicht gespeichert. Möchten Sie fortsetzen?")) {
			return;
		}
	}
	if(updatebody) document.location.href='body.php?'+url;
}

function save (rank) {
	document.forms[0].submit();
}

var changes;
function as() {
	if(!changes) {
		changes = true;
	}
}

function popup(theURL,winName,features) { 
	window.open(theURL,winName,features);
}


/* 
	öffnet das Objektefenster 
*/
function openObject(setrank, page) {
	var w=760;
	var h=250;
	var sx=(screen.width-w)/2;
	var sy=(screen.height-h)/2;
	
	props = "width="+w+",height="+h+",resizable=yes,menubar=no,status=no,toolbar=no,scrollbars=no,location=no";
	//props = props + ",screenx="+sx+",screeny="+sy;
	objects_window = window.open(contor+"/contents/3/popup.php?setrank="+setrank+'&page='+page,"objects",props);
	objects_window.moveTo(sx,sy); 
	objects_window.focus();
}

function ConfirmAction(text, afterEvent) {
	if(confirm(text)) {
		eval(afterEvent);
	} else {
		return false;
	}
}

/* findet ein Objekt anhand der id */
function getObj(name) {
	this.obj = $(name);
	this.style = this.obj.style;
}

// correctly handle PNG transparency in Win IE 5.5 or higher.
function correctPNG() {
   for(var i=0; i<document.images.length; i++) {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	}
  }
}

if (navigator.appName == 'Microsoft Internet Explorer') window.attachEvent("onload", correctPNG);

function closeWindows () {
	if(typeof window_css != "undefined") window_css.close();
	if(typeof objects_window != "undefined") objects_window.close();
}

