

	function toggleDiv( sDivId )
	{
		obj = document.getElementById( sDivId );
		if( obj )
		{
			if( obj.style.display == "none" )
			{
				obj.style.display = "";
			}
			else
			{
				obj.style.display = "none";
			}
			
			// Save state
			xajax_cClient.setUserSetting( "toggleDiv", sDivId, obj.style.display );
		}
		
		return false;
	}
	
	
	
	var dlgBoxOnCloseFunc;
	function closeDlgBox()
	{
		if( typeof dlgBoxOnCloseFunc == "function" )
		{
			dlgBoxOnCloseFunc();
		}
		return hm();
	}
	
	function DlgBoxSetCloseHandler( func )
	{
		dlgBoxOnCloseFunc = func;
	}
	
	function showDlgBox( sTitle, sSrc, iHeight, iWidth )
	{
		
		// All divs for displaying 'DlgBox' are defined in "canvas.screen" 
		
		document.getElementById("divDlgBoxCnavas").style.height 	= (iHeight + 55) + "px";
		document.getElementById("divDlgBoxCnavas").style.width 		= iWidth + "px";
		
		document.getElementById("divDlgBoxTitle").style.width 		= (iWidth - 50) + "px";
		document.getElementById("divDlgBoxTitle").innerHTML 		= sTitle;
		
		document.getElementById("ifDlgContent").style.height 		= iHeight + "px";
		document.getElementById("ifDlgContent").style.width 		= iWidth + "px";
		document.getElementById("ifDlgContent").src 				= sSrc;
		
		sm( "divDlgBox", iHeight, iWidth );
		
		return false;
	}

	function systemMessage( sInfoBox )
	{
		oSysMsgBox = document.getElementById( "_systemMessage_" );
		oSysMsgBox.innerHTML = sInfoBox;
		oSysMsgBox.style.display = "inline";
		window.setTimeout("hideSystemMesssage()", 2500);
	}
	
	function hideSystemMesssage()
	{
		document.getElementById( "_systemMessage_" ).style.display = "none";
	}
	
	
		
	function $c(elemName, properties) 
	{
			        var elem = document.createElement(elemName);
			        if (typeof properties == 'undefined' || !properties)
			                return elem;
			       
			        for (var property in properties) {
			                if (typeof properties[property] == typeof {}) {
			                        for (var member in properties[property]) {
			                                elem[property][member] = properties[property][member];
			                        }
			                } else {
			                        var setProperty = property;
			                        if (setProperty == 'forid')
			                                setProperty = 'htmlFor';
			                        elem[setProperty] = properties[property];
			                }
			        }
			       
			        return elem;
		}
	
	
	function showPopup()
	{
		initmb();
		sm( "testDiv", 200, 50 );
	}
	
	
	// Modal Dialog Box
	// copyright 8th July 2006 by Stephen Chapman
	// http://javascript.about.com/
	// permission to use this Javascript on your web page is granted
	// provided that all of the code in this script (including these
	// comments) is used without any alteration
	function pageWidth() 
	{
			return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
	}
	
	function pageHeight() 
	{
		return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
	}
	
	function posLeft() 
	{
		return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;
	}
	
	function posTop() 
	{
		return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;
	}
	
	function $(x)
	{
		return document.getElementById(x);
	}
	
	function scrollFix()
	{
		var obol=$('ol');
		obol.style.top=posTop()+'px';
		obol.style.left=posLeft()+'px';
	}
	
	function sizeFix()
	{
		var obol=$('ol');
		obol.style.height=pageHeight()+'px';
		obol.style.width=pageWidth()+'px';
	}
	
	function kp(e)
	{
		ky=e?e.which:event.keyCode;
		if(ky==88||ky==120)hm();
		return false;
	}
	function inf(h)
	{
		tag=document.getElementsByTagName('select');
		for(i=tag.length-1;i>=0;i--)
		{
			tag[i].style.visibility=h;
		}
		
		/*
		tag=document.getElementsByTagName('iframe');
		for(i=tag.length-1;i>=0;i--)
		{
			tag[i].style.visibility=h;
		}
		*/
		
		tag=document.getElementsByTagName('object');
		for(i=tag.length-1;i>=0;i--)
		{
			tag[i].style.visibility=h;
		}
	}
	
	function sm( obl, wd, ht )
	{
		initmb();
		
		var h='hidden';
		var b='block';
		var p='px';
		var obol=$('ol'); 
		var obbxd = $('mbd');
		var cont = $(obl);
		
		
		obbxd.innerHTML = cont.innerHTML;
		obol.style.height=pageHeight()+p;
		obol.style.width=pageWidth()+p;
		obol.style.top=posTop()+p;
		obol.style.left=posLeft()+p;
		obol.style.display=b;
		
		var tp=posTop()+((pageHeight()-ht)/2)-12;
		var lt=posLeft()+((pageWidth()-wd)/2)-12;
		var obbx=$('mbox');
		obbx.style.top=(tp<0?0:tp)+p;
		obbx.style.left=(lt<0?0:lt)+p;
		obbx.style.width=wd+p;
		obbx.style.height=ht+p;
		inf(h);
		obbx.style.display=b;
		
		return false;
	}
	
	function hm()
	{
		var v='visible';
		var n='none';
		$('ol').style.display=n;
		$('mbox').style.display=n;
		$('mbox').innerHTML = "";
		inf(v);
		document.onkeypress='';
		
		return false;
	}
	
	function initmb()
	{
		if( !document.getElementById("mbd") )
		{
			var ab='absolute';
			var n='none';
			var obody=document.getElementsByTagName('body')[0];
			var frag=document.createDocumentFragment();
			var obol=document.createElement('div');
			obol.setAttribute('id','ol');
			obol.style.display=n;
			obol.style.position=ab;
			obol.style.top=0;
			obol.style.left=0;
			obol.style.zIndex=998;
			obol.style.width='100%';
			frag.appendChild(obol);
			
			var obbx=document.createElement('div');
			obbx.setAttribute('id','mbox');
			obbx.style.display=n;
			obbx.style.position=ab;
			obbx.style.zIndex=999;
			
			var obl=document.createElement('span');
			obbx.appendChild(obl);
			
			var obbxd=document.createElement('div');
			obbxd.setAttribute('id','mbd');
			obl.appendChild(obbxd);
			frag.insertBefore(obbx,obol.nextSibling);
			obody.insertBefore(frag,obody.firstChild);
			
			
			
			window.onscroll = scrollFix; 
			window.onresize = sizeFix;
		}
	}
	
	

	
	function showInfo( sInfoBox )
	{
		if( document.getElementById( "_info_box_"+ sInfoBox ) )
		{
			document.getElementById( "quickInfo" ).innerHTML = document.getElementById( "_info_box_"+ sInfoBox ).innerHTML;
		}
		else
		{
			document.getElementById( "quickInfo" ).innerHTML = sInfoBox;
		}
		document.getElementById( "kasten2_bg" ).style.display = "";
	}
	
	function clearInfo()
	{
		document.getElementById( "kasten2_bg" ).style.display = "none";
		document.getElementById( "quickInfo" ).innerHTML = ""; 
	}
	
	var active = new Array();
	var slider = new Array();
	var slider_block = new Array();
	var pr_sel_block = false;

	/******************************************************************************/

	/*
	document.observe("dom:loaded", function() {


	});
	*/

	/******************************************************************************/

	function AddNewTarget(span) {
	    span.className.match(/entry_(\d+)/);
	    var cnt = parseInt(RegExp.$1);

	    var li_link = document.getElementById('li_link_'+ cnt);
	    var li_text = document.getElementById('li_text_'+ cnt);

	    cnt++;
	    var new_li_link = li_link.cloneNode(true);
	    new_li_link.id = 'li_link_'+ cnt;
	    new_li_link.getElementsByTagName('input')[0].name = "Link_"+ cnt;
	    new_li_link.getElementsByTagName('input')[0].id = "Link_"+ cnt;
	    new_li_link.getElementsByTagName('input')[0].value = "";

	    var new_li_text = li_text.cloneNode(true);
	    new_li_text.id = 'li_text_'+ cnt;
	    new_li_text.getElementsByTagName('input')[0].name = "Text_"+ cnt;
	    new_li_text.getElementsByTagName('input')[0].id = "Text_"+ cnt;
	    new_li_text.getElementsByTagName('input')[0].value = "";

	    li_link.parentNode.appendChild(new_li_link);
	    li_text.parentNode.appendChild(new_li_text);

	    span.className = "entry_"+ cnt;
	}

	function change_active(linkziel_id, name) {
	    active[linkziel_id] = name;
	}

	function add_slider(linkziel_id,options) {
	    options = options.evalJSON(true);
	    var myslider = false;
	    var myhandler = false;
	    var field_name = false;

	    options.each(function(row)
	    {
	    	if( linkziel_id )
	    	{
	    		field_name = row.field +'_'+ linkziel_id;
	    	}
	    	else
	    	{
	    		field_name = row.field;
	    	}
	    	

	    	myslider = $('slider_'+ field_name);
	        myhandler = myslider.down('.handle');

	        slider[field_name] = new Control.Slider(myhandler, myslider, {
	            axis:'horizontal',
	            range: $R(row.range_min,row.range_max),
	            sliderValue: row.default_value,
	            field_name: field_name,
	            default_value: row.default_value,
	            onSlide: function(value) {
	            	if(!slider_block[this.field_name]) {
	                    $(this.field_name).value = Math.round(value);
	                }
	            }
	        });

	        if(!$F(field_name)) {$(field_name).value = row.default_value;}
	        else {slider[field_name].setValue(parseInt($F(field_name)),0);}

	        $(field_name).observe('change',function(e){
	        	slider_block[this.id] = true;
	        	var value = parseInt(this.value);
	            var max = slider[this.id].maximum;
	            var min = slider[this.id].minimum;
	            var default_value = slider[this.id].options.default_value;

	            if(isNaN(value)) {value = default_value; $(this.id).value = value;}
	            else if(value > max) {value = max; $(this.id).value = value;}
	            else if(value < min) {value = min; $(this.id).value = value;}

	            slider[this.id].setValue(value,0);
	            slider_block[this.id] = false;
	        });

	    });
	}

	function add_pr_sel_observer(linkziel_id) {
		
		var objNameSel = 'ul_pr_sel_'+ linkziel_id;
		var objNameCk = 'ul_pr_chk_'+ linkziel_id;
		
		
	    $( objNameSel ).select('.pr_sel').invoke('observe','mouseover',function(e){
	        var checkbox = $(this.id.split('sel_').join(''));
	        this.style.backgroundColor = '#E8C173';
	    });

	    $( objNameSel ).select('.pr_sel').invoke('observe','mouseout',function(e){
	    	var checkbox = $(this.id.split('sel_').join(''));
	        if(checkbox.checked) {this.style.backgroundColor = '#E66E3B';}
		    else {this.style.backgroundColor = '#CCCCCC';}
	    });

	    $( objNameSel ).select('.pr_sel').invoke('observe','click',function(e){
	    	var checkbox = $(this.id.split('sel_').join(''));
	        pr_sel_block = true;
	        checkbox.click();

	        var chk = false;
	        var id = this.id;
	        id = id.replace(/^sel_pr_\d+?_/,"");
	        $( 'ul_pr_chk_'+ id ).select('.pr_chk').each(function(obj){
	            if(obj.checked) {chk=true;}
	        });

	        if(!chk) {$('errmsg_pr_'+ id).show();}
	        else {$('errmsg_pr_'+ id).hide();}

	        pr_sel_block = false;
	    });

	    $( objNameCk ).select('.pr_chk').invoke('observe','click',function(e){
	        if(!pr_sel_block) {
	            if(this.checked) {
	                $('sel_'+ this.id).style.backgroundColor = '#E66E3B';
	            } else {
	                $('sel_'+ this.id).style.backgroundColor = '#CCCCCC';
	            }

	            var chk = false;
	            var id = this.id;
	            id = id.replace(/^pr_\d+?_/,"");
	            $('ul_pr_chk_'+ id).select('.pr_chk').each(function(obj){
	                if(obj.checked) {chk=true;}
	            });

	            if(!chk) {$('errmsg_pr_'+ id).show();}
	            else {$('errmsg_pr_'+ id).hide();}
	        }
	    });

	}


	function add_yahoo_sel_observer(linkziel_id) {

	    $('ul_yahoo_sel_'+ linkziel_id).select('.yahoo_sel').invoke('observe','mouseover',function(e){
	        var checkbox = $(this.id.split('sel_').join(''));
	        this.style.backgroundColor = '#E8C173';
	    });

	    $('ul_yahoo_sel_'+ linkziel_id).select('.yahoo_sel').invoke('observe','mouseout',function(e){
	    	var checkbox = $(this.id.split('sel_').join(''));
	        if(checkbox.checked) {this.style.backgroundColor = '#E66E3B';}
		    else {this.style.backgroundColor = '#CCCCCC';}
	    });

	    $('ul_yahoo_sel_'+ linkziel_id).select('.yahoo_sel').invoke('observe','click',function(e){
	    	var checkbox = $(this.id.split('sel_').join(''));
	        pr_sel_block = true;
	        checkbox.click();

	        var chk = false;
	        var id = this.id;
	        id = id.replace(/^sel_yahoo_\d+?_/,"");
	        $('ul_yahoo_chk_'+ id).select('.yahoo_chk').each(function(obj){
	            if(obj.checked) {chk=true;}
	        });

	        if(!chk) {$('errmsg_yahoo_'+ id).show();}
	        else {$('errmsg_yahoo_'+ id).hide();}

	        pr_sel_block = false;
	    });

	    $('ul_yahoo_chk_'+ linkziel_id).select('.yahoo_chk').invoke('observe','click',function(e){
	        if(!pr_sel_block) {
	            if(this.checked) {
	                $('sel_'+ this.id).style.backgroundColor = '#E66E3B';
	            } else {
	                $('sel_'+ this.id).style.backgroundColor = '#CCCCCC';
	            }

	            var chk = false;
	            var id = this.id;
	            id = id.replace(/^yahoo_\d+?_/,"");
	            $('ul_yahoo_chk_'+ id).select('.yahoo_chk').each(function(obj){
	                if(obj.checked) {chk=true;}
	            });

	            if(!chk) {$('errmsg_yahoo_'+ id).show();}
	            else {$('errmsg_yahoo_'+ id).hide();}
	        }
	    });

	}
	
	var selAllIds = new Array();	
	function setSelAllIds()
	{
		if( arguments.length > 0 )
		{
			selAllIds = arguments[0].split( "," );
		}
	}
	
	function selAll( iSetStatus )
	{
	
		for (var i = 0; i < selAllIds.length; i++) 
		{
			Obj = document.getElementById( "selId[]_"+ selAllIds[i] );
			
			if( Obj && Obj != "undefined" )
			{
				if( iSetStatus == 0 )
				{
					Obj.checked = false;
				}
				else if( iSetStatus == 1 )
				{
					Obj.checked = true;
				}
				else if( iSetStatus == 2 )
				{
					Obj.checked = (( Obj.checked )? false : true );
				}
			}
		}
		
		return false;
	}
	
	var oLastHoveredDiv = null;
	function hover( oDiv, bHighlightIt )
	{
		if( oLastHoveredDiv )
		{
			oLastHoveredDiv.style.background = "none";
		}

		if( bHighlightIt )
		{
			oDiv.style.background="#efefef";
			oLastHoveredDiv = oDiv;
		}
		else
		{
			oDiv.style.background="none";
			oLastHoveredDiv = null;
		}
		
		
	}
	
	
	function findPos( obj ){
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
			return [curleft,curtop];
		}
	}
	
	function showToolTip( obj, sToolTipText ){
		width = obj.offsetWidth;
		height = obj.offsetHeight;
		coords = findPos( obj );
		x = coords[0];
		y = coords[1];
		obj_x = x + width;
		obj_y = y - 30;
		document.getElementById('ajaxToolTipContent').innerHTML = document.getElementById('toolTip'+sToolTipText).innerHTML;
		document.getElementById('ajaxToolTip').style.left = obj_x+"px";
		document.getElementById('ajaxToolTip').style.top = obj_y+"px";
		document.getElementById('ajaxToolTip').style.display = "block";
	}
	
	function hideToolTip(){
		document.getElementById('ajaxToolTip').style.display = "none";
	}
