﻿/*================================================================================*/
/*                                                                                */
/*       BW2Technologies.Web.JScript.Framework.ToolStrips (Alpha V1.0.0.0)        */
/*                                                                                */
/*                            Web-ToolStrips Mac OS-X Bar                         */
/*                                                                                */
/*              Copyright © 2006-2010 by BW2Technologies (HP. Lassnig)            */
/*                           mail to : hansi@lassnig.ch                           */
/*                                                                                */
/*                   Copyright © 2006 Parodi (Pier...) Eugenio                    */  
/*                           mail to : eudock@inwind.it                           */
/*                             http://eudock.jules.it                             */
/*                                                                                */
/*                                                                                */
/*================================================================================*/

var nAlignTop = 1;
var nAlignBottom = 2;
var nAlignLeft = 3;
var nAlignRight = 4;

var nAnimationIcon = 5;
var nAnimationWave = 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;

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;
euEnv.imageBasePath = "skin/style1/images/";
euEnv.imageSymPath = "sym-128x128/";

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/


/*================================================================================*/
/* <Function> Standard Dock Functions  </Function>
/*================================================================================*/
function euIdObjTop(oObj){
         var nRet = oObj.offsetTop;
		 
		 while ((oObj = oObj.offsetParent) != null)
		       nRet += oObj.offsetTop;
		 return nRet;
}
		
/*--------------------------------------------------------------------------------*/

function euIdObjLeft(oObj){
         var nRet = oObj.offsetLeft;
	
	     while ((oObj = oObj.offsetParent)!=null)
	           nRet += oObj.offsetLeft;
	     return nRet;
}

/*--------------------------------------------------------------------------------*/
		
function isEuInside(oObj, nX, y){
		 var euTop  = euIdObjTop(oObj);
		 var nAlignLeft = euIdObjLeft(oObj);			
		 return ((euTop<=y && (euTop + oObj.offsetHeight) >= y) && (nAlignLeft <= nX && (nAlignLeft + oObj.offsetWidth) >= nX));
}		
	
/*================================================================================*/
/* <Function> Get Window-Size </Function>
/*================================================================================*/
function getWindowSize(){
 	     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> Get Scroll-Offsets </Function>
/*================================================================================*/
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;
		    }		    
}

/*================================================================================*/
/* <Function> Dock Trans Functions </Function>
/*================================================================================*/
function euKostFunc30(nX){
 		 return 0.3;
}
	
/*--------------------------------------------------------------------------------*/

function euKostFunc100(nX){
		 return 1;
}	
	
/*--------------------------------------------------------------------------------*/
 
function euLinear(nX){
		 return nX;
}
	
/*--------------------------------------------------------------------------------*/

function euLinear30(nX){
		 return 1 * (nX + (1 - nX) * 0.3);
}
	
/*--------------------------------------------------------------------------------*/

function euLinear20(nX){	
		 return nX + (1 - nX) * 0.2;
}
	
/*--------------------------------------------------------------------------------*/

function euExp30(nX){
		 return euLinear30(nX * nX * nX);
}
	
/*--------------------------------------------------------------------------------*/

function euLinear50(nX){	
		 return nX + (1 - nX) * 0.5;
}		
	
/*--------------------------------------------------------------------------------*/

function euHarmonic(nX){
		 return euLinear30((1 - Math.cos(Math.PI * nX)) / 2);
}
	
/*--------------------------------------------------------------------------------*/

function euSemiHarmonic(nX){
		 return euLinear30(Math.cos(Math.PI * (1 - nX) / 2));
}	

