var containerOld = '';
var noContainerOld = '';
var commentFocus = false;
var hasFocus = Object();
var formFocus = Object();
var isActiveTop = null;
var editingCmt = 0;
var commentView = 1;
var pressPage = 1;
var archivePage = 2;
var searchPage = 1;
var readingPage = 1;
var expanded = Object();

Object.extend(Element, {
	nextSib: function(element,cntTag) {
		if (!isNaN(parseInt(cntTag))) {
			for (i=0;i<cntTag;i++) {	
				element = element.nextSibling; 	
				while ((element) && (element.nodeType!=1)) {
					element = element.nextSibling;
				}	
			}
		}
		else {
				element = element.nextSibling; 	
				while ((element) && (element.nodeType!=1)) {
					element = element.nextSibling;
				}			
		}
		return element;
	},
	prevSib: function(element,cntTag) {
		if (!isNaN(parseInt(cntTag))) {
			for (i=0;i<cntTag;i++) {
				element = element.previousSibling; 	
				while ((element) && (element.nodeType!=1)) {
					element = element.previousSibling;
				}	
			}
		}
		else {
				element = element.previousSibling; 	
				while ((element) && (element.nodeType!=1)) {
					element = element.previousSibling;
				}				
		}
		return element;
	},
	getParentNode: function(element,cntTag) {
		if (!isNaN(parseInt(cntTag))) {
			for (i=0;i<cntTag;i++) {
				if (element.parentNode)
					element = element.parentNode;
				else
					break;
			}			
		}
		else {
			element = element.parentNode; 	
			while ((element) && (element.tagName!=cntTag) && (element.nodeType==1)) {
				element = element.parentNode;
			}			
		}
		
	
		return element;
	}
});

function checkKey(e) {

	if(window.event)	
		keynum = e.keyCode; 
	else if(e.which) 
		keynum = e.which; 

	if (keynum==13) { 
		doLogin($('loginButton')); 
		return false;
	}
	
	return true;
}

function UnCryptMailto( s, sh ) {
		var n = 0;
		var r = "";
		for( var i = 0; i < s.length; i++)
		{
				n = s.charCodeAt( i );
				if( n >= 8364 )
				{
						n = 128;
				}
				r += String.fromCharCode( n - sh );
		}
		return r;
}
	
function lnkTrans(s, sh)	{
	location.href = 'mailto:'+UnCryptMailto(s, sh);
}

function checkMail(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,5})$');
		res = (reg.test(s));
	}
	else {
		res = (s.search('@') >= 1 &&
			s.lastIndexOf('.') > s.search('@') &&
			s.lastIndexOf('.') >= s.length-5)
	}
	return(res);
}



function switchMO(pObj){
		
	if (pObj) {

		if (pObj.tagName=='IMG')
			obj = pObj;
		else
			obj = pObj.getElementsByTagName('IMG')[0];

		if (obj.src.indexOf("_over.")>0) {

			obj.src = obj.src.replace(/_over/,"");
		}	
		else {
			obj.src = obj.src.substr(0,obj.src.lastIndexOf("."))+'_over'+obj.src.substr(obj.src.lastIndexOf("."));
		
		}	
		
		tmp = Element.getParentNode(obj,8);
		obj2 = tmp.getElementsByTagName('IMG')[0];
		if (obj2 && obj2!=obj) {	
			if (obj2.src.indexOf("_over.")>0) 
				obj2.src = obj2.src.replace(/_over/,"");
			else	
				obj2.src = obj2.src.substr(0,obj2.src.lastIndexOf("."))+'_over'+obj2.src.substr(obj2.src.lastIndexOf("."));
		}
	}

	return true;
}

function showNav(obj,doOpen) {

	return;

	for (i=0;i<obj.getElementsByTagName('ul').length;i++) {
		tmp = obj.getElementsByTagName('ul')[i]; 
		if (tmp)
			if (doOpen==1)
				tmp.style.display='block';
			else
				tmp.style.display='none';	
	}

}

function showExpandable(obj,objId,toolbar,color) {
	if (!color)
		color = 'white';
		
		
	
	objArr = $$('#'+objId+' .listPlus');
	tmpLength = objArr.length;
	for (i=0;i<objArr.length;i++) {

		/*if (objArr[i].style.display=='block') {
			objArr[i].style.display='none';						
		}	
		else {
			objArr[i].style.display='block';				
		}*/	
		if (objArr[i].style.display=='none') {
			objArr[i].style.display='block';						
		}	
		else {
			objArr[i].style.display='none';				
		}		
	}
	
	objArr = $$('#'+objId+' .listPlusLast');				
	if (objArr.length) {
		//objArr[0].setAttribute('class','listPlusLastT');
		oldClass = objArr[0].className;

		newClass = oldClass.replace(/listPlusLast/,'listPlusLastT');
		objArr[0].setAttribute('class',newClass);
	
				
		j=0;
		for (i=0;i<objArr[0].childNodes.length;i++) {
			if (objArr[0].childNodes[i].nodeType==1 && objArr[0].childNodes[i].nodeName=='DIV')
				j++;

			if (j==2 && tmpLength>0)	{
				objArr[0].childNodes[i].style.display='block';
				break;
			}	
		}	
	}
	else {
		objArr = $$('#'+objId+' .listPlusLastT');				
		if (objArr.length) {		
			//objArr[0].setAttribute('class','listPlusLast');
			oldClass = objArr[0].className;
			newClass = oldClass.replace(/listPlusLastT/,'listPlusLast');
			objArr[0].setAttribute('class',newClass);			
			j=0;
			for (i=0;i<objArr[0].childNodes.length;i++) {
				if (objArr[0].childNodes[i].nodeType==1 && objArr[0].childNodes[i].nodeName=='DIV')
					j++;

				if (j==2)	{
					objArr[0].childNodes[i].style.display='none';
					break;
				}	
			}	
		}	
	}

			
	if ((obj.tagName=='IMG' && obj.src.indexOf('cross')>0) || obj.innerHTML == '-') {
		if (obj.src)
			obj.src = 'fileadmin/template/img/minus_'+color+'.jpg';
		else
			obj.innerHTML = '+';
		$(toolbar).style.display='block';
		$(toolbar+'Spacer').style.display='none';
		expanded[objId] = 1;
	}	
	else {
		if (obj.tagName=='IMG')
			obj.src = 'fileadmin/template/img/cross_'+color+'.jpg';
		else	
			obj.innerHTML = '-';
			
		$(toolbar).style.display='none';
		$(toolbar+'Spacer').style.display='block';
		expanded[objId] = -1;
	}			
	return;	
}

