/* 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 $
*/
// --- Resize Fix for Layers
var top_distance = 0;
// Opera & NS4 resize-Topnavigation Fix START
var ResizeTimer;
var origW=window.innerWidth;
var origH=window.innerHeight;
// Opera / NS4.x resize-Topnavigaton Fix Check 
function checkResize() {
	clearTimeout( ResizeTimer );
	if ( !OP && !NS ) return true;
	if ( OP && !(window.innerWidth==origW && window.innerHeight==origH)) location.reload();
	else if ( NS && !(window.outerWidth==origW && window.outerHeight==origH)) location.reload();
	ResizeTimer = window.setTimeout("checkResize()", 500);
	return true;
}
// Opera & NS4 (on Mac) resize-Topnavigation Fix END	

function preLoad (imgfile) {
	Cache = new Image();
	eval ("Cache.src = \"" + imgfile+"\"");																		 
}
			
// hides corrupted HTML-Page when using Netscape-Resize-Patch
function grayOutPageOnNetscapeReload(){ 
	var grayOutAllLayer = new Layer(innerWidth);
	with(grayOutAllLayer){
		left = 0;
		top = 0;
		clip.height = innerHeight;
		clip.width = innerWidth;
		bgColor = "#e4e4e4";
		zIndex = 1000;
		document.open();
		document.write("Reloading, please wait...");
		document.close();
		visibility = "show";
	}
}

var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0, IE4 = 0, MAC = 0, NT4=0, IE6 = 0, WIN = 0;

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;
	// has to be extended so msie7+ are recognized too!
	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;
}

function getImageObjectForNS4(id, d){
	if (!NS) return null;
	var searchResult = null;
	if (!d) d = document;
	if (d.images[''+id+'']) searchResult = d.images[''+id+''];
	for (var i=0; !searchResult && i < d.layers.length; i++){			 
		searchResult = getImageObjectForNS4( id, d.layers[i].document );
	}
	return searchResult;
}

// initialise the window status bar and bugfix scrollbar for MAC+IE
function initPage(windowStatus){
		set_blink()

	if ( OP || NS ){	// Opera / NS4 Resize Patch
		clearTimeout( ResizeTimer );
		if (NS){
			origW=window.outerWidth;
			origH=window.outerHeight;
		}
		ResizeTimer = window.setTimeout("checkResize()",500);
	}
	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; };


	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; 
	}

// service function to get Layer-object in NS4 no matter how much surrounding layers
function getLayerObjectForNS4(id, d){
	if (!NS) return null;
	var searchResult = null;
	if (!d) d = document;
	if (d.layers[''+id+'']) searchResult = d.layers[''+id+''];
	for (var i=0; !searchResult && i < d.layers.length; i++){			 
		searchResult = getLayerObjectForNS4( id, d.layers[i].document );
	}
	return searchResult;
}
// almost like the getElem-function of DHTML.js, but can only get layer-objects
// and has advanced capabilities for NS4 using getLayerObjectForNS4()
function getLayerById(id, d){
	if (id == '' && !id ) return null;
	var layerObject = null;
	if (NS) layerObject = getLayerObjectForNS4( id, d );
	else if (MS) layerObject = document.all[''+id+''];
	else if (DOM) layerObject = document.getElementById(id);	
	return layerObject;
}
// START: eMBLayer - Object
function eMBLayer ( id ){
	// data member
	this.object = getLayerById( id ); // can be used if direct access on the layer-object is required
	this.id = id; // the id of the layer as a string
	
	// member functions 
	this.isObject = isObject; // returns true if layer was found, else false, object.isObject()
	this.getParentLayer = getParentLayer; // returns the parent layer as an eMBLayer object, object.getParentLayer()
	this.convertLayerToEmbLayer = convertLayerToEmbLayer; /* converts an usual layer object to an eMBLayer object, 
																													 targetEmbLayerObject.convertLayerToEmbLayer( sourceLayerObject )*/
	 
	this.getId = getId; // writes the id of the calling object into the "id"-property
	this.show = show; // object.show()
	this.hide = hide; // object.hide()
	
	this.setBgColor = setBgColor; // sets the background color of the caling eMBLayer, object.setBgColor("#ffffff")
	
	this.setX = setX; // set x Position of the layer, object.setX( int-Value )
	this.setY = setY; // set y Position of the layer, object.setY( int-Value )
	
	this.getX = getX; // retrieves x Position of the layer, relative to parent element, object.getX()
	this.getY = getY; // retrieves y Position of the layer, relative to parent element, object.getY()
	this.getAbsoluteY = getAbsoluteY; // retrieves y Position of the layer, relative to browser window, object.setAbsoluteX()
	
	this.getWidth = getWidth; // retrieves the width of the layer, object.getWidth()
	this.getHeight = getHeight; // retrieves the height of the layer, object.getHeight()
	
	this.setSize = setSize; // sets the size for the layer, object.setSize( int-Value width, int-Value height )
}
// member functions implementations, do NOT use as standalone function!
// if needed, can be used as follows: 
// (new eMBLayer(IdOfTheLayerYouWantToUseTheFunctionWith)).theFunctionYouWantToUse();
function convertLayerToEmbLayer( layerObject ){
	this.object = layerObject;
	this.id = this.getId();
	return this;
}

