/**
	Checks if a "unique id" cookie exists, otherwise create it
**/
	var x = 0;
	var y = 0;
	
	if (document.cookie.indexOf("uniqueid=") == -1) {
		var uniqueid = "uniqueid=" + (Math.floor(Math.random()*9999999999999)).toString(36);
		uniqueid += "; path=/";
		document.cookie=uniqueid;
	}

	function online(handle,prefix) {
		var countPic = new Image();
		var countDate = new Date();
		var pre = "uniqueid=";
		var start = document.cookie.indexOf("uniqueid=");
		var unique = "";
		if (start > -1) {
			var end = document.cookie.indexOf(";", start + pre.length);
			if (end == -1) {
				end = document.cookie.length;
			}
			unique = unescape(document.cookie.substring(start + pre.length, end));
		}
		var picName = prefix+"/usertrack"+handle+"/"+Math.round(countDate.getTime()/1000)+"_"+Math.round(Math.random()*9999999999999)+"_"+unique+".gif";
		countPic.src = picName;
	}

	function jumpTo(nameform,namelem) {
		var FormObj = document.forms[nameform].elements[namelem];
		var nr = FormObj.selectedIndex;
		var hyperref = FormObj.options[nr].value;
		if (hyperref.indexOf("-1") == -1 && hyperref.substring(0,1) == "/") {
			document.location.href=hyperref;
		}
	}

/**
	Used for pic rollovers
**/
	function BildWechsel(Bildname,Bildobjekt) {
		window.document.images[Bildname].src = Bildobjekt;
	}

/**
	Used for color rollovers
**/
	function changeTd(element, className)
	{
		//alert('setting element'+element.name+': '+className);
		
		element.className = className;
	}
	
/**
	Used for image rollovers
**/
	function changeImage(elementId, src)
	{
		document.getElementById(elementId).src = src;
	}
	
/**
	Create a tool bar within the templates (used for author mode only)
**/
	function makeBar(what,nr) {
		kriterium = document.getElementById('cticons'+nr).style.clip;
		if (kriterium == "rect(0px 525px 40px 0px)") {
			slideBar(525,nr,"left");
		}
		else {
			slideBar(44,nr,"right");
		}
	}

	function slideBar(what,nr,dir) {
		document.getElementById("opener"+nr).style.visibility="hidden";
		if (dir == "left") { what = what-37; }
		if (dir == "right") { what = what+37; }
		if (what >= 44 && what <= 525) {
			document.getElementById('cticons'+nr).style.clip="rect(0px "+what+"px 40px 0px)";
			self.setTimeout("slideBar("+what+",'"+nr+"','"+dir+"')",1);
		}
		else {
			if (what == 7) {
				document.getElementById("opener"+nr).style.visibility="visible";
			}
		}
	}

	function openOpener(page,ctobid,what,ctsite,prefix,anc) {
		if (checkOpener()) {
			self.opener.document.location.href=prefix+"/ctadmin/"+page+"?ctobid="+ctobid+"&"+what+"="+ctsite;
			self.opener.top.frames['leftFrame'].document.location.href=prefix+"/ctadmin/tree.jsp?ctobid="+anc+"&ctsite="+ctsite+"#"+anc;
			self.opener.focus();
		}
	}

	function checkOpener() {
		try {
			if (self.opener.document.location.href.indexOf("ctadmin")==-1) {
				alert("This action cannot be performed!\nReason: Try to access admin from popup!");
				return false;
			}
			else if (self.opener.closed == false) { return true; }
			else {
				alert("This action cannot be performed!\nReason: Opening window has been closed!");
				return false;
			}
		}
		catch (e) {
			alert("This action cannot be performed!\nReason: Opening window has been moved or reloaded!");
		}
	}

	function moveMe(what,ob1,ob2,prefix) {
		if (checkOpener()) {
			self.opener.document.location.href=prefix+"/ctadmin/list.jsp?"+what+"="+ob1+"&ctobid="+ob2;
			self.document.location.reload();
			self.focus();
		}
	}

	function setCookie(what,val) {
		document.forms[what].elements['myCookie'].value=val;
		document.forms[what].submit();
	}

	function askMe(what2,what,prefix) {
		if (checkOpener()) {
			var elem =(what==what2)?"page":"page element";
			var asking =window.confirm("Do you really wish to delete this "+elem+"?");
			if (asking == true) self.opener.document.location.href=prefix+"/ctadmin/list.jsp?ctobid="+what+"&ctdelete="+what2;
			self.location.reload();
			self.focus();
		}
	}

/**
	Function to create a pop up window
**/
	function ctpopup(datei) {
		var newWind = window.open(datei, "ctolpopup", "width=562,height=500,resizable=no,menubar=no,scrollbars=yes,status=yes");
		newWind.focus();
	}

/**
	Function to open a location within the pop up opener (if existing)
**/
	function ctopener(datei) {
		try {
			self.opener.document.location.href = datei;
			self.opener.focus();
		}
		catch (e) {
			self.open(datei);
		}
	}
	
	function checkRad() {
		formObj = document.forms['kontakt'];
		/*for (i=0;i<formObj.elements['anliegen'].length;i++) {
			if(formObj.elements['anliegen'][i].checked == true) break;
		}
		if (i == 0) formObj.elements['infomat'].disabled = false;
		else {
			formObj.elements['infomat'].disabled = true;
			formObj.elements['infomat'].checked = false;
		}*/
	}

	function iFrameSize(){
		ns6=(navigator.vendor=='Netscape6');
		var add=(ns6)?24:0;
		if(typeof(document.all)=="object")add=4;
		if(window.opera)add=8;
		try {
			//document.getElementById('ifr').style.height='10px';
			h=(ns6)?parent.frames['ifr'].document.body.offsetHeight:parent.frames['ifr'].document.body.scrollHeight;
			document.getElementById('ifr').style.height=h+add+800+'px';
		}
		catch (e) {
			// alert(e.description);
		}
	}
	
	function addBook(title,url) {
		if (window.sidebar) {
			window.sidebar.addPanel(title, url,""); 
		}
		else if( document.all ) {
			window.external.AddFavorite( url, title);
		}
		else if( window.opera && window.print) {
			return true;
		}
	}
	
	function handleLayer(layName,type) {
		if (type) {
			document.getElementById("sh"+layName).style.visibility='visible';
			document.getElementById("sh"+layName).style.display='block';
			var width = document.getElementById("im"+layName).width;
			if(width > 500)
				document.getElementById("im"+layName).width = 500;
		}
		if (!type) {
			document.getElementById("sh"+layName).style.visibility='hidden';
			document.getElementById("sh"+layName).style.display='none';
		}
	}
	
		function updateSearchTip(e) {
			x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
			y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
			if (SearchTip != null) {
				SearchTip.style.left = (x - 135) + "px";
				SearchTip.style.top  = (y - 70) + "px";
			}
		}
		
		function showSearchTip(id) {
			SearchTip = null;
			document.onmousemove = updateSearchTip;
			SearchTip = document.getElementById(id);
			SearchTip.style.display = "block"
			SearchTip = document.getElementById(id);
			if (SearchTip != null) {
				SearchTip.style.left = (x - 135) + "px";
				SearchTip.style.top  = (y - 70) + "px";
			}
		}
		
		function hideSearchTip() {
			SearchTip.style.display = "none";
		}

		
		function formSubmit(form, paramId, paramValue) {
			if(paramId != "") {
				document.getElementById(paramId).value = paramValue;
			}
			form.submit();		
		}

