DHTMLApi = {
	
	CSS : {
		getStyle: function (element, name) {
			var styleObj;
			if (element.style[name]) return element.style[name];
			if (element.currentStyle) {	
				name=name.replace(/-([a-z])/g, function (matched) {
					return matched.toUpperCase().slice(1, matched.length);
				});
				return element.currentStyle[name];
			}
			if (document.defaultView && document.defaultView.getComputedStyle) {
				name=name.replace(/([A-Z])/g,"-$1");
				name=name.toLowerCase();
				styleObj=document.defaultView.getComputedStyle(element,"");
				return styleObj && styleObj.getPropertyValue(name);
			} else {
				return null;
			}
		},
		
		setProperties: function (element, properties) {
			var oldProperties={};
			for (var i in properties) {
				oldProperties[i]=element.style[i];
				element.style[i]=properties[i];
			}
			return oldProperties;
		},
		
		setClass:function (element,addClassesArray,removeClassesArray) {
			var currentClasses=new Array();
			var newClasses=new Array();
			var removedClasses=new Array();
			findWordsExp=new RegExp("\\w+", "g");
			var result;
			while ((result= findWordsExp.exec(element.className))!= null) currentClasses.push(result[0]); 
			for (var i=0; i<addClassesArray.length; i++) {
				var classExists=false;
				for (var j=0; j<currentClasses.length; j++) {
					if (currentClasses[j]==addClassesArray[i]) {
						classExists=true;
						break;
					}					
				}
				if (!classExists) newClasses.push(addClassesArray[i]);
			}
			currentClasses=currentClasses.concat(newClasses);
			if (removeClassesArray==null) return removedClasses;
			for (var i=0; i<removeClassesArray.length; i++) {
				for (var j=0; j<currentClasses.length; j++) {
					if (currentClasses[j]==removeClassesArray[i]) {
						removedClasses=removedClasses.concat(currentClasses.splice(j,1));
						break;
					}					
				}
			}
			element.className=currentClasses.join(" ");
			return removedClasses;
		}
	},
	
	Position : {
		getXPosOnPage: function (element) {
			return element.offsetParent?element.offsetLeft+DHTMLApi.Position.getXPosOnPage(element.offsetParent):element.offsetLeft;
		},
		
		getYPosOnPage: function (element) {
			return element.offsetParent?element.offsetTop+DHTMLApi.Position.getYPosOnPage(element.offsetParent):element.offsetTop;
		},
		
		getXPosInElement: function (element,container) {
			return DHTMLApi.Position.getXPosOnPage(element)-DHTMLApi.Position.getXPosOnPage(container);
		},
		
		getYPosInElement: function (element,container) {
			return DHTMLApi.Position.getYPosOnPage(element)-DHTMLApi.Position.getYPosOnPage(container);
		},
		
		setXPosOnPage: function (element,posX) {
			var propertiesArray={};
			if (element.parentNode!=document.body) {
				element=element.parentNode.removeChild(element);
				document.body.appendChild(element);
			}
			if (DHTMLApi.CSS.getStyle(element,"position")!="absolute") {
				propertiesArray={position: "absolute"};
			}
			propertiesArray.left=posX+"px";
			DHTMLApi.CSS.setProperties(element,propertiesArray);
		},
		
		setYPosOnPage: function (element,posY) {
			var propertiesArray={};
			if (element.parentNode!=document.body) {
				element=element.parentNode.removeChild(element);
				document.body.appendChild(element);
			}
			if (DHTMLApi.CSS.getStyle(element,"position")!="absolute") {
				propertiesArray={position: "absolute"};
			}
			propertiesArray.top=posY+"px";
			DHTMLApi.CSS.setProperties(element,propertiesArray);
		},
		
		setXPos: function (element, posX, relativeToElement) {
			if (relativeToElement==undefined) {
				element.style.left=posX+"px";
			} else {
				if(DHTMLApi.CSS.getStyle(element.parentNode,"position")=="static"){
					element.parentNode.style.position="relative";
				}
				element.style.position="absolute";
				element.style.left=(posX-DHTMLApi.Position.getXPosInElement(element.parentNode,relativeToElement))+"px";
			}
		},
		
		setYPos: function (element, posY, relativeToElement) {
			if (relativeToElement==undefined) {
				element.style.top=posY+"px";
			} else {
				if(DHTMLApi.CSS.getStyle(element.parentNode,"position")=="static"){
					element.parentNode.style.position="relative";
				}
				element.style.position="absolute";
				element.style.top=(posY-DHTMLApi.Position.getYPosInElement(element.parentNode,relativeToElement))+"px";
			}
		}
		
	},
	
	Size : { 
		
		getElementWidth : function (element) {
			var tempProperties, width;
			if (DHTMLApi.CSS.getStyle(element, "display" ) != "none") {
				return element.offsetWidth || parseInt(DHTMLApi.CSS.getStyle(element, "width"));
			}
			tempProperties=DHTMLApi.CSS.setProperties(element, {display: "block", visibility: "hidden", position: "absolute"});
			width=element.clientWidth || parseInt(DHTMLApi.CSS.getStyle(element, "width"));
			DHTMLApi.CSS.setProperties(element, {display: "", visibility: "", position: ""});
			DHTMLApi.CSS.setProperties(element,tempProperties);
			return width;		
		},
		
		getElementHeight : function (element) {
			var tempProperties, height;
			if (DHTMLApi.CSS.getStyle(element, "display" ) != "none") {
				return element.offsetHeight || parseInt(DHTMLApi.CSS.getStyle(element, "height"));
			}
			tempProperties=DHTMLApi.CSS.setProperties(element, {display: "block", visibility: "hidden", position: "absolute"});
			height=element.clientHeight || parseInt(DHTMLApi.CSS.getStyle(element, "height"));
			DHTMLApi.CSS.setProperties(element, {display: "", visibility: "", position: ""});
			DHTMLApi.CSS.setProperties(element,tempProperties);
			return height;
		},
		
		getPageWidth: function () {
			return document.body.scrollHeight;
		},
		
		getPageHeight: function () {
			return Math.max(document.body.scrollHeight,document.body.offsetHeight);
		}
	
	},
	
	Visibility: {
		
		show: function (element) {
			element.style.display=element.__display__ || 'block';
		},
		
		hide: function (element) {
			var currentDisplay=DHTMLApi.CSS.getStyle(element,"display");
			if (currentDisplay != 'none') element.__display__=currentDisplay;
			element.style.display='none';
		},
		
		setOpacity: function (element,percent) {
			if (element.filters) {	
				element.style.filter='alpha(opacity='+percent+')';
			} else {
				element.style.opacity=percent/100;
			}
		}
		
	},
	
	Browser : {
		
		getViewportWidth: function () {
			return self.innerWidth || (document.documentElement && document.documentElement.clientWidth) || document.body.clientWidth;
		},
		
		getViewportHeight: function () {
			return self.innerHeight || (document.documentElement && document.documentElement.clientHeight) || document.body.clientHeight;
		},
		
		getScrollX: function () {
			return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || document.body.scrollLeft;
		},
		
		getScrollY: function () {
			return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
		}		
	}
};

