function showEditDIV(status,div,id,wert){
	//
	if(document.getElementById(div+id)){
	document.getElementById(div+id).style.display=status;
	if(wert)document.getElementById('sitetext'+id).style.paddingTop=wert;
	}
	
}
//confirm Abfrage ok=link bei ok, esc=link bei abbruch//
function confirmDelete(ok,esc,confText) {
	if (confirm(confText)){ 
		location.href=ok;		
	} else { 
		location.href=esc;		       
	} 
}
//versteckt die eMail Adresse vor SpamRobotern
function QI_writeMail(prefix,domain,tld,subject,txt){
	var prefix = prefix;
	var domain = domain;
	var tld = tld;
	var subject = subject;
	if(!txt)txt=subject;
document.write('<a class=\"mailLink\" href=\"mailto:'+prefix+'@'+domain+'.'+tld+'?subject='+subject+'\"><img src=\"layout/img/mail.gif\" title=\"E-Mail-Kontakt\" border=\"0\">&nbsp;'+txt+'</a>'); 
}

function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); 
  if (restore) selObj.selectedIndex=0;
}
function link(name)
{
	document.forms[name].submit();	
}	

function nw(url,fen)
{
    fensteri=window.open(url, fen,'width=750,height=600,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');	
	  fensteri.focus();
}
function datew()
{
    fensteri=window.open("datepicker/datepicker.php", "datewin",'width=350,height=400,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');	
	  fensteri.focus();
}
function setDatum(obj,formName){
	var mdate = showModalDialog("../datepicker/datepicker.php", "", "dialogWidth:20em; dialogHeight:19em");
	if(mdate){
		obj.innerHTML='<input type=\"text\" value=\"'+mdate.date+'\" class=\"INPUT\">';
		
		obj.time=mdate.timestamp;
		document.forms(formName)(obj.id).value=mdate.timestamp;
	}
}