function isObject(){
	return ( (this.object==null)?false:true );
}
// returns the parent-eMBLayer of the layer with the given id as an object
function getParentLayer( ){
	if (!this.isObject()) return null;
	var parentLayerObject = null;
	if (NS) parentLayerObject = new eMBLayer( this.object.parentLayer.name );
	else if (MS){
		var parentObject = this.object.parentElement;
		while (parentObject && parentObject.parentElement && parentObject.tagName.toLowerCase() != "div")
			parentObject = parentObject.parentElement;
		if (parentObject && parentObject.tagName.toLowerCase() != "div") parentObject = null;
	} else if (DOM){
		var parentObject = this.object.parentNode ;
		while (parentObject && parentObject.parentNode && !((parentObject.nodeType==1 || OP) && parentObject.tagName.toLowerCase()=="div") )
			parentObject = parentObject.parentNode ;
		if ( !( parentObject && (parentObject.nodeType==1 || OP) && parentObject.tagName.toLowerCase()=="div") ) parentObject = null;
	}
	return (new eMBLayer(null)).convertLayerToEmbLayer( parentObject );
}
function getId(){
	if ( !this.isObject() ) return null;
	if (MS || DOM) return this.object.id;
	else if (NS) return this.object.name;
}
function show(){
	if ( !this.isObject() ) return true;
	if (NS) this.object.visibility = "show";
	else if (MS || DOM) this.object.style.visibility = "visible";
}
function hide(){
	if ( !this.isObject() ) return true;
	if (NS) this.object.visibility = "hide";
	else if (MS || DOM) this.object.style.visibility = "hidden";
}
function setBgColor( newColor ){
	if ( !this.isObject() ) return true;
	if (NS) this.object.bgColor = newColor;
	else this.object.style.backgroundColor = newColor;
}
function setX( newXPosition ){
	if ( !this.isObject() ) return true;
	if (NS) this.object.left = newXPosition;
	else if (MS || DOM) this.object.style.left=newXPosition+"px";
}
function setY( newYPosition ){
	if ( !this.isObject() ) return true;
	if (NS) this.object.top = newYPosition;
	else if (MS || DOM) this.object.style.top = newYPosition+"px";
}
function getX(){
	var w = -1;
	if ( !this.isObject() ) return w;
	if (MS || DOM) w = this.object.offsetLeft;
	else if (NS) w = this.object.left;
	return w;
}
function getY(){
	var w = -1;
	if ( !this.isObject() ) return w;
	if (MS || DOM) w = this.object.offsetTop;
	else if (NS) w = this.object.top;
	return w;
}
function getAbsoluteY(){
	var absTop = 0;
	if ( !this.isObject() ) return -1;
	var layerObject = this;
	if (NS) return this.object.pageY;
	while( layerObject.isObject() ){
		absTop = absTop + layerObject.getY();
		layerObject = layerObject.getParentLayer();
	}
	return absTop;
}
function getWidth(){
	var w = -1;
	if ( !this.isObject() ) return w;
	if (DOM && !OP) this.object.style.width = "auto"; // needed but can reset a layers size in strict HTML4.01
	if (IE4 || OP) w = this.object.style.pixelWidth;
	else if (MS || (DOM && !OP)) w = this.object.offsetWidth; // IE5+ & NS6
	else if (NS) w = this.object.clip.width;
	return w;
}
function getHeight(){
	var w = -1;
	if ( !this.isObject() ) return w;
	if (DOM && !OP) this.object.style.height = "auto";
	if (MS || (DOM && !OP)) w = this.object.offsetHeight;
	else if (NS) w = this.object.clip.height;
	else if (OP) w = this.object.style.pixelHeight;
	return w;
}
// setting width and height for layers
// used on initalization and when positioning highlight layers
// on Mozilla 0.9x+ don't use getWidth or getHeight (on the same layer) after this function, this
// would shrink layer size to its contents size
function setSize( newWidth, newHeight ){
	if ( !this.isObject() ) return true;
	if (!NS){
		with (this.object.style) {
			if (MS || OP){
				pixelWidth = newWidth;
				pixelHeight = newHeight;
			}	else if (DOM && !OP){		
				width = newWidth+"px";
				height = newHeight+"px";
			}
		}
	} else if (NS){
		this.object.resizeTo(newWidth, newHeight);
		with(this.object.clip){
			top = 0;
			left = 0;
			width = newWidth;
			height = newHeight;
		}
	}
}
// END: eMBLayer - Object
/*
function openChild(source, name, attributes){
	if(!NS)
		var infoWin = window.open(source, name, attributes);
	else if(NS)
		if(window
}*/
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	