/*================================================================================*/
/* <Function> Create MacOsX-ToolItem Object </Function>
/*================================================================================*/
function __bw2ToolStripMacOsX(strToolStrip) {
            //this.id = strToolStrip;
			this.id = 'euDock_' + euEnv.Kost.next();
			document.write("<div id='" + this.id + "_bar' style='z-index:9;position:absolute;border:0px solid black;'></div>");	
			document.write("<div id='" + this.id + "' onMouseOut='euEnv.euDockArray." + this.id + ".mouseOut();' onMouseOver='euEnv.euDockArray." + this.id + ".mouseOver();' style='z-index:9;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 = nAlignTop;
			this.align = euSCREEN;
			this.objectAlign = nAlignBottom;
			this.idObjectHook;
			this.animaition = nAnimationIcon;
			this.animFading = euABSOLUTE;
			
			this.setIconsOffsetX = function(offsetX) { this.iconOffset = offsetX; }
			this.setIconsOffsetY = function(offsetY) { this.iconOffset = offsetY; }
			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==nAlignBottom)
					this.setCenterPos(
						euIdObjLeft(this.idObjectHook) + (this.idObjectHook.offsetWidth/2),
						euIdObjTop(this.idObjectHook)  + this.idObjectHook.offsetHeight + this.offset);
				else if (this.objectAlign==nAlignTop)
					this.setCenterPos(
						euIdObjLeft(this.idObjectHook) + (this.idObjectHook.offsetWidth/2),
						euIdObjTop(this.idObjectHook) - this.offset);
				else if (this.objectAlign==nAlignLeft)
					this.setCenterPos(
						euIdObjLeft(this.idObjectHook) - this.offset,
						euIdObjTop(this.idObjectHook)  + (this.idObjectHook.offsetHeight/2));
				else if (this.objectAlign==nAlignRight)
					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==nAlignTop || this.position==nAlignBottom || 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;
				if (align==nAlignTop)
					this.position=nAlignBottom;
				else if (align==nAlignBottom)					
					this.position=nAlignTop;
				else if (align==nAlignLeft)
					this.position=nAlignRight;
				else if (align==nAlignRight)					
					this.position=nAlignLeft;
				this.setScreenCoord();
			}
			
			this.setScreenCoord = function(){
				getWindowSize();
				offsEut();
				if (this.position==nAlignBottom)
					this.setCenterPos(
						euEnv.euScrOfX+euEnv.euFrameWidth/2,
						euEnv.euScrOfY+this.offset);
				else if (this.position==nAlignTop)
					this.setCenterPos(
						euEnv.euScrOfX+euEnv.euFrameWidth/2,
						euEnv.euScrOfY+euEnv.euFrameHeight-this.offset);					
				else if (this.position==nAlignRight)
					this.setCenterPos(
						euEnv.euScrOfX+this.offset,
						euEnv.euScrOfY+euEnv.euFrameHeight/2);
				else if (this.position==nAlignLeft)
					this.setCenterPos(
						euEnv.euScrOfX+euEnv.euFrameWidth-this.offset,
						euEnv.euScrOfY+euEnv.euFrameHeight/2);				
			}
			
			this.refreshDiv = function(){
				if (this.position==nAlignBottom){
					this.setPos(this.centerPosX - this.getWidth() / 2, this.centerPosY + this.iconOffset);					
				}else if (this.position==nAlignTop){
					this.setPos(this.centerPosX - this.getWidth() / 2,this.centerPosY - this.getHeight() - this.iconOffset);
				}else if (this.position==nAlignRight){					
					this.setPos(this.centerPosX+this.iconOffset,this.centerPosY-this.getHeight()/2);
				}else if (this.position==nAlignLeft){					
					this.setPos(this.centerPosX-this.getWidth()-this.iconOffset,this.centerPosY-this.getHeight()/2);
				}else if (this.position==euHORIZONTAL){
					this.setPos(this.centerPosX-this.getWidth()/2,this.centerPosY-this.getHeight()/2+this.iconOffset);
				}else if (this.position==euVERTICAL){
					this.setPos(this.centerPosX-this.getWidth()/2+this.iconOffset,this.centerPosY-this.getHeight()/2);
				}
				if (this.bar){
					if (this.position==nAlignBottom){
						this.setBarPos(this.centerPosX-this.getWidth()/2,this.centerPosY);					
					}else if (this.position==nAlignTop){
						this.setBarPos(this.centerPosX-this.getWidth()/2,this.centerPosY-this.bar.getSize());
					}else if (this.position==nAlignRight){
						this.setBarPos(this.centerPosX,this.centerPosY-this.getHeight()/2);
					}else if (this.position==nAlignLeft){
						this.setBarPos(this.centerPosX-this.bar.getSize(),this.centerPosY-this.getHeight()/2);
					}else if (this.position==euHORIZONTAL){
						this.setBarPos(this.centerPosX-this.getWidth()/2,this.centerPosY-this.bar.getSize()/2);						
					}else if(this.position==euVERTICAL){
						this.setBarPos(this.centerPosX-this.bar.getSize()/2,this.centerPosY-this.getHeight()/2);			
					}
				}
			}			
			
			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){					
					if (this.position==nAlignTop || this.position==nAlignBottom || this.position==euHORIZONTAL){						
						bakWidth  += this.iconsArray[i].getWidth();
						bakHeight = (this.iconsArray[i].getHeight()>bakHeight)?this.iconsArray[i].getHeight():bakHeight;
						bakHeight = Math.round(bakHeight);
					}else{						
						bakHeight += this.iconsArray[i].getHeight();
						bakWidth  = (this.iconsArray[i].getWidth()>bakWidth)?this.iconsArray[i].getWidth():bakWidth;
						bakWidth = Math.round(bakWidth);
					}
				}
				
				if (this.bar){
					if (this.position==nAlignTop || this.position==nAlignBottom || this.position==euHORIZONTAL)
						this.bar.setProperties(bakWidth,this.position)
					else
						this.bar.setProperties(bakHeight,this.position)
					this.bar.refresh();
				}
				
				//bakWidth=Math.ceil(bakWidth);			
				//bakHeight=Math.ceil(bakHeight);
								
				var posx=0;
				var posy=0;
				var updPosX=0;
				var updPosY=0;
				for (var i in this.iconsArray) if (this.iconsArray[i].id){					
					if (this.position==nAlignBottom){
						updPosX=posx;
						updPosY=posy;
						posx+=this.iconsArray[i].getWidth();
					}else if (this.position==nAlignTop){
						updPosX=posx;
						updPosY=bakHeight-this.iconsArray[i].getHeight();
						posx+=this.iconsArray[i].getWidth();
					}else if (this.position==nAlignRight){
						updPosX=posx;
						updPosY=posy;
						posy+=this.iconsArray[i].getHeight();
					}else if (this.position==nAlignLeft){
						updPosX=bakWidth-this.iconsArray[i].getWidth();
						updPosY=posy;
						posy+=this.iconsArray[i].getHeight();
					}else if (this.position==euHORIZONTAL){
						updPosX=posx;
						updPosY=(bakHeight-this.iconsArray[i].getHeight())/2;
						posx+=this.iconsArray[i].getWidth();
					}else if (this.position==euVERTICAL){
						updPosX=(bakWidth-this.iconsArray[i].getWidth())/2;
						updPosY=posy;
						posy+=this.iconsArray[i].getHeight();						
					}
					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;
				if (this.position==nAlignTop || this.position==nAlignBottom || this.position==euHORIZONTAL){
					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;
							if (this.animaition==nAnimationIcon){
								mouseRelX  = this.iconsArray[i].posX+border;
								border=0;
							}
						}
					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==nAnimationIcon  && Math.abs(i-overIcon)<=this.venusHillSize)
							frameTo = this.venusHillTrans(1-Math.abs(i-overIcon)/this.venusHillSize);
						else if (this.animaition==nAnimationWave && 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 (this.animFading==euABSOLUTE)
							if (this.iconsArray[i].isInsideX(mouseRelX))
								ret|=this.iconsArray[i].setFadingTo(1);
							else
								ret|=this.iconsArray[i].setFadingTo(0);
						else
							ret|=this.iconsArray[i].setFadingTo(frameTo);
						
					}
				}else{
					venusHeight = this.getVenusHeight();
					for (var i in this.iconsArray) if (this.iconsArray[i].id)
						if (this.iconsArray[i].isInsideY(mouseRelY)){
							overIcon=i;
							border=this.iconsArray[i].getHeight()/2;
							if (this.animaition==nAnimationIcon){
								mouseRelY  = this.iconsArray[i].posY+border;
								border=0;
							}
						}					
					for (var i in this.iconsArray) if (this.iconsArray[i].id){
						mediana = this.iconsArray[i].posY+this.iconsArray[i].getHeight()/2;
						if (Math.abs(mediana-mouseRelY)<=border)
							mediana=mouseRelY;
						else if (mediana<mouseRelY)
							mediana+=this.iconsArray[i].getHeight()/2;
						else if (mediana>mouseRelY)
							mediana-=this.iconsArray[i].getHeight()/2;
						if (this.animaition==nAnimationIcon  && Math.abs(i-overIcon)<=this.venusHillSize)
							frameTo = this.venusHillTrans(1-Math.abs(i-overIcon)/this.venusHillSize);
						else if (this.animaition==nAnimationWave && Math.abs(mediana-mouseRelY)<=venusHeight)
							frameTo = this.venusHillTrans(1-Math.abs(mediana-mouseRelY)/venusHeight);
						else
							frameTo = 0;
							
						if (frameTo==0 || frameTo==1 || Math.abs(frameTo-this.iconsArray[i].frame)>0.01)
							ret|=this.iconsArray[i].setFrameTo(frameTo);
							
						if (this.animFading==euABSOLUTE)
							if (this.iconsArray[i].isInsideY(mouseRelY))
								ret|=this.iconsArray[i].setFadingTo(1);
							else
								ret|=this.iconsArray[i].setFadingTo(0);
						else
							ret|=this.iconsArray[i].setFadingTo(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();
			}
}
 
/*================================================================================*/
/* <Function> Standard Dock Functions  </Function>
/*================================================================================*/
function euDockIcon(id, dock){
			this.id = id;			
			this.parentDock = dock;
			this.elementsArray;
			this.zoomFuncW=euLinear30;
			this.zoomFuncH=euLinear30;
			
			this.posX          = 0;
			this.posY          = 0;
			this.width         = 0;
			this.height        = 0;
			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(){
				if (!this.loaded)return;
				var stato = this.fadingFrame*(this.elementsArray.length-1);
				var prev  = Math.floor(stato);
				var next  = Math.ceil( stato);
				var fading=0;
				for (var i=0;i<this.elementsArray.length;i++){
					if (this.fadingType==euFIXED){
						if (i==next)
							fading=100-100*(i-stato);
						else if (i<next)
							fading=100;
						else
							fading=0;
					}else{
						if (i==next)
							fading=100-100*(i-stato);
						else if (i==prev){
							if (this.fadingType==euTRANSPARENT)
								fading=100-100*(stato-i);
							else
								fading=100;
						}else
							fading=0;
					}
					this.elementsArray[i].setFading(fading);
				}				
			}
			
			this.refresh = function(){
				this.updateDims();
				this.updateFading();
			}

			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.setFadingTo(to);
				this.setFrameTo(to) ;
				return this.isRunning();
			}
			
			this.setFadingTo = function(fadingTo){
				if (this.fadingFrame==fadingTo)
					this.runningFading = false;
				else{					
					if (this.fadingFrame>fadingTo)
						this.fadingFrame-=this.fadingStep;
					else
						this.fadingFrame+=this.fadingStep;
						
					this.runningFading = true;					
						
					if (Math.abs(this.fadingFrame-fadingTo)<this.fadingStep)
						this.fadingFrame=fadingTo;
				
					if (this.fadingFrame<0)
						this.fadingFrame = 0;
					if (this.fadingFrame>1)
						this.fadingFrame = 1;
				}
				return this.runningFading;
			}
			
			this.setFrameTo = function(frameTo){
				//frameTo=(Math.round(frameTo*100))/100;				
				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)                 *******
 **************************************** 
 */
 
 /* 
 ****************************************
 ******    euDock Bar Object     *******
 ******     (START)               *******
 **************************************** 
 */
		function euDockBar(id,dock){
			this.id = id;
			
			this.parentDock = dock;
			
			this.elementsArray=new Array();
			
			this.len=0;
			this.align=nAlignTop;
			
			this.loaded = false;
			
			this.getSize = function(){
				if (!this.loaded)
					return 0;				
				if (this.align==nAlignTop || this.align==nAlignBottom || this.align==euHORIZONTAL)				
					return this.elementsArray.left.getHeight();
				else
					return this.elementsArray.top.getWidth();
			}
			
			this.refresh = function(){
				if (!this.loaded)
					return;			
				if (this.align==nAlignTop || this.align==nAlignBottom || this.align==euHORIZONTAL){
					this.elementsArray.left.setPos(-this.elementsArray.left.getWidth(),0);
					this.elementsArray.horizontal.setProperties(0,0,Math.round(this.len),this.getSize());
					this.elementsArray.right.setPos(Math.round(this.len),0);
					this.elementsArray.left.show();
					this.elementsArray.horizontal.show();
					this.elementsArray.right.show();
					if (this.elementsArray.top)
						this.elementsArray.top.hide();
					if (this.elementsArray.bottom)
						this.elementsArray.bottom.hide();
					if (this.elementsArray.vertical){
						this.elementsArray.vertical.setProperties(0,0,0,0);
						this.elementsArray.vertical.hide();
					}
				}else{
					this.elementsArray.top.setPos(0,-this.elementsArray.top.getHeight());
					this.elementsArray.vertical.setProperties(0,0,this.getSize(),Math.round(this.len));
					this.elementsArray.bottom.setPos(0,Math.round(this.len));
					this.elementsArray.top.show();
					this.elementsArray.vertical.show();
					this.elementsArray.bottom.show();
					if (this.elementsArray.left)
						this.elementsArray.left.hide();
					if (this.elementsArray.right)
						this.elementsArray.right.hide();
					if (this.elementsArray.horizontal){
						this.elementsArray.horizontal.setProperties(0,0,0,0);
						this.elementsArray.horizontal.hide();
					}
				}				
					
			}
			
			this.setProperties = function(len,align){				
				this.len=len+1;
				this.align=align;
				this.refresh();
			}
			
			this.retrieveLoadingDims = function(elem){
				if (elem.onLoadPrev)
					elem.onLoadPrev();
				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.setElements = function(args){
				if (typeof(args)!="undefined" && args!=null){
					for (var i in args)
						for (var ii in args[i]){
							var id = "euDock_"+ii+"_"+euEnv.Kost.next();
							//if (this.elementsArray[i]){
							//	this.elementsArray[i].hide();
							//	euEnv.euDockArray[this.elementsArray[i].id]=null;
							//}
							euEnv.euDockArray[id]=new window[ii](id,args[i][ii],this.parentDock.divBar,"euEnv.euDockArray."+this.id+".retrieveLoadingDims(euEnv.euDockArray."+id+");");
							this.elementsArray[i]=euEnv.euDockArray[id];
							euEnv.euDockArray[id].loaded=false;
						}
				}				
			}
		}
/* 
 ****************************************
 ******    euDock Bar Object      *******
 ******     (END)                 *******
 **************************************** 
 */
function euThread() {
	getWindowSize();
	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;
}

/*================================================================================*/
/* <Function> Event-Handlers </Function>
/*================================================================================*/
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;

/*================================================================================*/
/* <Function> Startup </Function>
/*================================================================================*/
getWindowSize();
offsEut();
euThread();

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/


/*================================================================================*/
/* <Function> Image Preloading </Function>
/*================================================================================*/
function euPreloadImage(strImage) {
 		 var oDoc = document;
		
		 if (oDoc.images) {
			if (!oDoc.p) oDoc.p = new Array();
			oDoc.p.push(new Image());
			oDoc.p[oDoc.p.length - 1].src = strImage;
		}
}

/*================================================================================*/
/* <Function> Image-Object </Function>
/*================================================================================*/
function euImage(strID, oArgs, oContainer, onLoadFunc){
		 if (!oArgs.PngObjIE) oArgs.PngObjIE = euImageIE_PNG;
			
 		 if ((typeof(window.innerWidth) != 'number') && (oArgs.image.toLowerCase().indexOf("png") != -1)) { 
 		    return new oArgs.PngObjIE(strID, oArgs, oContainer, onLoadFunc);			
		 }
		 
		 this.id = strID;
		 this.container = oContainer;
			
      	 //var strImg = euEnv.imageBasePath + euEnv.imageSymPath + oArgs.image;
	     var strImg = oArgs.image;
						
			euPreloadImage(strImg);	
			
			this.setProperties = function(x,y,w,h){
				this.setPos(x,y);
				this.setDim(w,h);
			}
			
			this.setPos = function(x,y){
				this.setPosX(x);
				this.setPosY(y);
			}	
			
			this.setDim = function(w,h){
				this.setWidth(w);
				this.setHeight(h);
			}	
			
			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).width;}
			this.setWidth  = function(w){document.getElementById(this.id).width=Math.round(w);}
			this.getHeight  = function() {return document.getElementById(this.id).height;}		
			this.setHeight = function(h){document.getElementById(this.id).height=Math.round(h);}
			
			this.hide = function(){document.getElementById(this.id).style.visibility='hidden';}			
			this.show = function(){document.getElementById(this.id).style.visibility='visible';}			
			
			this.setFading = function(fad){
				fad=Math.round(fad);
				if (fad<0)
					fad=0;
				if (fad>100)
					fad=100;
       			document.getElementById(this.id).style.opacity = (fad/100);
       			document.getElementById(this.id).style.filter = "alpha(opacity="+(fad)+");";
			}
			
			this.container.innerHTML += "<img onLoad='" + onLoadFunc + ";' id='" + this.id + "' src='" + strImg + "' style='position:absolute;visibility:hidden;'>";
			
			this.destroy = function() {
				                   this.container.removeChild(document.getElementById(this.id));				
			}
}
 
