/*
 * euDock - javascript Emulation of Dock style MAC OS X bar
 *
 * Version: 2.0.06
 *
 * Copyright (C) 2006 Parodi (Pier...) Eugenio <eudock@inwind.it>
 *                                              http://eudock.jules.it
 *
 * SPECIAL THANKS TO Tiago D'Herbe (tvidigal) FOR (Multiple Dock) INSPIRATION
 *
 *                   Mario Zaizar to suggest and help me for Pointer icon patch and Target function
 *                  
 *                   Jérémie 'ahFeel' BORDIER to suggest and help me for DeleteIcon feature
 *
 *
 *
 *
 * This library is free software; you can redistribute it and/or             
 * modify it under the terms of the GNU Lesser General Public                
 * License as published by the Free Software Foundation; either              
 * version 2.1 of the License, or (at your option) any later version.        
 *                                                                           
 * This library is distributed in the hope that it will be useful,           
 * but WITHOUT ANY WARRANTY; without even the implied warranty of            
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         
 * Lesser General Public License for more details.                           
 *                                                                           
 * You should have received a copy of the GNU Lesser General Public          
 * License along with this library; if not, write to the Free Software       
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

if (!euEnv)
	var euEnv      = new Array();
euEnv.Kost         = new Array();
euEnv.Kost.num     = 0;
euEnv.Kost.next    = function(){return this.num++;}
euEnv.euDockArray  = new Array();
euEnv.refreshTime  = 35;
euEnv.exeThread          = true;
euEnv.exeThreadWhiteLoop = 0;
euEnv.x = 0;
euEnv.y = 0;
euEnv.mouseMoved=false;

var euUP       = 1;
var euDOWN     = 2;
var euLEFT     = 3;
var euRIGHT    = 4;

var euICON     = 5;
var euMOUSE    = 6;

var euSCREEN   = 7;
var euOBJECT   = 8;
var euABSOLUTE = 9;
var euRELATIVE = 10;

var euHORIZONTAL = 11;
var euVERTICAL   = 12;
var euCENTER     = 13;

var euTRANSPARENT = 14;
var euFIXED       = 15;
var euOPAQUE      = 16;

/* 
 ****************************************
 ****** Standard euDock Functions *******
 ******  (BEGIN)                  *******
 **************************************** 
 */		
		function euIdObjTop(euObj){
		    var ret = euObj.offsetTop;
		    while ((euObj = euObj.offsetParent)!=null)
		        ret += euObj.offsetTop;
		    return ret;
		};
		
		function euIdObjLeft(euObj){
		    var ret = euObj.offsetLeft;
		    while ((euObj = euObj.offsetParent)!=null)
		        ret += euObj.offsetLeft;
		    return ret;
		};
		
		function isEuInside(euObj,x,y){
			var euTop  = euIdObjTop(euObj);
			var euLeft = euIdObjLeft(euObj);			
			return ((euTop<=y && (euTop+euObj.offsetHeight)>=y)&&(euLeft<=x && (euLeft+euObj.offsetWidth)>=x));
		};		
	
		/*
		 * euDimensioni()
		 *
		 * standard code fo retrieve width and Height of Screen
		 *
		 */
		function euDimensioni(){
		    if( typeof( window.innerWidth ) == 'number' ) {
		        //Non-IE
		        euEnv.euFrameWidth = window.innerWidth-16;
		        euEnv.euFrameHeight = window.innerHeight;
		    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		        //IE 6+ in 'standards compliant mode'
		        euEnv.euFrameWidth = document.documentElement.clientWidth-16;
		        euEnv.euFrameHeight = document.documentElement.clientHeight;
		    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		        //IE 4 compatible
		        euEnv.euFrameWidth = document.body.clientWidth;
		        euEnv.euFrameHeight = document.body.clientHeight;
		    }
		};
		
		function offsEut() {
		    euEnv.euScrOfY = 0;
		    euEnv.euScrOfX = 0;
		    if( typeof( window.pageYoffsEut ) == 'number' ) {
		        //Netscape compliant
		        euEnv.euScrOfY = window.pageYoffsEut;
		        euEnv.euScrOfX = window.pageXoffsEut;
		    } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		        //DOM compliant
		        euEnv.euScrOfY = document.body.scrollTop;
		        euEnv.euScrOfX = document.body.scrollLeft;
		    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		        //IE6 standards compliant mode
		        euEnv.euScrOfY = document.documentElement.scrollTop;
		        euEnv.euScrOfX = document.documentElement.scrollLeft;
		    }		    
		};