function getArchive (pageId,catId,tb,pg,container,cnt) {
	params = 'pageId='+pageId+'&tb='+tb+'&catId='+catId+'&pg='+pg+'&cnt='+cnt;
	archivePage = pg;
	new Ajax.Updater(container, "ajax/getArchive.php5", {parameters: params, method:"get",evalScripts:true,onComplete:function (req) {getArchiveNav(container,req,tb,cnt,catId,pageId,pg)}, onFailure:show_failure, onException:show_exception });		
	
	return;
}

function getArchiveNav (container,req,tb,rowCnt,catId,pageId,pg) {

	params = 'pageId='+pageId+'&tb='+tb+'&cnt='+rowCnt+'&pg='+pg+'&catId='+catId;
	new Ajax.Updater('', "ajax/getArchiveNav.php5", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {tmp = $('archiveNav').parentNode;$('archiveNav').parentNode.removeChild($('archiveNav'));new Insertion.Bottom(tmp,req.responseText);$('archiveNav').style.display='block';}, onFailure:show_failure, onException:show_exception });		
	
	return;
}

function  archiveSubmit (obj,maxPage,pageId,catId,tb,destObj,cnt) {
	if (!cnt)
		cnt = 10;
	if (!isNaN(parseInt(obj.firstChild.value)) && parseInt(obj.firstChild.value)>=1 && parseInt(obj.firstChild.value)<=maxPage) 
		getArchive(pageId,catId,tb,obj.firstChild.value,destObj,cnt);
	else {
		alert('Bitte geben Sie eine Zahl von 1 bis '+maxPage+' ein');
		obj.firstChild.value='';
	}
	return;
}

function showCommentContainer(id) {
		$('commentContainer').style.display='block';
		showAddComment(id);
}

function getComments (entryId,tb,pg,container,cnt) {
	commentView = pg;
	params = 'entryId='+entryId+'&tb='+tb+'&pg='+pg+'&cnt='+cnt;
	new Ajax.Updater(container, "ajax/getComments.php", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {newComment(container,req,entryId,tb,cnt,pg)}, onFailure:show_failure, onException:show_exception });		
	
	return;
}
function newComment (container,req,entryId,tb,rowCnt,pg) {


	params = 'entryId='+entryId+'&tb='+tb+'&cnt='+rowCnt+'&pg='+pg;
	new Ajax.Updater('', "ajax/getCommentNav.php", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {tmp = $('commentNav').parentNode;$('commentNav').parentNode.removeChild($('commentNav'));new Insertion.Bottom(tmp,req.responseText);$('commentNav').style.display='block';$('commentContainer').style.display='block';}, onFailure:show_failure, onException:show_exception });		


	return;
}


function sentComment(obj,cmtId) {
		//new Ajax.Updater(container, "ajax/addComment.php", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {}, onFailure:show_failure, onException:show_exception });		
}

function addComment(entryId,tb) {
	if (!$('cmtName'+entryId))
		nick = '';
	else
		nick = $F('cmtName'+entryId);	
		
	if (!$('cmtMail'+entryId))	
		email = '';		
	else
		email = $F('cmtMail'+entryId);	
	if ($F('cmtText'+entryId)=="Bitte geben Sie einen Namen und eine E-Mail Adresse an,\noder melden Sie sich an" || $F('cmtText'+entryId)=="") {
		alert('Bitte geben Sie einen Text ein'); 	
		return;
	}	
	if (nick == '' && email=='' && !$('clogged'))  
		alert ('Bitte geben Sie einen Namen oder eine E-Mail Adresse an, oder melden Sie sich an.');
	else {		
		txt = escape($F('cmtText'+entryId));	

		if (nick && email)
			params = 'entryId='+entryId+'&tb='+tb+'&email='+email+'&nick='+nick+'&txt='+txt;
		else if (nick)
			params = 'entryId='+entryId+'&tb='+tb+'&nick='+nick+'&txt='+txt;
		else 
			params = 'entryId='+entryId+'&tb='+tb+'&email='+email+'&txt='+txt;
			
		new Ajax.Updater('', "ajax/addComment.php5", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {checkCmtSuccess(req,entryId,tb)}, onFailure:show_failure, onException:show_exception });		
	}
}

function checkCmtSuccess(req,entryId,tb) {
	maxRowCnt = 3;
	if (req.responseText!='' && !isNaN(parseInt(req.responseText))) {
		if ($('cmtName'+entryId))
			$('cmtName'+entryId).value='';	
		if ($('cmtMail'+entryId))	
			$('cmtMail'+entryId).value='';	
		$('cmtText'+entryId).value='';	
		hideAddComment(entryId);	

		getComments(entryId,tb,-1,'commentList',maxRowCnt);
		window.location.hash='#comments';
		alert('Kommentar erfolgreich hinzugefügt');
		window.location.reload();
	}
	else {
		alert('Kommentar konnte nicht hinzugefügt werden.');
		
	}	
}



function hideAddComment(entryId) {
		$('addCmt'+entryId).style.display='none';
		if (!$('commentList').hasChildNodes())
			$('commentContainer').style.display='none';
}


function showAddComment(entryId) {
		$('addCmt'+entryId).style.display='block';
		params = '&entryId='+entryId;
		new Ajax.Updater('cmtAddFrm'+entryId, "ajax/getComment.php", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {}, onFailure:show_failure, onException:show_exception });		
		
}

function sendCommentReply(obj,pobj,cmtId,name,email) {
	if (!name)
		name='';
	if (!email)
		email='';		
	if (!name) {
		alert('Bitte geben Sie einen Namen ein.');
	}
	else {
	
		txt = obj.parentNode.parentNode.firstChild.value;
		if (!txt || txt=='')
			alert('Bitte geben Sie einen Text ein.');
		else {	
			params = '&cmtId='+cmtId+'&txt='+txt+'&name='+name+'&email='+email;
			new Ajax.Updater('', "ajax/addCommentReply.php", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {if (req.responseText) {tmp3 = 0; 	if ($('replLogin'+cmtId)) {tmp2 = $('replLogin'+cmtId).parentNode; $('replLogin'+cmtId).remove();} else {tmp2 = Element.nextSib(pobj.parentNode).firstChild;if (tmp2.nodeType!=1) tmp2 = tmp2.nextSibling;} for (i=0;i<tmp2.childNodes.length;i++) if (tmp2.childNodes[i].nodeType==1) tmp3++;  closeReplyForm(pobj,tmp3);addCommentReplyText(pobj,req.responseText);$('cmtNext_'+cmtId).style.display='none';if(tmp3>1) $('cmtPrev_'+cmtId).style.display='inline';else $('cmtPrev_'+cmtId).style.display='none';return false;} new Insertion.Bottom(pobj.parentNode.nextSibling.nextSibling.firstChild.nextSibling,req.responseText);}, onFailure:show_failure, onException:show_exception });		
		}
	}
}

