//setTimeout("window.location.reload(true)", 1000 * 60 * 10);
var undercon		= false;
var DisablePNGfix	= false; // Disable PNGfix ?

var userAgent		= navigator.userAgent.toLowerCase();
var is_ie			= (userAgent.indexOf("msie") > -1)?true:false;
var is_ie6			= (userAgent.indexOf("msie 6") > -1)?true:false;
var is_ie7			= (userAgent.indexOf("msie 7") > -1)?true:false;
var is_ie8			= (userAgent.indexOf("msie 8") > -1)?true:false;
var is_opera		= (userAgent.indexOf("opera") > -1)?true:false;
var is_firefox		= (userAgent.indexOf("firefox") > -1)?true:false;
var is_firefox2		= (userAgent.indexOf("firefox/2") > -1)?true:false;
var is_firefox3		= (userAgent.indexOf("firefox/3") > -1)?true:false;
var site			= null;
var secTop			= 0;
var siteLeft		= 0;
var siteTop			= 0;
var siteRight		= 0;
var siteBottom		= 0;
var siteWidth		= 0;
var siteHeight		= 0;
intGroup = rq("group");

var scrollerCount = 0;
var scrollerBoxCenter = null;
var scrollerBoxRight = null;
var defaultScrollbarHeight = -1;

var iMenu = null;

function setup_global()
{
	initialize();
}

function initialize()
{
	if(window.captureEvents){
		window.onmousemove=sourceCheck;
	} else {
		document.onmousemove=sourceCheck;
	}
	if (window.location.href.toLowerCase().indexOf("print.asp")  > -1 ) return;
	defaultScrollbarHeight = crf*355;

	site = g("divSite");
	reposition();
	setupContents();


	if (g("divUnderConstruction") && undercon == true)
	{
		g("divUnderConstruction").style.left = 0 + "px";
		g("divUnderConstruction").style.top  = 0 + "px";
	}

	//raiseElementOnMouseOver();

	if (g("divBgLight") && pagetype > 2)
	{
		g("divBgLight").style.display= "block";
		g("divBgLight").style.backgroundColor = "#D9D5C1";
		g("divBgLight").style.left   = siteLeft + "px";
		g("divBgLight").style.top    = siteTop + crf*65 + crf*60 - crf*18 + "px"; //rypos("tblFiveMenu"), g("tblFiveMenu").offsetHeight
		g("divBgLight").style.width  = siteWidth + "px";
		g("divBgLight").style.height = siteHeight - crf*60 - g("imgLogo").offsetHeight - 2 + "px"; // g("tblFiveMenu").offsetHeight
	}

	if (blnFirstRun == true)
	{
		if (TextInCenterExists == 1)
		{
			if (TextInCenterShow == 1)
			{
				//alert("now");
				showhideBoxCenterText(1);
			}
		}

		if (is_firefox)
		{
			if (g("tblBoxLeftProducts"))
			{
				g("tblBoxLeftProducts").style.marginLeft  = resValue(1,2,2) + "px";
				g("tblBoxLeftProducts").style.width = crf*resValue(193,194,194) + "px";

				g("tblBoxTypesOther").style.marginLeft  = 1 + "px";
				g("tblBoxTypesOther").style.width = crf*194 + "px";
			}

			if (intGroup != "")
			{
				try
				{
					intGroup = parseInt(intGroup);
				}
				catch (ex)
				{
					alert(ex);
					intGroup = 0;
				}
			}

			els = document.getElementsByTagName("div");
			for(i=0,len=els.length;i<len;i++)
			{
				// fix Inspiration-box
				if (els[i].className == "divFiveImagesTextInspiration")
				{
					if (jsres == 1)
					{
						el = els[i];
						el.style.position = "absolute";
						if (is_firefox2)
						{
							el.style.width = 242 + (intGroup>2?-1:0) + "px";
						} else {
							if (",1,3,5,".indexOf("," + intGroup + ",") > -1)
							{
								el.style.width = 241 + "px";
							} else {
								el.style.width = 242 + "px";
							}
						}
						el.style.left = 0 + "px";
						el.style.top = 48 + "px";


						break;
					}
				}
			}
		}

		if (is_ie)
		{
			obj = g("divFiveImagesTextInspiration");
			//alert("test");
			
			if (g("tblBoxLeftProducts"))
			{
				g("tblBoxLeftProducts").style.width = crf*193 + "px";
			}

			if (is_ie6)
			{
				if (g("tblBoxLeftProducts"))
				{
					if (jsres == 1)
					{
						g("tblBoxLeftProducts").style.width = parseInt(crf*(193+2)) + "px";
					}
					if (jsres == 0 || jsres == 2)
					{
						g("tblBoxLeftProducts").style.width = parseInt(crf*(193+1)) + "px";
					}
				}
				
				obj = g("divFiveImagesTextInspiration");
				if (obj)
				{

					if (jsres == 1)
					{
						var intExtra = 0;
						if (parseInt(rq("group")) > 2) intExtra = -1;
						obj.style.position = "absolute";
						obj.style.left = 0 + "px";
						obj.style.top  = 48 + "Px";
						obj.style.width = 242 + intExtra + "px";
						intExtra = 0;
					}
					if (jsres == 2)
					{

						var intExtra = 0;
						if (is_ie6) intExtra = -1;
						if (parseInt(rq("group")) > 2) intExtra = 1;
						obj.style.position = "relative";
						obj.style.width = 303 + intExtra + "px";
						intExtra = 0;
					}
				}

			}

			if ( (is_ie7 || is_ie8) && obj)
			{
				obj.style.position = "relative";
				obj.style.height = resValue(17,21,25) + "px";
				obj.style.lineHeight = obj.offsetHeight - 2 + "px";
				obj.style.top = resValue(1,6,7) + "px";
				obj.style.left = 0 + "px";
				obj.style.marginLeft = 0 + "px";
				obj.style.paddingLeft = 0 + "px";

				if (jsres == 1)
				{
					obj.style.position = "absolute";
					obj.style.top = 45 + "px";

					//obj.parentNode.parentNode.style.width = 50 + "px";
					//obj.style.width = obj.parentNode.offsetWidth + 1 + "px";
					var diff = 0;
					if (intGroup == 1 || intGroup == 3 || intGroup == 5)
					{
						diff = -1;
					}
					obj.style.width = 242 + diff + "px"; //
					//alert("intGroup: " + intGroup);
					//obj.parentNode.removeChild(obj);
				}

				/**/
				if (jsres == 2)
				{
					obj.style.position = "absolute";
					obj.style.top = 58 + "px";

					//obj.parentNode.parentNode.style.width = 50 + "px";
					//obj.style.width = obj.parentNode.offsetWidth + 1 + "px";
					obj.style.width = 302 + "px";
					//obj.parentNode.removeChild(obj);
				}
				/**/
				obj = null;
			} else {
				// ie 6 and older
				if (DisablePNGfix == false) addPngFix();
				
				/*
				els = document.getElementsByTagName("div");
				for(i=0,len=els.length;i<len;i++)
				{
					// fix Inspiration-box
					if (els[i].className == "divFiveImagesTextInspiration")
					{
						if (is_ie && jsres == 1)
						{
							el = els[i];
							el.style.position = "absolute";
							el.style.left = 0 + "px";
							el.style.top = 48 + "px";
							break;
						}
					}
				}
				*/
			}// end of is_ie7


			



		} // end of is_ie
	} // end of blnFirstRun


	/**
	els = document.getElementsByTagName("td");
	blnBypass = 1;
	for(i=0,len=els.length;i<len;i++)
	{
		if (blnBypass == 1) break;
		el = els[i];

		//el.style.border = "1px solid #ff0000";
		//el.onclick = function() { alert(this.id); }

		// td:
		el.onclick = function () {
				w = -1;
				if (jsres == 0)
				{
					w = this.offsetWidth;
				}
				if (jsres == 0)
				{
					w = parseInt(this.offsetWidth / 1.25);
				}
				if (jsres == 2)
				{
					w = parseInt(this.offsetWidth / 1.5625);
				}


				msg = "";
				msg += "type: " + this.tagName.toLowerCase() + "\n";
				msg += "width: " + w + "\n";
				msg += "id: " + el.id + "\n";

				alert(msg);				
		};
	}
	/**/

	if (g("divDebugResolution") && g("imgLogo"))
	{
		g("divDebugResolution").style.left = rxpos("imgLogo") + g("imgLogo").offsetWidth + crf*10 + "px";
		g("divDebugResolution").style.top  = rypos("imgLogo") + "px";
	}

	//if (arrPageImages.length == 0 && g("imgBoxCenter")) g("imgBoxCenter").style.display = "none";

	if (arrPageImages.length > 0 && g("imgBoxCenter") && TextInCenterShow == 0)
	{
		if (g("imgBoxCenterArrowLeft")) g("imgBoxCenterArrowLeft").style.visibility = "visible";
		if (g("imgBoxCenterArrowRight")) g("imgBoxCenterArrowRight").style.visibility = "visible";
	}
	
	if (intHideBoxTopMenu == 1 && g("divBoxTopMenu")) g("divBoxTopMenu").style.display = "none";

	positionLinkPopupThingy();

}