/* 
 ****************************************
 ****** Standard euDock Functions *******
 ******  (END)                    *******
 **************************************** 
 */

/* 
 ****************************************
 ****** euDock Trans Functions    *******
 ******  (BEGIN)                  *******
 **************************************** 
 */

	function euKostFunc30(x){
		return 0.3;
	};
	
	function euKostFunc100(x){
		return 1;
	};	
 
 	function euLinear(x){
		return x;
	};
  
	function euLinear30(x){
		return 1*(x+(1-x)*0.3);
	};
	
	function euLinear20(x){	
		return x+(1-x)*0.2;
	};
	
	function euExp30(x){
		return euLinear30(x*x*x);
	};

	function euLinear50(x){	
		return x+(1-x)*0.5;
	};		

	function euLinear65(x){	
		return x+(1-x)*0.65;
	};	

	function euHarmonic(x){
		return euLinear30((1-Math.cos(Math.PI*x))/2);
	};
	
	function euSemiHarmonic(x){
		return euLinear30(Math.cos(Math.PI*(1-x)/2));
	};	
 
/* 
 ****************************************
 ****** euDock Trans Functions    *******
 ******  (END)                    *******
 **************************************** 
 */ 
 
/* 
 ****************************************
 ******    euDock Object          *******
 ******     (START)               *******
 **************************************** 
 */
		function euDock(){
			this.id = 'euDock_'+euEnv.Kost.next();
			document.write("<div id='"+this.id+"_bar' style='z-index:1000;position:absolute;border:0px solid black;'></div>");	
			document.write("<div onMouseOut='euEnv.euDockArray."+this.id+".mouseOut();' onMouseOver='euEnv.euDockArray."+this.id+".mouseOver();' id='"+this.id+"' style='z-index:1000;position:absolute;border:0px solid black; cursor: pointer;'></div>");	
			this.div   =document.getElementById(this.id);
			this.divBar=document.getElementById(this.id+"_bar");
			this.iconsArray=new Array();
			this.isInside=false;
			euEnv.euDockArray[this.id]=this;
			this.bar=null;
			
			this.mouseX = 0;
			this.mouseY = 0;
			
			this.centerPosX = 0;
			this.centerPosY = 0;
			this.offset     = 0;
			this.iconOffset = 0;
			
			this.venusHillSize  = 3;//200;
			this.venusHillTrans = euLinear;

			this.position    = euUP;
			this.align       = euSCREEN;
			this.objectAlign = euDOWN;
			this.idObjectHook;
			this.animaition  = euICON;
			this.animFading  = euABSOLUTE;
			
			this.setIconsOffset = function(offset){
				this.iconOffset=offset;
			};
			
			this.setAnimation = function(anim,size){				
				this.animaition    = anim;
				this.venusHillSize = size;
			};
			
			this.setPointAlign = function(x,y,pos){
				this.offset   = 0;
				this.align    = euABSOLUTE;
				this.position = pos;
				this.setCenterPos(x,y);
			}
			
			this.setObjectAlign = function(idObj,align,offset,pos){
				this.offset       = offset;
				this.align        = euOBJECT;
				this.objectAlign  = align;
				this.position     = pos;
				this.idObjectHook = document.getElementById(idObj);
				this.setObjectCoord();
			};
			
			this.setObjectCoord = function(){
				if (this.objectAlign==euDOWN)
					this.setCenterPos(
						euIdObjLeft(this.idObjectHook) + (this.idObjectHook.offsetWidth/2),
						euIdObjTop(this.idObjectHook)  + this.idObjectHook.offsetHeight + this.offset);
				else if (this.objectAlign==euUP)
					this.setCenterPos(
						euIdObjLeft(this.idObjectHook) + (this.idObjectHook.offsetWidth/2),
						euIdObjTop(this.idObjectHook) - this.offset);
				else if (this.objectAlign==euLEFT)
					this.setCenterPos(
						euIdObjLeft(this.idObjectHook) - this.offset,
						euIdObjTop(this.idObjectHook)  + (this.idObjectHook.offsetHeight/2));
				else if (this.objectAlign==euRIGHT)
					this.setCenterPos(
						euIdObjLeft(this.idObjectHook) + this.idObjectHook.offsetWidth + this.offset,
						euIdObjTop(this.idObjectHook)  + (this.idObjectHook.offsetHeight/2));
				else if (this.objectAlign==euCENTER){
					if (this.position==euUP || this.position==euDOWN || this.position==euHORIZONTAL)	
						this.setCenterPos(
							euIdObjLeft(this.idObjectHook) + (this.idObjectHook.offsetWidth/2),
							euIdObjTop(this.idObjectHook)  + (this.idObjectHook.offsetHeight/2) - this.offset);
					else
						this.setCenterPos(
							euIdObjLeft(this.idObjectHook) + (this.idObjectHook.offsetWidth/2) + this.offset,
							euIdObjTop(this.idObjectHook)  + (this.idObjectHook.offsetHeight/2));												
				}	
			};			
			
			this.setScreenAlign = function(align,offset){
				this.offset=offset;
				this.align = euSCREEN;
				this.position=euUP;
				this.setScreenCoord();
			};
			
			this.setScreenCoord = function(){
				euDimensioni();
				offsEut();
				this.setCenterPos(
					euEnv.euScrOfX+euEnv.euFrameWidth/2,
					euEnv.euScrOfY+this.offset);		
			};
			
			this.refreshDiv = function(){
				if (this.position==euDOWN){
					this.setPos(this.centerPosX-this.getWidth()/2,this.centerPosY+this.iconOffset);					
				}
			}			
			
			this.riposition = function(){
				if (this.align == euSCREEN)
					this.setScreenCoord();
				else if (this.align == euOBJECT)
					this.setObjectCoord();				
			};
									
			this.setCenterPos = function(x,y){
				this.centerPosX = x;
				this.centerPosY = y;
				this.refreshDiv();
			};

			this.setPos = function(x,y){				
				this.setPosX(x);
				this.setPosY(y);
			};	
			
			this.setBarPos = function(x,y){
				this.setBarPosX(x);
				this.setBarPosY(y);
			};			
			
			this.setDim = function(w,h){
				this.setWidth(w);
				this.setHeight(h);				
			};	
			
			
			this.setBarPosX   = function(x) {document.getElementById(this.id+"_bar").style.left=x+'px';};
			this.setBarPosY   = function(y) {document.getElementById(this.id+"_bar").style.top=y+'px';};			
			
			this.getPosX   = function() {return document.getElementById(this.id).style.left.replace(/[^0-9]/g,"");};			
			this.setPosX   = function(x) {document.getElementById(this.id).style.left=x+'px';};
			this.getPosY   = function() {return document.getElementById(this.id).style.top.replace(/[^0-9]/g,"");};	
			this.setPosY   = function(y) {document.getElementById(this.id).style.top=y+'px';};
			this.getWidth  = function() {return document.getElementById(this.id).style.width.replace(/[^0-9]/g,"");};
			this.setWidth  = function(w){document.getElementById(this.id).style.width=Math.round(w)+'px';};
			this.getHeight  = function() {return document.getElementById(this.id).style.height.replace(/[^0-9]/g,"");};		
			this.setHeight = function(h){document.getElementById(this.id).style.height=Math.round(h)+'px';};
			
			this.getVenusWidth  = function() {return this.venusHillSize*this.getWidth();};
			this.getVenusHeight = function() {return this.venusHillSize*this.getHeight();};
			
			this.getMouseRelativeX = function(){return this.mouseX-euIdObjLeft(this.div);};
			this.getMouseRelativeY = function(){return this.mouseY-euIdObjTop(this.div);};
			
			this.updateDims = function(){
				var bakWidth  = 0;
				var bakHeight = 0;
				
				for (var i in this.iconsArray) if (this.iconsArray[i].id){					
						bakWidth  += this.iconsArray[i].getWidth();
						bakHeight = (this.iconsArray[i].getHeight()>bakHeight)?this.iconsArray[i].getHeight():bakHeight;
						bakHeight = Math.round(bakHeight);
				}
						
				var posx=0;
				var posy=0;
				var updPosX=0;
				var updPosY=0;
				
				for (var i in this.iconsArray) if (this.iconsArray[i].id){
					updPosX=posx;
					updPosY=posy;
					posx+=this.iconsArray[i].getWidth();
					
					this.iconsArray[i].setPos(updPosX,updPosY);
					this.iconsArray[i].refresh();
				}
				
				this.setDim(bakWidth,bakHeight);
				this.refreshDiv();
			};
			
			this.kernel = function(){				
				if (this.isInside)
					return this.kernelMouseOver();
				else
					return this.kernelMouseOut();			
			};
			
			this.kernelMouseOver = function(){				
				var ret=false;
				var overI = -1;
				var mouseRelX = this.getMouseRelativeX();
				var mouseRelY = this.getMouseRelativeY();
				var mediana;
				var border;
				var frameTo;
				var venusWidth;
				var venusHeight;
				var overIcon;
				
					venusWidth = this.getVenusWidth();
					
					for (var i in this.iconsArray) if (this.iconsArray[i].id)
						if (this.iconsArray[i].isInsideX(mouseRelX)){
							overIcon=i;
							border=this.iconsArray[i].getWidth()/2;
						}
	
					for (var i in this.iconsArray) if (this.iconsArray[i].id)
					{
						mediana = this.iconsArray[i].posX + this.iconsArray[i].getWidth()/2;
						
						if (Math.abs(mediana-mouseRelX)<=border)
							mediana=mouseRelX;
						else if (mediana<mouseRelX)
							mediana+=this.iconsArray[i].getWidth()/2;
						else if (mediana>mouseRelX)
							mediana-=this.iconsArray[i].getWidth()/2;
						if (this.animaition==euICON  && Math.abs(i-overIcon) <= this.venusHillSize)
							frameTo = this.venusHillTrans(1-Math.abs(i-overIcon) / this.venusHillSize);
						else if (this.animaition==euMOUSE && Math.abs(mediana-mouseRelX)<=venusWidth)
							frameTo = this.venusHillTrans(1-Math.abs(mediana-mouseRelX)/venusWidth);
						else
							frameTo = 0;
							
						if (frameTo==0 || frameTo==1 || Math.abs(frameTo-this.iconsArray[i].frame)>0.01)
							ret|=this.iconsArray[i].setFrameTo(frameTo);
					}

				if (ret) this.updateDims();
				return ret;				
			};
			
			this.kernelMouseOut = function(){
				var ret=false;
				for (var i in this.iconsArray) if (this.iconsArray[i].id)
					ret|=this.iconsArray[i].setAllFrameTo(0);	
				if (ret)
					this.updateDims();				
				return ret;	
			};			
			
			this.mouseOut = function(){
				this.isInside=false;
				euEnv.exeThreadWhiteLoop=5;				
			};
			
			this.mouseOver = function(){
				this.isInside=true;
				euEnv.exeThreadWhiteLoop=5;				
			};			
			
			this.mouseMove = function(x,y){
				var inside = isEuInside(this.div,x,y);
				var ret = (this.mouseX!=x || this.mouseY!=y) && inside;
				
				this.mouseX=x;
				this.mouseY=y;

				
				if (inside!=this.isInside){					
					this.isInside=inside;
					ret=true;
				}
								
				for (var i in this.iconsArray) if (this.iconsArray[i].id)
						ret|=this.iconsArray[i].isRunning();					
				return ret;
			};
			
			this.iconParams=new Array();
			this.setAllFrameStep = function(step){
				this.iconParams.frameStep=step;
				for (var i in this.iconsArray) if (this.iconsArray[i].id)
					this.iconsArray[i].frameStep=step;				
			};
			
			this.setAllZoomFunc = function(func){
				this.setAllZoomFuncW(func);
				this.setAllZoomFuncH(func);
			};		
			
			this.setAllZoomFuncW = function(func){
				this.iconParams.zoomFuncW=func;
				for (var i in this.iconsArray) if (this.iconsArray[i].id)
					this.iconsArray[i].zoomFuncW=func;
			};
			
			this.setAllZoomFuncH = function(func){
				this.iconParams.zoomFuncH=func;
				for (var i in this.iconsArray) if (this.iconsArray[i].id)
					this.iconsArray[i].zoomFuncH=func;	
			};
			
			this.setBar = function(args){
				var id = 'euDock_bar_'+euEnv.Kost.next(); 
				euEnv.euDockArray[id] = new euDockBar(id,this);
				euEnv.euDockArray[id].setElements(args);
				this.bar=euEnv.euDockArray[id];				
				return euEnv.euDockArray[id];				
			};
			
			this.addIcon = function(args,params){
				var id = 'euDock_icon_'+euEnv.Kost.next(); 
				euEnv.euDockArray[id] = new euDockIcon(id,this);
				euEnv.euDockArray[id].addElement(args);
				this.iconsArray.push(euEnv.euDockArray[id]);
				for (i in this.iconParams)
					euEnv.euDockArray[id][i]=this.iconParams[i];
				for (i in params)
					euEnv.euDockArray[id][i]=params[i];				
				return euEnv.euDockArray[id];				
			};
			
			this.delIcon = function(elem) {
				euEnv.euDockArray.splice(elem);
				euEnv.euDockArray[elem.id]=0;
				for (var i in this.iconsArray) if (this.iconsArray[i] == elem) 
					this.iconsArray.splice(i,1);
				elem.destroy();	
				elem=null;			
				this.updateDims();
			};			
			
		};
