

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	WCH.js - Windowed Controls Hider v3.10
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	(c) Copyright 2003, Aleksandar Vacic, aleck@sezampro.yu, www.aplus.co.yu
	## This work is licensed under the Creative Commons Attribution-ShareAlike License.
	## To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Credits: Mike Foster for x functions (cross-browser.com)
	Credits: Tim Connor for short and sweet way of dealing with IE5.0 - dynamic creation of style rule (www.infosauce.com)
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Based on idea presented by Joe King. Works with IE5.0+/Win
	IE 5.5+: place iFrame below the layer to hide windowed controls
	IE 5.0 : hide/show all elements that have "WCHhider" class
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
var WCH_Constructor = function() {
	//	exit point for anything but IE5.0+/Win
	if ( !(document.all && document.getElementById && !window.opera && navigator.userAgent.toLowerCase().indexOf("mac") == -1) ) {
		this.Apply = function() {};
		this.Discard = function() {};
		return;
	}

	//	private properties
	var _bIE55 = false;
	var _bIE6 = false;
	var _oRule = null;
	var _bSetup = true;
	var _oSelf = this;
	var lastVLayer = false;
	
	//	public: hides windowed controls
	this.Apply = function(vLayer, vContainer, bResize) {
		//alert('toto');
		//this.lastVLayer = vLayer;
		
		if (_bSetup) _Setup();

		if ( _bIE55 && (oIframe = _Hider(vLayer, vContainer, bResize)) ) {
			oIframe.style.visibility = "visible";
		} else if(_oRule != null) {
			_oRule.style.visibility = "hidden";
		}
		
	};

	//	public: shows windowed controls
	this.Discard = function(vLayer, vContainer) {
		if ( _bIE55 && (oIframe = _Hider(vLayer, vContainer, false)) ) {
			oIframe.style.visibility = "hidden";
		} else if(_oRule != null) {
			_oRule.style.visibility = "visible";
		}
	};

	//	private: returns iFrame reference for IE5.5+
	function _Hider(vLayer, vContainer, bResize) {
		var oLayer = _GetObj(vLayer);
		var oContainer = ( (oTmp = _GetObj(vContainer)) ? oTmp : document.getElementsByTagName("body")[0] );
		if (!oLayer || !oContainer) return;
		//	is it there already?
		var oIframe = document.getElementById("WCHhider" + oLayer.id);
		
		//	if not, create it
		if ( !oIframe ) {
			//	IE 6 has this property, IE 5 not. IE 5.5(even SP2) crashes when filter is applied, hence the check
			var sFilter = (_bIE6) ? "filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);" : "";
			//	get z-index of the object
			var zIndex = oLayer.style.zIndex;
			if ( zIndex == "" ) zIndex = oLayer.currentStyle.zIndex;
			zIndex = parseInt(zIndex);
			//	if no z-index, do nothing
			if ( isNaN(zIndex) ) return null;
			//	if z-index is below 2, do nothing (no room for Hider)
			if (zIndex < 2) return null;
			//	go one step below for Hider
			zIndex--;
			var sHiderID = "WCHhider" + oLayer.id;
			oContainer.insertAdjacentHTML("afterBegin", '<iframe class="WCHiframe" src="javascript:false;" id="' + sHiderID + '" scroll="no" frameborder="0" style="position:absolute;visibility:hidden;' + sFilter + 'border:0;top:0;left;0;width:0;height:0;background-color:#ccc;z-index:' + zIndex + ';"></iframe>');
			oIframe = document.getElementById(sHiderID);
			//	then do calculation
			_SetPos(oIframe, oLayer);
		} else if (bResize) {
			//	resize the iFrame if asked
			_SetPos(oIframe, oLayer);
		}
		return oIframe;
	};

	//	private: set size and position of the Hider
	function _SetPos(oIframe, oLayer) {
		//	fetch and set size
		oIframe.style.width = oLayer.offsetWidth + "px";
		oIframe.style.height = oLayer.offsetHeight + "px";
		//	move to specified position
		oIframe.style.left = oLayer.offsetLeft + "px";
		oIframe.style.top = oLayer.offsetTop + "px";
	};

	//	private: returns object reference
	function _GetObj(vObj) {
		var oObj = null;
		switch( typeof(vObj) ) {
			case "object":
				oObj = vObj;
				break;
			case "string":
				oObj = document.getElementById(vObj);
				break;
		}
		return oObj;
	};

	//	private: setup properties on first call to Apply
	function _Setup() {
		_bIE55 = (typeof(document.body.contentEditable) != "undefined");
		_bIE6 = (typeof(document.compatMode) != "undefined");

		if (!_bIE55) {
			if (document.styleSheets.length == 0)
				document.createStyleSheet();
			var oSheet = document.styleSheets[0];
			oSheet.addRule(".WCHhider", "visibility:visible");
			_oRule = oSheet.rules(oSheet.rules.length-1);
		}

		_bSetup = false;
	};
};
var WCH = new WCH_Constructor();