function reposition()
{	
	siteleft = ( pageWidth / 2)  - (site.offsetWidth / 2);
	sitetop  = ( pageHeight / 2) - (site.offsetHeight / 2) ; //- (boxbreadcrumb.offsetHeight / 2)
	site.style.left = ( (siteleft > 0)?siteleft:0 ) + "px";
	site.style.top = ( (sitetop > 0)?sitetop-2:0 ) + "px";

	siteLeft  = rxpos("divSite");
	siteRight = siteleft + g("divSite").offsetWidth;
	siteTop = rypos("divSite")
	siteBottom = sitetop + g("divSite").offsetHeight;

	if (blnFirstRun == true)
	{
		siteHeight = g("divSite").offsetHeight;
		siteWidth = g("divSite").offsetWidth;
	}
}

function addPngFix()
{
	if (navigator.userAgent.toLowerCase().indexOf("msie 7") > -1) return;
	pngimg = document.getElementsByTagName("img");
	for(var i = 0, len = pngimg.length; i < len; i++)
	{
		if (pngimg[i].src.toLowerCase().indexOf(".png") > -1)
		{
			pngimg[i].className += " overlay";
		}
	}
}

function setupContents()
{
	try
	{
		iMenu = parseInt(rq("menu"));
	}
	catch (ex)
	{
		iMenu = null;
	}
	

	g("divLogo").style.left = siteLeft + "px";
	g("divLogo").style.top  = siteTop - 2 + "px";

	secTop = rypos("divLogo") + g("imgLogo").offsetHeight + 1;
	if (pagetype == 2)
	{
		theTop = secTop + g("tblFiveMenu").offsetHeight;
	} else {
		theTop = secTop + crf*165;
	}

	g("divLogoAgon").style.left = rxpos("divSite") + g("divSite").offsetWidth - g("divLogoAgon").offsetWidth - crf*12 - 1 + "px";
	g("divLogoAgon").style.top  = rypos("divLogo") + g("imgLogo").offsetHeight - g("imgLogoAgon").offsetHeight + "px";

	//g("divSiteMenu").style.left = siteRight - g("divSiteMenu").offsetWidth + "px";
	g("divSiteMenu").style.left = siteLeft +  g("divSite").offsetWidth - g("divSiteMenu").offsetWidth + "px";
	g("divSiteMenu").style.top  = siteTop + "px";

	g("divTabReferencer").style.left = rxpos("divLogo") + g("imgLogo").offsetWidth + 1 + "px";
	g("divTabReferencer").style.top  = rypos("divLogo") + g("imgLogo").offsetHeight - g("divTabReferencer").offsetHeight + resValue(0,0,0) + "px";

	g("divTabProdukter").style.left  = rxpos("divTabReferencer") + g("divTabReferencer").offsetWidth + 1 + "px";
	g("divTabProdukter").style.top   = rypos("divTabReferencer") + "px";

	if (showMenuFive && g("tblFiveMenu"))
	{
		g("tblFiveMenu").style.left = siteLeft + "px";
		g("tblFiveMenu").style.top  = secTop + "px";
	}

	createLine(
		rxpos("divLogo") + g("imgLogo").offsetWidth + g("divTabReferencer").offsetWidth + g("divTabProdukter").offsetWidth + 3,
		rypos("divLogo") + g("imgLogo").offsetHeight - resValue(10,12 + ((ns6)?1:0),15 + ((ns6)?1:0) ),
		rxpos("divLogoAgon") - (rxpos("divLogo") + g("imgLogo").offsetWidth + g("divTabReferencer").offsetWidth + g("divTabProdukter").offsetWidth) - 1 - 3,
		crf*10,
		"#766b67",
		1,
		"line_brown_wide"
	);

	createLine(
		rxpos("divLogoAgon") + g("imgLogoAgon").offsetWidth + 1,
		rypos("divLogoAgon") + g("imgLogoAgon").offsetHeight - resValue(10,12 + ((ns6)?1:0),15 + ((ns6)?1:0)),
		crf*12,
		crf*10,
		"#766b67",
		1,
		"line_brown_narrow"
	);

	if (pagetype == 1 || pagetype == 2) // NOTE: collapsed!
	{
		if (g("divBottomText")) g("divBottomText").style.display = "block";

		if (g("divImageArea"))
		{
			g("divImageArea").style.left = siteLeft + "px";
			g("divImageArea").style.top  = secTop + "px";
			g("divImageArea").style.overflow = "hidden";
		}

		if (pagetype == 2 && g("tblFiveImages"))
		{
			g("tblFiveImages").style.left = siteLeft + "px";
			g("tblFiveImages").style.top  = rypos("divImageArea") + g("divImageArea").offsetHeight - g("tblFiveImages").offsetHeight + "px";
		}

		createLine(
			siteLeft,
			rypos("divImageArea") + g("divImageArea").offsetHeight + 1,
			siteWidth,
			crf*18,
			"#000000",
			1,
			"line_news_black"
		);

		createLine(
			siteLeft,
			rypos("line_news_black") + g("line_news_black").offsetHeight,
			siteWidth,
			crf*247,
			"#d9d5c1",
			1,
			"line_news_background"
		);

		if (g("tblNewsLine") && g("line_news_black"))
		{
			g("tblNewsLine").style.left = siteLeft + "px";
			g("tblNewsLine").style.top  = rypos("line_news_black") + "px";
		}

		if (g("divNewsLeft") && g("line_news_background"))
		{
			g("divNewsLeft").style.left  = siteLeft + crf*20 + "px";
			g("divNewsLeft").style.top   = centerVert("divNewsLeft", "line_news_background") + "px";
		}

		if (g("divNewsLeftText") && g("divNewsRightText"))
		{
			g("divNewsRight").style.left = rxpos("divNewsLeft") + g("divNewsLeft").offsetWidth + (rxpos("divNewsLeft") - siteLeft) + "px";;
			g("divNewsRight").style.top  = centerVert("divNewsRight", "line_news_background") + "px";
		}
		
		if (g("divNewsLeftText") && g("divNewsRightText"))
		{
			g("divNewsLeftText").style.marginTop = crf*10 + "px";
			g("divNewsRightText").style.marginTop = crf*10 + "px";
		}

		if (g("divBottomText"))
		{
			g("divBottomText").style.left  = siteLeft + "px";
			g("divBottomText").style.top   = siteBottom - g("divBottomText").offsetHeight + "px";
			g("divBottomText").style.width = siteWidth + "px";
			g("divBottomText").style.textIndent = crf*15 + "px";
			g("divBottomText").style.lineHeight = resValue(20,25,32) + "px";
		}


		if (g("imgNewsLeft"))
		{
			g("divNewsLeft").style.margin = 0;
			if (is_ie6)
			{
				g("imgNewsLeft").style.position = "absolute";
				g("imgNewsLeft").style.left = 0 + "px";
				g("imgNewsLeft").style.top  = 0 + "px";
			}
			g("imgNewsLeft").style.marginLeft = -1 + "px";
			g("imgNewsLeft").style.marginTop  = -1 + "px";
			g("imgNewsLeft").style.height = g("divNewsLeft").offsetHeight - 2 + "px";
		}
		
		if (g("imgNewsRight"))
		{
			g("divNewsRight").style.margin = 0;
			if (is_ie6)
			{
				g("imgNewsRight").style.position = "absolute";
				g("imgNewsRight").style.left = 0 + "px";
				g("imgNewsRight").style.top  = 0 + "px";
			}
			g("imgNewsRight").style.marginLeft = -1 + "px";
			g("imgNewsRight").style.marginTop  = -1 + "px";
			g("imgNewsRight").style.height = g("divNewsRight").offsetHeight - 2 + "px";

		}

		obj = getElementsWithClassName("divFiveImagesTextInspiration");
		if (obj.length == 1)
		{
			obj = obj[0];
			obj.style.width = resValue(193,241,302);
		}
	
	}


	// -------------- type 3
	if (pagetype == 3 || pagetype == 4)
	{
		if (pagetype > 2)
		{
			extra = 0;
			if (is_firefox && jsres == 1)
			{
				extra = 1;
			}
			if (is_ie)
			{
				if (jsres > 0)
				{
					extra = 1;
				}
			}

			createLine(
				siteLeft + crf*193 + extra,
				secTop,
				1,
				crf*512,
				"#ffffff",
				1,
				"line_vertical_left_type_higher_than_2"
			);			
		}



		// ----------------------------------- Referencer
		if (rq("category") == 1 || rq("category") == 2 || pagetype == 4)
		{

			//if ( arrPageImages.length > 0 )
			//{
				if (blnFirstRun)
				{

					if (g("spanImageCounterCurrent"))
					{
						intCurrImg++;
						g("spanImageCounterCurrent").childNodes[0].nodeValue = intCurrImg + 1;
					}
					if (g("spanImageCounterTotal"))
					{
						g("spanImageCounterTotal").childNodes[0].nodeValue = arrPageImages.length;
					}

					/* // 16-12-2008
					if ( g("imgBoxCenter").src.indexOf("img/x.gif") != -1 )
					{
						//nextImage(); // 16-12-2008
					}
					*/ // 16-12-2008
					
					//nextImage(); // 16-12-2008
				}
//				g("imgBoxCenter").style.backgroundColor = "#FFFFFF";
				g("imgBoxCenter").style.display = "block";
				g("imgBoxCenter").style.width = parseInt( crf*(621+1)   + ((is_ie6 && jsres == 1)?-1:0)       ) + "px";
				g("imgBoxCenter").style.height = parseInt( crf*422 ) + "px";
				g("imgBoxCenter").style.left = siteLeft + crf*194 + ((is_ie6 && jsres == 1)?1:0) + "px";
				g("imgBoxCenter").style.top = (siteTop + siteHeight - 3) - g("imgBoxCenter").offsetHeight + "px";
				g("imgBoxCenter").style.borderTop = "1px solid #ffffff";

				g("divBoxItemTopMenuPrint").style.left = rxpos("imgBoxCenter") + g("imgBoxCenter").offsetWidth - g("divBoxItemTopMenuPrint").offsetWidth + resValue(0,0,0) + "px";
				g("divBoxItemTopMenuPrint").style.top  = rypos("imgBoxCenter") - g("divBoxItemTopMenuPrint").offsetHeight + 1 + "px";
				g("divBoxItemTopMenuPrint").style.zIndex = 999;

				g("divImageCounter").style.left = right("imgBoxCenter")  - g("divImageCounter").offsetWidth  - crf*10 + "px";
				g("divImageCounter").style.top  = bottom("imgBoxCenter") - g("divImageCounter").offsetHeight - crf*10 + "px";
				
				if (arrPageImages.length > 1)
				{
					g("imgBoxCenterArrowLeft").style.left = left("imgBoxCenter") + "px";
					g("imgBoxCenterArrowLeft").style.top  = centerVert("imgBoxCenterArrowLeft", "imgBoxCenter") + "px";
					g("imgBoxCenterArrowRight").style.left = right("imgBoxCenter") - g("imgBoxCenterArrowRight").offsetWidth + "px";
					g("imgBoxCenterArrowRight").style.top  = centerVert("imgBoxCenterArrowRight", "imgBoxCenter") + "px";
				}

				g("divBoxTopMenu").style.display = "block";
				g("divBoxTopMenu").style.left    = rxpos("imgBoxCenter") + "px";

				g("divBoxTopMenu").style.top     =  rypos("imgBoxCenter") - g("divBoxTopMenu").offsetHeight + "px";
//				g("divBoxTopMenu").style.top     =  theTop + 1 + "px";

				g("divBoxTopMenu").style.height  = rypos("imgBoxCenter") - 1 + "px";

				if ( g("tblBoxTopMenu1") && g("divBoxItemTopMenuPrint") )
				{
					intTabMenuCounter = 1;
					g("tblBoxTopMenu" + intTabMenuCounter).style.left   = rxpos("divBoxItemTopMenuPrint") - 0*g("divBoxItemTopMenuPrint").offsetWidth - g("tblBoxTopMenu" + intTabMenuCounter).offsetWidth + "px";
//					g("tblBoxTopMenu" + intTabMenuCounter).style.top    = rypos("divBoxTopMenu") - g("tblBoxTopMenu" + intTabMenuCounter).offsetHeight + resValue(1,1,1) + ie7Top + "px";
					g("tblBoxTopMenu" + intTabMenuCounter).style.top    = rypos("divBoxItemTopMenuPrint") + resValue(0,0,0) + "px";
					g("tblBoxTopMenu" + intTabMenuCounter).style.zIndex = 10 - intTabMenuCounter;
					if (intHideBoxTopMenu == 1) g("tblBoxTopMenu" + intTabMenuCounter).style.display = "none";
					while ( g("tblBoxTopMenu" + ++intTabMenuCounter) != null )
					{
						g("tblBoxTopMenu" + intTabMenuCounter).style.left   = rxpos("tblBoxTopMenu" + (intTabMenuCounter-1) ) - g("tblBoxTopMenu" + intTabMenuCounter).offsetWidth + crf*resValue(9,10,10) + "px";
						g("tblBoxTopMenu" + intTabMenuCounter).style.top    = rypos("tblBoxTopMenu" + (intTabMenuCounter-1)) + "px";
						g("tblBoxTopMenu" + intTabMenuCounter).style.zIndex = 10 - intTabMenuCounter;
						if (intHideBoxTopMenu == 1) g("tblBoxTopMenu" + intTabMenuCounter).style.display = "none";
					}


				}
				if (intHideBoxTopMenu == 1) g("divBoxTopMenu").style.display = "none";

			//}

			
			intBoxWidth = crf*195;
			g("divBoxLeft").style.display = "block";
			if (intBoxLeftShowMenu == 1)
			{
				g("divBoxLeft").style.width   = crf*194 + "px";
				g("divBoxLeft").style.top     = secTop + crf*60 + "px";
			} else {
				g("divBoxLeft").style.width   = crf*174 + "px";
				g("divBoxLeft").style.top     = 0*theTop+1 + crf*35 + rypos("imgBoxCenter") + "px";
			}
			g("divBoxLeft").style.left    = siteLeft + ( intBoxWidth / 2 -  g("divBoxLeft").offsetWidth / 2) + (is_firefox?crf*-2:0) + "px";
//			g("divBoxLeft").style.height  = crf*(451-8) - rypos("divBoxLeft") + theTop + "px";
			g("divBoxLeft").style.height  = g("imgBoxCenter").offsetHeight - crf*20 - crf*35 + "px";

			

			if (intBoxRightShow == 1)
			{
				g("divBoxRight").style.display = "block";
				g("divBoxRight").style.width   = crf*141 + "px";
				//g("divBoxRight").style.left    = siteRight - g("divBoxRight").offsetWidth  + "px";
				g("divBoxRight").style.left    = siteLeft + crf*825   + "px";
				g("divBoxRight").style.top     = rypos("imgBoxCenter") + crf*36 + "px";
				//g("divBoxRight").style.height  = crf*451 - rypos("divBoxRight") + theTop + "px";
				g("divBoxRight").style.height  = crf*388 + "px";


				if (intShowNews == 1)
				{
					g("divBoxRight").style.width   = crf*125 + "px";
					//g("divBoxRight").style.backgroundColor = "#ff0000";
					g("divBoxRight").style.overflow = "auto";
				}
			}
			//g("divBoxRight").style.display = "none";

			if (ScrollbarRightShow == 1 && intBoxRightShow == 1 && g("divBoxRight"))
			{

				if (g("divBoxRightDocument").offsetHeight > g("divBoxRight").offsetHeight)
				{

					g("divScrollbarBoxRight").style.display         = "block";
					g("divScrollSliderBoxRight").style.display      = "block";
					g("imgArrowScrolbarBoxRightUp").style.display   = "block";
					g("imgArrowScrolbarBoxRightDown").style.display = "block";

					g("divScrollbarBoxRight").style.left   = right("divBoxRight") - crf*12 + "px";
					g("divScrollbarBoxRight").style.top    = rypos("divBoxRight") + crf*11 + "px";

					if (intShowNews == 1)
					{
						g("divScrollbarBoxRight").style.left   = right("divBoxRight") + crf*8 + "px";
						g("divBoxRight").style.overflow = "";
						g("divBoxRightTextMaster").style.height = defaultScrollbarHeight + crf*20 + "px";
					}


					g("divScrollbarBoxRight").style.height = defaultScrollbarHeight + "px";
	//				g("divScrollbarBoxRight").style.height = g("divBoxRight").offsetHeight - (rypos("divScrollbarBoxRight") - rypos("divBoxRight")) - crf*20 + "px";
					//alert( g("divScrollbarBoxRight").offsetHeight - rypos("divScrollbarBoxRight"));
					iLeft = 1;
					iLeft = is_ie7?1:iLeft;
					iLeft = is_opera?1:iLeft;
					iLeft = is_firefox?0:iLeft;
					g("imgArrowScrolbarBoxRightUp").style.left = rxpos("divScrollbarBoxRight") - g("imgArrowScrolbarBoxRightUp").offsetWidth /2 + iLeft + "px";
					g("imgArrowScrolbarBoxRightUp").style.top  = rypos("divScrollbarBoxRight") - crf*11 + "px";

					g("imgArrowScrolbarBoxRightDown").style.left = rxpos("imgArrowScrolbarBoxRightUp") + "px";
					g("imgArrowScrolbarBoxRightDown").style.top  = bottom("divScrollbarBoxRight") + "px";

					/**/
					if (scrollerBoxRight == null)
					{
						scrollerBoxRight = new textScroller(scrollerCount++);
					}


					scrollerBoxRight = new textScroller(scrollerCount++);
					scrollerBoxRight.masterobj = 'divBoxRight';
					scrollerBoxRight.scrollerobj = 'divBoxRightDocument';
					scrollerBoxRight.scrollbar = 'divScrollbarBoxRight';
					scrollerBoxRight.arrowobj = 'divScrollSliderBoxRight'; //fake shit
					scrollerBoxRight.scrollslider = 'divScrollSliderBoxRight';
					scrollerBoxRight.prepare();

					/**/
				}
			}

			if (TextInCenterExists == 1)
			{
				if (TextInCenterShow == 0)
				{

					g("imgBoxCenterArrowLeft").style.visibility = "hidden";
					g("imgBoxCenterArrowRight").style.visibility = "hidden";
					//g("imgBoxCenterArrowLeft").style.display = "none";
					//g("imgBoxCenterArrowRight").style.display = "none";

					//g("divImageCounter").style.display = "none";
					g("divImageCounter").style.visibility = "hidden";
				} else {
					g("divBoxCenterTextMaster").style.visibility = "visible";
					g("divBoxCenterTextDocument").style.visibility = "visible";
				}
				
				g("divBoxCenterText").style.backgroundColor = "#ffffff";
				g("divBoxCenterText").style.display = "block"; // not it
				if (iMenu == 2 || iMenu == 3 || iMenu == 4 || iMenu == 5)
				{
					g("divBoxCenterText").style.left = rxpos("imgBoxCenter") + "px";
					g("divBoxCenterText").style.width = g("imgBoxCenter").offsetWidth + "px";
					g("divBoxCenterText").style.filter = "alpha(opacity=100);";
					g("divBoxCenterText").style.MozOpacity  = 1;

					g("divBoxCenterTextMaster").style.width = crf*575 + "px";
					g("divBoxCenterTextMaster").style.height = crf*370 + "px";
					g("divBoxCenterTextDocument").style.width = 100 + "%";
				} else {
					g("divBoxCenterText").style.left = siteLeft + crf*390 + ((ns6)?resValue(0,-1,0):0) + (is_firefox3?resValue(0,1,0):0) + "px";
					g("divBoxCenterText").style.width = crf*426 + "px";
				}


				extra = 0;
				if (is_firefox && jsres == 1)
				{
					extra = 1;
				}

				g("divBoxCenterText").style.height = crf*422 + "px";
				g("divBoxCenterText").style.top = (siteTop + siteHeight - 3) - g("divBoxCenterText").offsetHeight + extra + "px";
				g("divBoxCenterText").style.borderTop = "1px solid #ffffff";
				
				if ( (iMenu == 1 || iMenu == 3 || pagetype == 4) && TextInCenterExists == 1 && blnFirstRun == true && arrPageImages.length > 0)
				{
					g("divTextShowHideBoxCenterText").style.display = "block";
				}

				if (iMenu == 3)
				{
					
				}

				g("divTextShowHideBoxCenterText").style.left = right("imgBoxCenter") - g("divTextShowHideBoxCenterText").offsetWidth + "px";
				g("divTextShowHideBoxCenterText").style.top = rypos("imgBoxCenter") + "px";
				//showhideBoxCenterText();
				
				iLeft = 0;
				iLeft = is_ie7?1:iLeft;
				iLeft = is_opera?1:iLeft;
				iLeft = is_firefox?0:iLeft;

				createScrollbar(
					"main",
					"divBoxCenterTextMaster",
					"divBoxCenterTextDocument",
					right("imgBoxCenter") - crf*20 - g("imgArrowScrolbarBoxCenterUp").offsetWidth /2 + iLeft,
					rypos("imgBoxCenter") + crf*36,
					99999
				);

				g("imgArrowScrolbarmainUp").style.visibility = g("imgArrowScrolbarmainDown").style.visibility = g("divScrollSlidermain").style.visibility =  g("divScrollbarmain").style.visibility = (ToggleTextInCenterShow == 1)?"visible":"hidden";
			


				/**
				if (g("divBoxCenterText") && g("divScrollbarBoxCenter") && g("divScrollSliderBoxCenter"))
				{

					if (g("divBoxCenterTextDocument").offsetHeight > g("divBoxCenterTextMaster").offsetHeight)
					{

						g("divScrollSliderBoxCenter").style.left = rxpos("divScrollbarBoxCenter") - g("divScrollSliderBoxRight").offsetWidth/2 + "px";				

						iLeft = 0;
						iLeft = is_ie7?1:iLeft;
						iLeft = is_opera?1:iLeft;
						iLeft = is_firefox?0:iLeft;

						g("imgArrowScrolbarBoxCenterUp").style.left = right("imgBoxCenter") - crf*20 - g("imgArrowScrolbarBoxCenterUp").offsetWidth /2 + iLeft + "px";
						g("imgArrowScrolbarBoxCenterUp").style.top  = rypos("imgBoxCenter") + crf*36 + "px";
						
						//g("imgArrowScrolbarBoxCenterUp").style.left = rxpos("divScrollbarBoxCenter") - g("imgArrowScrolbarBoxCenterUp").offsetWidth /2 + iLeft + "px";
						//g("imgArrowScrolbarBoxCenterUp").style.top  = rypos("divScrollbarBoxCenter") - crf*11 + "px";

						g("imgArrowScrolbarBoxCenterDown").style.left = rxpos("imgArrowScrolbarBoxCenterUp") + "px";
						g("imgArrowScrolbarBoxCenterDown").style.top  = rypos("imgArrowScrolbarBoxCenterUp") + defaultScrollbarHeight + crf*15 + "px";

						//g("imgArrowScrolbarBoxCenterDown").style.left = rxpos("imgArrowScrolbarBoxCenterUp") + "px";
						//g("imgArrowScrolbarBoxCenterDown").style.top  = bottom("imgBoxCenter") - crf*15 + "px";

						g("imgArrowScrolbarBoxRightDown").style.top   = rypos("imgArrowScrolbarBoxCenterDown") + "px";

						g("divScrollbarBoxCenter").style.left   = rxpos("imgArrowScrolbarBoxCenterUp") + g("imgArrowScrolbarBoxCenterUp").offsetWidth/2 - g("divScrollbarBoxCenter").offsetWidth/2 + "px";

						g("divScrollbarBoxCenter").style.top    = rypos("imgBoxCenter") + crf*47 + "px";
						g("divScrollbarBoxCenter").style.height = defaultScrollbarHeight + "px";

						if (scrollerBoxCenter == null)
						{
							scrollerBoxCenter = new textScroller(scrollerCount++);
						}
						scrollerBoxCenter.masterobj = 'divBoxCenterTextMaster';
						scrollerBoxCenter.scrollerobj = 'divBoxCenterTextDocument';
						scrollerBoxCenter.scrollbar = 'divScrollbarBoxCenter';
						scrollerBoxCenter.arrowobj = 'divScrollSliderBoxCenter'; //fake shit
						scrollerBoxCenter.scrollslider = 'divScrollSliderBoxCenter';
						scrollerBoxCenter.prepare();

						if (!blnFirstRun)
						{
							g("divScrollSliderBoxCenter").style.top = rypos("divScrollbarBoxCenter") + intPosY_scrollbarCenterSlider + "px";
							g("divScrollSliderBoxRight").style.top  = rypos("divScrollbarBoxRight")  + intPosY_scrollbarRightSlider  + "px";
						}
					}
				}
				/**/

			}

			if (g("divBoxItemTopMenuPrint"))
			{
				maxIndex = 10;

				if (rq("categor") == 1 || rq("category") == 2)
				{

					if (rq("category") == 1)
					{
						// ref

					} else {
						// pro
						//g("divTabReferencer").style.backgroundColor = "#ff00ff";
					}					

					if (g("tblTabDescription"))
					{
						g("tblTabDescription").style.left = rxpos("divBoxItemTopMenuPrint") - g("tblTabDescription").offsetWidth + "px";
						g("tblTabDescription").style.top  = rypos("divBoxItemTopMenuPrint") + "px";
						g("tblTabDescription").style.zIndex = maxIndex--;
					}

					if (g("tblTabDescription") && g("tblTabDownloadCatalogs"))
					{
						g("tblTabDownloadCatalogs").style.left = rxpos("tblTabDescription") - g("tblTabDownloadCatalogs").offsetWidth + crf*resValue(9,10,10) + "px";
						g("tblTabDownloadCatalogs").style.top  = rypos("divBoxItemTopMenuPrint") + "px";
						g("tblTabDownloadCatalogs").style.zIndex = maxIndex--;
					}

					if (g("tblTabDownloadCatalogs") && g("tblData"))
					{
						g("tblData").style.left = rxpos("tblTabDownloadCatalogs") - g("tblData").offsetWidth + crf*resValue(9,10,10) + "px";
						g("tblData").style.top  = rypos("divBoxItemTopMenuPrint") + "px";
						g("tblData").style.zIndex = maxIndex--;
					}

					if (g("tblData") && g("tblShowPhoto"))
					{
						g("tblShowPhoto").style.left = rxpos("tblData") - g("tblShowPhoto").offsetWidth + crf*resValue(9,10,10) + "px";
						g("tblShowPhoto").style.top  = rypos("divBoxItemTopMenuPrint") + "px";
						g("tblShowPhoto").style.zIndex = maxIndex--;
					}

					if (g("tblShowPhoto") && g("tblGreening"))
					{
						g("tblGreening").style.left = rxpos("tblShowPhoto") - g("tblGreening").offsetWidth + crf*resValue(9,10,10) + "px";
						g("tblGreening").style.top  = rypos("divBoxItemTopMenuPrint") + "px";
						g("tblGreening").style.zIndex = maxIndex--;
					}

					objs = new Array("tblTabDescription","tblTabDownloadCatalogs","tblData","tblShowPhoto","tblGreening");
					if ( g(objs[iMenu-1]) )
					{
						img = null;
						td  = null;

						img = getObjectFromMenu(g(objs[iMenu-1]),0);
						td  = getObjectFromMenu(g(objs[iMenu-1]),1);

						if (img != null && td != null)
						{

							if (img) img.src = img.src.replace("sand","red");
							if (td)
							{
								td.style.background = "url('img/tab_menu_bg_red_" + jsres + ".png')";
								td.childNodes[0].style.color = "#ffffff"
							}
						}
					}
				}



				// ----------------------------------- Produkter
				if (rq("category") == 2)
				{
					// produkter
					if (pagetype == 3)
					{
						if (iMenu == 2)
						{
							if (is_ie)
							{
								if ( g("tblRelevantProduct") ) g("tblRelevantProduct").style.top = crf*3 + "px";
								if ( g("tblRelevantGroup") )   g("tblRelevantGroup").style.top   = crf*3 + "px";
							}
						}
					}
				}


				// tblAnvendteProdukter

			}
		}

	}

	if (pagetype == 3 && rq("thankyou") == "1")
	{
		g("divBoxCenterText").style.display = "block";
		g("divBoxCenterText").style.backgroundColor = "#ffffff";
		g("divBoxCenterText").style.left = rxpos("divSite") + crf*193 + (is_ie?1:0) + "px";
		g("divBoxCenterText").style.top  = rypos("divSite") + crf*106 + (is_ie?1:0) + "px";
		g("divBoxCenterText").style.width = crf*621 + "px";
		g("divBoxCenterText").style.height = crf*452 + "px";
		g("divBoxCenterText").style.filter = "alpha(opacity=100);";
		g("divBoxCenterText").style.MozOpacity  = 1;
	}

	if (g("tbxMeter"))
	{
		g("tbxMeter").focus();
	}

	if (g("divLoading")) g("divLoading").style.display = "none";

} // end function setupContents