/*================================================================================*/
/* <Function> PNG-Image handler for IIS < V7 </Function>
/*================================================================================*/
function euImageIE_PNG(strID, oArgs, oContainer, onLoadFunc){
	     this.id        = strID;
		 this.container = oContainer;

      	 //var strImg = euEnv.imageBasePath + euEnv.imageSymPath + args.image;
	     var strImg = oArgs.image;
			
		 euPreloadImage(strImg);	
			
		 this.setProperties = function(nX, nY, nW, nH) { this.setPos(nX, nY); this.setDim(nW, nH); }
	  	 this.setPos = function(nX, nY) { this.setPosX(nX); this.setPosY(nY); }
	     this.setDim = function(nW, nH) { this.setWidth(nW); this.setHeight(nH); }
 		 
 		 this.getPosX = function() {return document.getElementById(this.id).style.left.replace(/[^0-9]/g,"");}			
		 this.setPosX = function(nX) { document.getElementById(this.id).style.left = nX + 'px'; }
		 this.getPosY = function() {return document.getElementById(this.id).style.top.replace(/[^0-9]/g,"");}	
		 this.setPosY = function(nY) { document.getElementById(this.id).style.top = nY + 'px'; }
			
	     this.getWidth = function() {if (!this.width) return 0; return this.width; }
	     this.setWidth = function(nW) {
				                  if (!this.width) return;
				                  nW = Math.round(nW);
				                  this.width = nW;		
				                  document.getElementById(this.id).style.width = nW + 'px';
				                  document.getElementById(this.id + "_IMG").style.width = nW + 'px';				
		 }
		 
		 this.getHeight = function() { if (!this.height) return 0; return this.height; }		
 		 this.setHeight = function(nH) {
				                  if (!this.height) return;
				                  nH = Math.round(nH);
				                  this.height = nH;		
				                  document.getElementById(this.id).style.height = nH + 'px';
				                  document.getElementById(this.id + "_IMG").style.height = nH + 'px';				
		 }
			
		 this.onLoadPrev = function() {
		                      	   if (this.width && this.height) return;
				                   this.width = document.getElementById(this.id + "_IMG_BAK").width;
				                   this.height = document.getElementById(this.id + "_IMG_BAK").height;
				                   document.getElementById(this.id + "_IMG_BAK").width = 0;
				                   document.getElementById(this.id + "_IMG_BAK").height = 0;							
				                   this.setDim(this.width, this.height);
	  	 }
			
		 this.hide = function() { document.getElementById(this.id).style.visibility = 'hidden'; }	
	     this.show = function() { document.getElementById(this.id).style.visibility = 'visible'; if (this.width && this.height) this.setDim(this.width, this.height); }
			
	     this.setFading = function(nFade) {
				                  nFade = Math.round(nFade);
				                  if (nFade < 0) nFade = 0;
				                  if (nFade > 100) nFade = 100;
        			              document.getElementById(this.id).style.opacity = (nFade / 100);
        			              document.getElementById(this.id).style.filter = "alpha(opacity=" + nFade + ");";
		 }
			
		 this.container.innerHTML += "<div id='" + this.id + "' style='position:absolute;'></div>";
		 document.getElementById(this.id).innerHTML = "<img src='" + euEnv.imageBasePath + "blank.gif' id='" + this.id + "_IMG' style=\"top:0px;left:0px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + strImg + "',sizingMethod='scale');position:absolute;\">";
		 this.container.innerHTML += "<img onLoad='" + onLoadFunc + ";' id='" + this.id + "_IMG_BAK' src='" + strImg + "' style='visibility:hidden;position:absolute;'>";		
			
		 this.destroy = function() {
		                		this.container.removeChild(document.getElementById(this.id));
				                this.container.removeChild(document.getElementById(this.id + "_IMG_BAK"));
		 }			
}
 