function addCommentReplyText(obj,txt) {
	tmp = Element.nextSib(obj.parentNode);
	tmp2 = tmp.firstChild;
	if (tmp2.nodeType!=1)
		tmp2 = tmp2.nextSibling;
		
	tmp2.insert(txt.replace(/\\'/g,'\''));	
		

}
function addCommentReply(obj,cmtId) {
	params = '';
	new Ajax.Updater('', "ajax/getLogin.php5", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {if (req.responseText) addCommentReplyForm(obj,cmtId,req.responseText); else cmtReplyLogin(obj,cmtId)}, onFailure:show_failure, onException:show_exception });		
}

function addNewCommentReply(obj,cmtId) {
	Element.nextSib(obj.parentNode).style.display='block';
	obj.parentNode.style.display='none';
	tmp = Element.nextSib(obj.parentNode).getElementsByTagName('a')[0];
	tmp.onclick();
}


function cmtReplyLogin(obj,cmtId) {

	elemInp = document.createElement('input');
	elemInp.style.height='16px';
	elemInp.style.width='162px';
	elemInp.style.backgroundColor='#ffffff';
	elemInp.style.fontSize='11px';
	elemInp.style.lineHeight='11px';
	elemInp.style.fontFamily='Courier New';
	elemInp.style.border='0px';
	elemInp.style.padding='0px';
	elemInp.style.position = 'absolute';
	elemInp.style.top = '55px';		
	elemInp.style.left = '0px';
	elemInp.style.verticalAlign='baseline';
	//elemInp.style.marginTop='12px';
	elemInp.setAttribute('id','nameLogin'+cmtId);
	elemInp.setAttribute('maxlength',22);
	//elemInp.style.position = 'relative';
	elemInp.style.zIndex = 3;

	
	elemInp.value= '';
	
	elemInpImg = new Image();
	elemInpImg.src = 'fileadmin/template/img/comments/name.png';
	elemInpImg.style.zIndex = 4;
	elemInpImg.style.cursor = 'pointer';
	elemInpImg.style.position = 'absolute';
	elemInpImg.style.top = '55px';		
	elemInpImg.style.left = '0px';
	elemInpImg.style.height='16px';
	elemInpImg.style.width='160px';	
	elemInpImg.onclick=function () {
		this.style.zIndex=1;
		$('nameLogin'+cmtId).focus();
		return false;
	}

	elemInp2 = document.createElement('input');
	elemInp2.style.height='16px';
	elemInp2.style.width='162px';
	elemInp2.style.backgroundColor='#ffffff';
	elemInp2.style.fontSize='11px';
	elemInp2.style.lineHeight='11px';
	elemInp2.style.fontFamily='Courier New';
	elemInp2.style.border='0px';
	elemInp2.style.padding='0px';
	//elemInp2.style.marginTop='5px';
	elemInp2.style.position = 'absolute';
	elemInp2.style.top = '77px';		
	elemInp2.style.left = '0px';
	elemInp2.style.verticalAlign='baseline';
	elemInp2.value= '';
	elemInp2.style.marginBottom='16px';
	//elemInp2.style.position = 'relative';
	elemInp2.style.zIndex = 3;		
	elemInp2.setAttribute('id','emailLogin'+cmtId);
	
	elemInpImg2 = new Image();
	elemInpImg2.src = 'fileadmin/template/img/comments/email.png';
	elemInpImg2.style.zIndex = 4;
	elemInpImg2.style.cursor = 'pointer';
	elemInpImg2.style.position = 'absolute';
	elemInpImg2.style.top = '77px';		
	elemInpImg2.style.left = '0px';
	elemInpImg2.style.height='16px';
	elemInpImg2.style.width='160px';	

	elemInpImg2.onclick=function () {
		this.style.zIndex=1;
		$('emailLogin'+cmtId).focus();
		return false;
	}	
	
	elemText = new Image();
	//elemText.src = 'fileadmin/temp/86f59a8709d85937598559a8d839f88a.png';
	elemText.src = 'fileadmin/template/img/comments/KommentarKommentierenText.gif';
	
	elemSend = new Image();
	elemSend.style.position = 'absolute';
	elemSend.style.top = '98px';		
	elemSend.style.left = '0px';	
	//elemSend.src = 'fileadmin/temp/26db949b3aafed297f9230191a6a02d3.png';
	elemSend.src = 'fileadmin/template/img/comments/KommKommentierenSenden.gif';
	elemSend.onclick=function () {
		if (!$F('nameLogin'+cmtId))
			alert('Bitte geben Sie einen Namen ein');
		else
			addCommentReplyForm(obj,cmtId,$F('nameLogin'+cmtId),$F('emailLogin'+cmtId));
	}	


	elemCancel = new Image();
	//elemCancel.src = 'fileadmin/temp/dadaa9daa4c9b309be015d898160b034.png';
	elemCancel.src = 'fileadmin/template/img/comments/KommKommentierenAbbrechen.gif';
	elemCancel.style.position = 'absolute';
	elemCancel.style.top = '98px';		
	elemCancel.style.left = '85px';
	elemCancel.onclick=function () {	

		closeReplyForm(obj,0);
		tmp = Element.nextSib(obj.parentNode);
		tmp = tmp.firstChild;
		if (tmp.nodeType!=1)
			tmp = tmp.nextSibling;
		j=0;	
		for (i=0;i<tmp.childNodes.length;i++)	 {
			if (tmp.childNodes[i].nodeType==1)
				j++;
		}

		if (j>=2)					
			$('cmtNext_'+cmtId).style.display='inline';
		else
			$('cmtNext_'+cmtId).style.display='none';
	
		$('cmtPrev_'+cmtId).style.display='none';
		
	}	
	
	elemDivButtons = document.createElement('div');
	elemDivButtons.style.marginTop = '2px';
	elemDivButtons.appendChild(elemSend);
	elemDivButtons.appendChild(elemCancel);
	
	elemDiv = document.createElement('div');
	elemDiv.setAttribute('id','replLogin'+cmtId);
	elemDiv.style.position = 'relative';
	
	elemDiv.appendChild(elemText);
	elemDiv.appendChild(elemInp);
	elemDiv.appendChild(elemInpImg);
	elemDiv.appendChild(elemInp2);
	elemDiv.appendChild(elemInpImg2);
	elemDiv.appendChild(elemDivButtons);
	
	tmp = obj.parentNode.nextSibling;
	if (tmp.nodeType!=1)
		tmp = tmp.nextSibling;
		
	tmp2 = tmp.childNodes[0];	
	if (tmp2.nodeType!=1)
		tmp2 = tmp2.nextSibling;	
	for (i=0;i<tmp2.childNodes.length;i++) {
		if (tmp2.childNodes[i].nodeType==1)	
			tmp2.childNodes[i].style.display='none';
	}
	tmp2 = tmp2.nextSibling;	
	if (tmp2.nodeType!=1)
		tmp2 = tmp2.nextSibling;
	tmp2.style.display='none';	
	
	if ($('commentReply'+cmtId+'_1'))
		new Insertion.Bottom($('commentReply'+cmtId+'_1').parentNode,elemDiv);
	else {
		tmp = Element.nextSib(obj.parentNode).firstChild;
		if (tmp.nodeType!=1)
			tmp = tmp.nextSibling;

		new Insertion.Bottom(tmp,elemDiv);	
	}
	
	obj.style.visibility='hidden';
	
}