function getObjectFromMenu(obj,num)
{
//	return;

	if (document.getElementById&&!document.all)
	{
		// opera, ns6 (even in opera)
		
		if (num == 0)
		{
			// img
			if (is_opera)
			{
				return obj.childNodes[0].childNodes[0].childNodes[0].childNodes[0];
			} else {
				return obj.childNodes[1].childNodes[0].childNodes[1].childNodes[0];
			}
		} else if (num == 1)
		{
			// td
			if (is_opera)
			{
				return obj.childNodes[0].childNodes[0].childNodes[1];
			} else {
				return obj.childNodes[1].childNodes[0].childNodes[3];
			}
		}
	} else {
		// ie 7

		if (num == 0)
		{
			// img
			 return obj.childNodes[0].childNodes[0].childNodes[0].childNodes[0];
		} else if (num == 1)
		{
			// td
			return obj.childNodes[0].childNodes[0].childNodes[1];
		}
	}
}

function showhideBoxCenterText(doshow)
{

	if (doshow == 1)
	{
		//g("divBoxCenterText").style.display = "block";
		g("divBoxCenterText").style.visibility = "visible";
		g("divBoxCenterTextMaster").style.visibility = "visible";
		g("divBoxCenterTextDocument").style.visibility = "visible";

		g("imgBoxCenterArrowLeft").style.visibility = "hidden";
		g("imgBoxCenterArrowRight").style.visibility = "hidden";

//		g("imgBoxCenterArrowLeft").style.display = "none";
//		g("imgBoxCenterArrowRight").style.display = "none";

		//g("divImageCounter").style.display = "none";
		g("divImageCounter").style.visibility = "hidden";
/*
		g("divScrollbarBoxCenter").style.display = "block";
		g("divScrollSliderBoxCenter").style.display = "block";
		g("imgArrowScrolbarBoxCenterUp").style.display = "block";
		g("imgArrowScrolbarBoxCenterDown").style.display = "block";
*/

		if (g("divBoxCenterText").style.visibility == "visible" && g("imgArrowScrolbarmainUp") && g("imgArrowScrolbarmainDown") && g("divScrollSlidermain") && g("divScrollbarmain"))
		{
			g("imgArrowScrolbarmainUp").style.visibility = "visible";
			g("imgArrowScrolbarmainDown").style.visibility = "visible";
			g("divScrollSlidermain").style.visibility = "visible";
			g("divScrollbarmain").style.visibility = "visible";
		}

		g("imgTextShowHideBoxCenterText").src = "img/icon_arrow_right_boxcenter_" + jsres + ".jpg";
		ToggleTextInCenterShow = 1;
	} else {
		// toggle show/hide text center button/image
		g("imgTextShowHideBoxCenterText").src = "img/icon_arrow_left_boxcenter_" + jsres + ".jpg";

		// text center related: textbox
		//g("divBoxCenterText").style.display = "none";
		g("divBoxCenterText").style.visibility = "hidden";
		g("divBoxCenterTextMaster").style.visibility = "hidden";
		g("divBoxCenterTextDocument").style.visibility = "hidden";

		// img center related: arrows left and right, image counter
		g("imgBoxCenterArrowLeft").style.visibility = "visible";
		g("imgBoxCenterArrowRight").style.visibility = "visible";

//		g("imgBoxCenterArrowLeft").style.display = "block";
//		g("imgBoxCenterArrowRight").style.display = "block";

		//g("divImageCounter").style.display = "block";
		g("divImageCounter").style.visibility = "visible";

		// scrollbar elements for box center
		/*
		g("divScrollbarBoxCenter").style.display = "none";
		g("divScrollSliderBoxCenter").style.display = "none";
		g("imgArrowScrolbarBoxCenterUp").style.display = "none";
		g("imgArrowScrolbarBoxCenterDown").style.display = "none";
		*/

		g("imgArrowScrolbarmainUp").style.visibility = "hidden";
		g("imgArrowScrolbarmainDown").style.visibility = "hidden";
		g("divScrollSlidermain").style.visibility = "hidden";
		g("divScrollbarmain").style.visibility = "hidden";
		ToggleTextInCenterShow = 0;
	}
}

