		/**
		 * FishEye-Class.
		 *
		 * @author Steffen Friedrich, steffen.friedrich@pingping.ag
		 * @copy pingping, www.pingping.ag
		 **/
		function FishEyeR(_config)
		{
			this.declareMethods = FishEyeR_declareMethods;
			this.declareMethods();
			
			this.config = _config;
			
			// todo: default this.config.steps
			if(!this.validate()) return;
			
			this.started = 0;
			this.settles = -1;
			this.focuses = -1;
			this.currentSteps = 0;
			this.images = new Object();
			this.images["-"] = new Array();
			
			this.startUp();
						
			
			// for ie6... 8c]
			this.refresh();
		}
		
		function FishEyeR_declareMethods()
		{	this.validate = FishEyeR_validate;
			this.startUp = FishEyeR_startUp;
			this.determineSize = FishEyeR_determineSize;
			this.onmouseover = FishEyeR_onmouseover;
			this.onmouseout = FishEyeR_onmouseout;
			this.onerror = FishEyeR_onerror;
			this.refresh = FishEyeR_refresh;
			this.resize = FishEyeR_resize;
			this.sizomatic = FishEyeR_sizomatic;
			this.pathidate = FishEyeR_pathidate;
			this.settle = FishEyeR_settle;
			this.focus = FishEyeR_focus;
		}
		
		function FishEyeR_onerror(a,b,c)
		{	this.failed = 1;
			if(this.oldOE) return this.oldOE(a,b,c);
		}
		
		function FishEyeR_onmouseout(a,b,c)
		{	if(this.proxyFish) this.proxyFish.onmouseout(a,b,c);
			else if(this.config.eye.settles!=this.number)
			{	this.config.eye.focuses=-1;
				this.config.eye.settles = this.number;
				window.setTimeout(this.config.eye.config.accessName+'.settle('+this.number+')',this.config.eye.config.delay);
			}
			if(this.oldOU) return this.oldOU(a,b,c);
		}
		
		function FishEyeR_onmouseover(a,b,c)
		{	if(this.proxyFish) this.proxyFish.onmouseover(a,b,c);
			else if(this.config.eye.focuses!=this.number)
			 {	this.config.eye.settles=-1;
			 	this.config.eye.focuses=this.number;
			 	this.config.eye.focus(this.number);
			 	//window.setTimeout(this.config.eye.config.accessName+'.focus('+this.number+')',this.config.eye.config.delay);
			 }
			if(this.oldOO) return this.oldOO(a,b,c);
		}		
		
		function FishEyeR_settle(nr)
		{	if(this.settles!=nr || this.focuses>-1) return;
			
			if( this.config.stayOnInitial && this.config.initial ) this.config.initial.onmouseover();
			else {
				this.currentSteps=0;
				for(var sklave=0;sklave<this.nodes.length;sklave++)
					this.resize(this.nodes[sklave],this.config.size_width_default);
			}
		}
		
		function FishEyeR_focus(nr)
		{	if(this.focuses!=nr) return;
			
			var steps = this.nodes[nr].mainSteps, nodes = this.nodes;
		 	if(!steps)
		 	{	// certainly optimizable algorithm to determine widths
		 		steps = new Object();
			 	var ec = this.config,
					sklave=0, 
					lS = ec.radius && ec.radius-1<nr
								? ec.radius 
								: nr,
					rS = ec.radius && ec.radius<this.nodes.length-1-nr
								? ec.radius 
								: this.nodes.length-1-nr,
					nWi = ec.size_width_palette-nodes.length*ec.margin_horizontal-ec.size_width_large,
					deWi = nWi/(nodes.length-1),
					oS = nodes.length-1-lS-rS,
					siDi = ec.size_width_large-ec.size_width_default,
					deWi = ec.size_width_default,//-(siDi+(lS?(lS>1?siDi:siDi/2):0)+(rS?(rS>1?siDi:siDi/2):0))/nodes.length,
					deWiR = Math.ceil(deWi),
					nWi = nodes.length*ec.margin_horizontal,
					maxE=Math.max(lS,rS),
					know, lP, rP;

				for(;sklave<nodes.length;sklave++)
				{	if(sklave<nr-lS || sklave>nr+rS) steps[sklave]=deWi;
					else if(sklave<nr) steps[sklave]=deWi+siDi/(lS+1)*(lS-nr+1+sklave);
					else if(sklave>nr) steps[sklave]=deWi+siDi/(rS+1)*(rS-sklave+nr+1);
					else steps[sklave] = ec.size_width_large;
					
					nWi+=steps[sklave];
				}
				
				know = (ec.size_width_palette-nodes.length*ec.margin_horizontal)/nWi;
				nWi = nodes.length*ec.margin_horizontal+ec.size_width_large;
				for(sklave=0;sklave<nodes.length;sklave++)
					if(sklave!=nr)
					{	steps[sklave]=know*steps[sklave];
						nWi+=Math.ceil(steps[sklave]);
					}
				
				nWi = nodes.length*ec.margin_horizontal;
				for(sklave=0;sklave<nodes.length;sklave++)
				{	steps[sklave]=Math.ceil(steps[sklave]);
					nWi += steps[sklave];
				}

				know = nWi-ec.size_width_palette;
				if(know>0)
				{	rP=lP=0;
					if(lS&&rS)
					{	rP = Math.round(know*lS/(lS+rS));
						lP = know-rP;
					}else
					if(rS)rP=know;else lP=know;
					
					while(lP>0 || rP>0)
					{	sklave=nr-1;
						while(lP>0&&steps[sklave]>1)
							for(;sklave>=nr-lS && lP>0;sklave--)
								if(steps[sklave]>1)
									{	steps[sklave]--;
										lP--;
									}
						sklave=nr+1
						while(rP>0&&steps[sklave]>1)
							for(;sklave<=nr+rS&&rP>0;sklave++)
							if(steps[sklave]>1)
								{	steps[sklave]--;
									rP--;
								}
						if(lP>0) { rP+=lP; lP=0; }
						else if(rP>0) { lP+=rP; rP=0; }
					}

				}else
				{	know = 0-know;
					while(know>nodes.length-1)
					{	for(sklave=0;sklave<nodes.length;sklave++)
							if(sklave!=nr) steps[sklave]++;
						know-=nodes.length-1;
					}
					
					while(know>0)
						for(sklave=Math.max(lS,rS);sklave>0&&know>0;sklave--)
						{	if(sklave<=lS)
							{	steps[nr-sklave]++;
								know--;
							}
							if(know>0&&sklave<=rS)
							{	steps[nr+sklave]++;
								know--;									
							}
						}
				}
				this.mainSteps = steps;
		 	}
		 	this.currentSteps=0;
			for(sklave=0;sklave<nodes.length;sklave++)
				this.resize(nodes[sklave], steps[sklave]);

		}
		
		function FishEyeR_resize(img, width, instantly)
		{	if(img.width==width) return;
			
			if(instantly)
			{	img.width=Math.round(width);
				siSo = -100000;
				if(img.config && img.config.sizes)
				{	var va = '';
					for(size in img.config.sizes)
						if(Math.abs(width-size)<Math.abs(width-siSo)) siSo = size;
					if(siSo!=-100000)
						img.src = img.config.sizes[siSo].src;
				}
			}else img.new_width=width;
		}
		
		function FishEyeR_sizomatic()
		{	var siSo, img, width, aWi=this.nodes.length*this.config.margin_horizontal;
			if(this.currentSteps<this.config.steps)
			{	for(var sklave=0;sklave<this.nodes.length;sklave++)
				{	img = this.nodes[sklave];
					if(img.width!=Math.round(img.new_width)&&img.new_width>0)
					{	if(this.currentSteps==this.config.steps-1) width=img.new_width;
						else width = Math.round(this.currentSteps/this.config.steps*(img.new_width-img.width)+img.width);
						aWi+=width;
						this.resize(img,width,1);
					}else aWi+=img.width;
				}
				var cha=1;
				while(cha&&aWi!=this.config.size_width_palette) // stupid auto adjustment
				{	cha=0;
					var adja=aWi>this.config.size_width_palette?-1:1;
					for(var sklave=0;sklave<this.nodes.length&&aWi!=this.config.size_width_palette;sklave++)
					{	img = this.nodes[sklave];
						if(img.new_width>0&&(img.width<Math.round(img.new_width)&&adja>0||img.width>Math.round(img.new_width)&&adja<0))
						{	aWi+=adja;
							this.resize(img,img.width+adja,1);
							cha=1;
						}
					}
				}
				if(!cha) if(this.focuses>-1) this.focus(this.focuses);
					else if(this.settles>-1) this.settle(this.settles);

				this.currentSteps++;
			}	
			window.setTimeout(this.config.accessName+'.sizomatic();',this.config.timeout);
		}
		
		function FishEyeR_refresh()
		{	if(!this.started)
			{	var width = this.config.size_width_palette, started=1, sklave;
				for(sklave=0;sklave<this.nodes.length;sklave++)
				{	if(!this.nodes[sklave].complete) started=0;
					width-=this.nodes[sklave].width;
				}
				if(this.config.size_width_palette>0&&width<this.nodes.length*this.config.margin_horizontal)
				{	this.config.size_width_default=Math.floor((this.config.size_width_palette-this.config.margin_horizontal*this.nodes.length)/this.nodes.length);
					this.config.size_width_palette = Math.ceil( this.config.size_width_default*this.nodes.length+this.config.margin_horizontal*this.nodes.length );
					for(sklave=0;sklave<this.nodes.length;sklave++)
						this.resize(this.nodes[sklave],this.config.size_width_default,1);
				}
				if(started)	
				{	this.started=1;
					var no;
					for(var sklave=0;sklave<this.nodes.length;sklave++)
					{	if(this.nodes[sklave].onmouseover) this.nodes[sklave].oldOO = this.nodes[sklave].onmouseover;
						this.nodes[sklave].onmouseover = null;
						this.nodes[sklave].onmouseover = this.onmouseover;
						if(this.nodes[sklave].onmouseout) this.nodes[sklave].oldOU = this.nodes[sklave].onmouseout;
						this.nodes[sklave].onmouseout = null;
						this.nodes[sklave].onmouseout = this.onmouseout;
						
						no=this.nodes[sklave].parentNode;
						if(!this.config.ignoreParentNodes)
							while(no && no!=this.config.palette)
							{	no.proxyFish = this.nodes[sklave];
								if(no.onmouseover) 
								{	no.oldOO = no.onmouseover
									no.onmouseover = null;
								}
								no.onmouseover = this.onmouseover;
								if(no.onmouseout) 
								{	no.oldOU = no.onmouseout
									no.onmouseout = null;
								}
								no.onmouseout = this.onmouseout;
								no=no.parentNode;
							}
					}
					this.sizomatic();
					if(this.config.initial) 
						window.setTimeout('get("'+this.config.initial.id+'").onmouseover()',100);
				}
			}
		}
		
		function FishEyeR_startUp()
		{	this.nodes = this.config.palette.getElementsByTagName('img')
			var sklave, knecht, i, ws, c;
			
			for(sklave=0;sklave<this.nodes.length;sklave++)
			{	if(!this.nodes[sklave].id) this.nodes[sklave].id = 'imgF-R-'+sklave;
				c=new Object();
				c.eye = this;
				c.sizes=new Object();
				this.images[this.nodes[sklave].id] = c;
				
				if(this.nodes[sklave].onerror)
				{	this.nodes[sklave].oldOE = this.nodes[sklave].onerror;
					this.nodes[sklave].onerror = null;
				}
				this.nodes[sklave].onerror = this.onerror;
				
				i = new Image();
				i.config = c;
				c.node=this.nodes[sklave];
				c.node.config = c;
				i.onload = this.determineSize;
				i.src = this.nodes[sklave].src;
				
				if(this.nodes[sklave].complete) i.onload();
			}

			if(this.config.images)
				for(sklave=0;sklave<this.config.images.length;sklave++)
				{	if(!this.config.images[sklave].id) this.config.images[sklave].id = 'imgF-R-'+(sklave+this.nodes.length);
					c=this.images[this.config.images[sklave].id];
					
					i = new Image();
					if(!c)
					{	c=new Object();
						c.eye = this;
						this.images[this.config.images[sklave].id] = c;
						c.sizes=new Object();
						c.node=document.createElement('img');
						if(this.config.size_width_default)
							c.node.width = this.config.size_width_default;
						c.node.id=this.config.images[sklave].id;
						for(knecht=sklave+1;knecht<this.config.images.length;knecht++)
							if(this.config.images[knecht].id && this.images[this.config.images[knecht].id])
							{	this.config.palette.insertBefore(c.node, this.images[this.config.images[knecht].id].node);
								break;
							}
						if(knecht==this.config.images.length)
							this.config.palette.appendChild(c.node);
						c.node.config = c;
					}
					
					if(!this.config.images[sklave].src.push)
						this.config.images[sklave].src = [this.config.images[sklave].src];
					
					for(var knecht=0;knecht<this.config.images[sklave].src.length;knecht++)
					{	
						i.config = c;
						i.onload = this.determineSize;
						i.src = ( this.config.images[sklave].path
									? this.pathidate(this.config.images[sklave].path)
									: ( this.config.path
										? this.config.path
										: ''))+this.config.images[sklave].src[knecht];
						if(!c.node.src) c.node.src = i.src;
						this.images["-"].push(i);
						i = new Image();
					}

				}
				
			for(sklave=0;sklave<this.nodes.length;sklave++)
				this.nodes[sklave].number = sklave;
		}
		
		function FishEyeR_pathidate(path)
		{	if(!path) return '';
			path = path.replace(/\\/g, '/').replace (/^\s+/, '').replace (/\s+$/, '');
			if(path.lastIndexOf('/')!=path.length-1) path+='/';
			return path;
		}
		
		function FishEyeR_validate()
		{	if(typeof this.config.palette == "string") this.config.palette = get(this.config.palette);

			this.config.path = this.pathidate(this.config.path);
			
			if(!this.config.margin_horizontal) this.config.margin_horizontal=0;
			
			if(!this.config.palette)
			{	if(this.config.debug) alert('Fisheye-R configuration error ! Bouncing out.');
				return false;
			}
		
			if(this.config.initial) this.config.initial=get(this.config.initial);
			
			return true;
		}
		
		function FishEyeR_determineSize()
		{	this.config.sizes[this.width] = this;
			if(!this.config.node.complete || this.config.node.failed) 
			{	this.config.node.src = this.src;
				this.config.node.failed = 0;
			}
			this.config.eye.refresh();
			// for ie6... 8c]

			window.setTimeout(this.config.eye.config.accessName+'.refresh()',1);
		}