MousePositionOnPage = {
	getX: function (mouseEvent) {
		return mouseEvent.pageX || mouseEvent.clientX+DHTMLApi.Browser.getScrollX();
	},
	getY: function (mouseEvent) {
		return mouseEvent.pageY || mouseEvent.clientY+DHTMLApi.Browser.getScrollY();
	}
};

function DOMEventHandle(element, type, handler) {
	this.element=element;
	this.type=type;
	this.handler=handler;
}

DOMEvent = {	

	// public
	
	addDomListener: function (element, type, handler) {
		var handlers;
		if (!handler.__id__) handler.__id__ = DOMEvent.currentId++;
		if (!element.events) element.events = {};
		handlers = element.events[type];
		if (!handlers) {
    		handlers = element.events[type] = {};
		    if (element["on" + type]) {
      			handlers[0] = element["on" + type];
    		}
  		}
		handlers[handler.__id__] = handler;
		element["on" + type] = DOMEvent.handleEvent;
		return new DOMEventHandle(element, type, handler);
	},
	
	removeListener: function (domEventHandleObj) {
		var element,type,handler;
		element=domEventHandleObj.element;
		type=domEventHandleObj.type;
		handler=domEventHandleObj.handler;
		if (element.events && element.events[type]) {
   			delete element.events[type][handler.__id__];
  		}
	},
	
	preventDefault: function (eventObj) {
		if (eventObj.preventDefault) {
			eventObj.preventDefault();
		} else {
			eventObj.returnValue=false;
		}
	},
	
	stopPropagation: function (eventObj) {
		if (eventObj.stopPropagation) {
			e.stopPropagation();
		} else {
			e.cancelBubble=true;
		}
	},
	
	// private
	
	currentId: 1,
	
	handleEvent: function (event) {
  		var handlers;
		event = event || window.event;
  		handlers = this.events[event.type];
  		for (var i in handlers) {
    		this.__handleEvent = handlers[i];
    		this.__handleEvent(event);
  		}
		this.__handleEvent=null;
	}
};


MousePositionOnPage = {
	getX: function (mouseEvent) {
		return mouseEvent.pageX || mouseEvent.clientX+DHTMLApi.Browser.getScrollX();
	},
	getY: function (mouseEvent) {
		return mouseEvent.pageY || mouseEvent.clientY+DHTMLApi.Browser.getScrollY();
	}
};

////////////////////
// Class Rollover //
////////////////////

function Rollover(imageId,rolloverPicPath) {
	var rolloverImage,rolloverImgSrc,rolloutImgSrc;

	this.imageObject=document.getElementById(imageId);
	rolloverImage= new Image();
	rolloverImage.src=rolloverPicPath;
	this.rolloutImageSrc=this.imageObject.src;
	this.rolloverImageSrc=rolloverPicPath;

	rolloverImgSrc=this.rolloverImageSrc;
	rolloutImgSrc=this.rolloutImageSrc;
	this.imageObject.onmouseover= function () {
		this.src=rolloverImgSrc;
	}
	this.imageObject.onmouseout= function () {
		this.src=rolloutImgSrc;
	}	
}

function implementsInterface() {
	var prototypeObj=new Object();
	for (var i=0; i<arguments.length; i++) {
		for (var method in arguments[i]) {
			prototypeObj[method]=arguments[i][method];
		}	
	}
	return prototypeObj;
}

//////////////////////////
// Interface Observable //
//////////////////////////

Observable = {
	addListener : function(listenerObj) {
		if (typeof this.listeners == 'undefined') {
			this.listeners=new Array();
		}
		for (var i=0; i<this.listeners.length; i++) {
			if (this.listeners[i]==listenerObj) return;
		}
		this.listeners[this.listeners.length]=listenerObj;
	},

	removeListener : function(listenerObj) {
		for (var i=0; i<this.listeners.length; i++) {
			if (this.listeners[i]==listenerObj) {
				this.listeners.splice(i,1);
				return;
			}
		}
	},
	
	notifyListeners : function (eventName,eventObj) {
		if (typeof this.listeners == 'undefined') return;
		for (var i=0; i< this.listeners.length; i++) {
			if (typeof this.listeners[i][eventName]!="undefined") {
				this.listeners[i][eventName](eventObj);
			}
		}
	}
}

/////////////////////////////////////////////
// Class Draggable (implements Observable) //
/////////////////////////////////////////////

/************************************
 listenerObj must implement methods:	
 onDragStop(DraggableEventObj event)
 onDrag(DraggableEventObj event)
************************************/

DraggableMode= {HORIZONTAL : 1,VERTICAL : 2,HORIZONTAL_VERTICAL : 3};

function Draggable(dragObj,dragHandleObj,boundingObj,dragMode) {
	this.dragObj=dragObj;
	if (dragHandleObj==null) {
		this.dragHandle=this.dragObj;
	} else {
		this.dragHandle=dragHandleObj;
	}
	this.mode=dragMode;
	this.boundingObj = boundingObj;			
	this.boundingBox = this.getBoundingBox();
	
	this.mousePosXOnHandle=null;
	this.mousePosYOnHandle=null;
	
	this.mouseDownHandler=null;
	this.mouseUpHandler=null;
	this.mouseMoveHandler=null;
};

Draggable.prototype = implementsInterface(Observable);

Draggable.prototype.set=function() {
	var obj=this;
	
	function dragStart(e) {
		obj.notifyListeners("onDragStart",obj.getDraggableEventObj());
		obj.boundingBox = obj.getBoundingBox();
		obj.mousePosXOnHandle=MousePositionOnPage.getX(e)-DHTMLApi.Position.getXPosOnPage(obj.dragObj);
		obj.mousePosYOnHandle=MousePositionOnPage.getY(e)-DHTMLApi.Position.getYPosOnPage(obj.dragObj);
		obj.mouseMoveHandler=DOMEvent.addDomListener(document, "mousemove" , drag);
		obj.mouseUpHandler=DOMEvent.addDomListener(document, "mouseup" , dragEnd);
		DOMEvent.preventDefault(e);
	}
	
	function dragEnd(e) {
		DOMEvent.removeListener(obj.mouseMoveHandler);
		DOMEvent.removeListener(obj.mouseUpHandler);
		obj.notifyListeners("onDragStop",obj.getDraggableEventObj());
	}
	
	function drag(e) {
		var dragObjPosX,dragObjPosY;
		DOMEvent.preventDefault(e);
		dragObjPosX=obj.calculatePosX(MousePositionOnPage.getX(e));
		dragObjPosY=obj.calculatePosY(MousePositionOnPage.getY(e));
		if (obj.mode!=DraggableMode.VERTICAL) {
			if (obj.boundingBox.tlX<=dragObjPosX && dragObjPosX<=obj.boundingBox.brX) {
				DHTMLApi.Position.setXPos(obj.dragObj, dragObjPosX-obj.boundingBox.tlX, obj.boundingObj);
			} else if (obj.boundingBox.tlX>dragObjPosX) {
				DHTMLApi.Position.setXPos(obj.dragObj, 0, obj.boundingObj);
			} else {
				DHTMLApi.Position.setXPos(obj.dragObj, obj.boundingBox.brX-obj.boundingBox.tlX, obj.boundingObj);
			}
		}		
		if (obj.mode!=DraggableMode.HORIZONTAL) {
			if (obj.boundingBox.tlY<=dragObjPosY && dragObjPosY<=obj.boundingBox.brY) {
				DHTMLApi.Position.setYPos(obj.dragObj, dragObjPosY-obj.boundingBox.tlY, obj.boundingObj);
			} else if (obj.boundingBox.tlY>dragObjPosY) {
				DHTMLApi.Position.setYPos(obj.dragObj, 0, obj.boundingObj);
			} else {
				DHTMLApi.Position.setYPos(obj.dragObj, obj.boundingBox.brY-obj.boundingBox.tlY, obj.boundingObj);
			}
		}
		obj.notifyListeners("onDrag",obj.getDraggableEventObj());
	}
	
	this.mouseDownHandler=DOMEvent.addDomListener(this.dragHandle, "mousedown" , dragStart);
};