function closeReplyForm(obj,showEntry) {

	tmp = obj.parentNode.nextSibling;
	if (tmp.nodeType!=1)
		tmp = tmp.nextSibling;	

	
	tmp = tmp.getElementsByTagName('div')[0]	
	for (i=tmp.childNodes.length-1;i>=0;i--) {
		if (tmp.childNodes[i].nodeType==1)	{
			tmp.removeChild(tmp.childNodes[i]);
			break;
		}	
	}
	
	tmp2 = tmp.nextSibling;
	if (tmp2.nodeType!=1)
		tmp2 = tmp2.nextSibling;	
	tmp2.style.display='block';	
	
	
	
	if (showEntry==0) {	
		for (i=0;i<tmp.childNodes.length;i++) {
			if (tmp.childNodes[i].nodeType==1)	{					
				tmp.childNodes[i].style.display='block';
				break;
			}	
		}
		if (tmp2.getElementsByTagName('span')[0].innerHTML != '00') {
			tmp2.getElementsByTagName('span')[0].innerHTML = '01';
		}
		else {
			tmp = obj.parentNode.parentNode.parentNode;
			tmp.style.display='none';
			tmp = Element.prevSib(tmp);
			tmp.style.display='block';
		}
	}
	else {
		active = showEntry;
		if (showEntry<10)
			showEntry = '0'+showEntry;
		tmp2.getElementsByTagName('span')[0].innerHTML = showEntry;
		tmp2.getElementsByTagName('span')[1].innerHTML = showEntry;
		
		
	}
	
	obj.style.visibility='visible';

}

function addCommentReplyForm(obj,cmtId,nick,email) {
	if (!email)
		email = '';
	
	elemTA = document.createElement('textarea');
	elemTA.style.height='56px';
	elemTA.style.width='163px';
	elemTA.style.backgroundColor='#ffffff';
	elemTA.style.fontSize='11px';
	elemTA.style.lineHeight='11px';
	elemTA.style.fontFamily='Courier New';
	elemTA.style.overflow='hidden';
	elemTA.style.border='0px';
	elemTA.style.padding='0px';
	elemTA.style.marginLeft='-2px';
	elemTA.style.verticalAlign='baseline';
	
	elemTA.onkeyup=function () {
		CountRows(this);
	}
	
	elemSend = new Image();
	//elemSend.src = 'fileadmin/temp/26db949b3aafed297f9230191a6a02d3.png';
	elemSend.src = 'fileadmin/template/img/comments/KommKommentierenSenden.gif';
	elemSend.onclick=function () {
		
		sendCommentReply(this,obj,cmtId,nick,email);		
	}	
	
	elemCancel = new Image();
	//elemCancel.src = 'fileadmin/temp/dadaa9daa4c9b309be015d898160b034.png';
	elemCancel.src = 'fileadmin/template/img/comments/KommKommentierenAbbrechen.gif';
	elemCancel.style.marginLeft='55px';
	elemCancel.onclick=function () {		
		closeReplyForm(obj,0);		
		j=0;	
		for (i=0;i<tmp.childNodes.length;i++)	 {
			if (tmp.childNodes[i].nodeType==1)
				j++;
		}
		if (j>=2)	
			$('cmtNext_'+cmtId).style.display='inline';
		else	
			$('cmtNext_'+cmtId).style.display='none';
		$('cmtPrev_'+cmtId).style.display='none';
		if ($('replLogin'+cmtId))
			$('replLogin'+cmtId).remove();
	}	
	
	elemText = document.createTextNode(nick); 

	
	elemDivName = document.createElement('div');
	elemDivName.style.marginTop = '20px';
	elemDivName.style.fontSize='11px';
	elemDivName.style.lineHeight='11px';
	elemDivName.style.fontFamily='Courier New';	
	elemDivName.appendChild(elemText);
	
	elemDivButtons = document.createElement('div');
	elemDivButtons.style.marginTop = '2px';
	elemDivButtons.appendChild(elemSend);
	elemDivButtons.appendChild(elemCancel);
	
	elemDiv = document.createElement('div');
	
	
	elemDiv.appendChild(elemTA);
	elemDiv.appendChild(elemDivName);
	elemDiv.appendChild(elemDivButtons);

	tmp = obj.parentNode.nextSibling;
	if (tmp.nodeType!=1)
		tmp = tmp.nextSibling;
		
	tmp2 = tmp.childNodes[0];	
	if (tmp2.nodeType!=1)
		tmp2 = tmp2.nextSibling;	
	for (i=0;i<tmp2.childNodes.length;i++) {
		if (tmp2.childNodes[i].nodeType==1)	
			tmp2.childNodes[i].style.display='none';
	}
	tmp2 = tmp2.nextSibling;	
	if (tmp2.nodeType!=1)
		tmp2 = tmp2.nextSibling;
	tmp2.style.display='none';
	

	if ($('commentReply'+cmtId+'_1'))
		new Insertion.Bottom($('commentReply'+cmtId+'_1').parentNode,elemDiv);
	else {
		tmp = Element.nextSib(obj.parentNode).firstChild;
		if (tmp.nodeType!=1)
			tmp2 = tmp.nextSibling;
		else
			tmp2 = tmp;
		new Insertion.Bottom(tmp2,elemDiv);	
	}
	
	obj.style.visibility='hidden';
	
}


function editComment(obj,entryId) {
		
		
		if (editingCmt!=0) {
			if (editingCmt!=entryId)
				alert('Sie bearbeiten bereits einen Beitrag. Schliessen Sie diesen zuvor ab.');
			return;
		}	
			
		editingCmt = entryId;
		
		prnt = Element.getParentNode(obj,3);
		div = Element.nextSib(prnt,2);
		
		text = div.innerHTML;
		
		ta = document.createElement('textarea');
		ta.style.width = '463px';
		ta.style.height = (parseInt(prnt.parentNode.offsetHeight)-47)+'px';
		ta.style.border = '1px solid #000000';
		ta.setAttribute('id','taEdit'+entryId); 
		ta.innerHTML = text;
		
		
		saveText = document.createTextNode('speichern');
		sav = document.createElement('a');
		sav.href = '#';
		sav.onclick = function() {
			saveEditedComment(this,entryId);
			return false;
		}
		sav.appendChild(saveText);
		
		cancelText = document.createTextNode('abbrechen');
		cancel = document.createElement('a');
		cancel.href = '#';
		cancel.onclick = function() {
			$('taEdit'+entryId).parentNode.innerHTML = $('taEdit'+entryId).parentNode.firstChild.innerHTML;
			editingCmt = 0;
			return false;
		}
		cancel.style.marginLeft = '20px';
		cancel.appendChild(cancelText);	
		
		
		divTmp = document.createElement('div');
		divTmp.style.display = 'none';
		divTmp.innerHTML = text;
		
		div.innerHTML = '';
		div.appendChild(divTmp);
		div.appendChild(ta);
		div.appendChild(sav);
		div.appendChild(cancel);
		
		return;
}

