/* DHTML-library 
needed for eventhandling event_init() and main navigation
extended with show/hidelayer service functions and IE4 recognition variable
$Source: /usr/cvs/eMB/Clickstream_DCVD/js/dhtml.js,v $
$Revision: 1.1 $
Check-In $Date: 2002/10/08 10:14:32 $
*/

function preLoad (imgfile) {
	Cache = new Image();
	eval ("Cache.src = \"" + sUriPrefix + imgfile+"\"");																		 
}

var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0, IE4 = 0, MAC = 0, NT4=0, IE6 = 0, WIN = 0;
var sUriPrefix;
function DHTML_init() {
	if (window.opera) OP = 1;
	if(document.getElementById) {
		DHTML = 1;
		DOM = 1;
	}
	if(document.all && !OP) {
		DHTML = 1;
		MS = 1;
	}
	if(document.layers && !OP) {
		DHTML = 1;
		NS = 1;
	}
	if (MS && !DOM) IE4 = 1;
	// check for Mac.
	if (navigator.userAgent.toLowerCase().indexOf("mac")>-1) MAC = 1;
	// new detection for IE 7!
	if (navigator.userAgent.toLowerCase().indexOf("msie 7")>-1) IE6 = 1;
	if (navigator.userAgent.toLowerCase().indexOf("msie 6")>-1) IE6 = 1;
	if (navigator.userAgent.toLowerCase().indexOf("windows nt;")>-1) NT4 = 1;
	if (navigator.userAgent.toLowerCase().indexOf("windows")>-1) WIN = 1;
}

function swapImage(imgName, imgSource, layerId){//Bildwechsel
    var imageObject;
		if (NS) {
			if (layerId)
        imageObject = getImageObjectForNS4( imgName, getLayerById(layerId).document );
			else 
				imageObject = getImageObjectForNS4( imgName );
      imageObject.src = imgSource;
		} else if (document.images[imgName]) { 
			document.images[imgName].src = imgSource;
		} else if (DOM){
			document.getElementById(imgName).src = imgSource;
		}
	return true;
}

// initialise the window status bar and bugfix scrollbar for MAC+IE
function initPage(windowStatus){
	if (MAC && MS) { window.resizeBy(0,1); window.resizeBy(0,-1); } // garanties the scrollbar on mac+IE
	
	window.status = windowStatus;
	window.defaultStatus = windowStatus;
	
	// remove the rectangle around links for IE+Win
	if (MS&&WIN) { document.onmousedown = ExplorerFix; };
	
	// call PSYMA 
	init_survey();
	
	return true;
}

// remove the rectangle around links for IE+Win only onClick-event, TAB function remains
function ExplorerFix() {
	for (a in document.links) document.links[a].onfocus = document.links[a].blur; 
	}

var popUps = new Array();
function openChild(source, name, attributes) {
	if (!popUps[name] || popUps[name].closed==true) {
		window.open(source,name,attributes);
	} else {
		popUps[name].close();
		popUps[name] = window.open(source,name,attributes);
	}
}
DHTML_init(); // this library is automaticly initialized during loading	






/**********************************************************************
***************** added with release 7.1 ******************************
**********************************************************************/
function getLayer( strID )
{
	if( document.all && !window.opera )
		return document.all[ strID ];
	else
		return document.getElementById( strID );
}

// for backward compatibility
function getLayerById( strID )
{
	return getLayer( strID );
}

function hideLayer( mixLayer )
{
	setLayerVisibility( mixLayer, "hidden" );
}

function showLayer( mixLayer )
{
	setLayerVisibility( mixLayer, "visible" );
}

function setLayerVisibility( mixLayer, strMode )
{
	if( isString( mixLayer ) )
		mixLayer = getLayer( mixLayer );
	if( mixLayer )
		mixLayer.style.visiblity = strMode;
}

function setSize( objLayer, intWidth, intHeight )
{
	if( !isNaN( intWidth ) && intWidth >= 0 )
		objLayer.style.width = intWidth + "px";
	if( !isNaN( intHeight ) && intHeight >= 0 )
		objLayer.style.height = intHeight + "px";
}

function isString( objTest )
{
	return typeof objTest == "string";
}




function getWindowHeight( )
{
	if(MS)
		return document.documentElement.clientHeight + getTopScroll( );
	else
		return innerHeight + getTopScroll( );
}

function getTopScroll()
{
	if(MS)
		return document.documentElement.scrollTop ;
	else
		return pageYOffset ;
}


function setDocumentPosition( )
{
	var objLayer = getLayer( "cms_position" );
	if( objLayer )
		objLayer.style.marginTop = getToolbarHeight( ) + "px";
}

function setBackgroundPos( )
{
	document.body.style.backgroundPosition = "0 " + getToolbarHeight( ) + "px";
	
}


var dhtml_TOOLBAR_ID = "CFCToolBarDiv";
var dhtml_objToolbar = null;
var dhtml_intToolbarHeight = 0;

function getToolbarHeight( )
{
	if( !dhtml_objToolbar )
	{
		dhtml_objToolbar = getLayer( dhtml_TOOLBAR_ID );
		if( dhtml_objToolbar )
			dhtml_intToolbarHeight = dhtml_objToolbar.offsetHeight;
	}

	return dhtml_intToolbarHeight;	
}


function setPositions( )
{
	setDocumentPosition( );
	setBackgroundPos( );
}

function init_survey() {};