Draggable.prototype.unset=function() {
	DOMEvent.removeListener(this.mouseDownHandler);
	DOMEvent.removeListener(this.mouseMoveHandler);
	DOMEvent.removeListener(this.mouseUpHandler);	
};

Draggable.prototype.getXBounds=function() {
	return (this.boundingBox.brX-this.boundingBox.tlX);
}

Draggable.prototype.getYBounds=function() {
	return (this.boundingBox.brY-this.boundingBox.tlY);
}

Draggable.prototype.setDragObjXPos=function(xPos) {
	DHTMLApi.Position.setXPos(this.dragObj, xPos, this.boundingObj);
}

Draggable.prototype.setDragObjYPos=function(yPos) {
	DHTMLApi.Position.setYPos(this.dragObj, yPos, this.boundingObj);
}

Draggable.prototype.getDragObjXPos=function() {
	return  DHTMLApi.Position.getXPosOnPage(this.dragObj)-DHTMLApi.Position.getXPosOnPage(this.boundingObj);
}

Draggable.prototype.getDragObjYPos=function() {
	return  DHTMLApi.Position.getYPosOnPage(this.dragObj)-DHTMLApi.Position.getYPosOnPage(this.boundingObj);
}

Draggable.prototype.refreshAfterResize=function() {
	this.boundingBox = this.getBoundingBox();
}

// private

Draggable.prototype.calculatePosX=function (mousePosX) {
	return mousePosX-this.mousePosXOnHandle;
};

Draggable.prototype.calculatePosY=function (mousePosY) {
	return mousePosY-this.mousePosYOnHandle;
};

Draggable.prototype.getBoundingBox= function () {
	return {
		tlX: DHTMLApi.Position.getXPosOnPage(this.boundingObj), 
		tlY: DHTMLApi.Position.getYPosOnPage(this.boundingObj),
		brX: DHTMLApi.Position.getXPosOnPage(this.boundingObj)+DHTMLApi.Size.getElementWidth(this.boundingObj)-DHTMLApi.Size.getElementWidth(this.dragObj),
		brY: DHTMLApi.Position.getYPosOnPage(this.boundingObj)+DHTMLApi.Size.getElementHeight(this.boundingObj)-DHTMLApi.Size.getElementHeight(this.dragObj)};
}

Draggable.prototype.getDraggableEventObj=function() {
	return new DraggableEventObj(DHTMLApi.Position.getXPosInElement(this.dragObj,this.boundingObj), DHTMLApi.Position.getYPosInElement(this.dragObj,this.boundingObj), this.boundingBox.brX-this.boundingBox.tlX, this.boundingBox.brY-this.boundingBox.tlY);
}

/////////////////////////////
// Class DraggableEventObj //
/////////////////////////////

function DraggableEventObj (objPosX, objPosY, boundWidth, boundHeight) {
	this.posX=objPosX;
	this.posY=objPosY;
	this.boundWidth=boundWidth;
	this.boundHeight=boundHeight;
}

///////////////////
// Class VSlider //
///////////////////

/************************************
 listenerObj must implement methods:	
 onChange(ChangeEventObj event)
 onUpperSliderBarClick(ChangeEventObj event)
 onLowerSliderBarClick(ChangeEventObj event)
************************************/

function VSlider(dragObj,boundingObj,topValue,bottomValue,initValue) {
	this.topValue=topValue;
	this.bottomValue=bottomValue;
	this.sliderBar=boundingObj;
	this.sliderBarClickHandler=null;
	this.draggableObject=new Draggable(dragObj,null,boundingObj,DraggableMode.VERTICAL);
	this.draggableObject.set();
	this.draggableObject.addListener(this);
	if (typeof initValue!= 'undefined') {
		this.setValue(initValue);
	}
	this.initSliderBar();
}

VSlider.prototype = implementsInterface(Observable);

VSlider.prototype.initSliderBar=function() {
	var obj=this;
	this.sliderBarClickHandler=DOMEvent.addDomListener(this.sliderBar, "click" , function (e) {
		var clickPosY=MousePositionOnPage.getY(e)-DHTMLApi.Position.getYPosOnPage(obj.sliderBar);
		if (clickPosY<obj.draggableObject.getDragObjYPos()) {
			obj.notifyListeners("onUpperSliderBarClick",new SliderEventObj(obj.getValue(obj.draggableObject.getDraggableEventObj())));
		}
		if (clickPosY>obj.draggableObject.getDragObjYPos()+DHTMLApi.Size.getElementHeight(obj.draggableObject.dragObj)) {
			obj.notifyListeners("onLowerSliderBarClick",new SliderEventObj(obj.getValue(obj.draggableObject.getDraggableEventObj())));
		}
	});
}

VSlider.prototype.getValue=function(draggableEventObj) {
	return this.topValue+(draggableEventObj.posY/draggableEventObj.boundHeight)*1.0*(this.bottomValue-this.topValue); 
}

VSlider.prototype.setBoundaryValues=function(topValue,bottomValue) {
	this.topValue=topValue;
	this.bottomValue=bottomValue;
}

VSlider.prototype.setValue=function(value) {
	var dragObjYPos=Math.round((value-this.topValue)*this.draggableObject.getYBounds()/(this.bottomValue-this.topValue));
	this.draggableObject.setDragObjYPos(dragObjYPos);
}

VSlider.prototype.onDragStop = function (draggableEventObj) {
	this.notifyListeners("onChange",new SliderEventObj(this.getValue(draggableEventObj)));
}

VSlider.prototype.onDrag = function (draggableEventObj) {
	this.notifyListeners("onChange",new SliderEventObj(this.getValue(draggableEventObj)));
}

function SliderEventObj (value) {
	this.value=value;
}

///////////////////
// Class VScroll //
///////////////////