/* 
 ****************************************
 ******    euDock Object          *******
 ******     (END)                 *******
 **************************************** 
 */
 
/* 
 ****************************************
 ******    euDock Icon Object     *******
 ******     (START)               *******
 **************************************** 
 */
		function euDockIcon(id,dock){
			this.id = id;			
			
			this.parentDock = dock;
			
			this.elementsArray;
			
			this.zoomFuncW=euLinear65;
			this.zoomFuncH=euLinear65;
			
			this.posX          = 0;
			this.posY          = 0;
			this.width         = 110;
			this.height        = 110;
			this.frame         = 0;
			this.frameStep     = 0.5;
			this.fadingFrame   = 0;
			this.fadingStep    = 1;
			this.fadingType    = euTRANSPARENT;
			
			this.loaded        = false;
			this.runningFrame  = false;
			this.runningFading = false;
			
			this.updateDims = function(){
				if (!this.loaded)return;
				
				for (var i=0;i<this.elementsArray.length;i++)
					this.elementsArray[i].setProperties(this.posX,this.posY,this.getWidth(),this.getHeight());
			};
			
			this.updateFading = function(){} 
			
			this.refresh = function(){
				this.updateDims();
			};

			this.isAbsoluteInside = function(x,y){
				x-=this.getAbsolutePosX();
				y-=this.getAbsolutePosY();
				return x>0 && y>0 && x<this.getWidth() && y<this.getHeight();
			};			
						
			this.isInside = function(x,y){
				return this.isInsideX(x) && this.isInsideY(y);
			};
			
			this.isInsideX = function(x){			
				return 	(this.loaded && (this.posX<=x) && ((this.posX+this.getWidth())>=x));
			};
			
			this.isInsideY = function(y){
				return 	(this.loaded && (this.posY<=y) && ((this.posY+this.getHeight())>=y));
			};			
			
			this.retrieveLoadingDims = function(elem,num){
			
				if (elem.onLoadPrev)
					elem.onLoadPrev();
				if (num==0 && !this.loaded)
					this.setDim(elem.getWidth(),elem.getHeight());
				elem.loaded=true;				
				var ret=true;			
				for (var i in this.elementsArray) if (this.elementsArray[i].id)
						ret&=this.elementsArray[i].loaded
				this.loaded=ret;	
				if (this.loaded){
					this.parentDock.updateDims();					
					for (var i in this.elementsArray) if (this.elementsArray[i].id)
						this.elementsArray[i].show();
				}
				if (elem.onLoadNext)
					elem.onLoadNext();				
			};
			
			this.setPos = function(x,y){
				this.posX = x;
				this.posY = y;				
			};	
			
			this.setDim = function(w,h){
				if (this.width==0)
					this.width  = w;
				if (this.height==0)
					this.height = h;				
			};	
			
			this.getAbsolutePosX = function(){return euIdObjLeft(this.parentDock.div)+this.posX;};
			this.getAbsolutePosY = function(){return euIdObjTop(this.parentDock.div)+this.posY;};
			
			this.setPosX   = function(x) {this.posX=x;};
			this.setPosY   = function(y) {this.posY=y;};
			this.getWidth  = function()  { if (!this.loaded){return 0;} return this.width*this.zoomFuncW(this.frame);};
			this.getHeight = function()  {if (!this.loaded)return 0; return this.height*this.zoomFuncH(this.frame);};		
			
			this.isRunning = function(){
				return this.runningFrame || this.runningFading;
			};
			
			this.setAllFrameTo = function(to){
				this.setFrameTo(to) ;
				return this.isRunning();
			};
			
			this.setFadingTo = function(fadingTo){}
			
			this.setFrameTo = function(frameTo){
	
				if (this.frame==frameTo)
					this.runningFrame = false;
				else{
					this.runningFrame = true;
					
					this.frame+=(frameTo-this.frame)*this.frameStep;					
	
					if (Math.abs(this.frame-frameTo)<0.01)
							this.frame=frameTo;
					
					if (this.frame<0)
						this.frame = 0;
					if (this.frame>1)
						this.frame = 1;				
				}
				return this.runningFrame;
			};
			
			this.addElement = function(args){				
				if (typeof(args)!="undefined" && args!=null){
					this.elementsArray=new Array();
					//this.fadingStep = 0.5/args.length;

					for (var i=0;i<args.length;i++)
						for (var ii in args[i]){
							var id = "euDock_"+ii+"_"+euEnv.Kost.next();
							euEnv.euDockArray[id]= new window[ii](id,args[i][ii],this.parentDock.div,"euEnv.euDockArray."+this.id+".retrieveLoadingDims(euEnv.euDockArray."+id+","+i+");");
							this.elementsArray.push(euEnv.euDockArray[id]);
							euEnv.euDockArray[id].loaded=false;							
						}
				}
			};
			
			this.destroy = function() {
				for (var i in this.elementsArray) if (this.elementsArray[i].id){
					euEnv.euDockArray[this.elementsArray[i].id]=0;
					euEnv.euDockArray.splice(this.elementsArray[i],1);
					this.elementsArray[i].destroy();
				}
				this.elementsArray.splice(0,this.elementsArray.length);				
			};
			
			this.mouseClick = function(x,y){
				if (this.isAbsoluteInside(x,y)){
					if (this.link)
						if (this.target){			
							if (top.frames[this.target])
								top.frames[this.target].location.href=this.link;
							else
								top.frames[this.target] = window.open(this.link,this.target,"");
						}else
							document.location.href=this.link;
					else if (this.mouseInsideClick)
						this.mouseInsideClick(x,y);						
				}
			};
			
		};
