// charset=utf-8
// $Id: ServiceBox.js 309 2010-04-09 08:15:21Z dierker $
// $HeadURL: svn://svnserver/heytex/relaunch_2010/modules/ServiceBox/scripts/ServiceBox.js $
// +----------------------------------------------------------------------+
// | mcm module: ServiceBox                                               |
// | mcm version 5.6                                                      |
// | (c) 2002-2010 monsun media (http://www.monsun-media.com)             |
// +----------------------------------------------------------------------+


/**
* ServiceBox
*
* @author	md
*/
var ServiceBox = {
	/**
	* open the downloads-overlay
	*
	* @param	Event	evt
	* @return	void
	*/
	openDownloadsOverlay : function(evt){
		// create the semi-transparent background
		var overlayBground = document.getElementById('ServiceBoxOverlayBackground');
		overlayBground.style.width = '100%';
		overlayBground.style.height = parseInt(document.body.scrollHeight)+'px';
		overlayBground.style.visibility = 'visible';
		if( overlayBground.addEventListener ){
			overlayBground.addEventListener('click',ServiceBox.hideDownloadOverlay,false);
		}else if( overlayBground.attachEvent ){
			overlayBground.attachEvent('onclick',ServiceBox.hideDownloadOverlay);
		};
		
		var overlayContainer = document.getElementById('ServiceBoxOverlay');
		var top = ServiceBox.getScrollTop() + ServiceBox.getViewportHeight()/2 - (324/2);
		overlayContainer.style.top = top+'px';
		overlayContainer.style.visibility = 'visible';

		mcm.cancelEvent(evt);
	}
	,
	/**
	* get the scroll-top value
	*
	* @return	int
	*/
	getScrollTop : function(){
		var scrollTop = document.body.scrollTop;
		if( scrollTop==0 ){
			if(window.pageYOffset){
				scrollTop = window.pageYOffset;
			}else{
				scrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
			};
		};
		return scrollTop;
	}
	,
	/**
	* get the height of the visible viewport
	*
	* @return	int
	*/
	getViewportHeight : function(){
		var height = 0;
		if( typeof window.innerHeight!='undefined' ){
			height = window.innerHeight;
		}else if( typeof document.documentElement!='undefined'
			   && typeof document.documentElement.clientHeight!='undefined'
			   && document.documentElement.clientHeight!=0 ){
		height = document.documentElement.clientHeight
		}else{
			height= document.getElementsByTagName('body')[0].clientHeight
		};
		return height;
	}
	,
	/**
	* hide the downloads-overlay
	*
	* @return	void
	*/
	hideDownloadOverlay : function(evt){
		var overlayBground = document.getElementById('ServiceBoxOverlayBackground');
		overlayBground.style.visibility = 'hidden';

		var overlayContainer = document.getElementById('ServiceBoxOverlay');
		overlayContainer.style.visibility = 'hidden';

		mcm.cancelEvent(evt);
	}
}

