pressButton = "";

function buttonPressed(that)
{
	pressButton = that;
	buttonOver(that);
}

function buttonOver(that)
{
	if (pressButton==that) {
		if (that.src) {
			that.src = that.src.replace(/.gif/,"_pressed.gif");
		} else {
			that.style.borderLeft = "1px solid #333";
			that.style.borderTop = "1px solid #333";
		}
	}
}

function buttonOut(that)
{
	if (that.src) {
		that.src = that.src.replace(/_pressed.gif/,".gif");
	} else {
		that.style.borderLeft = "1px solid #d6d6d6";
		that.style.borderTop = "1px solid #d6d6d6";
	}
}

function buttonReleased(that)
{
	buttonOut(that)
	pressButton = "";
}

function outsideReleased()
{
	pressButton = "";
}

if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
	document.onmouseup=outsideReleased;
} else {
	window.captureEvents(Event.MOUSEUP);
	window.onmouseup = outsideReleased;
}

function displayLang(country)
{
	var objCountryList = document.getElementById("country-list");
	var lis = objCountryList.getElementsByTagName('li');
	var objLink = document.getElementById(country);

	for ( var i=0; i < lis.length; i++ ) {
		if(lis.item(i).getElementsByTagName('a')[0] != null) {
			lis.item(i).getElementsByTagName('a')[0].style.fontWeight = "normal";
			lis.item(i).getElementsByTagName('a')[0].style.color = "#333333";
		}

		if(lis.item(i).getElementsByTagName('span')[0] != null) {
			lis.item(i).getElementsByTagName('span')[0].style.visibility = "hidden";
		}
	}

	objLink.style.fontWeight = "bold";
	objLink.style.color = "#ff6600";
	objLink.nextSibling.style.visibility = "visible";
}

function pressReview(sImage, title, iWidth, iHeight)
{
	var windowHeight = iHeight;
	var windowWidth = iWidth+26;			//Addition wegen Fensterrand und resize

	sParameter = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,left=0,top=0,height='+windowHeight+',width='+windowWidth;
	if ( typeof openWin=="undefined" || openWin.closed ) {
		openWin = window.open("", "", sParameter);
	}

	openWin.resizeTo(windowWidth,windowHeight);
	openWin.document.open();
	openWin.document.writeln('<html><head>');
	openWin.document.writeln('<meta http-equiv=\"imagetoolbar\" content=\"no\" />');
	openWin.document.writeln('<title>' + title + '</title>');
	openWin.document.writeln('<style>html,body{margin: 0;}</style></head>');
	openWin.document.writeln('<body>');
	openWin.document.writeln('<img src="'+sImage+'" alt="'+title+'" />');
	openWin.document.writeln('</body></html>');
	openWin.document.close();
	openWin.focus();
}

function displayForms(that)
{
	//only for radio buttons
	if(that.type == 'radio') {
		var elementName = that.name;
		var elements = document.getElementsByName(elementName);

		for (var i=0; i<elements.length; i++) {
			var singleElementId = 'table-'+elements[i].id;
			var singleElement = document.getElementById(singleElementId);
			if (singleElement)
				singleElement.style.display = "none";
		}
	}

	//for radio buttons and checkboxes
	var elementId = 'table-'+that.id;
	var element = document.getElementById(elementId);
	if (element) {
		if(that.checked) {
			element.style.display = "block";
		} else {
			element.style.display = "none";
		}
	}
}

function getPos(id)
{
	var obj = document.getElementById(id);
	var pos = {left:0, top:0};

	if(typeof obj.offsetLeft != 'undefined') {

		while (obj) {
			pos.left += obj.offsetLeft;
			pos.top += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else {
		pos.left = obj.left;
		pos.top = obj.top;
	}
	return pos;
}

function getPosObj(obj)
{
	var pos = {left:0, top:0};

	if(typeof obj.offsetLeft != 'undefined') {

		while (obj) {
			pos.left += obj.offsetLeft;
			pos.top += obj.offsetTop;
			obj = obj.offsetParent;
		}
	} else {
		pos.left = obj.left;
		pos.top = obj.top;
	}
	return pos;
}

function getBottom(obj)
{
	var pos=getPosObj(obj);
	return pos.top+obj.offsetHeight;
}

function getBottomForId(id)
{
	var obj = document.getElementById(id);
	if (!obj)
		return 0;
	var pos=getPos(id);
	return pos.top+obj.offsetHeight;
}

function setContentTDHeight(id)
{
	var iHeight = 149;			//-149 for Header Height + Breadcrumb Height
	if (getPos(id).top > parseInt(iHeight)) {
		document.getElementById('wrapper-content').style.height = getPos(id).top - iHeight + "px";
	}
}

function setContentTDHeightTeaser(id)
{
	var iHeight = getBottomForId("headline");	//-149 for Header Height + Breadcrumb Height
	if (iHeight<149) iHeight=149;
	if (getPos(id).top > parseInt(iHeight)) {
		document.getElementById('wrapper-content-teaser').style.height = getPos(id).top - iHeight + "px";
	}

	var lc=null;
	var childNodes=document.getElementById("wrapper-content").childNodes;
	for (i=0;i<childNodes.length;i++)
	{
		if (childNodes[i].nodeType==1)
			lc=childNodes[i];
	}
	var lcBottom = getBottom(lc);
	var middleBottom = getBottomForId("wrapper-content");
	var diff=middleBottom-lcBottom;
	var newHeight=middleBottom-getPosObj(lc).top;
	if (diff>1)
	{
		lc.style.height=newHeight+"px";
	}
}


function setContentTDHeightHome(id)
{
	var lc=null;
	var childNodes=document.getElementById("content").childNodes;
	for (i=0;i<childNodes.length;i++)
	{
		if (childNodes[i].nodeType==1)
			lc=childNodes[i];
	}
	var lcBottom = getBottom(lc);
	var middleBottom = getBottomForId("content");
	var diff=middleBottom-lcBottom;
	var newHeight=middleBottom-getPosObj(lc).top;
	if (diff>1)
	{
		lc.style.height=newHeight+"px";
	}
}

function setPriceTDHeight(id) 
{
	var iWrapperDetail = getBottomForId("wrapper-content");
	var iPricePlaceholder = getBottomForId("price-pos");
	var diff = iWrapperDetail-iPricePlaceholder+17;

	if (diff > 1)
		document.getElementById('price-placeholder').style.height = diff+"px";
}


function openPopUp(URL,Name,Width,Height) {
	  var Size = 'width='+Width+',height='+Height;
	  window.open(URL,Name,Size);
 }
 
 function openScrollablePopUp(URL,Name) {
	  var Size = 'scrollbars';
	  window.open(URL,Name,Size);
 }

  function openScrollablePopUp(URL,Name,Width,Height) {
	  var Size = 'width='+Width+',height='+Height+',scrollbars';
	  window.open(URL,Name,Size);
 }

function goToUrl()
{
	myObj = document.getElementById('new-products');
	if (myObj.selectedIndex > 0)
	{
		var target = (myObj.options[myObj.selectedIndex].value);
		window.location.href = target; 
		return;
	}
}