function VScroll(containerElement,contentElement,sliderbarElement,sliderElement,viewport,upButton,downButton, scrollIncrement) {
	this.containerElement=containerElement;
	this.contentElement=contentElement;
	this.sliderbarElement=sliderbarElement;
	this.sliderElement=sliderElement;
	this.upButton=upButton;
	this.downButton=downButton;
	this.viewportWidth=viewport.width;
	this.viewportHeight=viewport.height;
	this.viewportPosX=viewport.x;
	this.viewportPosY=viewport.y;
	this.bottomViewportPadding=DHTMLApi.Size.getElementHeight(this.containerElement)-this.viewportHeight-this.viewportPosY;
	this.rightViewportPadding=DHTMLApi.Size.getElementWidth(this.containerElement)-this.viewportWidth-this.viewportPosX;
	this.invisibleContentHeight=null;
	this.scrollIncrement=scrollIncrement;
	this.slider=null;
	this.mask=this.buildMask();
	this.animation=new Animation.SmoothVMove(this.contentElement, this.mask);
	this.initialAnimation=new Animation.SmoothVMoveDecc(this.contentElement, this.mask);
	this.initialAnimation.addListener(this);
	this.firstScrolling=true;
	this.initSlider();
	this.initButtons();
	if (this.viewportHeight>DHTMLApi.Size.getElementHeight(this.contentElement)) {
		this.hideControls();
		this.controlsHidden=true;
	} else {
		this.controlsHidden=false;
	}
}

VScroll.prototype.buildMask=function() {
	var maskDiv=document.createElement("div");
	DHTMLApi.CSS.setProperties(maskDiv, {position: "absolute", left: this.viewportPosX+"px", top: this.viewportPosY+"px", width: this.viewportWidth+"px", height: this.viewportHeight+"px", overflow:'hidden'});
	this.contentElement=this.containerElement.replaceChild(maskDiv,this.contentElement);
	maskDiv.appendChild(this.contentElement);
	return maskDiv;
}

VScroll.prototype.initSlider=function() {
	var obj=this;
	this.invisibleContentHeight=DHTMLApi.Size.getElementHeight(this.contentElement)-this.viewportHeight;
	this.slider=new VSlider(this.sliderElement,this.sliderbarElement,0,-this.invisibleContentHeight,0);
	this.slider.onDragStart = function (draggableEventObj) {
		obj.removeInitAnimation();
	}
	this.slider.onDragStop = function (draggableEventObj) {
		var value=this.getValue(draggableEventObj);
		obj.animation.setPosition(value);
		this.notifyListeners("onChange",new SliderEventObj(value));
	}
	this.slider.onDrag=function (draggableEventObj) {
		if (obj.animation.getAnimationStep()===null || obj.animation.getAnimationStep()>0) {
			obj.animation.setPosition(this.getValue(draggableEventObj));
		}
		this.notifyListeners("onChange",new SliderEventObj(this.getValue(draggableEventObj)));
	}
	this.slider.addListener(this);
}

VScroll.prototype.initButtons=function() {
	var obj=this;
	var mousedownInterval;
		
	DOMEvent.addDomListener(this.downButton,"mousedown",function() {
		mousedownInterval=window.setInterval(function () {obj.scrollDown(obj.scrollIncrement, true)},10);
	});
	
	DOMEvent.addDomListener(this.downButton,"mouseout",function() {
		window.clearInterval(mousedownInterval);
	});
	
	DOMEvent.addDomListener(this.downButton,"mouseup",function() {
		window.clearInterval(mousedownInterval);
	});
		
	DOMEvent.addDomListener(this.upButton,"mousedown",function() {
		mousedownInterval=window.setInterval(function () {obj.scrollUp(obj.scrollIncrement, true)},10);
	});
	
	DOMEvent.addDomListener(this.upButton,"mouseup",function() {
		window.clearInterval(mousedownInterval);
	});
	
	DOMEvent.addDomListener(this.upButton,"mouseout",function() {
		window.clearInterval(mousedownInterval);
	});
}

VScroll.prototype.hideControls=function () {
	DHTMLApi.Visibility.hide(this.upButton);
	DHTMLApi.Visibility.hide(this.downButton);
	DHTMLApi.Visibility.hide(this.sliderElement);
	DHTMLApi.Visibility.hide(this.sliderbarElement);
	DHTMLApi.Visibility.hide(this.sliderbarElement.parentNode);
}

VScroll.prototype.showControls=function () {
	DHTMLApi.Visibility.show(this.sliderbarElement.parentNode);
	DHTMLApi.Visibility.show(this.sliderbarElement);
	DHTMLApi.Visibility.show(this.sliderElement);
	DHTMLApi.Visibility.show(this.downButton);
	DHTMLApi.Visibility.show(this.upButton);
}

VScroll.prototype.setPosition=function (numOfPixels) {
	DHTMLApi.Position.setYPos(this.contentElement, -1*numOfPixels, this.containerElement);
	this.slider.setValue(-1*numOfPixels);
}

VScroll.prototype.removeInitAnimation=function () {
	if (this.initialAnimation!==null) {
		this.initialAnimation.removeListener(this);
		this.initialAnimation.stop();
		this.initialAnimation=null;
	}
}

VScroll.prototype.setBottomPosition=function () {
	this.setPosition(this.invisibleContentHeight);
}

VScroll.prototype.resize=function (width, height) {
	if (height<DHTMLApi.Size.getElementHeight(this.contentElement)) {
		if (this.controlsHidden) {
			DHTMLApi.CSS.setProperties(this.mask, {overflow:'hidden'});
			this.showControls();
			this.controlsHidden=false;
		}
		this.resizeElements(width, height);
		this.recalculateAfterResize(width, height);
	} else {
		if (!this.controlsHidden) {
			this.hideControls();
			this.setPosition(0);
			this.controlsHidden=true;
			DHTMLApi.CSS.setProperties(this.mask, {overflow:'visible'});
		}
	}
}

VScroll.prototype.resizeElements=function(width, height) {
	var heightDifference;
	heightDifference=height-DHTMLApi.Size.getElementHeight(this.containerElement);
	DHTMLApi.CSS.setProperties(this.containerElement, {width: width+"px", height: height+"px"});
	DHTMLApi.CSS.setProperties(this.mask, {width: (width-this.rightViewportPadding-this.viewportPosX)+"px", height: (height-this.bottomViewportPadding-this.viewportPosY)+"px"});
	DHTMLApi.CSS.setProperties(this.sliderbarElement, {height: (DHTMLApi.Size.getElementHeight(this.sliderbarElement)+heightDifference)+"px"});
	DHTMLApi.CSS.setProperties(this.sliderbarElement.parentNode, {height: height+"px"});
	DHTMLApi.CSS.setProperties(this.downButton, {top: (height-(DHTMLApi.Size.getElementHeight(this.downButton)))+"px", height: DHTMLApi.Size.getElementHeight(this.downButton)+"px", width: DHTMLApi.Size.getElementWidth(this.downButton)+"px"});
}