/***************************************************************
*
*  JavaScript DHTML layer menu
*
* $Id: jsfunc.layermenu.js,v 1.2 2003/10/26 17:07:43 typo3 Exp $
* 
*
*
*  Copyright notice
* 
*  (c) 1998-2003 Kasper Skårhøj
*  All rights reserved
*
*  This script is part of the TYPO3 tslib/ library provided by
*  Kasper Skårhøj <kasper@typo3.com> together with TYPO3
*
*  Released under GNU/GPL (see license file in tslib/)
* 
*  This script 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.
* 
*  This copyright notice MUST APPEAR in all copies of this script
***************************************************************/
var GLV_x=0;
var GLV_y=0;
var GLV_curLayerWidth = new Array();
var GLV_curLayerHeight = new Array();
var GLV_curLayerX = new Array();
var GLV_curLayerY = new Array();
var GLV_menuOn = new Array();
var GLV_gap = new Array();
var GLV_currentLayer = new Array();
var GLV_currentROitem = new Array();
var GLV_hasBeenOver = new Array();
var GLV_doReset = new Array();
var GLV_lastKey = new Array();
var GLV_menuXY = new Array();
var GLV_date = new Array();
var GLV_timeout = new Array();
var GLV_timeoutRef = new Array();
var GLV_onlyOnLoad = new Array();
var GLV_dontHideOnMouseUp = new Array();
var GLV_date = new Date();
var GLV_restoreMenu = new Array();
var GLV_timeout_count=0;
var GLV_timeout_pointers = new Array();
var GLV_dontFollowMouse = new Array();

	//browsercheck...
