function wbild(id,config)
 {
	var btab=config.Bilder;
	var akt=true;
	var bi=0;
	var start=config.Zufall?Math.floor(Math.random()*btab.length):0;
	var b=document.getElementById(id+'-img');
	var a=document.getElementById(id+'-a');
	if(b&&a)
	{
		a.href=btab[start].Link||'#';
		b.src="../../MEDIA/"+btab[start].Bild;
	}
	if ( config.Intervall )
	{
		YUI().use("node","transition",function(Y) {
			var a0=Y.one(a);
			var b0=Y.one(b);
			var a1=a0.next();
			var b1=a1.one('img');
			a1.setStyle('opacity',0);
			var dauer=parseInt(config.Dauer,10) || 0.5;
			if ( dauer>100 )
				dauer/=1000;
			window.setInterval(function(){
				var ain=akt?a1:a0;
				var aout=akt?a0:a1;
				var bin=akt?b1:b0;
				akt=!akt;
				var startalt=start;
				start=config.Zufall?Math.floor(Math.random()*(btab.length-1)):(start+1)%btab.length;
				if ( start==startalt )
					start=btab.length-1;
				bin.once('load',function(){
					aout.transition({opacity:0,duration:dauer},function(){
						this.setStyle('visibility','hidden');
					 });
					ain.setStyle('opacity',0);
					ain.setStyle('visibility','visible');
					ain.transition({opacity:1,duration:dauer});
				 });
				bin.set("src",'../../MEDIA/'+btab[start].Bild);
				ain.set("href",btab[start].Link||'#');
			 },config.Intervall);
		 });
	}
 }

cms_inittab.push(function()
 {
	var RE=/~b|~e|~~|~lt;|~gt;|~tilde;|~amp;|~q|~u/g;
	var rpl = {
		'~b':'<',
		'~e':'>',
		'~~':'~',
		'~lt;':'<',
		'~gt;':'>',
		'~tilde;':'~',
		'~u':'&',
		'~amp;':'&',
		'~q':'"'
	 }
	function decodeConfig(config)
	 {
		return config.replace(RE,function(a){return rpl[a];})
	 }
	function getconfig(e)
	 {
		var confstr=e.currentTarget.getAttribute("config");
		var config={};
		try
		{
			config=Y.JSON.parse(decodeConfig(confstr));
		}
		catch (ex)
		{
			config={error:ex};
		}
		
		return config;
	 }
	
	YUI().use("node","event","selector-css3","json","overlay", function(Y) {
		if ( Y.one(".dyn-tooltip[config]") )
		{
			var tt=new Y.Overlay({visible:false,width:120,zIndex:1});
			tt.render();
			tt.get("contentBox").addClass("tooltip");
			Y.delegate("mouseover",function(e) {
				var el=e.currentTarget;
				var fn=null,ret=null;
				var config;
				el.set("title","");
				function showtooltip(html)
				 {
					tt.set("bodyContent",html);
					tt.set("align",{node:config.el||el,points:config.points||["tl","bl"]});
					if ( config.width )
						tt.set("width",config.width);
					tt.show();
				 }
				
				try
				{
					config=Y.JSON.parse(decodeConfig(el.getAttribute("config")));
					ret=config.html||config.title;
					if ( config.fun )
					{
						try
						{
							fn=new Function("config","calltooltip",config.fun);
							ret=fn.call(el,config,showtooltip)
						}
						catch (ex)
						{
						}
					}
					if ( ret!==false  )
						showtooltip(ret||config.html);
				}
				catch (ex)
				{
					Y.log('CATCH: mouseover: '+el.get("tagName"));
				}
				
			 },document,".dyn-tooltip[config]");
			Y.delegate("mouseout",function(e) {
				Y.log('mouseout');
				tt.hide();
			 },document,".dyn-tooltip[config]");
		}
	 });
 });