VScroll.prototype.recalculateAfterResize=function(width, height) {
	this.viewportWidth=width-this.rightViewportPadding-this.viewportPosX;
	this.viewportHeight=height-this.bottomViewportPadding-this.viewportPosY;
	this.invisibleContentHeight=DHTMLApi.Size.getElementHeight(this.contentElement)-this.viewportHeight;
	this.slider.setBoundaryValues(0,-this.invisibleContentHeight);
	this.slider.draggableObject.refreshAfterResize();
	if (DHTMLApi.Position.getYPosInElement(this.contentElement,this.containerElement)<-1*this.invisibleContentHeight) {
		DHTMLApi.Position.setYPos(this.contentElement, -1*this.invisibleContentHeight, this.containerElement);
	} 
	this.slider.setValue(DHTMLApi.Position.getYPosInElement(this.contentElement,this.containerElement));
	
}

VScroll.prototype.scrollUp=function (scrollIncrement, refreshSliderPos) {
	var targetPosY;
	this.removeInitAnimation();
	if ((this.getCurrentScrollPosition()+scrollIncrement) >= 0) {
			targetPosY=0;
		} else {
			targetPosY=this.getCurrentScrollPosition()+scrollIncrement;
		}
		if (refreshSliderPos) {
			this.animation.setPosition(targetPosY);
			this.slider.setValue(targetPosY);
		} else {
			this.animation.setPosition(targetPosY);
			this.animation.addListener(this);
		}
}

VScroll.prototype.scrollDown=function (scrollIncrement, refreshSliderPos) {
	var targetPosY;
	this.removeInitAnimation();
	if ((this.getCurrentScrollPosition() - scrollIncrement) < -this.invisibleContentHeight) {
			targetPosY=-this.invisibleContentHeight;
		} else {
			targetPosY=this.getCurrentScrollPosition()- scrollIncrement;
		}
		if (refreshSliderPos) {
			this.animation.setPosition(targetPosY);
			this.slider.setValue(targetPosY);
		} else {
			this.animation.setPosition(targetPosY);
			this.animation.addListener(this);
		}
}

VScroll.prototype.getCurrentScrollPosition=function() {
	return DHTMLApi.Position.getYPosInElement(this.contentElement,this.mask);
}

VScroll.prototype.scrollToTop=function() {	
	this.scrollTo(0);
}

VScroll.prototype.initScrollToTop=function() {
	if (this.initialAnimation!==null) {
		this.initialAnimation.setPosition(0);
	}
}

VScroll.prototype.scrollTo=function (pixelValue) {
	this.removeInitAnimation();
	if (pixelValue<this.invisibleContentHeight) {
		this.animation.setPosition(-1*pixelValue);
	} else {
		this.animation.setPosition(-1*this.invisibleContentHeight);
	}
	this.animation.addListener(this);
}

VScroll.prototype.onUpperSliderBarClick=function(event) {
	this.scrollUp(this.viewportHeight,false);
}

VScroll.prototype.onLowerSliderBarClick=function(event) {
	this.scrollDown(this.viewportHeight,false);
}

VScroll.prototype.onAnimationStep=function() {
	this.slider.setValue(this.getCurrentScrollPosition());
}

VScroll.prototype.onAnimationEnd=function() {
	if (this.initialAnimation===null) {
		this.animation.removeListener(this);
	}
}

///////////////////////
// Package Animation //
///////////////////////

Animation= new Object();

Animation.FRAME_RATE=50; // miliseconds

/////////////////////////////////
// Class Animation.SmoothVMove //
/////////////////////////////////

Animation.SmoothVMove=function(movingObject, relativeToObject) {
	this.movingObject=movingObject;
	this.relativeToObject=relativeToObject;
	this.currentYPos=DHTMLApi.Position.getYPosInElement(movingObject,relativeToObject);
	this.targetYPos=null;
	this.interval=null;
	this.numOfAnimationStep=null;
}

Animation.SmoothVMove.prototype=implementsInterface(Observable);

Animation.SmoothVMove.prototype.setPosition=function (targetPosition) {
	this.currentYPos=DHTMLApi.Position.getYPosInElement(this.movingObject,this.relativeToObject);
	if (this.interval!==null) {
		window.clearInterval(this.interval);
		this.notifyListeners("onAnimationEnd",null);
	}
	var animationObject=this;
	this.targetYPos=targetPosition;
	this.numOfAnimationStep=0;
	this.notifyListeners("onAnimationStart",null);
	this.animate();
	this.interval=window.setInterval(function() {animationObject.animate()},Animation.FRAME_RATE);
}

Animation.SmoothVMove.prototype.animate=function () {
	var stepDistance=(this.targetYPos-this.currentYPos)/3;
	if (Math.abs(stepDistance)>0.3) {
		this.currentYPos+=stepDistance;
		DHTMLApi.Position.setYPos(this.movingObject, this.currentYPos, this.relativeToObject);
		++this.numOfAnimationStep;
		this.notifyListeners("onAnimationStep",this.numOfAnimationSteps);
		return this.numOfAnimationStep;
	} else {
		this.currentYPos=this.targetYPos;
		DHTMLApi.Position.setYPos(this.movingObject, this.currentYPos, this.relativeToObject);
		this.notifyListeners("onAnimationStep",++this.numOfAnimationSteps);
		window.clearInterval(this.interval);
		this.notifyListeners("onAnimationEnd",null);
		this.numOfAnimationStep=null;
		return false;
	}
}

Animation.SmoothVMove.prototype.getAnimationStep=function () {
	return this.numOfAnimationStep;
}


/////////////////////////////////////
// Class Animation.SmoothVMoveDecc //
/////////////////////////////////////

Animation.SmoothVMoveDecc=function(movingObject, relativeToObject) {
	this.movingObject=movingObject;
	this.relativeToObject=relativeToObject;
	this.currentYPos=DHTMLApi.Position.getYPosInElement(movingObject,relativeToObject);
	this.targetYPos=null;
	this.initYPos=null;
	this.v0=null;
	this.distance=null;
	this.a0=null;
	this.a1=null;
	this.a=null;
	this.v=null;
	this.s=null;
	this.interval=null;
	this.snapToMode=false;
	this.snapToFactor=null;
	this.numOfAnimationStep=null;
}

Animation.SmoothVMoveDecc.prototype=implementsInterface(Observable);

Animation.SmoothVMoveDecc.prototype.setPosition=function (targetPosition,absoluteInitVelocity) {
	var sign;
	this.initYPos=DHTMLApi.Position.getYPosInElement(this.movingObject,this.relativeToObject);
	if (this.interval!==null) {
		window.clearInterval(this.interval);
		this.notifyListeners("onAnimationEnd",null);
	}
	var animationObject=this;
	this.targetYPos=targetPosition;
	this.numOfAnimationStep=0;
	this.snapToMode=false;
	this.distance=this.targetYPos-this.initYPos;
	if (this.distance==0) return;
	this.stepDistance=null;
	sign=(this.distance<0) ? -1 : 1;
	if (typeof absoluteInitVelocity=="undefined") {
		this.v0=this.distance/50.0;
		//this.v0=sign*100;
	} else {
		this.v0=sign*absoluteInitVelocity;
	}
	this.a0=-2*Math.pow(this.v0,2)/(3.0*this.distance);
	this.a1=-1*this.v0*this.a0/(3.0*this.distance);
	this.a=this.a0;
	this.v=this.v0;
	this.s=0;
	this.notifyListeners("onAnimationStart",null);
	this.animate();
	this.interval=window.setInterval(function() {animationObject.animate()},Animation.FRAME_RATE);
}