function GL_checkBrowser(){
	this.dom= (document.getElementById);
	this.op=this.opera= (navigator.userAgent.indexOf("Opera")>-1);
	this.konq=  (navigator.userAgent.indexOf("Konq")>-1);
	this.ie4= (document.all && !this.dom && !this.op && !this.konq);
	this.ie5= (document.all && this.dom && !this.op && !this.konq);
	this.ns4= (document.layers && !this.dom && !this.konq);
	this.ns5= (!document.all && this.dom && !this.op && !this.konq);
	this.ns6= (this.ns5);
	this.bw=  (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
	return this;
}
bw= new GL_checkBrowser();

	//NS4 resize fix.
if(document.layers){
    scrX= innerWidth; scrY= innerHeight;
    onresize= function()	{if(scrX!= innerWidth || scrY!= innerHeight)	{history.go(0);}};
}
	//Returns css
function GL_getObjCss(obj){								
	return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
};
function GL_isObjCss(obj){								
	flag = bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
	if (flag)	return true;
};
function GL_getObj(obj){
//	nest= (!nest)?"":"document."+nest+".";
	nest="";
	this.el= bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);	
   	this.css= bw.ns4?this.el:this.el.style;
	this.ref= bw.ns4?this.el.document:document;		
	this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
	this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
	this.height= (bw.ie4||bw.ie5||bw.ns6)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.op?this.css.pixelHeight:0;
	this.width= (bw.ie4||bw.ie5||bw.ns6)?this.el.offsetWidth:bw.ns4?this.ref.width:bw.op?this.css.pixelWidth:0;
	return this;
}
function GL_initLayers() {
	if(bw.ns4) document.captureEvents(Event.MOUSEMOVE);
	GL_timeout_func();
}
function GL_updateTime(WMid)	{
	GLV_date = new Date();
	GLV_timeout[WMid] = GLV_date.getTime();
}
function GL_doResetAll(WMid) {
	var resetSubMenus="";
	eval('resetSubMenus = GL'+WMid+'_resetSubMenus();');
	if (GLV_doReset[WMid] && resetSubMenus) {
		GLV_doReset[WMid] = false;
		GL_hideAll(WMid);
		if (GLV_onlyOnLoad[WMid])	GL_restoreMenu(WMid);
	}
}
function GL_timeout_func()	{
	GLV_date = new Date();
	var stuff="";
	for (var a=0;a<GLV_timeout_count;a++)	{
		WMid = GLV_timeout_pointers[a];
		if (GLV_date.getTime()-GLV_timeout[WMid] > GLV_timeoutRef[WMid])	{
			GL_doResetAll(WMid);
		}
	}
//window.status = GLV_date.getTime()-GLV_timeout[WMid]-GLV_timeoutRef[WMid]
	window.setTimeout("GL_timeout_func();",200);
}
function GL_resetAll(WMid) {
	if (!GLV_doReset[WMid]) {
		GL_updateTime(WMid);
		GLV_doReset[WMid] = true;
	}
}
function GL_mouseUp(WMid,e) {
	GLV_doReset[WMid] = false;
	if (!GLV_dontHideOnMouseUp[WMid])	{
		GL_hideAll(WMid);
		if (GLV_onlyOnLoad[WMid])	GL_restoreMenu(WMid);
	}
}
function GL_stopMove(WMid) { 
	GLV_menuOn[WMid] = null;	
}
function GL_restoreMenu(WMid)	{
	eval('GL'+WMid+'_restoreMenu()');
}
function GL_doTop(WMid,id) { 
	GL_hideAll(WMid);
	if (GL_isObjCss(id))	{
		GLV_menuOn[WMid] = GL_getObjCss(id);
		GLV_menuOn[WMid].visibility = "visible";

		eval('GL'+WMid+'_doTop(WMid,id)');

		var layerObj = GL_getObj(id);
		GLV_curLayerHeight[WMid] = layerObj.height;
		GLV_curLayerWidth[WMid] = layerObj.width;
		GLV_curLayerX[WMid] = layerObj.x;
		GLV_curLayerY[WMid]  = layerObj.y;
		GLV_currentLayer[WMid] = id;
		GLV_hasBeenOver[WMid]=0;
		WCH.lastVLayer = id;
		//alert(id);
		WCH.Apply(id);
	}
}
	//Capturing mousemove
function GL_getMouse(e) {
	GLV_x= (bw.ns4||bw.ns5)?e.pageX:(bw.ie4||bw.op)?event.x:(event.x-2)+document.body.scrollLeft;
	GLV_y= (bw.ns4||bw.ns5)?e.pageY:(bw.ie4||bw.op)?event.y:(event.y-2)+document.body.scrollTop;
}
function GL_mouseMoveEvaluate(WMid)	{
	if (GLV_gap[WMid] && GLV_currentLayer[WMid]!=null)	{
		if (	GLV_x+GLV_gap[WMid]-GLV_curLayerX[WMid] <0 || GLV_y+GLV_gap[WMid]-GLV_curLayerY[WMid] <0 || GLV_curLayerX[WMid]+GLV_curLayerWidth[WMid]+GLV_gap[WMid]-GLV_x <0 || GLV_curLayerY[WMid]+GLV_curLayerHeight[WMid]+GLV_gap[WMid]-GLV_y <0)	{
			if (GLV_hasBeenOver[WMid])	{
				GLV_doReset[WMid]=true;
			}
		} else {
			GL_updateTime(WMid);
			GLV_hasBeenOver[WMid]=1;
			GLV_doReset[WMid]=false;	// Added 120902: When on the layer we do not want the layer to be reset... 
		}
	}
}
function GL_hideAll(WMid)	{
	
	GLV_doReset[WMid] = false;
	GLV_currentLayer[WMid] = null;
	if (GL_isObjCss(GLV_lastKey[WMid]) && GL_getObjCss(GLV_lastKey[WMid]))	{	eval('GL'+WMid+'_hideCode()');	WCH.Discard(WCH.lastVLayer);}
	GLV_hasBeenOver[WMid]=0;
	
}