function saveEditedComment(obj,entryId) {
	text = $F('taEdit'+entryId);
	params = 'entryId='+entryId+'&text='+text;
	new Ajax.Updater('', "ajax/editComment.php5", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {confirmEditComment(req,entryId);}, onFailure:show_failure, onException:show_exception });		
}

function confirmEditComment(req,entryId) {
	$('taEdit'+entryId).parentNode.innerHTML = $F('taEdit'+entryId);
	if (req.responseText) 
		alert('Eintrag erfolgreich gespeichert.');
	editingCmt = null;
}


function deleteComment(obj,entryId) {		
	if (confirm('Möchen Sie den Beitrag wirklich löschen?')) {
		params = 'entryId='+entryId;	
		new Ajax.Updater('', "ajax/deleteComment.php5", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {if (req.responseText) {	if (!expanded['commentList'] && $('commentExpand')) $('commentExpand').onclick();	if ($('commentView'+commentView)) $('commentView'+commentView).onclick();}}, onFailure:show_failure, onException:show_exception });					
	}
	return;
}

function CountRows(fld){
	old = document.getElementById('commentReplyDummy').innerHTML;
	document.getElementById('commentReplyDummy').innerHTML=fld.value.replace(/\n/g,"\n<br>");

	if (parseInt(document.getElementById('commentReplyDummy').offsetHeight)>56) {	
		fld.value = old.replace(/<br>/g,'');
		if ((fld.value.lastIndexOf('\n')+1)==fld.value.length)
			fld.value = fld.value.substr(0,fld.value.lastIndexOf('\n'));
		document.getElementById('commentReplyDummy').innerHTML = old;
	}

}

function addToReadingList(entryId,tb,obj) {
	params = 'entryId='+entryId+'&tb='+tb;
	new Ajax.Updater('', "ajax/addToReadingList.php", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {addToReadingListResponse(req,obj);}, onFailure:show_failure, onException:show_exception });		
}

function addToReadingListResponse(req,obj) {
	if (parseInt(req.responseText)>0) 
		alert('Artikel erfolgreich hinzugefügt'); 
	else if (parseInt(req.responseText)==0) {
		isActive = Object();
		
		if ($(containerOld)) {
			objOld = $(containerOld).parentNode.getElementsByTagName('IMG')[0];
			objOld.src = objOld.src.replace(/_active/,"");	
			
		}
			
		if ($('errorReadListExist').style.display=='none'){

			$('addToReadingList').style.height=parseInt($('addToReadingList').style.height)+115+'px';
			minimizeToolbox();
			$('errorReadListExist').style.display='block';
			containerOld = $('errorReadListExist');

			isActive = obj;
		}
		else {
			$('addToReadingList').style.height=parseInt($('addToReadingList').style.height)-115+'px';
			$('errorReadListExist').style.display='none';	

			obj.src = obj.src.replace(/_active/,"");			
		}
	}	
	else {
		isActive = Object();
		
		if ($(containerOld)) {
			objOld = $(containerOld).parentNode.getElementsByTagName('IMG')[0];
			objOld.src = objOld.src.replace(/_active/,"");			
		}
			
		if ($('errorReadListLogin').style.display=='none'){
			$('addToReadingList').style.height=parseInt($('addToReadingList').style.height)+115+'px';
			minimizeToolbox();
			$('errorReadListLogin').style.display='block';
			containerOld = $('errorReadListLogin');

			isActive = obj;
			
			tmp = $$('div.cmtReplyContainer');
			for (i=0;i<tmp.length;i++) {
				tmp[i].style.display='none';
			}	

		//	$('toolbox').style.display='none';			
		}
		else {
			$('addToReadingList').style.height=parseInt($('addToReadingList').style.height)-115+'px';
			$('errorReadListLogin').style.display='none';	

			obj.src = obj.src.replace(/_active/,"");		
			
			tmp = $$('div.cmtReplyContainer');
			for (i=0;i<tmp.length;i++) {
				tmp[i].style.display='block';
			}	

			//$('toolbox').style.display='block';
		
		}

	}	
	
	
}

function getSearchPage (pg,container,cnt,maxPage,day,month,year,search_str,assoc,cat,author) {
	searchPage = pg;
	params = '&pg='+pg+'&cnt='+cnt+'&day='+day+'&month='+month+'&year='+year+'&search_str='+search_str+'&category='+cat+'&author='+author;
	if (assoc)
		params += '&assoc='+assoc;
		
	new Ajax.Updater(container, "ajax/getSearch.php5", {parameters: params, method:"post",evalScripts:true, onComplete:function (req) {getSearchNav(params);}, onFailure:show_failure, onException:show_exception });		
	
	return;
}

function getSearchNav (params) {
	
	//params = 'pageId='+pageId+'&tb='+tb+'&cnt='+rowCnt+'&pg='+pg;
	new Ajax.Updater('', "ajax/getSearchNav.php5", {parameters: params, method:"post",evalScripts:true, onComplete:function (req) {tmp = $('searchNav').parentNode;$('searchNav').parentNode.removeChild($('searchNav'));new Insertion.Bottom(tmp,req.responseText);$('searchNav').style.display='block';}, onFailure:show_failure, onException:show_exception });		
	
	return;
}

function  searchGoToPage (obj,maxPage,destObj,cnt,day,month,year,search_str,assoc,cat,author) {

	if (!isNaN(parseInt(obj.firstChild.value)) && parseInt(obj.firstChild.value)>=1 && parseInt(obj.firstChild.value)<=maxPage) 
		getSearchPage(obj.firstChild.value,destObj,cnt,maxPage,day,month,year,search_str,assoc,cat,author);
	else {
		alert('Bitte geben Sie eine Zahl von 1 bis '+maxPage+' ein');
		obj.firstChild.value = '';
	}
	return;
}

function  commentGoToPage (obj,maxP,entryId,tb,destObj) {

	if (!isNaN(parseInt(obj.firstChild.value)) && parseInt(obj.firstChild.value)>=1 && parseInt(obj.firstChild.value)<=maxP) 
		getComments(entryId,tb,parseInt(obj.firstChild.value),destObj,3);
	else {
		alert('Bitte geben Sie eine Zahl von 1 bis '+maxP+' ein');
		obj.firstChild.value = '';
	}
	return;
}

