
var bwInfo = new Object();

bwInfo.isWindows = (navigator.platform.indexOf("Win") == 0);
bwInfo.isLinux = (navigator.platform.indexOf("Linux") == 0);
bwInfo.isMacOS = (navigator.platform.indexOf("Mac") == 0);
bwInfo.isFirefox = (navigator.userAgent.indexOf("Firefox/") > -1);
bwInfo.isFirefox10 = (navigator.userAgent.indexOf("Firefox/1.0") > -1);
bwInfo.isNetscape = (navigator.userAgent.indexOf("Netscape/7") > -1);
bwInfo.isExplorer =
	((navigator.userAgent.indexOf("MSIE 6") > -1)
	|| (navigator.userAgent.indexOf("MSIE 7") > -1)
	|| (navigator.userAgent.indexOf("MSIE 8") > -1))
	&& (navigator.userAgent.indexOf("Opera") == -1)
	&& (bwInfo.isWindows);

bwInfo.isExplorer6 = 
	(navigator.userAgent.indexOf("MSIE 6") > -1)
	&& (navigator.userAgent.indexOf("Opera") == -1)
	&& bwInfo.isWindows;


function openWin(link, name, height, width, top, left)
{
	window.open(link, name , 'height=' + height + ',width=' + width + ',top=' + top + ',left=' + left + ',scrollbars=yes,resizable=yes');
	this.navigate ='';
}

function doSubmitForm(formId)
{
	if(document.getElementById)
	{
		var ref = document.getElementById(formId);
		ref.submit();
	}	
}

function onSetFocus(id)
{
	var funcStr = "onSetRealFocus('" + id + "');";
	window.setTimeout(funcStr, 200);
}

function onSetRealFocus(id)
{
	if(document.getElementById)
	{
		var ref = document.getElementById(id);
		if(ref != null)
		{
			ref.focus();
		}
	}
}

function openWindow(url, name, width, height)
{
	var propStr = "width=";
	propStr += new String(width);
	propStr += ",height=";
	propStr += new String(height);
	propStr += ",left=0,top=0,resizable=yes,menubar=yes";
	
	window.open(url, name, propStr);
}

function posLeft(obj) 
{ 
	return obj.offsetParent? obj.offsetLeft+posLeft(obj.offsetParent) : obj.offsetLeft;
}

function posTop(obj) 
{
	return obj.offsetParent ? obj.offsetTop + posTop(obj.offsetParent) : obj.offsetTop; 
}


/**************************************************************
	NEU eingebaute Funktionen
**************************************************************/

function showProdImage(id, path, width, height)
{
	var prodImage = null;
	if(document.getElementById)
	{
		prodImage = document.getElementById(id);
		
		if(prodImage != null)
		{
			prodImage.src = path;
			prodImage.width = width;
			prodImage.height = height;
		}
	}
}

function showTreeMenu(mainCatIDStr, mainCatListIDStr, doDisplay, downMenu)
{
	var linkElem;
	var menuElem;
	var pLeft;
	var pTop;
	var img;
	var menuHeight = 0;
	
	if (document.getElementById)
	{
		linkElem = document.getElementById(mainCatIDStr);
		menuElem = document.getElementById(mainCatListIDStr);
		
		if ((linkElem != null) && (menuElem != null))
		{
			if (doDisplay == true)
			{
				menuElem.style.display = "block";
				
				pLeft = linkElem.offsetLeft - 11;
				pTop = linkElem.offsetTop - 14;
				
				menuElem.style.left = pLeft + "px";
				
				if (downMenu == true)
				{
					menuHeight = menuElem.clientHeight;
					pTop -=  menuHeight - linkElem.clientHeight;
					
					img = linkElem.getElementsByTagName("img");
					if (img != null && img.length > 0)
					{
						pTop += (linkElem.clientHeight / 2) - 14;
					}
					else
					{
						pTop -= (linkElem.clientHeight - 14) / 2;
					}
				}
				
				menuElem.style.top = pTop + "px";
			}
			else
			{
				menuElem.style.display = "none";
			}
		}
	}
}

var keepAliveTimer = null;
var duration = 4 * 60 * 1000;
var keepAliveImgElem = null;
var keepAliveUrl = "/shop/KeepSessionAlive.gif";
function startKeepAlive()
{
	if (document.getElementById)
	{
		keepAliveImgElem = document.getElementById("keepAliveImg");
		if (keepAliveImgElem != null)
		{
			keepAliveTimer = window.setTimeout("keepAlive()", duration);
		}
	}
}

function keepAlive()
{
	if (keepAliveImgElem != null)
	{
		if (keepAliveTimer != null)
		{
			window.clearTimeout(keepAliveTimer);
			keepAliveTimer = null;
		}
		
		keepAliveImgElem.src = keepAliveUrl + "?dt=" + new Date().getTime();
		keepAliveTimer = window.setTimeout("keepAlive()", duration);
	}
}
