/*
* 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
*
*/

/*
*
* This program is absolutely free...
*           ...BUT...
* If you modify(OR TRY TO DO THAT)this Source Code,
* my SOUL will carry you some monstrous Nightmares
*
* Have a nice day
* enjoy yourself.
*          Pier...
*
* (Sorry but I'm Italian not an American writer)
*                            (...a day Maybe...)
*/

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 euLinear70(x){
return 1*(x+(1-x)*0.7);
};

function euLinear20(x){	
return x+(1-x)*0.2;
};

function euExp30(x){
return euLinear30(x*x*x);
};

function v(x){	
return x+(1-x)*0.5;
};		

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;
if (align==euUP)
this.position=euDOWN;
else if (align==euDOWN)					
this.position=euUP;
else if (align==euLEFT)
this.position=euRIGHT;
else if (align==euRIGHT)					
this.position=euLEFT;
this.setScreenCoord();
};

this.setScreenCoord = function(){
euDimensioni();
offsEut();
if (this.position==euDOWN)
this.setCenterPos(
euEnv.euScrOfX+euEnv.euFrameWidth/2,
euEnv.euScrOfY+this.offset);
else if (this.position==euUP)
this.setCenterPos(
euEnv.euScrOfX+euEnv.euFrameWidth/2,
euEnv.euScrOfY+euEnv.euFrameHeight-this.offset);					
else if (this.position==euRIGHT)
this.setCenterPos(
euEnv.euScrOfX+this.offset,
euEnv.euScrOfY+euEnv.euFrameHeight/2);
else if (this.position==euLEFT)
this.setCenterPos(
euEnv.euScrOfX+euEnv.euFrameWidth-this.offset,
euEnv.euScrOfY+euEnv.euFrameHeight/2);				
};