function showCommentReply(nr,direct) {

	/*obj = document.getElementById(objStr);
	prntObj = obj.parentNode;
	for (i=0;i<prntObj.childNodes.length;i++) {
		if (prntObj.childNodes[i].tagName == 'DIV') {
			prntObj.childNodes[i].style.display = 'none';
			
		}	
	}
	
	obj.style.display = 'block';*/
	active = -1;

	obj = document.getElementById('commentReply'+nr+'_1');
	prntObj = obj.parentNode;

	for (i=0;i<prntObj.childNodes.length;i++) {
		if (prntObj.childNodes[i].tagName == 'DIV') {

			if(prntObj.childNodes[i].style.display!='none') {
				prntObj.childNodes[i].style.display = 'none';

				if (prntObj.childNodes[i+direct].nodeType==1) {
					prntObj.childNodes[i+direct].style.display = 'block';
					
					if (direct<0) {
						tmpNr = parseInt($('cmtNr_'+nr).innerHTML,10)-1;
					
						if (tmpNr<10)
							tmpNr = '0'+tmpNr;
			
						if (i>=2) 
							if (!prntObj.childNodes[i-2])
								$('cmtPrev_'+nr).style.display='none';
						if (tmpNr=='01') {	
							$('cmtPrev_'+nr).style.display='none';							
						}	
						$('cmtNext_'+nr).style.display='inline';	
						$('cmtNr_'+nr).innerHTML = tmpNr;			
					}	
					else {
						if (!prntObj.childNodes[i+2])
							$('cmtNext_'+nr).style.display='none';	
						
						tmpNr = parseInt($('cmtNr_'+nr).innerHTML,10)+1;					
						if (tmpNr<10)
							tmpNr = '0'+tmpNr;
							
						$('cmtNr_'+nr).innerHTML = tmpNr;	
						
						$('cmtPrev_'+nr).style.display='inline';		
					}
				}						
				else {
					if (direct<0) {
						prntObj.childNodes[i+direct].previousSibling.style.display = 'block';
						tmpNr = parseInt($('cmtNr_'+nr).innerHTML,10)-1;
						if (tmpNr<10)
							tmpNr = '0'+tmpNr;
						
						$('cmtNr_'+nr).innerHTML = tmpNr;	
						if (i<=3)
							$('cmtPrev_'+nr).style.display='none';
						$('cmtNext_'+nr).style.display='inline';	
					}	
					else {							
						prntObj.childNodes[i+direct].nextSibling.style.display = 'block';
						
						if (i>=(prntObj.childNodes.length-4))
							$('cmtNext_'+nr).style.display='none';
						tmpNr = parseInt($('cmtNr_'+nr).innerHTML,10)+1;
						
						if (tmpNr<10)
							tmpNr = '0'+tmpNr;			
							
						$('cmtNr_'+nr).innerHTML = tmpNr;																		
						$('cmtPrev_'+nr).style.display='inline';
						
					}	
				}
			
				active = i;
				break;
				
			}	
			
		}	
	}
	
	j=k=0;
	if (active<0) {
		for (i=0;i<prntObj.childNodes.length;i++) {
			if (prntObj.childNodes[i].tagName == 'DIV') {
				j++;	
				if(j==2) {
					prntObj.childNodes[k].style.display = 'none';
					
					if (prntObj.childNodes[i].nodeType==1)
						prntObj.childNodes[i].style.display = 'block';
					else {
						prntObj.childNodes[i].nextSibling.style.display = 'block';
					}
					$('cmtPrev_'+nr).style.display='inline';
					tmpNr = parseInt($('cmtNr_'+nr).innerHTML,10)+1;
					if (tmpNr<10)
						tmpNr = '0'+tmpNr;							
					$('cmtNr_'+nr).innerHTML = tmpNr;					
					break;

				}
				k=i;

			}	
		}	
	
	}
		
	
}


function getPressPage (pageId,tb,pg,container,cnt) {
	params = 'pageId='+pageId+'&tb='+tb+'&pg='+pg+'&cnt='+cnt;
	pressPage = pg;
	new Ajax.Updater(container, "ajax/getPressPage.php", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) { getPressNav(tb,cnt,pageId,pg);	},	onFailure:show_failure, onException:show_exception });		

	return;
}

function getPressNav (tb,rowCnt,pageId,pg) {

	params = 'pageId='+pageId+'&tb='+tb+'&cnt='+rowCnt+'&pg='+pg;
	new Ajax.Updater('', "ajax/getPressNav.php", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {tmp = $('pressNav').parentNode;$('pressNav').parentNode.removeChild($('pressNav'));new Insertion.Bottom(tmp,req.responseText);$('pressNav').style.display='block';}, onFailure:show_failure, onException:show_exception });		
	
	return;
}





function  pressGoToPage (obj,maxPage,pageId,tb,destObj) {

	if (!isNaN(parseInt(obj.firstChild.value)) && parseInt(obj.firstChild.value)>=1 && parseInt(obj.firstChild.value)<=maxPage) 
		getPressPage(pageId,tb,obj.firstChild.value,destObj,maxPage);
	else {
		alert('Bitte geben Sie eine Zahl von 1 bis '+maxPage+' ein');
		obj.firstChild.value = '';
	}
	return;
}
function getReadingListPage (pageId,tb,pg,container,cnt) {
	params = 'pageId='+pageId+'&tb='+tb+'&pg='+pg+'&cnt='+cnt;
	readingPage = pg;
	new Ajax.Updater(container, "ajax/getReadingListPage.php", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {}, onFailure:show_failure, onException:show_exception });		
	
	return;
}

function  readingListGoToPage (obj,maxPage,pageId,tb,destObj) {

	if (!isNaN(parseInt(obj.firstChild.value)) && parseInt(obj.firstChild.value)>=1 && parseInt(obj.firstChild.value)<=maxPage) 
		getReadinglistPage(pageId,tb,obj.firstChild.value,destObj,maxPage);
	else {
		alert('Bitte geben Sie eine Zahl von 1 bis '+maxPage+' ein');
		obj.firstChild.value = '';
	}
	return;
}
function showCalCat(obj,direction){
	obj= obj.parentNode.parentNode;
	obj.style.display='none';
	if (direction>0) {
		if (obj.nextSibling.nodeType!=1)
			obj = obj.nextSibling;
		obj.nextSibling.style.display='block';	
	}
	else {
		if (obj.previousSibling.nodeType!=1)
			obj = obj.previousSibling;
		obj.previousSibling.style.display='block';	
	}
}

function showCalTab(obj){
	objPrnt= obj.parentNode.parentNode;
	for (i=0;i<objPrnt.childNodes.length;i++) {
		objDiv = objPrnt.childNodes[i];
		for (j=0;j<objDiv.childNodes.length;j++) {
			if (objDiv.childNodes[j].nodeType==1)
				objDiv.childNodes[j].style.zIndex=0;
		}
	}	
	objDiv = obj.parentNode.getElementsByTagName('div');
	for (j=0;j<objDiv.length;j++) {
			objDiv[j].style.zIndex=3;
	}	
}