function nwin(url)
{
    fensteri=window.open (url, 'neufen','width=800,height=600,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
    fensteri.focus();	
}

function nf(url)
{
    fenst=window.open (url, 'nfen','width=900,height=500,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
    fenst.focus();	
}
function del_img(bi_id,a_id)
{
	document.location.href="../act/del_img.php?bi_id="+bi_id+"&a_id="+a_id;
}
function goTo(kat)
{
	document.location.href="index.php?kat="+kat;
}

function delete_kat(kat){
	check = confirm("Wollen sie diese Rubrik, mit allen inhalten, wirklich endgültig löschen?");
	if(check==true) document.location.href='act/del_kat.php?kat_id='+kat;

}
function delete_rub(kat){
	check = confirm("Wollen sie diese Rubrik, mit allen inhalten, wirklich endgültig löschen?");
	if(check==true) document.location.href='act/del_rub.php?kat_id='+kat;

}
function delete_page(kat){
	check = confirm("Wollen sie diese Rubrik, mit allen inhalten, wirklich endgültig löschen?");
	if(check==true) document.location.href='act/del_page.php?kat_id='+kat;

}

function newi(url)
{
    fe=window.open (url, 'upload','width=900,height=500,directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
    fe.focus();	
}
function datwin(dat)
{
    fensteri=window.open ('archiv/dateien/'+dat, 'datei','width=900,height=700,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
    fensteri.focus();	
}
function checkKey(evt){
	if (!evt)
    	evt = window.event;
  	if(evt.keyCode == 180 ){
  		document.getElementById("login").style.visibility='visible';
  		if(document.loginForm){
  			document.loginForm.u_name.focus();
  			document.loginForm.u_name.value="";
  		}
  		return false;
	}
}
document.onkeypress=checkKey;

var oldid=0;
var oldobj=0;
var actid=0;

function setoldid(id){
	oldid=id;
	actid=id;
}
function show_umen(id,obj,leftPos,topPos){
	if(id==null)id=act_id;
	if(id){
		document.getElementById(id).style.visibility='visible';
		var test="";
		var point = { x: 0, y: 0 };
	    while (obj){
		    point.x = point.x + parseInt(0+obj.offsetLeft,10);
		    point.y = point.y + parseInt(0+obj.offsetTop,10);
		    obj = obj.offsetParent;
	    }
	    document.getElementById(id).style.left=point.x-5+leftPos+"px";
		document.getElementById(id).style.top=point.y+18+topPos+"px";
		//alert(document.getElementById(id).style.top);
	}
	if(oldid && (oldid != id))document.getElementById(oldid).style.visibility='hidden';
	oldid=id;
}

function checkLocationA(){
	ystart=eval(y)+5;
	xstart=eval(x)+5;
}

spread=40;
function scrollOn(){
	items=5;
		if (ob<=items){
			objectX="object"+ob;
			y1+=10;
		
			N=(document.layers)?1:0;
			V=(N) ? 4:5;
		if (V==4){
			eval(dS + objectX + sD + v + y1);
		} else {
		object=document.getElementById(objectX);
		object.style.top=y1;
		}
		if (y1<max) xx=setTimeout("scrollOn()",200);
		else y1=-50, max+=spread, ob+=1, xx=setTimeout("scrollOn()",200); // this max sets the spacing
		}
		if (ob>6){
			clearTimeout(xx);
			checkLocation();
		}
}


function scrolldown(i) {
  self.resizeTo (window_width,i);
     if(i < window_height) {
        setTimeout ("pos_down()",10);
     }
} 
function pos_down() {  
resizeTo(window_width,window_height)     		         	
 // i += 4;
  //scrolldown(i);
}
function scrollup(x) {
  self.resizeTo (window_width,x);
  setTimeout ("pos_up()",10);
}  
function pos_up() {       			
  if(x <= 0) {
    self.close();
  }
  x -= 4;
  scrollup(x);
}

function nixFrame() { 
	if (self.parent.frames.length == 0){
		self.parent.location = "index.html?kat=<?=$kat ?>";
	}
}
function init(){
	//initBiMenue();
	//initsubMenue();
	if(document.getElementById("biHtmlEditor")){
		initEditor();
	}
}


function write_cookie(n,w){
 var a = new Date();
 e=1000*60*60*24*365;
 a = new Date(a.getTime() +e);
 document.cookie = n+'='+w+'; expires='+a.toGMTString()+';';
}

function read_cookie(n){
 a = document.cookie;
 res = '';
 while(a != '')
 {
  while(a.substr(0,1) == ' '){a = a.substr(1,a.length);}
  cookiename = a.substring(0,a.indexOf('='));
  if(a.indexOf(';') != -1)
  {cookiewert = a.substring(a.indexOf('=')+1,a.indexOf(';'));}
  else{cookiewert = a.substr(a.indexOf('=')+1,a.length);}
  if(n == cookiename){res = cookiewert;}
  i = a.indexOf(';')+1;
  if(i == 0){i = a.length}
  a = a.substring(i,a.length);
 }
 return(res);
}

function delete_cookie(n){
 document.cookie = n+'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
function link(name)
{
	document.forms[name].submit();	
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}	
function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function nw(url,fen)
{
    fensteri=window.open(url, fen,'width=850,height=600,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');	
	  fensteri.focus();
}

function nwin(url)
{
    fensteri=window.open (url, 'neufen','width=800,height=600,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
    fensteri.focus();	
}

function nf(url)
{
    fenst=window.open (url, 'nfen','width=900,height=500,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
    fenst.focus();	
}
function del_img(bi_id,a_id)
{
	document.location.href="../act/del_img.php?bi_id="+bi_id+"&a_id="+a_id;
}

function delete_kat(kat){
	check = confirm("Wollen sie diese Rubrik, mit allen inhalten, wirklich endgültig löschen?");
	if(check==true) document.location.href='act/del_kat.php?kat_id='+kat;

}
function delete_rub(kat){
	check = confirm("Wollen sie diese Rubrik, mit allen inhalten, wirklich endgültig löschen?");
	if(check==true) document.location.href='act/del_rub.php?kat_id='+kat;

}
function delete_page(kat){
	check = confirm("Wollen sie diese Rubrik, mit allen inhalten, wirklich endgültig löschen?");
	if(check==true) document.location.href='act/del_page.php?kat_id='+kat;

}

function newi(url)
{
    fe=window.open (url, 'upload','width=900,height=500,directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
    fe.focus();	
}
function datwin(dat)
{
    fensteri=window.open ('archiv/dateien/'+dat, 'datei','width=900,height=700,directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
    fensteri.focus();	
}

var oldid=0;
var oldobj=0;
var actid=0;

function setoldid(id){
	oldid=id;
	actid=id;
}

function show_umen(id,obj,leftPos,topPos){
	if(id==null)id=act_id;
	if(id){
		document.getElementById(id).style.visibility='visible';
		var test="";
		var point = { x: 0, y: 0 };
	    while (obj){
		    point.x = point.x + parseInt(0+obj.offsetLeft,10);
		    point.y = point.y + parseInt(0+obj.offsetTop,10);
		    obj = obj.offsetParent;
	    }
	    document.getElementById(id).style.left=point.x-5+leftPos+"px";
		document.getElementById(id).style.top=point.y+18+topPos+"px";
		//alert(document.getElementById(id).style.top);
	}
	if(oldid && (oldid != id))document.getElementById(oldid).style.visibility='hidden';
	oldid=id;
}
var n=0;
var obj;
var hght=0;
var height=1;
var min_hght=0;
function smooth_size(){
	if(obj){
		h=parseInt(document.getElementById(obj).style.height);
		if(h <= hght && h >= 1){
			nh= n+h;
			nh=nh-10;
			if(nh>hght)nh=hght;
			if(nh<min_hght)nh=min_hght;
			document.getElementById(obj).style.height=nh;
			setTimeout('smooth_size()',100);
		}
	}
}

function size_box(id,th){
	hght=th.offsetHeight;
	h=parseInt(document.getElementById(id).style.height);
	if(!h)document.getElementById(id).style.height=hght;
	min_hght=50;
	obj=id;
	//alert(hght);
	if(h<30){
		n=20;
		height=0;
	}else{
		n=0;
		height=25;
	}
    smooth_size();
    write_cookie(id,height);
}

function get_c_height(c_obj){
	document.getElementById(c_obj).style.height=read_cookie(c_obj);
}
function cpstyle(kat,classId){
	newname=document.getElementById('newname').value;
	if(newname)
		location.href='styles/cp_style.php?kat='+kat+'&class_id='+classId+'&newname='+newname;
}


function getPosition(obj){
	var position=new Object();
	position.pxleft=0;
	position.pxtop=0;
	while (obj){
		if(obj.scrollTop)position.pxtop-=parseInt(obj.scrollTop);
		if(obj.scrollLeft)position.pxleft-=parseInt(obj.scrollLeft);
    	position.pxleft = position.pxleft + parseInt(obj.offsetLeft);
	    position.pxtop  = position.pxtop  + parseInt(obj.offsetTop);
	    obj = obj.offsetParent;
    }
	return position;
}

function kickSel(visbility){
	for(i=0;i< document.getElementsByTagName("select").length;i++){
		document.getElementsByTagName("select")[i].style.visibility = visbility;
	}
}

function getRight(objectType,objectPk,right){
	//uRight = new biXml("webservice/rightXml.php","&katId="+katId+"&right="+right);
	return true;//uRight.xmlDoc.responseText;
}

function replaceAll(str,search,replace){
	while(str.indexOf(search) > 0){
		str=str.replace(search,replace);
	}
	return str;
}

function inArray(str,arr){
	indx=false;
	for(a=0;a<arr.length;a++){
		if(arr[a] == str)indx=true;
	}
	return indx;
}

function rowCol(color,item){
    item.style.backgroundColor = color==1?"#eeeeee":"";
}
var picCcntainer;
var bildleiste;
var bildtable;
var bmx;
var bloop;
function movePics(evt){
	if(evt)
		bmx=evt.pageX;
	else
		bmx=event.clientX;
	bloop=true;

}
function bildloop(){
	if(bloop){
		bildtable=document.getElementById("bildtable");
		lpos=parseInt(bildleiste.style.left);
		mx=bmx-parseInt(picCcntainer.style.width)/2;
		n=mx*0.06;
		max=0-(parseInt(bildtable.offsetWidth)-parseInt(picCcntainer.style.width));
		if(mx < 0 && lpos < 0){
			lpos-=n;
		}else if(mx > 0 && lpos > max){
			lpos-=n;
		}
		bildleiste.style.left=lpos;
	}
	window.setTimeout("bildloop()",10);
}

function stopPics(){
	bloop=false;
}
function removePics(){
	bloop=false;
	document.getElementsByTagName("body")[0].removeChild(picCcntainer);	
}
function showpics(){
	picCcntainer=document.createElement("div");
	picCcntainer.style.position="absolute";
	picCcntainer.style.overflow="hidden";
	picCcntainer.style.backgroundColor="#333333";
	picCcntainer.style.height="187px";
	picCcntainer.style.paddingTop="20px";
	picCcntainer.onmousemove=movePics;
	picCcntainer.onmouseout=stopPics;
	picCcntainer.onclick=removePics;
	picCcntainer.style.width="1024px";
	picCcntainer.style.zIndex=1000;
	picCcntainer.style.visibility="visible";
	picCcntainer.style.top="558px";
	picCcntainer.style.left="0px";
	bildleiste=document.createElement("div");
	bildleiste.style.position="relative";
	bildleiste.style.left="0px";
	bilder = new biXml("php/webservice/contentActionXML.php","&action=imgListXml&dir=sanLorenzo");
	nodeList=bilder.xmlDoc.responseXML.getElementsByTagName("doc");
	content="<table cellspacing=0 cellpadding=4 id=bildtable><tr>";
	for(var i=0; i< nodeList.length;i++){
		content+="<td><img src='img/sanLorenzo/"+nodeList[i].attributes[0].value+"'></td>";
	}
	content+="</tr></table>";
	bildleiste.innerHTML=content;
	picCcntainer.appendChild(bildleiste);
	document.getElementsByTagName("body")[0].appendChild(picCcntainer);	
	bildloop();
}

window.onload=init;

