var prefix = (document.layers) ? 'document.layers.' : (document.all) ? "document.all." : (document.getElementById) ? "document.getElementById('" : "document.all.";
			
var sufix = (document.layers) ? '' : (document.all) ? "" : (document.getElementById) ? "')" : "";


/***
*	Pannel ausfahren oder einfahren
*/
function toolPannel(thisName, lay, iframe, alignImg, height, btnImgObj, iframeUrl) {

	toolPannels[toolPannels.length] = thisName;

	// Onjekt Name
	this.name = thisName;

	// Pannle Layer
	this.lay = eval(prefix + lay + sufix);

	// Pannle Layer
	
	// iFrame mit Inhalt
	this.iframe = eval(prefix + iframe + sufix);
	
	// Btn
	this.btnImg = btnImgObj;
	
	// ausrichten an Bild
	this.alignImg = document.images[alignImg];
	
	// Max. Hoehe
	this.height = height;
	
	// go Hoehe
	this.goHeight = this.height;
	
	// Max. Hoehe
	this.iframeUrl = iframeUrl;
	
	// Status des Pannels
	this.status = "up";
	
	
	// MouseOver FX
	this.over = function() {
		if (this.status == "up") {
			this.btnImg.over();
		}
	}
	
	// MouseOut FX
	this.out = function() {
		if (this.status == "up") {
			this.btnImg.out();
		}
	}
	
	// MouseClick FX
	this.click = function() {
		if (this.status == "up") {
			this.iframe.src = this.iframeUrl;
			resetPannels(this.name);
			this.show();
		} else if (this.status == "down") {
			this.hide();
		}
	}
	
	// Pannel Positionieren
	this.setPos = function() {
		// x position des Pannels
		this.position = imagePos(alignImg);
		// Bild Hoehe dazuzaehlen
		this.position.y = this.position.y + 25;
		this.lay.style.top = this.position.y + "px";
		this.lay.style.left = this.position.x + "px";
	}
	
	// Verstecken
	this.hide = function() {
		if (!client.opera) {
			this.status = "up";
			this.goHeight = 0;
			obj.btnImg.click();
			movePannel(this);
		}
	}
	
	// Einblenden
	this.show = function() {
	
		if (client.opera) {
			this.btnImg.click();
			this.btnImg.click();
			this.win = new initWin(this.name, this.iframeUrl ,'175', this.height, 'no', 'no', 'no', 1);
			this.win.open();
		} else {
			this.status = "down";
			this.goHeight = this.height;
			this.setPos();
			this.btnImg.click();
			this.lay.style.visibility = "visible";
			animPan = this;
			movePannel(this);
		}
	}
}

/***
*	andere Pannels ausblenden
*/
function resetPannels(name) {
	initName = eval(toolPannels[i]);
	for(i = 0; i < toolPannels.length; i++) {
		objStat = eval(toolPannels[i] + ".status");
		if ((eval(toolPannels[i] + ".name") != name) && (objStat == "down")) {
			eval(toolPannels[i] + ".status = 'up'");
			eval(toolPannels[i] + ".goHeight = 0");
			eval(toolPannels[i] + ".btnImg.click()");
		}
	}
}

function posPannels() {
	initName = eval(toolPannels[i]);
	for(i = 0; i < toolPannels.length; i++) {
		eval(toolPannels[i] + ".setPos()");
	}
}

/***
*	Pannel Gruppe
*/
toolPannels = new Array();

animPan = "";

height = 0;

/***
*	Pannel Bewegung
*/
function movePannel() {
	obj = animPan;
	if (height < obj.goHeight) {
		height = height + 5;
		obj.lay.style.height = height + "px";
		obj.iframe.height = height;
		timeout = window.setTimeout("movePannel()", 5);
	} else if (height > obj.goHeight) {
		height = height - 5;
		obj.lay.style.height = height + "px";
		obj.iframe.height = height;
		timeout = window.setTimeout("movePannel()", 5);
	} else if (obj.goHeight == 0) {
		obj.lay.style.visibility = "hidden";
	}
}	

/***
* Image Postition
*/
function imagePos(imgName) {

	if (client.mie || client.opera) {
		img = document.images[imgName];
		posX = img.offsetLeft;
		posY = img.offsetTop;
		elm = img.offsetParent;
		while(elm && elm!=null) {
			posX += elm.offsetLeft;
			posY += elm.offsetTop;
			elm = elm.offsetParent;
    	}
	} else {
		img = document.getElementById(imgName);
		posX=img.offsetLeft;
		posY=img.offsetTop;
		parentObjX=img.offsetParent;
		parentObjY=img.offsetParent;
		while(parentObjX != null && parentObjY != null) {
			posX +=parentObjX.offsetLeft;parentObjX=parentObjX.offsetParent;
			posY +=parentObjY.offsetTop;parentObjY=parentObjY.offsetParent;
		}
	}
	return {x:posX, y:posY};
}

/***
*	mailto tool
*/
function opneMailto(URL,theme, lang) {
	URL = '/forms/mailto.php?siteurl=' + URL +'&theme=' + theme +'&lang=' + lang;
	mailtoWin = window.open(URL,'mailto','height=250,width=175,locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=no,top=' + (screen.height-250)/2 + ',left=' + (screen.width-175)/2 + ',status=yes');
}