/* 
 ****************************************
 ******    euDock Icon Object     *******
 ******     (END)                 *******
 **************************************** 
 */
 
function euThread(){
	euDimensioni();
	offsEut();
    euEnv.timeout=window.setTimeout("euThread();",euEnv.refreshTime);
    
    euEnv.exeThread = false;
    if (euEnv.mouseMoved)
		for (var i in euEnv.euDockArray)
			if (euEnv.euDockArray[i].mouseMove)
				euEnv.exeThread |= euEnv.euDockArray[i].mouseMove(euEnv.euScrOfX+euEnv.x,euEnv.euScrOfY+euEnv.y);
	euEnv.mouseMoved=false;			
	if (euEnv.exeThread)
		euEnv.exeThreadWhiteLoop=5;    
  
    if(euEnv.exeThreadWhiteLoop>0)
    	euKernel();    	
		
	for (var i in euEnv.euDockArray)
		if (euEnv.euDockArray[i].riposition)
			euEnv.euDockArray[i].riposition();    	
};

function euKernel(){
	euEnv.exeThread = false;
	for (var i in euEnv.euDockArray)
		if (euEnv.euDockArray[i].kernel)
			euEnv.exeThread |= euEnv.euDockArray[i].kernel();

	if (euEnv.exeThread)
		euEnv.exeThreadWhiteLoop=5;
	else
		euEnv.exeThreadWhiteLoop--;					
}; 

