// JavaScript Document


/* for backward compatibility / facelift */
function setPositions() {
	var footer = getLayer("bo-footer");
	if(footer) {
		footer.style.display = "block";
	}
}


/**
	some common helper functions
*/

function getLayer( strID )
{
	if( document.all && !window.opera )
		return document.all[ strID ];
	else
		return document.getElementById( strID );
}


/**
* set events, w3c-compatible and ie
*/
function addEvent(obj, eventType, func, useCaption)
{
	if (!obj || !eventType || !func) {
		return false;
	} else if (obj.addEventListener) {
		obj.addEventListener(eventType, func, useCaption);
		return true;
	} else if (obj.attachEvent) {
    var retVal = obj.attachEvent("on"+eventType, func);
		return retVal;
	} else {
		return false;
	}
}


/**
 * special handling for ie 6, to place the bottom of the window
 */
if(document.all && !window.opera) {
	try {
		if (navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE")>0) {		
			var str = navigator.appVersion;
			var ind = parseInt(str.indexOf("MSIE"))+5;
			var ver = parseInt(str.substring(ind, ind+1));
			if (ver<7) {
				addEvent(window, "load", initFooterIE);
			}
		}
	} catch(e) {}
}


function initFooterIE() {
	window.onscroll = positionFooter;
	window.onresize = positionFooter;
	positionFooter();
}


function positionFooter() {
	try {
		var toolbarHeight = getLayer("cms_position") && getLayer("CFCToolBarDiv") ? getLayer("CFCToolBarDiv").offsetHeight : 0;
		var topValue = document.documentElement.clientHeight + document.documentElement.scrollTop - getLayer("bo-footer").offsetHeight - toolbarHeight;
		getLayer("bo-footer").style.position = "absolute";
		getLayer("bo-footer").style.display = "block";		
		// special value for t9091 in ie6 and only on author-instance
		if( getLayer("bo-footer").parentNode==getLayer("ms-website") && document.body.getAttribute('instance')=='Author' ) {
			topValue -= 44;
		}				
		getLayer("bo-footer").style.top = (topValue);
	} catch(e) {}
}