this.refreshDiv = function(){
if (this.position==euDOWN){
this.setPos(this.centerPosX-this.getWidth()/2,this.centerPosY+this.iconOffset);					
}else if (this.position==euUP){
this.setPos(this.centerPosX-this.getWidth()/2,this.centerPosY-this.getHeight()-this.iconOffset);
}else if (this.position==euRIGHT){					
this.setPos(this.centerPosX+this.iconOffset,this.centerPosY-this.getHeight()/2);
}else if (this.position==euLEFT){					
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==euDOWN){
this.setBarPos(this.centerPosX-this.getWidth()/2,this.centerPosY);					
}else if (this.position==euUP){
this.setBarPos(this.centerPosX-this.getWidth()/2,this.centerPosY-this.bar.getSize());
}else if (this.position==euRIGHT){
this.setBarPos(this.centerPosX,this.centerPosY-this.getHeight()/2);
}else if (this.position==euLEFT){
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==euUP || this.position==euDOWN || 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==euUP || this.position==euDOWN || 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==euDOWN){
updPosX=posx;
updPosY=posy;
posx+=this.iconsArray[i].getWidth();
}else if (this.position==euUP){
updPosX=posx;
updPosY=bakHeight-this.iconsArray[i].getHeight();
posx+=this.iconsArray[i].getWidth();
}else if (this.position==euRIGHT){
updPosX=posx;
updPosY=posy;
posy+=this.iconsArray[i].getHeight();
}else if (this.position==euLEFT){
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==euUP || this.position==euDOWN || 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==euICON){
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==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 (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==euICON){
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==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-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();
};			

};
/* 
****************************************
******    euDock Object          *******
******     (END)                 *******
**************************************** 
*/

/* 
****************************************
******    euDock Icon Object     *******
******     (START)               *******
**************************************** 
*/
function euDockIcon(id,dock){
this.id = id;			

this.parentDock = dock;

this.elementsArray;

this.zoomFuncW=euLinear70;
this.zoomFuncH=euLinear70;


this.posX          = 0;
this.posY          = 0;
this.width         = 136;
this.height        = 201;
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;
/*ekli*/				this.fadingType = euFIXED;
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=euUP;

this.loaded = false;

this.getSize = function(){
if (!this.loaded)
return 0;				
if (this.align==euUP || this.align==euDOWN || this.align==euHORIZONTAL)				
return this.elementsArray.left.getHeight();
else
return this.elementsArray.top.getWidth();
};

this.refresh = function(){
if (!this.loaded)
return;			
if (this.align==euUP || this.align==euDOWN || 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(){
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();

/*blank*/
function euBlank(id,args,container,onLoadFunc){
this.id = id;

this.setProperties = function(x,y,w,h,fad){
this.setPos(x,y);
this.setDim(w,h);
this.setFading(fad);
};

this.setPos = function(x,y){
this.setPosX(x);
this.setPosY(y);
};	

this.setDim = function(w,h){
this.setWidth(w);
this.setHeight(h);
};

this.x=0;
this.y=0;
/*
this.width=0;
this.height=0;
*/
this.width=134;
this.height=156;

this.getPosX   = function() {return this.x;};			
this.setPosX   = function(x){this.x=x;};
this.getPosY   = function() {return this.y;};	
this.setPosY   = function(y){this.y=y;};
this.getWidth  = function() {return this.width;};
this.setWidth  = function(w){this.width=w;};
this.getHeight  = function(){return this.height;};		
this.setHeight = function(h){this.height=h;};		

this.hide = function(){};			
this.show = function(){};			

this.setFading = function(fad){};

if (typeof(args)!="undefined" && args!=null)
for (var i in args)
this[i]=args[i];

window.setTimeout(onLoadFunc,500);

this.destroy = function(){};			
};
/* 
******    euBlank Object         *******
******     (END)                 *******
*/

/*image*/
function euPreloadImage(a) {
var d=document;
if(d.images){
if(!d.p) d.p=new Array();
d.p.push(new Image());
d.p[d.p.length-1].src=a;
}
};

if (!euEnv.imageBasePath)
euEnv.imageBasePath = "./";
/* 
****************************************
******    euImage Object         *******
******     (START)               *******
**************************************** 
*/
function euImage(id,args,container,onLoadFunc){
if (!args.PngObjIE)
args.PngObjIE=euImageIE_PNG;
if (typeof( window.innerWidth ) != 'number' && args.image.toLowerCase().indexOf("png")!=-1)
return new args.PngObjIE(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() {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='"+args.image+"'  style='position:absolute;visibility:hidden;'>";

this.destroy = function(){
this.container.removeChild(document.getElementById(this.id));				
};
};
/* 
****************************************
******    euImage Object         *******
******     (END)                 *******
**************************************** 
*/

/* 
****************************************
******    euImageIE_PNG Object   *******
******     (START)               *******
**************************************** 
*/
function euImageIE_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';
document.getElementById(this.id+"_IMG").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';
document.getElementById(this.id+"_IMG").style.height=Math.round(h)+'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(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+="<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='"+args.image+"',sizingMethod='scale');position:absolute;\">";
this.container.innerHTML+="<img onLoad='"+onLoadFunc+";' id='"+this.id+"_IMG_BAK' src='"+args.image+"' style='visibility:hidden;position:absolute;' class='buyuk'>";		

this.destroy = function(){
this.container.removeChild(document.getElementById(this.id));
this.container.removeChild(document.getElementById(this.id+"_IMG_BAK"));

};			
};
/* 
****************************************
******    euImageIE_PNG Object   *******
******     (END)                 *******
**************************************** 
*/

/* 
****************************************
*****euImageNoFadingIE_PNG Object ******
******     (START)               *******
**************************************** 
*/
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"));
};			
};
/* 
****************************************
*****euImageNoFadingIE_PNG Object ******
******     (END)                 *******
**************************************** 
*/


/*lab*/
function euLabel(id,args,container,onLoadFunc){

this.id = id;
this.container = container;

//			this.anchor  = euDOWN;
this.anchor  = euCENTER;
this.offsetX = 0;
//			this.offsetY = 0;
this.offsetY = -100;

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.width=0;
this.height=0;




this.posX=0;
this.posY=0;

this.getPosX   = function() {return this.object.getPosX();};			
this.setPosX   = function(x) {this.posX=x;this.object.setPosX(x);};
this.getPosY   = function() {return this.object.getPosY();};	
this.setPosY   = function(y) {this.posY=y;this.object.setPosY(y);
};
this.getWidth  = function() {return this.object.getWidth();};
this.setWidth  = function(w){this.width=w;this.object.setWidth(w);};
this.getHeight  = function() {return this.object.getHeight();};		
this.setHeight = function(h){this.height=h;this.object.setHeight(h);};

this.hide = function(){this.object.hide();document.getElementById(this.id).style.visibility='hidden';};			
this.show = function(){this.object.show();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.object.setFading(fad);
};

this.onLoadPrev = function(){
if (this.object.onLoadPrev)
this.object.onLoadPrev();
};	

this.onLoadNext = function(){
if (this.object.onLoadNext)
this.object.onLoadNext();
};

this.mouseMove = function(x,y){
if (this.object.mouseMove)
this.object.mouseMove(x,y);
return false;				
};			

this.riposition = function(){
if (this.object.riposition)
this.object.riposition();		
if (this.anchor==euDOWN){
document.getElementById(this.id).style.left=(this.posX+this.offsetX+(this.width-document.getElementById(this.id).offsetWidth)/2)+'px';					
document.getElementById(this.id).style.top =(this.posY+this.height+this.offsetY)+'px';
}else if (this.anchor==euUP){
document.getElementById(this.id).style.left=(this.posX+this.offsetX+(this.width-document.getElementById(this.id).offsetWidth)/2)+'px';					
document.getElementById(this.id).style.top =(this.posY+this.offsetY)+'px';
}else if (this.anchor==euLEFT){
document.getElementById(this.id).style.left=(this.posX+this.offsetX)+'px';					
document.getElementById(this.id).style.top =(this.posY+this.offsetY+(this.height-document.getElementById(this.id).offsetHeight)/2)+'px';					
}else if (this.anchor==euRIGHT){
document.getElementById(this.id).style.left=(this.posX+this.width+this.offsetX)+'px';					
document.getElementById(this.id).style.top =(this.posY+this.offsetY+(this.height-document.getElementById(this.id).offsetHeight)/2)+'px';					
}else if (this.anchor==euCENTER){
document.getElementById(this.id).style.left=(this.posX+this.offsetX+(this.width-document.getElementById(this.id).offsetWidth)/2)+'px';					
document.getElementById(this.id).style.top =(this.posY+this.offsetY+(this.height-document.getElementById(this.id).offsetHeight)/2)+'px';					
}
};			

if (args.anchor)	
this.anchor  = args.anchor;
if (args.offsetX)
this.offsetX  = args.offsetX;


if (args.offsetY)
this.offsetY  = args.offsetY;

var style="";
if (args.style)
style = args.style;

for (var i in args.object)
this.object = new window[i](this.id+"_LABEL_OBJECT",args.object[i],this.container,onLoadFunc);
this.container.innerHTML+="<span id='"+this.id+"' src='"+args.image+"' style='position:absolute;visibility:hidden;' class='but_label'>"+args.txt+"</span>";

this.destroy = function(){
this.object.destroy();
this.object=null;
this.container.removeChild(document.getElementById(this.id));
};			
};
/*lab*/

/*
* jQuery selectbox plugin
*/
jQuery.fn.extend({
selectbox: function(options) {
return this.each(function() {
new jQuery.SelectBox(this, options);
});
}
});


/* pawel maziarz: work around for ie logging */
if (!window.console) {
var console = {
log: function(msg) { 
}
}
}

jQuery.SelectBox = function(selectobj, options) {

var opt = options || {};
opt.inputClass = opt.inputClass || "selectbox";
opt.containerClass = opt.containerClass || "selectbox-wrapper";
opt.hoverClass = opt.hoverClass || "current";
opt.currentClass = opt.selectedClass || "selected"
opt.debug = opt.debug || false;

var elm_id = selectobj.id;
var active = -1;
var inFocus = false;
var hasfocus = 0;
//jquery object for select element
var $select = $(selectobj);
// jquery container object
var $container = setupContainer(opt);
//jquery input object 
var $input = setupInput(opt);

$input.css("width", $select.css("width"));
// hide select and append newly created elements
$select.hide().before($input).before($container);


init();

$input
.click(function(){


if (!inFocus ){
$container.toggle();
}else if (firstFocusEvent){
firstFocusEvent = false;
$container.show();
}else{
hideMe();	
}	

})
.focus(function(e){
if (!$container.is(':visible')) {	   
inFocus = true;
firstFocusEvent = true;
//$container.show();
}
})
.focus(function(e){
if (!$container.is(':visible')) {	   
inFocus = true;
firstFocusEvent = true;
//$container.show();
}
})
.keydown(function(event) {	   
switch(event.keyCode) {
case 38: // up
event.preventDefault();
moveSelect(-1);
if (!$container.is(':visible')){
$('li.'+opt.hoverClass).click();
}
break;
case 40: // down
event.preventDefault();
moveSelect(1);
if (!$container.is(':visible')){
$('li.'+opt.hoverClass).click();
}
break;
//case 9:  // tab 
case 13: // return
event.preventDefault(); // seems not working in mac !
$('li.'+opt.hoverClass).trigger('click');
break;
case 27: //escape
hideMe();
break;
}
})

.blur(function() {
//modified by CJA to allow clicking on scrollbar
if (($container.is(':visible') && hasfocus > 0) || (event.srcElement.id === $input[0].id)) {
if (opt.debug) console.log('container visible and has focus')
} else {
hideMe();
}
});

function hideMe() { 
hasfocus = 0;
inFocus = false;
firstFocusEvent = false;
$container.hide(); 
}

function init() {
$container.append(getSelectOptions($input.attr('id'))).hide();
var width = $input.css('width');
$container.width(width);
}

function setupContainer(options) {
var container = document.createElement("div");
$container = $(container);
$container.attr('id', elm_id+'_container');
$container.addClass(options.containerClass);

return $container;
}

function setupInput(options) {
var input = document.createElement("input");
var $input = $(input);
$input.attr("id", elm_id+"_input");
$input.attr("type", "text");
$input.addClass(options.inputClass);
$input.attr("autocomplete", "off");
$input.attr("readonly", "readonly");
$input.attr("tabIndex", $select.attr("tabindex")); // "I" capital is important for ie

return $input;	
}

function moveSelect(step) {
var lis = $("li", $container);
if (!lis) return;

active += step;

if (active < 0) {
active = 0;
} else if (active >= lis.size()) {
active = lis.size() - 1;
}

lis.removeClass(opt.hoverClass);

$(lis[active]).addClass(opt.hoverClass);
}

function setCurrent() {	
var li = $("li."+opt.currentClass, $container).get(0);
var ar = (''+li.id).split('_');
var el = ar[ar.length-1];
//$select.val(el);
$select.val(el).attr("selectedIndex", $container.find("li").index(li));
$input.val($(li).html());
return true;
}
// select value
function getCurrentSelected() {
return $select.val();
}
// input value
function getCurrentValue() {
return $input.val();
}

function getSelectOptions(parentid) {
var select_options = new Array();
var ul = document.createElement('ul');
$select.children('option').each(function() {
var li = document.createElement('li');
li.setAttribute('id', parentid + '_' + $(this).val());
li.innerHTML = $(this).html();
if ($(this).is(':selected')) {
$input.val($(this).html());
$(li).addClass(opt.currentClass);
}
ul.appendChild(li);
$(li)
.mouseover(function(event) {
hasfocus = 1;
if (opt.debug) console.log('over on : '+this.id);
jQuery(event.target, $container).addClass(opt.hoverClass);
})
.mouseout(function(event) {
hasfocus = -1;
if (opt.debug) console.log('out on : '+this.id);
jQuery(event.target, $container).removeClass(opt.hoverClass);
})
.click(function(event) {
var fl = $('li.'+opt.hoverClass, $container).get(0);
if (opt.debug) console.log('click on :'+this.id);
$('li.'+opt.currentClass).removeClass(opt.currentClass); 
$(this).addClass(opt.currentClass);
setCurrent();
hideMe();
$select.change();
//$select.get(0).blur();
var $inputbox = $(this).parents(".selectboxbg").next(".textareabg)").children(".answerText")
$inputbox.fadeOut("fast", function (){
$(this).attr("value","");
$(this).show();
});
});
});
return ul;
}

};

/* ------------------------------------------------------------------------
prettyCheckboxes

Developped By: Stephane Caron (http://www.no-margin-for-errors.com)
Inspired By: All the non user friendly custom checkboxes solutions ;)
Version: 1.1

Copyright: Feel free to redistribute the script/modify it, as
long as you leave my infos at the top.
------------------------------------------------------------------------- */

jQuery.fn.prettyCheckboxes = function(settings) {
settings = jQuery.extend({
checkboxWidth: 19,
checkboxHeight: 19,
className : 'prettyCheckbox',
display: 'list'
}, settings);

$(this).each(function(){
// Find the label
$label = $('label[for="'+$(this).attr('id')+'"]');

// Add the checkbox holder to the label
$label.prepend("<span class='holderWrap'><span class='holder'></span></span>");

// If the checkbox is checked, display it as checked
if($(this).is(':checked')) { $label.addClass('checked'); };

// Assign the class on the label
$label.addClass(settings.className).addClass($(this).attr('type')).addClass(settings.display);

// Assign the dimensions to the checkbox display
$label.find('span.holderWrap').width(settings.checkboxWidth).height(settings.checkboxHeight);
$label.find('span.holder').width(settings.checkboxWidth);

// Hide the checkbox
$(this).addClass('hiddenCheckbox');

// Associate the click event
$label.bind('click',function(){
$('input#' + $(this).attr('for')).triggerHandler('click');

if($('input#' + $(this).attr('for')).is(':checkbox')){
$(this).toggleClass('checked');
$('input#' + $(this).attr('for')).checked = true;

$(this).find('span.holder').css('top',0);
}else{
$toCheck = $('input#' + $(this).attr('for'));

// Uncheck all radio
$('input[name="'+$toCheck.attr('name')+'"]').each(function(){
$('label[for="' + $(this).attr('id')+'"]').removeClass('checked');	
});

$(this).addClass('checked');
$toCheck.checked = true;
};
});

$('input#' + $label.attr('for')).bind('keypress',function(e){
if(e.keyCode == 32){
if($.browser.msie){
$('label[for="'+$(this).attr('id')+'"]').toggleClass("checked");
}else{
$(this).trigger('click');
}
return false;
};
});
});
};

checkAllPrettyCheckboxes = function(caller, container){
if($(caller).is(':checked')){
// Find the label corresponding to each checkbox and click it
$(container).find('input[type=checkbox]:not(:checked)').each(function(){
$('label[for="'+$(this).attr('id')+'"]').trigger('click');
if($.browser.msie){
$(this).attr('checked','checked');
}else{
$(this).trigger('click');
};
});
}else{
$(container).find('input[type=checkbox]:checked').each(function(){
$('label[for="'+$(this).attr('id')+'"]').trigger('click');
if($.browser.msie){
$(this).attr('checked','');
}else{
$(this).trigger('click');
};
});
};
};

/*#####################*/
function activebox(id){document.getElementById(id).style.display= 'block';}

function deactivebox(id){
if(id=="tecilyok"){
document.getElementById('tecilli').style.display= 'none';
document.getElementById('muaf').style.display= 'none';
}else{
document.getElementById(id).style.display= 'none';
}
}

function allc(sec){

var gruplar = new Array('g1','g2', 'g3', 'g4', 'g5','g6', 'g7');

for(var i=0;i<5;i++){
document.getElementById(gruplar[i]).style.display='none';	
}

document.getElementById(sec).style.display='';

/*
for(i=0;i<5;i++){
	if(gruplar[i] == "g1"){
		document.getElementById(gruplar[i]).style.display='';
	}
	else{
	document.getElementById(gruplar[i]).style.display='none';	
	}
*/
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