function on_MouseMove(e) {	
	if (!e) var e = window.event;
	euEnv.x = e.clientX;
	euEnv.y = e.clientY;
	euEnv.mouseMoved = true;
	if (euEnv.onmousemoveBK)
		return euEnv.onmousemoveBK(e);
	return true;
};

function on_MouseDown(e) {
	if (!e) var e = window.event;	
	for (var i in euEnv.euDockArray)
		if (euEnv.euDockArray[i].mouseDown)
			euEnv.exeThread |= euEnv.euDockArray[i].mouseDown(euEnv.euScrOfX+e.clientX,euEnv.euScrOfY+e.clientY);
	if (euEnv.onmousedownBK)
		return euEnv.onmousedownBK(e);
	return true;
};

function on_MouseUp(e) {
	if (!e) var e = window.event;	
	for (var i in euEnv.euDockArray)
		if (euEnv.euDockArray[i].mouseUp)
			euEnv.exeThread |= euEnv.euDockArray[i].mouseUp(euEnv.euScrOfX+e.clientX,euEnv.euScrOfY+e.clientY);
	if (euEnv.onmouseupBK)
		return euEnv.onmouseupBK(e);
	return true;
};

function on_MouseClick(e) {
	if (!e) var e = window.event;
	for (var i in euEnv.euDockArray)
		if (euEnv.euDockArray[i].mouseClick)
			euEnv.exeThread |= euEnv.euDockArray[i].mouseClick(euEnv.euScrOfX+e.clientX,euEnv.euScrOfY+e.clientY);
	if (euEnv.onclickBK)
		return euEnv.onclickBK(e);
	return true;
};

if (document.onmousemove)
	euEnv.onmousemoveBK = document.onmousemove;
document.onmousemove  = on_MouseMove;

if (document.onmousedown)
	euEnv.onmousedownBK = document.onmousedown;
document.onmousedown  = on_MouseDown;

if (document.onmouseup)
	euEnv.onmouseupBK = document.onmouseup;
document.onmouseup    = on_MouseUp;

/*
if (document.onclick)
	euEnv.onclickBK = document.onclick;
document.onclick      = on_MouseClick;
*/

euDimensioni();
offsEut();
euThread();

