/* #############################################
	# Module: TextBild-Popup (2Spalten)
*/
function showPopup(file,width,height,maxW)
{	file=file.src;	
	file=file.split("w__");
	file=file[1];
	
	newwidth=width;
	newheight=height;
	
	ratio=maxW/newwidth;
		
	if (newwidth>maxW)
	{	newwidth=maxW;
		newheight=height*ratio;
	}

	if (document.attachEvent)
	{	newwidth=newwidth+20;
		newheight=newheight+20;
	}
	var x=window.open('index.php?rex_resize='+newwidth+'w__'+file, 'bigPrev', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+(newwidth+16)+',height='+(newheight+16));
}	
/*	#############################################*/http://redaxo.gn2-demo.de/index.php?rex_resize=200w__testbild_gross.jpg


Behaviour.addLoadEvent 
(	function()
	{	
	
	
	
		//Hide all sub pages
		var swappers=document.getElementsBySelector('.bildswapper');
		
		for (i=0;i<swappers.length;i++)
		{	swappics=swappers[i].getElementsByTagName('DIV');
			
			//Filter out divs which arent areas.
			var counter=0;
			swappics2=new Array();
			for (j=0;j<swappics.length;j++)
			{	if(swappics[j].className!="bilddesc")
				{	swappics2[counter]=swappics[j];
					counter++;
				}
			}
			swappics=swappics2;
			
			//Loop through subpics
			for (j=0;j<swappics.length;j++)
			{	swapperclass=swappics[j].className;
				swapperclass=swapperclass.split(' ');
				
				desc=swappics[j].getElementsByTagName('DIV')[0];
				desc.style.display="none";
				
				if (swapperclass[0]=="bild")
				{	thepic=swappics[j].getElementsByTagName('IMG')[0];
					var img=document.createElement("IMG");
					img.setAttribute('src',thepic.getAttribute('src'));
					img.style.cursor="pointer";
					img.className="swapthumb s"+j;
					swappers[i].appendChild(img);
				}
			}
			var newDesc=document.createElement("SPAN");
			newDesc.style.display="block";
			newDesc.innerHTML=swappers[i].getElementsByTagName('DIV')[0].getElementsByTagName('DIV')[0].innerHTML;;
			swappers[i].appendChild(newDesc);
			Behaviour.apply();
		}
		
	}
);

var Rules = {
        '.extern' : function(el)
	{	el.onclick = function()
		{    this.setAttribute('target','_blank');
		}
	},
	'a.print' : function(el)
	{	el.onclick = function()
		{    this.setAttribute('href','javascript:window.print();');
		}
	},
	'.swapthumb' : function(el)
	{	el.onclick = function()
		{	x=this.className;
			x=x.split(' ');x=x[1];
			x=x.split('s');x=x[1];						
			thepics=this.parentNode.getElementsByTagName('DIV');
			var counter=0;
			thepics2=new Array();
			for (i=0;i<thepics.length;i++)
			{	if(thepics[i].className!="bilddesc")
				{	thepics2[counter]=thepics[i];
					counter++;
				}
			}
			thepics=thepics2;
			
			for (i=0;i<thepics.length;i++)
			{	if (i!=x)
				{	thepics[i].style.display="none";
				}
			}
			desc=thepics[x].getElementsByTagName('DIV')[0];
			thepics[x].parentNode.getElementsByTagName('SPAN')[0].innerHTML=desc.innerHTML;
			thepics[x].style.display="block";
		},
		el.onmouseover = function()
		{	this.className=this.className+" bildswaphover";
		},
		el.onmouseout = function()
		{	x=this.className;
			x=x.split(' ');
			this.className=x[0]+" "+x[1];
		}
	}
};

Behaviour.register(Rules);