///////////////////////////////////

function sub_form (id) {
	var obj= getLayerById(id)
	obj.submit()

	}
	
function popup(id) {
obj =  open(id,'pop_up','menubar=no,statusbar=yes,width=440,height=480,scrollbars=yes');
obj.window.focus()
}

function popup2() {
obj =  open('','mercedes_wallpaper', 'toolbars=0,scrollbars=1,location=0,statusbars=1,menubars=0,resizable=0,width=780,height=580');
obj.window.focus()
}







/* <config>*/
var fadeOutColor ="#000000"
var fadeInColor = "#ff6600";
var stepIn = 20;
var stepOut = 20;



/* </config>*/


var hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";




var fadeId = new Array();

function dehexize(Color){
	var colorArr = new makearray(3);
	for (i=1; i<7; i++){
		for (j=0; j<16; j++){
			if (Color.charAt(i) == hexa[j]){
				if (i%2 !=0)
					colorArr[Math.floor((i-1)/2)]=eval(j)*16;
				else
					colorArr[Math.floor((i-1)/2)]+=eval(j);
			}
		}
	}
	return colorArr;
}



function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
       return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function setColor(r, g, b, element) {
//  alert (blink)
	var hr = hex(r); var hg = hex(g); var hb = hex(b);
		  var blink = document.getElementsByTagName("acronym")
  for (var i=0; i < blink.length; i++)
  	{
		      blink[i].style.color = "#"+hr+hg+hb;
	}
      

}
//fade(srcElement.startColor,fadeColor,srcElement.uniqueID,stepIn);
function fade(s,e,step) {
//	alert (element)
	var sr = s[0]; var sg = s[1]; var sb = s[2];
	var er = e[0]; var eg = e[1]; var eb = e[2];
	
	for(var i = 0; i <= step; i++) {
		fadeId[i+1] = setTimeout("setColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +
			step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+
			")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")));",i*step);
	}

}



function set_blink() {
	 	fadeOutColor= dehexize(fadeOutColor.toLowerCase());
		fadeInColor = dehexize(fadeInColor.toLowerCase());
	    var bi = setInterval("doBlink()",1000)
	}

var blk = 1
function doBlink() {
  // Blink, Blink, Blink...
  
  if (document.getElementsByTagName("acronym"))
  {
	blk = blk == 0 ? 1 : 0
			
		if (blk == 0)
			{
			fade(fadeOutColor,fadeInColor,stepOut);
//			blink[i].style.color="#527BB9"
			}
		else
			{
			fade(fadeInColor,fadeOutColor,stepIn);
//			blink[i].style.color="#ff6600"
			}


  }
  else
  {
	  clearInterval(bi)
	  }
}