Animation.SmoothVMoveDecc.prototype.animate=function () {
	var newDistance,stepDistance;
	if (this.snapToMode===false) {
		newDistance=this.v+0.5*this.a-1.0/6*this.a1;
		this.s+=newDistance;
		this.v+=this.a+0.5*this.a1;
		this.a+=this.a1;
		this.currentYPos=Math.round(this.initYPos+this.s);	
		if (Math.abs(this.distance)<Math.abs(newDistance)/* || Math.abs(this.distance)<2*/) {
			this.snapToMode=true;
			this.stepDistance=Math.round(this.v);
		} else {
			this.distance=newDistance;
		}
		DHTMLApi.Position.setYPos(this.movingObject, this.currentYPos, this.relativeToObject);
		++this.numOfAnimationStep;
		this.notifyListeners("onAnimationStep",this.numOfAnimationSteps);
		return this.numOfAnimationStep;
	} else {		
		if (Math.abs(this.targetYPos-this.currentYPos)>Math.abs(this.stepDistance)) {
			this.currentYPos+=this.stepDistance;
			DHTMLApi.Position.setYPos(this.movingObject, this.currentYPos, this.relativeToObject);
			//if (Math.abs(stepDistance)!=1) stepDistance=(stepDistance>0) ? Math.floor(stepDistance/2.0) : Math.ceil(stepDistance/2.0);
			++this.numOfAnimationStep;
			this.notifyListeners("onAnimationStep",this.numOfAnimationSteps);
			return this.numOfAnimationStep;
		} else {		
			this.currentYPos=this.targetYPos;
			DHTMLApi.Position.setYPos(this.movingObject, this.currentYPos, this.relativeToObject);
			this.notifyListeners("onAnimationStep",++this.numOfAnimationSteps);
			window.clearInterval(this.interval);
			this.notifyListeners("onAnimationEnd",null);
			this.numOfAnimationStep=null;
			return false;
		}
	}
}

Animation.SmoothVMoveDecc.prototype.stop=function () {
	window.clearInterval(this.interval);
	this.notifyListeners("onAnimationEnd",null);
	this.numOfAnimationStep=null;
}

Animation.SmoothVMoveDecc.prototype.getAnimationStep=function () {
	return this.numOfAnimationStep;
}

/////////////////////////////
// Static Class ColumnLink //
/////////////////////////////

ColumnLink= new Object();

/* parameters: scrollObject: class VScroll instance, scrollToValue: int or string (element id) */

ColumnLink.add=function (linkElement, scrollObject, scrollToValue) {
	if (typeof scrollToValue=="number") {
		DOMEvent.addDomListener(linkElement, "click" , function () {
			scrollObject.scrollTo(scrollToValue);
		});
	} else if (typeof scrollToValue=="string") {
		var scrollToElement= document.getElementById(scrollToValue);
		if (ColumnLink.isElementInScroll(scrollObject, scrollToElement)==false) return;
		DOMEvent.addDomListener(linkElement, "click" , function () {
			scrollObject.scrollTo(DHTMLApi.Position.getYPosInElement(scrollToElement,scrollObject.contentElement));
		});
	}
}

ColumnLink.isElementInScroll=function(scrollObject, searchElement) {
	var element=searchElement;
	if (element===null) return false;
	while (element.parentNode!==scrollObject.contentElement) {
		if (element.parentNode===document.body) return false;
		element=element.parentNode;
	}
	return true;
}

//////////////////////////
// Static Class HotSpot //
//////////////////////////

HotSpot= new Object();

HotSpot.init=function () {
	var obj=this;
	this.hotSpots=new Object();
	DOMEvent.addDomListener(document.body, "mousemove", function (mouseEvent) {
		HotSpot.check(mouseEvent);
	});
	DOMEvent.addDomListener(window, "resize", function () {
		/*var interval;
		interval=window.setInterval(function () {obj.update();window.clearInterval(interval);}, 50);*/
		obj.update();
	});
}

HotSpot.update=function () {
	for (var hotSpotId in this.hotSpots) {
		this.hotSpots[hotSpotId].bounds=this.getBounds(this.hotSpots[hotSpotId].element);
	}
}

HotSpot.add=function (elementId,onMouseOverHandler,onMouseOutHandler) {
	var hotSpotObject=new Object();
	var element=document.getElementById(elementId);
	hotSpotObject.element=element;
	hotSpotObject.bounds=HotSpot.getBounds(element);
	hotSpotObject.onMouseOverHandler=onMouseOverHandler;
	hotSpotObject.onMouseOutHandler=onMouseOutHandler;
	hotSpotObject.mouseIsInHotSpot=null;
	this.hotSpots[elementId]=hotSpotObject;
}

HotSpot.remove=function (elementId) {
	delete this.hotSpots[elementId];
}

// private

HotSpot.getBounds=function (element) {
	return {left: DHTMLApi.Position.getXPosOnPage(element), top: DHTMLApi.Position.getYPosOnPage(element), right: DHTMLApi.Position.getXPosOnPage(element)+DHTMLApi.Size.getElementWidth(element), bottom: DHTMLApi.Position.getYPosOnPage(element)+DHTMLApi.Size.getElementHeight(element)};
}

HotSpot.check=function (mouseEvent) {
	var hotSpot;
	for (var hotSpotId in this.hotSpots) {
		hotSpot=this.hotSpots[hotSpotId];
		if (hotSpot.bounds.left < MousePositionOnPage.getX(mouseEvent) && hotSpot.bounds.right > MousePositionOnPage.getX(mouseEvent) && hotSpot.bounds.top < MousePositionOnPage.getY(mouseEvent) && hotSpot.bounds.bottom > MousePositionOnPage.getY(mouseEvent)) {
			if (hotSpot.mouseIsInHotSpot===false || hotSpot.mouseIsInHotSpot===null) {
				if (hotSpot.onMouseOverHandler!==null) {
					hotSpot.onMouseOverHandler();
				}
				hotSpot.mouseIsInHotSpot=true;
			}
		} else {
			if (hotSpot.mouseIsInHotSpot===true || hotSpot.mouseIsInHotSpot===null) {
				if (hotSpot.onMouseOutHandler!==null) {
					hotSpot.onMouseOutHandler();
				}
				hotSpot.mouseIsInHotSpot=false;
			}
		}
	}
}

/////////////////////////////
// Static Class PopUpFrame //
/////////////////////////////

/* parameters 
css Classes: {background: string, frameContainer: string}*/ 

/*

!!!!!!!!!!!!!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
place this piece of code in document that loads in frame (ie)

window.onload=function () {
	window.parent.PopUpFrame.frameIsLoaded=true;
	}
*/

PopUpFrame=new Object();
PopUpFrame.containerZIndex=10000;

PopUpFrame.initialize=function(pageContentContainer, frameContainerId, cssClasses) {
	this.cssClasses=cssClasses;
	this.pageContentContainer=pageContentContainer;
	this.frameContainerId=frameContainerId;
	this.popUpElement=null;
	this.popUpContainerElement=null;
	this.backgroundElement=null;
	this.frameContainerElement=null;
	this.closePopupHandler=null;
	this.closeButtonHandler=null;
	this.resizeHandler=null;
	this.frameIsLoaded=false;
	this.framePageHeight=null;
	this.framePageWidth=null;
}