function raiseElementOnMouseOver()
{
	els = document.getElementsByTagName("*");
	for(i = 0, len = els.length; i < len; i++)
	{
		el = els[i];
		z = el.style.zIndex;
		el.onmouseout  = function() { this.style.zIndex = z; }
		el.onmouseover = function() { this.style.zIndex = 9999; }
	}
}

function changeRes(r)
{
	q = "" + window.location.search;
	if (q.indexOf("docalc=yes") == -1 && q.indexOf("res=") == -1)
	{
		window.location.href += "&docalc=yes&res=" + r;
	} else {
		if (q.indexOf("docalc=yes") == -1)
		{
			window.location.href += "&docalc=yes";
		} else if (q.indexOf("res=") == -1) {
			window.location.href += "&res=" + r;
		} else {
			// http://localhost/inoxline/index.asp?page=0&vpath=0|&type=3&category=1&group=1&menu=1&project=1&docalc=yes&res=1024&inspiration=1
			first = q.substring(0,q.indexOf("res=") + 4);
			last = q.substring(first.length);
			if (last.indexOf("&") == -1)
			{
				last = ""
			} else {
				last = last.substring(last.indexOf("&"));
			}
			window.location.href = first + r + last;
		}
	}
}

function basketCalculateCurrentPrice(AddToBasket,lang)
{
	//alert("this is basketCalculateCurrentPrice");

	blnOK = false;
	arrError = {
		"dkGenerel":"Der opstod en fejl under beregningen.",
		"ukGenerel":"An error occured while calculating price.",
		"dkNAN": "De indtastede værdier skal være tal.",
		"ukNAN": "Use numbers only."
	};


	/**
	if ( g("spanBasketCurrentProductCalculatedPrice") && g("tbxMeter") && g("tbxQuantity") )
	{
		if (g("tbxMeter").text != "" && g("tbxQuantity").text != "")
		{
			/**/
			try
			{
				tM = parseFloat(g("tbxMeter").value);
				tQ = parseFloat(g("tbxQuantity").value);
				res = tM * tQ;
				if ("" + res == "NaN")
				{
					throw '\n\n' + arrError[lang + 'NAN']; //"\n\nDe indtastede værdier skal være tal.";
				} else {
					//g("spanBasketCurrentProductCalculatedPrice").childNodes[0].nodeValue = tM * tQ;
					//g("basket_price").value = "" + tM * tQ;
					blnOK = true;
				}
			}
			catch (ex)
			{
				alert(arrError[lang + 'Generel'] + ex);
				//return false;
			}
			/**
		}
	}
	/**/

	if (blnOK == true && AddToBasket == true)
	{
		//alert("return true");
		return true;
	} else {
		//alert("return false");
		return false;
	}
}