function showCalCatAll(cat){
	objList = $('day_list');
	

	for (k=0;k<objList.childNodes.length;k++) {
		objPrnt = objList.childNodes[k];
		l=0;
		doReset = -1;
		for (i=0;i<objPrnt.childNodes.length;i++) {
			objDiv = objPrnt.childNodes[i];
			
			for (j=0;j<objDiv.childNodes.length;j++) {
				if (objDiv.childNodes[j].nodeType==1) {				
					objDiv.childNodes[j].style.zIndex=0;
					if (l==0)
						doReset=i;
						
					if (l==cat)
						objDiv.childNodes[j].style.zIndex=3;								
				}	
			}
			if (objDiv.nodeType==1) 	
				l++;			
		}	

		
		if (doReset>=0){
			l=0;
			for (i=0;i<objPrnt.childNodes.length;i++) {
				objDiv = objPrnt.childNodes[i];
				if (objDiv.nodeType==1) {	 
					for (j=0;j<objDiv.childNodes.length;j++) {
						if (objDiv.childNodes[j].nodeType==1) {				
							if (l==0)
								objDiv.childNodes[j].style.zIndex=3;	

						}	
					}				
					l++;	
				}				
			}
			
		}
	}
}

function showToolboxContainer(container) {
	minimizeToolbox();
	if ($(container+'Container') && container+'Container'!=containerOld) {
		$(container+'Container').style.display='block';
		var tmpHeight = 0;
		for (i=0;i<$(container+'Container').parentNode.childNodes.length;i++) {
			if ($(container+'Container').parentNode.childNodes[i].nodeType==1)
				tmpHeight+=parseInt($(container+'Container').parentNode.childNodes[i].offsetHeight);
		}
		tmp = $(container+'Container').getElementsByTagName('INPUT');
		for (i=0;i<tmp.length;i++) {			
			tmp[i].value = '';
		}
		tmp = $(container+'Container').getElementsByTagName('IMG');
		for (i=0;i<tmp.length;i++) {			
			tmpId = tmp[i].getAttribute('id');
			if (tmpId && tmpId.indexOf('_first')>0)
				tmp[i].style.zIndex = 4;
		}		
		tmp = $(container+'Container').getElementsByTagName('TEXTAREA');
		for (i=0;i<tmp.length;i++) {
			tmp[i].value = '';
		}		
		$(container+'Container').parentNode.style.height=tmpHeight+'px';
		
		
		obj = $(container+'Container').parentNode.getElementsByTagName('IMG')[0];
		isActive = obj;

		if ($(containerOld)) {
			obj = $(containerOld).parentNode.getElementsByTagName('IMG')[0];
			obj.src = obj.src.replace(/_active/,"");			
		}
		else if (noContainerOld!='' && $(noContainerOld)) {
			noContainerOld.src = noContainerOld.src.replace(/_active/,"");		
			noContainerOld = '';		
		}
		
		containerOld = container+'Container';
		if ($('recommend') && container!='recommend') {
			$('toolboxExtended').style.display='none';
			$('minimizeToolbox').style.display='block';
		}	
		else if ($('toolboxExtended') && container!='recommend') {
			$('toolboxExtended').style.display='none';
			//$('minimizeToolbox').style.display='block';
			$('minimizeToolbox').style.display='block';
		}		
		else if ($('minimizeToolboxExtended')) {
			$('minimizeToolboxExtended').style.display='block';
		}			
		else {
			$('minimizeToolbox').style.display='block';
		}
		tmp = $$('div.cmtReplyContainer');

		for (i=0;i<tmp.length;i++) {
			tmp[i].style.display='none';
		}		
	}
	else
		containerOld = '';
}

