/*
	DHTML crossbrowser JavaScript library
	Author: Thomas Weckert, t.weckert@alkacon.com
	(C) 2002 Alkacon GbR, http://www.alkacon.com
*/

// some global variables
var NS4=false, IE4=false;
var windowWidth=0, windowHeight=0;
var layerRef, layerStyleRef, styleSwitch, pixSwitch, leftSwitch, topSwitch;

// detect the browser
function checkBrowser() {
	if( (parseInt( navigator.appVersion )) >= 4 ) {
		( navigator.appName.indexOf("etscape") != -1 ) ? NS4=true : NS4 = false;
		( navigator.appName.indexOf("xplorer") != -1 ) ? IE4=true : IE4 = false;
	}
	
	// init crossbrowser-code for referring layers
	if( NS4 ) {
		layerStyleRef = "layer.";	
		layerRef = "document.layers";	
		styleSwitch = "";
		pixSwitch = "";
		leftSwitch = ".left";
		topSwitch = ".top";   
	}
	else if( IE4 ) {	
		layerStyleRef = "layer.style.";	
		layerRef = "document.all";
		styleSwitch = ".style";	
		pixSwitch = "px";  
		leftSwitch = ".pixelLeft";
		topSwitch = ".pixelTop";
	}  
}

function getDimensions() {
	if( NS4 ) {
		windowWidth = innerWidth;
		windowHeight = innerHeight;
	}
	else if( IE4 ) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
}


// functions to move layers:
function moveLayerUp( layerName, pix ) {
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + topSwitch + ' -= pix' );
}

function moveLayerDown( layerName, pix ) {
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + topSwitch + ' += pix' );
}

function moveLayerRight( layerName, pix ) {
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + leftSwitch + ' += pix' );
}

function moveLayerLeft( layerName, pix ) {
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + leftSwitch + ' -= pix' );
}


// functions to toggle the visibility of a layer:
function showLayer( layerName ) {
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + '.visibility = "visible"' );
}

function hideLayer( layerName ) {
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + '.visibility = "hidden"' );
}


// functions to get the position of a layer:
function getLayerLeftPos( layerName ) {
	eval( "pos = " + layerRef + '["' + layerName + '"]' + styleSwitch + leftSwitch );
	return pos;
}

function getLayerTopPos( layerName ) {
	eval( "pos = " + layerRef + '["' + layerName + '"]' + styleSwitch + topSwitch );
	return pos;
}


// functions to position layer:
function setLayerLeftPos( layerName, leftPos ) {
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + leftSwitch + ' = leftPos' );
}

function setLayerTopPos( layerName, topPos ) {
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + topSwitch + ' = topPos' );
}

function setLayerPos( layerName, leftPos, topPos ) {
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + leftSwitch + ' = leftPos' );
	eval( layerRef + '["' + layerName + '"]' + styleSwitch + topSwitch + ' = topPos' );
}