PopUpFrame.build=function () {
	var obj=this;
	this.popUpElement=document.createElement("DIV");
	DHTMLApi.CSS.setProperties(this.popUpElement,{position: "absolute", top: "0px", left: "0px", width: (DHTMLApi.Browser.getViewportWidth())+"px", height: DHTMLApi.Browser.getViewportHeight()+"px", zIndex: PopUpFrame.containerZIndex, overflow:"auto"});
	
	document.body.appendChild(this.popUpElement);
	
	this.popUpContainerElement=document.createElement("DIV");
	this.popUpElement.appendChild(this.popUpContainerElement);
	
	this.backgroundElement=document.createElement("DIV");
	DHTMLApi.CSS.setProperties(this.backgroundElement,{position: "absolute", top: "0px", left: "0px", zIndex: 1, cursor: "pointer"});
	DHTMLApi.CSS.setClass(this.backgroundElement,new Array(this.cssClasses.background),new Array());
	
	this.popUpContainerElement.appendChild(this.backgroundElement);
	
	this.frameContainerElement=document.createElement("IFRAME");
	this.frameContainerElement.setAttribute("id","__pop_up_frame__");
	this.frameContainerElement.setAttribute("scrolling","no");
	this.frameContainerElement.setAttribute("allowTransparency","true");
	DHTMLApi.CSS.setProperties(this.frameContainerElement,{position: "absolute", zIndex: 2, border: "none", display: "none"});
	this.closePopupHandler=DOMEvent.addDomListener(this.backgroundElement,"click", function () {obj.close();});
	
	this.resizeHandler=DOMEvent.addDomListener(window, "resize", function () {
		DHTMLApi.CSS.setProperties(obj.popUpElement,{width: DHTMLApi.Browser.getViewportWidth()+"px", height: DHTMLApi.Browser.getViewportHeight()+"px"});
		obj.positionFrame();
		obj.setBackgroundSize();
	});
}

PopUpFrame.open=function (frameSrc) {
	var waitInterval=null;
	var obj=this;
	this.frameIsLoaded=false;
	this.build();
	this.popUpContainerElement.appendChild(this.frameContainerElement);
	this.frameContainerElement.setAttribute("src",frameSrc);
	if (this.frameIsLoaded===false) {
		waitInterval=window.setInterval(function () {
			if (obj.frameIsLoaded) {
				window.clearInterval(waitInterval);	
				PopUpFrame.displayFrame();
			}
		}, 50);
	} else {
		PopUpFrame.displayFrame();
	}
}

PopUpFrame.close=function () {
	DOMEvent.removeListener(this.closePopupHandler);
	DOMEvent.removeListener(this.resizeHandler);
	if (this.closeButtonHandler!==null) {
		DOMEvent.removeListener(this.closeButtonHandler);
	}	
	document.body.removeChild(this.popUpElement);
	this.popUpElement=null;
	this.closePopupHandler=null;
	this.resizeHandler=null;
	this.closeButtonHandler=null;
}

PopUpFrame.setBackgroundSize=function() {	
	var bgHeight, bgWidth;
	bgHeight=Math.max(DHTMLApi.Position.getYPosOnPage(this.frameContainerElement) + this.framePageHeight, DHTMLApi.Browser.getViewportHeight());
	if (DHTMLApi.Size.getElementHeight(this.frameContainerElement)>DHTMLApi.Browser.getViewportHeight()) {
		bgWidth=Math.max(DHTMLApi.Position.getXPosOnPage(this.frameContainerElement) + this.framePageWidth, DHTMLApi.Browser.getViewportWidth() - 20);
	} else {
		bgWidth=Math.max(DHTMLApi.Position.getXPosOnPage(this.frameContainerElement) + this.framePageWidth, DHTMLApi.Browser.getViewportWidth());
	}
	DHTMLApi.CSS.setProperties(this.backgroundElement,{height: bgHeight+"px", width: bgWidth});
}

PopUpFrame.centerHorizontally=function () {
	var posLeft=0;
	if (DHTMLApi.Size.getElementWidth(this.frameContainerElement)<DHTMLApi.Browser.getViewportWidth()) posLeft=Math.round((DHTMLApi.Browser.getViewportWidth()-DHTMLApi.Size.getElementWidth(this.frameContainerElement))/2.0);
	//if (DHTMLApi.Size.getElementHeight(this.frameContainerElement)>DHTMLApi.Browser.getViewportHeight()) posLeft-=10;
	DHTMLApi.CSS.setProperties(this.frameContainerElement,{left: posLeft+"px"});
}

PopUpFrame.centerVertically=function () {
	var posTop=0;
	if (DHTMLApi.Size.getElementHeight(this.frameContainerElement)<DHTMLApi.Browser.getViewportHeight()) posTop=Math.round((DHTMLApi.Browser.getViewportHeight()-DHTMLApi.Size.getElementHeight(this.frameContainerElement))/2.0);
	DHTMLApi.CSS.setProperties(this.frameContainerElement,{top: posTop+"px"});
}

PopUpFrame.displayFrame=function () {
	var frameDocument;
	
	frameDocument=this.getFrameDocumentObject();
	DHTMLApi.Visibility.show(this.frameContainerElement);
	this.framePageWidth=DHTMLApi.Size.getElementWidth(frameDocument.getElementById(this.frameContainerId));
	this.framePageHeight=DHTMLApi.Size.getElementHeight(frameDocument.getElementById(this.frameContainerId));
	//if (this.framePageHeight>DHTMLApi.Browser.getViewportHeight()) this.framePageWidth-=20;
	DHTMLApi.CSS.setProperties(this.frameContainerElement,{width: this.framePageWidth+"px", height: this.framePageHeight+"px"});
	this.positionFrame();
	this.setBackgroundSize();
}

// beware: lots of cross browser horse shit inside 
PopUpFrame.getFrameDocumentObject=function () {
	var frameDocument;
	
	if (this.frameContainerElement.contentDocument) {
		frameDocument=this.frameContainerElement.contentDocument;
	} else if (this.frameContainerElement.contentWindow) {
		frameDocument=this.frameContainerElement.contentWindow.document;
	} else {
		frameDocument=this.frameContainerElement.document;
	}
	if (frameDocument===null) {
		this.frameContainerElement.setAttribute("name","__pop_up_frame__");
		frameDocument=window.frames["__pop_up_frame__"].document;
	}
	
	return frameDocument;
}

PopUpFrame.positionFrame=function () {
	if (DHTMLApi.CSS.getStyle(this.pageContentContainer.parentNode, "marginRight")=="auto") {
		this.centerHorizontally();
	} else {
		if (this.framePageHeight>DHTMLApi.Browser.getViewportHeight()) {
			DHTMLApi.CSS.setProperties(this.frameContainerElement,{left: "5px"});
		} else {
			DHTMLApi.CSS.setProperties(this.frameContainerElement,{left: "25px"});
		}
	}
	DHTMLApi.CSS.setProperties(this.frameContainerElement,{top: "0px"});
}


