/**
	Checks if a "unique id" cookie exists, otherwise create it
**/
	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;
	}

/**
	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)" || 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=620,height=610,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+'px';
		}
		catch (e) {	}
	}
	
	function addBook(title,url) {
		title = decodeURI(title);
		title = title.replace(/\+/," ");
		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;
		}
	}
	
	/**
	*
	*	Onlineregistrierung: �berpr�fung ob zweiter radiobutton aktiv ist.
	*	Dann textfeld enabled.
	*
	**/
	function checkIsPartner(element)
	{
		if(element.checked == true && element.id == "radio2")
		{
			document.forms.onlinereg.partnerno.disabled = false;
		}
		else
		{
			document.forms.onlinereg.partnerno.disabled = true;
		}
		element.focus();
	}
	
	function initDatePicker(idArray, withTime){
		if(initDatePicker.arguments && initDatePicker.arguments.length == 1 && initDatePicker.arguments.length != 2){
			if( !isArray(initDatePicker.arguments[0]) ){
				if(initDatePicker.arguments[0]){
					withTime = true;
				}
				idArray = false;
			}
		}
		if(!idArray){
		jQuery(function()
	        {
				if(withTime){
					jQuery('#startBegin').datePicker({startDate:'01.01.1996',appendTime:true});
					jQuery('#startEnd').datePicker({startDate:'01.01.1996',appendTime:true});
					jQuery('#endBegin').datePicker({startDate:'01.01.1996',appendTime:true});
					jQuery('#endEnd').datePicker({startDate:'01.01.1996',appendTime:true});
				}
				else{
					jQuery('#startBegin').datePicker({startDate:'01.01.1996'});
					jQuery('#startEnd').datePicker({startDate:'01.01.1996'});
					jQuery('#endBegin').datePicker({startDate:'01.01.1996'});
					jQuery('#endEnd').datePicker({startDate:'01.01.1996'});
				}
	        });
		}
		else {
			jQuery(function() {
	        	for(var i = 0; i < idArray.length; i++){
	        		if(withTime){
	        			jQuery(idArray[i]).datePicker({startDate:'01.01.1996', appendTime:true});
	        		}
	        		else {
	        			jQuery(idArray[i]).datePicker({startDate:'01.01.1996'});
	        		}
	        	}
		    });
		}
	}