/*================================================================================*/
/* <Function> PNG-Image handler for IIS < V7 (Without Fading) </Function>
/*================================================================================*/
function euImageNoFadingIE_PNG(id,args,container,onLoadFunc){
		this.id = id;
		this.container = container;
					
		euPreloadImage(args.image);	
		
		this.setProperties = function(x,y,w,h){
			this.setPos(x,y);
			this.setDim(w,h);
		}
		
		this.setPos = function(x,y){
			this.setPosX(x);
			this.setPosY(y);
		}	
		
		this.setDim = function(w,h){
			this.setWidth(w);
			this.setHeight(h);
		}
		
		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() {if (!this.width) return 0;return this.width;}
		this.setWidth  = function(w){if (!this.width) return;  this.width=Math.round(w);document.getElementById(this.id).style.width=Math.round(w)+'px';}
		this.getHeight  = function(){if (!this.height)return 0;return this.height;}		
		this.setHeight = function(h){if (!this.height)return;  this.height=Math.round(h);document.getElementById(this.id).style.height=Math.round(h)+'px';}
		
		this.hide = function(){document.getElementById(this.id).style.visibility='hidden';}			
		this.show = function(){document.getElementById(this.id).style.visibility='visible';}
		
		this.onLoadPrev = function(){
			if (this.width && this.height)return;
			this.width=document.getElementById(this.id+"_IMG_BAK").width;
			this.height=document.getElementById(this.id+"_IMG_BAK").height;
			document.getElementById(this.id+"_IMG_BAK").width=0;
			document.getElementById(this.id+"_IMG_BAK").height=0;							
			this.setDim(this.width,this.height);
		}			
		
		this.setFading = function(fad){}
		
		this.container.innerHTML+="<img src='"+euEnv.imageBasePath+"blank.gif' id='"+this.id+"' style='position:absolute;visibility:hidden;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\""+args.image+"\",sizingMethod=\"scale\");' >";
		this.container.innerHTML+="<img onLoad='" + onLoadFunc + ";' id='"+this.id+"_IMG_BAK' src='"+args.image+"' style='position:absolute;visibility:hidden;'>";
		
		this.destroy = function(){
			this.container.removeChild(document.getElementById(this.id));
			this.container.removeChild(document.getElementById(this.id+"_IMG_BAK"));
		}			
}

/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