function confimDeleteItemFromBasket(lang, itemNumber, itemText)
{
	var arrText = {
		"dk": "Er du sikker på at du vil slette nedenstående vare fra kurven?",
		"uk": "Are you sure you want to delete the following item from the basket?"
	}
	return window.confirm(arrText[lang] + "\n\n\n" + itemNumber + " - " + itemText + "\n\n ");
}

function getCalcutePrice(pS, pM, pE, nM)
{
	return (   ( pS + pM )  +  ( (nM-1) * pM )  +  pE   );
}

function basketValidateFields(f)
{
	if (
			2 == 3
			|| f.customer_name.value == ""
			|| f.customer_address.value == ""
			|| f.customer_zipcode.value == ""
			|| f.customer_city.value == ""
			|| f.customer_phone.value == ""
			|| f.customer_email.value == ""
	   )
	{
		alert("Du skal udfylde felterne der er markeret med *.");
		return false;
	}
	return true;
}

function doPrint()
{
//	if (g("ifrmPrint") == null) return;

	if ( g("imgBoxCenter") && g("divBoxCenterTextDocument")  && g("frmPrint") ) // && g("printtitle") && g("printcontents")
	{
		/*
		html_img = "";
		html_txt = "";

		if (g("imgBoxCenter")) html_img = '<img src="' + g("imgBoxCenter").src + '"><br><br>'
		html_txt = g("divBoxCenterTextDocument").innerHTML;
		output = html_img + html_txt;

		g("printtitle").text = document.title;
		g("printcontents").value = output;
		*/
		g("frmPrint").submit();
	} else {
		//alert("False");
	}
}