/////////////////////////////
// Class OkomitoHeaderMenu //
/////////////////////////////

function OkomitoHeaderMenu(headerContainerId) {
	var obj=this;
	var preloadImg=new Image();
	preloadImg.src="gfx/header_menu_rollover.gif";
	this.headerContainer=document.getElementById(headerContainerId);
	HotSpot.init();
	HotSpot.add(headerContainerId,function () {DHTMLApi.CSS.setClass(obj.headerContainer,new Array("headermenuon"),new Array("headermenuoff")); },function () {DHTMLApi.CSS.setClass(obj.headerContainer,new Array("headermenuoff"),new Array("headermenuon"));});
}

function OkomitoHeaderMenuEnglish(headerContainerId) {
	var obj=this;
	var preloadImg=new Image();
	preloadImg.src="gfx/header_menu_rollover.gif";
	this.headerContainer=document.getElementById(headerContainerId);
	HotSpot.init();
	HotSpot.add(headerContainerId,function () {DHTMLApi.CSS.setClass(obj.headerContainer,new Array("headermenuon_en"),new Array("headermenuoff_en")); },function () {DHTMLApi.CSS.setClass(obj.headerContainer,new Array("headermenuoff_en"),new Array("headermenuon_en"));});
}

//////////////////////////////
// Class OkomitoTitleScreen //
//////////////////////////////

function OkomitoTitleScreen(titleContainers, targetHeight, onHideHandlers) {
	var obj=this;
	this.containers=titleContainers;
	this.onHideHandlers=onHideHandlers;
	this.onMenuHideHandlers= {1: new Object(), 2: new Object(), 3: new Object(), 4: new Object()};
	this.intervals=new Object();
	this.isPresentFlags={1: true, 2: true, 3: true, 4:true};
	this.setHeight(targetHeight);
	this.init();
}

OkomitoTitleScreen.prototype.init=function () {
	var obj=this;
	for (var id in this.containers) {
		(function () {	
			var i=id;
			DOMEvent.addDomListener(obj.containers[i],"click", function () {obj.removeTitleScreen(i);(obj.onHideHandlers[i])();});
			obj.intervals[i]=window.setInterval(function () {
				DOMEvent.addDomListener(obj.containers[i],"mousemove", function () {obj.removeTitleScreen(i);(obj.onHideHandlers[i])();});
				window.clearInterval(obj.intervals[i]);
			}, 8000);
		})();
	}
}

OkomitoTitleScreen.prototype.removeTitleScreen=function (columnId) {
	this.containers[columnId].parentNode.removeChild(this.containers[columnId]);
	this.isPresentFlags[columnId]=false;
}

OkomitoTitleScreen.prototype.setHeight=function (targetHeight) {
	for (id in this.containers) DHTMLApi.CSS.setProperties(this.containers[id], {height: targetHeight +"px"});
}

OkomitoTitleScreen.prototype.isPresent=function (columnId) {
	return this.isPresentFlags[columnId];
}

OkomitoTitleScreen.prototype.addMenuItemHideTitleHandlers=function (elementId, columnId, onHideHandler) {
	var obj=this;
	this.onMenuHideHandlers[columnId][elementId]=DOMEvent.addDomListener(document.getElementById(elementId),"mouseover", function () {
		obj.removeTitleScreen(columnId);
		(onHideHandler)();	
		obj.removeMenuItemHideTitleHandlers(columnId);
	});
}

OkomitoTitleScreen.prototype.removeMenuItemHideTitleHandlers=function(columnId) {
	for (var elementId in this.onMenuHideHandlers[columnId]) {
		DOMEvent.removeListener(this.onMenuHideHandlers[columnId][elementId]);
	}
}


//////////////////////////
// Class ProjectGallery //
//////////////////////////

/*
cssStyles= {rollover: string, selected: string}
*/

function ProjectGallery(slideContainer, controllerContainer, gallerySlidesURLArray, cssStyles, selectedSlide) {
	this.slideContainer=slideContainer;
	this.controllerContainer=controllerContainer;
	this.gallerySlidesURLArray=gallerySlidesURLArray;
	this.cssStyles=cssStyles;
	this.selectedSlide=(typeof selectedSlide == "undefined")? 0: (selectedSlide-1);
	this.buttons=[];
	this.init();
}

ProjectGallery.prototype.init=function () {
	if (this.gallerySlidesURLArray.length==0) {
		DHTMLApi.Visibility.hide(this.slideContainer);
		DHTMLApi.Visibility.hide(this.controllerContainer);
	} else if (this.gallerySlidesURLArray.length==1) {
		DHTMLApi.Visibility.hide(this.controllerContainer);
		this.displaySlide(0);
	} else {
		this.displaySlide(this.selectedSlide);
		this.createController();
		this.displaySelectedButton(this.selectedSlide);
	}
}

ProjectGallery.prototype.displaySlide=function (slideNum) {
	var imageElement;
	var obj=this;
	this.slideContainer.innerHTML="";
	imageElement=document.createElement("IMG");
	imageElement.onload=function () {
		obj.slideContainer.appendChild(imageElement);
		window.parent.PopUpFrame.displayFrame();
	}
	imageElement.setAttribute("src",this.gallerySlidesURLArray[slideNum]);
}

ProjectGallery.prototype.createController=function () {
	for (var i=0; i<this.gallerySlidesURLArray.length; i++) {
		this.buttons[i]=document.createElement("SPAN");
		this.buttons[i].appendChild(document.createTextNode(i+1));
		this.controllerContainer.appendChild(this.buttons[i]);
		if (i != this.gallerySlidesURLArray.length-1) this.controllerContainer.appendChild(document.createTextNode(" - "));
	}
	this.initControls();
}

ProjectGallery.prototype.initControls=function () {	
	var obj=this;
	for (var i=0; i<this.buttons.length; i++) {
		(function ()
		{
			var j=i;
			DOMEvent.addDomListener(obj.buttons[j],"click",function () {
				if (obj.selectedSlide != j) {
					obj.displayUnselectedButton(obj.selectedSlide);
					obj.selectedSlide=j;
					obj.displaySelectedButton(obj.selectedSlide);
					obj.displaySlide(obj.selectedSlide);
				}
			});
			
			DOMEvent.addDomListener(obj.buttons[j],"mouseover",function () {
				if (obj.selectedSlide != j) {
					obj.displaySelectedButton(j);
				}
			});
			
			DOMEvent.addDomListener(obj.buttons[j],"mouseout",function () {
				if (obj.selectedSlide != j) {
					obj.displayUnselectedButton(j);
				}
			});
		}
		)();
	}
}

ProjectGallery.prototype.displaySelectedButton=function (buttonNum) {
	DHTMLApi.CSS.setClass(this.buttons[buttonNum],[this.cssStyles.selected],[]);
}

ProjectGallery.prototype.displayUnselectedButton=function (buttonNum) {
	DHTMLApi.CSS.setClass(this.buttons[buttonNum],[],[this.cssStyles.selected]);
}
