var openpopupWindow = null;
function openpopup (mypage,myname,w,h,pos,infocus,scrolling){
	if (openpopupWindow) {
		openpopupWindow.close();
	}
	if(pos=='random'){
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=='center'){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	} else if((pos!='center' && pos!='random') || pos==null){
		LeftPosition=100;TopPosition=100;
	}
	settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=' + scrolling + ',resizable=no,dependent=no';
	openpopupWindow = window.open('',myname,settings);
	if(infocus=='front'){
		openpopupWindow.focus();
		openpopupWindow.location=mypage;
	}
}

var dropdown_timeout;
var dropdown_node;
var dropdown_timer;


function dropdown_onmouseover()
{
	if(dropdown_timeout == true)
	{
		dropdown_timeout = false;
		window.clearTimeout(dropdown_timer);

		if(dropdown_node == this) return;
		else dropdown_onmouseout_timeout();
	}

	if(navigator.appVersion.indexOf("MSIE 5") >= 0 &&
	   navigator.appVersion.indexOf("Macintosh") >= 0)
	{
		if(this.firstChild) this.firstChild.style.display = "block";
	}
	else
	{
		if(navigator.appVersion.indexOf("MSIE 5") >= 0)
		{
			if(this.childNodes[1] && this.childNodes[1].style) this.childNodes[1].style.display = "block";
		}

		this.className += " hover";
	}
}

function dropdown_onmouseout()
{
	dropdown_timeout = true;
	dropdown_node = this;
	dropdown_timer = window.setTimeout("dropdown_onmouseout_timeout()", 250);
}

function dropdown_onmouseout_timeout()
{
	dropdown_timeout = false;

	if(navigator.appVersion.indexOf("MSIE 5") >= 0 &&
	   navigator.appVersion.indexOf("Macintosh") >= 0)
	{
		if(dropdown_node.firstChild) dropdown_node.firstChild.style.display = "none";
	}
	else
	{
		if(navigator.appVersion.indexOf("MSIE 5") >= 0)
		{
			if(dropdown_node.childNodes[1] && dropdown_node.childNodes[1].style) dropdown_node.childNodes[1].style.display = "none";
		}

		dropdown_node.className = dropdown_node.className.replace(" hover", "");
	}
}

function ie5_init()
{
	ul = document.getElementsByTagName("ul");

	for(i = 0; i < ul.length; i++)
	{
		if(ul[i].className.indexOf("dropdown") < 0) continue;

		for(d = 0; d < ul[i].childNodes.length; d++)
		{
			node = ul[i].childNodes[d];
			if(node.nodeName == "LI")
			{
				//if(node.id != "inter") node.className = node.className.replace(" hover", "");
				if(node.childNodes[1] && node.childNodes[1].style)
				{
					node.childNodes[1].style.display = "none";
					node.childNodes[1].style.visibility = "visible";
				}
			}
		}

	}
}

function dropdown_init()
{
	if(!document.getElementsByTagName) return;

	ul = document.getElementsByTagName("ul");

	for(i = 0; i < ul.length; i++)
	{
		if(ul[i].className.indexOf("dropdown") < 0) continue;

		for(d = 0; d < ul[i].childNodes.length; d++)
		{
			node = ul[i].childNodes[d];
			if(node.nodeName == "LI")
			{
				node.onmouseover = dropdown_onmouseover;
				node.onmouseout = dropdown_onmouseout;
				
				if(navigator.appVersion.indexOf("MSIE 5") >= 0 &&
				   navigator.appVersion.indexOf("Macintosh") < 0)
				{
					if(node.childNodes[1] && node.childNodes[1].style)
					{
						node.childNodes[1].style.visibility = "hidden";
						node.childNodes[1].style.display = "block";
					}
					// node.className += " hover";
				}
			}
		}

	}

	dropdown_timeout = false;

	if(navigator.appVersion.indexOf("MSIE 5") >= 0 &&
	   navigator.appVersion.indexOf("Macintosh") < 0)
	{
		window.setTimeout("ie5_init()", 1);
	}
}

function confirmthis(jsmsg) { 
	Check = confirm(jsmsg);
	if(Check == false) {
		return false;
	}
}


function external_init() {
	var a;
	var f;
	var node;

	if(!document.getElementsByTagName) return;
	
	a = document.getElementsByTagName("a");

	for(i = 0; i < a.length; i++) {
		if(!a[i].getAttribute("href") ||
		   a[i].getAttribute("rel") != "external") continue;
		a[i].target = "_blank";
	}

	f = document.getElementsByTagName("form");

	for(i = 0; i < f.length; i++) {
		if(f[i].className != "external") continue;
		f[i].target = "_blank";
	}
}

function textLimiter(myelement, maxlimit) {
	field = document.getElementById(myelement);
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	}
}

function calculate_price_single(action, price) {
	var x;
	x = eval(document.formular.MENGE.value) + action;
	if (x < 1) {
		x = 1;
	}
	document.formular.MENGE.value = x;
}

function calculate_price(action, price, feld) {
	var x;

	x = eval('document.formular.' + feld + '.value');
	action++;
	action--;
	x++;
	x--;
	x = (x) + (action) + 0.0;
	if (x < 0) {
		x = 0;
	}
	eval('x = document.formular.' + feld + '.value = x');
}

function init_all() {
	external_init();
	dropdown_init();
}

window.onload = init_all; 