function minimizeToolbox() {
	$('loginContainer').style.display='none';
	$('loginContainer').parentNode.style.height='30px';
	$('bookmarkContainer').style.display='none';
	$('bookmarkContainer').parentNode.style.height='30px';	
	
	if ($('recommendContainer')) {
		$('recommendContainer').style.display='none';
		$('recommendContainer').parentNode.style.height='30px';	
		
		$('toolboxExtended').style.display='block';			
	}
	else if ($('toolboxExtended')) {
		$('toolboxExtended').style.display='block';				
	}
	
	tmp = $$('div.cmtReplyContainer');

	for (i=0;i<tmp.length;i++) {
		tmp[i].style.display='block';
	}	
	if ($('errorLogin').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-136+'px';		
	if ($('errorRemind').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-106+'px';			
	if ($('confirmRemind').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-151+'px';				
	$('errorLogin').style.display='none';
	$('errorPwd').style.display='none';
	$('errorNick').style.display='none';
	$('errorRemind').style.display='none';	
	$('confirmRemind').style.display='none';
	$('errorMyReadList').style.display='none';		
	$('errorMail').style.display='none';		

	/*tmp  = $('toolboxForm').getElementsByTagName('li');
	for (i = 0;i<tmp.length;i++) {
		tmp2 = tmp[i].getElementsByTagName('div');
		if (tmp2.length) {
			tmp2[0].style.display='none';
			tmp2[0].parentNode.style.height='30px';
		}
	}*/
	$('minimizeToolbox').style.display='none';
	if ($('minimizeToolboxExtended'))
		$('minimizeToolboxExtended').style.display='none';
	isActive = null;
}


function doLogin(obj) {

	if ($('errorLogin').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-136+'px';		
	if ($('errorRemind').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-106+'px';		
	$('errorRemind').style.display='none';
	$('email_first').style.zIndex='4';
	$('email_field').value='';
	
	if ($('confirmRemind').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-151+'px';		

	$('errorLogin').style.display='none';
	$('errorPwd').style.display='none';
	$('errorNick').style.display='none';
	$('errorMail').style.display='none';	
	params = $(obj.parentNode.parentNode).serialize();
	new Ajax.Updater('', "ajax/doLogin.php5", {parameters: params, method:"get",evalScripts:true, onComplete:function (req) {if (req.responseText) loginCommit(req); else showLoginError();}, onFailure:show_failure, onException:show_exception });		
}

function loginCommit(req) {
	$('userstatus').getElementsByTagName('div')[0].innerHTML = 'Hallo '+req.responseText;
	minimizeToolbox();
	$('logout').style.display='block';
	$('myprofile').style.display='block';
	$('register').style.display='none';
	
	$('login').style.display='none';
	if ($('errorLogin').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-136+'px';		
	if ($('errorRemind').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-106+'px';			
	if ($('confirmRemind').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-151+'px';				
	$('errorLogin').style.display='none';
	$('errorPwd').style.display='none';
	$('errorNick').style.display='none';
	$('errorMail').style.display='none';
	rl = $('myReadingList').getElementsByTagName('a')[0];
	rl.removeAttribute('onclick');
	rl.setAttribute('href','index.php5?page=20');
}

function showLoginError() {
	if ($('errorLogin').style.display=='none')
		$('login').style.height=parseInt($('login').style.height)+136+'px';
	$('errorLogin').style.display='block';
	$('errorPwd').style.display='block';
	$('errorNick').style.display='block';
	/*if (parseInt($('login').style.height)<310)
		$('login').style.height=parseInt($('login').style.height)+136+'px';*/
}

function showRemindError() {
	if ($('errorRemind').style.display=='none')
		$('login').style.height=parseInt($('login').style.height)+106+'px';
	$('errorRemind').style.display='block';
	$('errorMail').style.display='block';

}

function showMyReadingListError(obj) {
	isActive = Object();
	
	if ($(containerOld)) {
		objOld = $(containerOld).parentNode.getElementsByTagName('IMG')[0];
		objOld.src = objOld.src.replace(/_active/,"");	
		
	}
		
	if ($('errorMyReadList').style.display=='none'){
		$('myReadingList').style.height=parseInt($('myReadingList').style.height)+106+'px';
		minimizeToolbox();
		$('errorMyReadList').style.display='block';
		containerOld = $('errorMyReadList');
		obj = obj.getElementsByTagName('IMG')[0];
		isActive = obj;
		//obj.src = obj.src.substr(0,obj.src.lastIndexOf("."))+'_active'+obj.src.substr(obj.src.lastIndexOf("."));
		
		tmp = $$('div.cmtReplyContainer');
		for (i=0;i<tmp.length;i++) {
			tmp[i].style.display='none';
		}	
		if ($('toolboxExtended'))
			$('toolboxExtended').style.display='none';	

		
	}
	else {
		$('myReadingList').style.height=parseInt($('myReadingList').style.height)-106+'px';
		$('errorMyReadList').style.display='none';	
		
		obj = obj.getElementsByTagName('IMG')[0];
		obj.src = obj.src.replace(/_active/,"");			
		tmp = $$('div.cmtReplyContainer');
		for (i=0;i<tmp.length;i++) {
			tmp[i].style.display='block';
		}	
		if ($('toolboxExtended'))
			$('toolboxExtended').style.display='block';			
	}


}

function lostPwd(obj) {
	if ($('errorLogin').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-136+'px';		
	if ($('errorRemind').style.display=='block')
		$('login').style.height=parseInt($('login').style.height)-106+'px';			
	$('errorLogin').style.display='none';
	$('errorPwd').style.display='none';
	$('errorNick').style.display='none';
	$('errorMail').style.display='none';	
	$('errorRemind').style.display='none';

	params = 'email='+$F('email_field');
	new Ajax.Updater('', "ajax/doRemindPwd.php", {parameters:params, method:"get",evalScripts:true, onComplete:function (req) {confirmRemind(req);}, onFailure:show_failure, onException:show_exception });		


	return false;
}

function confirmRemind(req) {
	if (req.responseText==1) {
		if ($('confirmRemind').style.display=='none')
			$('login').style.height=parseInt($('login').style.height)+151+'px';			
		$('confirmRemind').style.display='block';	
	}
	else
		showRemindError();
}

function recommendMessage(pid,id) {
		$('errorMailYour').style.display='none';
		$('errorMailReceiver').style.display='none';
		$('errorRecommend').style.display='none';
		obj = $('recommend').getElementsByTagName('img')[0];
		obj.src = obj.src.replace(/_active/,"");

		ym = $F('youremail_field');
		rm = $F('receiveremail_field');
		m = $F('message_field');
		
		params = 'ym='+ym+'&rm='+rm+'&m='+m+'&pid='+pid+'&id='+id;
		new Ajax.Updater('', "ajax/sendRecommendation.php", {parameters:params,method:"get",evalScripts:true, onComplete:function (req) {resp = req.responseText; if (resp==1) {obj = $('recommend').getElementsByTagName('img')[0];obj.src = obj.src.replace(/_active/,"");showToolboxContainer('recommend');alert('Nachricht erfolgreich verschickt.');} else if (resp==0) alert('Nachricht konnte nicht verschickt werden');else if (resp==-1) alert('Nachricht wurde bereits verschickt'); else if (resp==-2) alert('Zu viele Nachrichten verschickt')}, onFailure:show_failure, onException:show_exception });		

}

function showRecommendMessageError(isReceiverMail,isYourMail) {
	if ($('errorRecommend').style.display=='none')
		$('recommend').style.height=parseInt($('recommend').style.height)+106+'px';
	$('errorRecommend').style.display='block';
	if (!isYourMail)
		$('errorMailYour').style.display='block';
	else
		$('errorMailYour').style.display='none';
	if (!isReceiverMail)	
		$('errorMailReceiver').style.display='block';
	else
		$('errorMailReceiver').style.display='none';
		//$('errorMessage').style.display='block';

}


function doLogout(obj) {
	new Ajax.Updater('', "ajax/doLogout.php", {method:"get",evalScripts:true, onComplete:function (req) {if (req.responseText) $('userstatus').getElementsByTagName('div')[0].innerHTML = 'Erfolgreich abgemeldet';$('logout').style.display='none';$('myprofile').style.display='none';$('register').style.display='block';$('login').style.display='block';}, onFailure:show_failure, onException:show_exception });		
}



function showPDF (entryId,tb,pageId) {
	params = 'tb='+tb+'&id='+entryId+'&page='+pageId;
	window.open('functions/createPDF.php?'+params,'','');
	//new Ajax.Updater('', "functions/createPDF.php", {parameters:params,method:"get",evalScripts:true, onFailure:show_failure, onException:show_exception });		
}




function activateTop(obj) {
	if (isActiveTop) 
		isActiveTop.src = isActiveTop.src.replace(/_active/,"");	
	
	isActiveTop = obj;
	isActiveTop.src = isActiveTop.src.replace(/_over/,"_active");	
	//obj.src = obj.src.replace(/_active/,"");	
}



function chgCalCol(obj,colNew,colOld) {
	var oldStr = '_'+colOld+'';
		
	obj.src = obj.src.replace(oldStr,"_"+colNew);	

}






var FHM_FORM_checkboxActive = "fileadmin/template/img/cbActive.gif";		// checkbox checked
var FHM_FORM_checkboxInactive = "fileadmin/template/img/cbInActive.gif";		// checkbox unchecked
var FHM_FORM_radioActive = "fileadmin/template/img/radioActive.gif";		// checkbox checked
var FHM_FORM_radioInactive = "fileadmin/template/img/radioInActive.gif";		// checkbox unchecked

function show_exception( requestObject, ex) {
	alert("Keine AJAX-Anfrage an " + requestObject.url + " moeglich: " + ex);
}

function show_failure( requestObject ) {
	alert("Error from Server:" + requestObject.statusText);
}