function positionLinkPopupThingy()
{
	if (g("lnkOpenPopup"))
	{
		g("lnkOpenPopup").style.left = 0 + "px";
		g("lnkOpenPopup").style.top  = 0 + "px";
	}
}

function popupthingy()
{
	if (g("ifrmPrint") == null) return;

	html_img = "";
	html_txt = "";

	if (g("imgBoxCenter")) html_img = '<img src="' + g("imgBoxCenter").src + '"><br><br>'
	html_txt = g("divBoxCenterTextDocument").innerHTML;
	output = html_img + html_txt;

	g("printtitle").text = document.title;
	g("printcontents").value = output;
	if (window.confirm( "PRINT?:\n\n" + g("printcontents").value) ) g("frmPrint").submit();
	

}

/*
	g("ifrmPrint").style.position = "absolute";
	g("ifrmPrint").style.left = 200 + "px";
	g("ifrmPrint").style.top  = 200 + "px";
	g("ifrmPrint").style.width = 200 + "px";
	g("ifrmPrint").style.height = 200 + "px";
	g("ifrmPrint").style.border = "2px solid #ff0000";
	g("ifrmPrint").style.zIndex = 99999;
	g("ifrmPrint").style.display = "block";

	//g("ifrmPrint").document.body.innerHTML = "hello world";
	//alert(
	*/