﻿
// PH: Jeg formoder at denne er lavet af frygt for session timeout
// uheldigvis betyder det også at den sender en ny kvitering hver 10 min.
//setTimeout("window.location.reload(true)", 1000 * 60 * 10);


function showConditions(){
	
	//alert("ok");
	g("divOverlay").style.visibility = "visible";
	g("divZipcode").style.display = "block";
	}

function hideConditions(){
	
	//alert("ok");
	g("divOverlay").style.visibility = "hidden";
	g("divZipcode").style.display = "none";
	}


/****************Vedr. cookie****************/

function setFormValues(paymentform){
	//alert("form");

	document.frmPayment.tbxCompanyName.value = getCookie('tbxCompanyName');
	document.frmPayment.tbxCustomerName.value = getCookie('tbxCustomerName');
	document.frmPayment.tbxCustomerAddress.value = getCookie('tbxCustomerAddress');
	//document.frmPayment.tbxCustomerZipCode.value = getCookie('tbxCustomerZipCode');
	document.frmPayment.tbxCustomerCity.value = getCookie('tbxCustomerCity');
	document.frmPayment.tbxCustomerPhone.value = getCookie('tbxCustomerPhone');
	document.frmPayment.tbxCustomerEmail.value = getCookie('tbxCustomerEmail');
	document.frmPayment.txaCustomerNote.value = getCookie('txaCustomerNote');
	
	
	if(getCookie('chkUseDelivery') == 'true'){
	 	
	 	document.frmPayment.tbxCustomerZipCode.value = getCookie('tbxCustomerZipCode');
	 	document.frmPayment.tbxCustomerZipCode.disabled = false;
	 	document.getElementById("tbxCustomerZipCode").readOnly = false;
		//alert("test");
		setFormValuesDelivery();
		//toggleFormElements(this.form,this,!this.checked,'Delivery',<%=Session("zipcode")%>);
		//toggleFormElements(document.frmPayment,document.frmPayment.chkUseDelivery,false,'Delivery',getCookie('tbxDeliveryCustomerZipCode'));
		
	}


}
//setFormValues('frmPayment');

function setFormValuesDelivery()
{
	
	document.frmPayment.chkUseDelivery.checked = 'true';
	//document.frmPayment.tbxDeliveryCompanyName.value = 'on';
	 
	
	document.frmPayment.tbxDeliveryCustomerCompanyName.value = getCookie('tbxDeliveryCustomerCompanyName');
	document.frmPayment.tbxDeliveryCustomerName.value = getCookie('tbxDeliveryCustomerName');
	document.frmPayment.tbxDeliveryCustomerAddress.value = getCookie('tbxDeliveryCustomerAddress');
	//document.frmPayment.tbxDeliveryCustomerZipCode.value = getCookie('tbxDeliveryCustomerZipCode');
	document.frmPayment.tbxDeliveryCustomerCity.value = getCookie('tbxDeliveryCustomerCity');
	document.frmPayment.tbxDeliveryCustomerPhone.value = getCookie('tbxDeliveryCustomerPhone');
	document.frmPayment.tbxDeliveryCustomerEmail.value = getCookie('tbxDeliveryCustomerEmail');
	document.frmPayment.txaDeliveryCustomerNote.value = getCookie('txaDeliveryCustomerNote');	
	
//el[i].disabled = stat;
	document.frmPayment.tbxDeliveryCustomerCompanyName.disabled = false;
	document.frmPayment.tbxDeliveryCustomerName.disabled = false;
	document.frmPayment.tbxDeliveryCustomerAddress.disabled = false;
	//document.frmPayment.tbxDeliveryCustomerZipCode.disabled = false;
	document.frmPayment.tbxDeliveryCustomerCity.disabled = false;
	document.frmPayment.tbxDeliveryCustomerPhone.disabled = false;
	document.frmPayment.tbxDeliveryCustomerEmail.disabled = false;
	document.frmPayment.txaDeliveryCustomerNote.disabled = false;
	
	}



function updateCookie(c_name)
{
	//alert(c_name.checked);
	if (c_name.name == 'chkUseDelivery'){
		setCookie(c_name.name,c_name.checked,365);
		if(c_name.checked == true){
			setFormValuesDelivery();
			}
		
	}else{
		setCookie(c_name.name,c_name.value,365);
	}
}


function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}




/****************Vedr. cookie****************/



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_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;

var scrollerCount			= 0;
var scrollerMainText		= null;
var scrollerBasketLarge	= null;
var scrollerDummy			= null;
var scrollerBasketRelatedItems	= null;
var defaultScrollbarHeight	= -1;

var imgFrontpageImagesPosX1	= 0;
var imgFrontpageImagesPosX2	= 0;
imgFrontpageImagesStartPos	= 0;

var intBasketButtonWidth	= -1;
var intBasketButtonHeight	= -1;

var intMenu					= null;

var intX = intY = intW = intH = 0;

function setup_global()
{
	if (g("divSite") == null)
	{
		alert("The site was not detected. Stop.");
		return;
	} else {
		initialize();
	}
}

function initialize()
{
	
	
	
	if(window.captureEvents){
		window.onmousemove=sourceCheck;
	} else {
		document.onmousemove=sourceCheck;
	}
	if (window.location.href.toLowerCase().indexOf("print.asp")  > -1 ) return;

	site = g("divSite");
	reposition();

	intBasketButtonWidth  = resvalue(150,189,236);
	intBasketButtonHeight = resvalue(19,24,30);
	
	if (blnFirstRun == true)
	{
		preload_images();
		if (is_ie && !is_ie7) addPngFix();
	}
	

	setupContents();
	if (blnFrontpage == false) setupBoxBaskets();
	if (blnShowBoxGreenLeftSmall == 1) setupBoxGreenLeftSmall();
	if (blnShowBoxGreenLeftBig == 1) setupBoxGreenLeftBig();
	if (blnFrontpage == 1)
	{
		setupFrontpage();
		setupFrontpageSlidingImages();
	}

	setupScrollbars();

	if (g("tbxZipcode"))
	{
		g("tbxZipcode").focus();
		//g("tbxZipcode").value = 3400;
		//g("tbxZipcode").form.submit();
	}


	if ( rq("hk") != null ) g("tblTabLeftGardenCalendar").onmouseout = g("tblTabLeftGardenCalendar").onmouseover;
	if ( rq("rv") != null ) g("tblTabLeftAdviceGuide").onmouseout = g("tblTabLeftAdviceGuide").onmouseover;

	// Settings for the image scroller:
	arrowB = new Array("imgback","img/icon_arrow_left_"  + jsres + ".png","img/icon_arrow_left_dim_"  + jsres + ".png"); //image name, active image ref, inactive image ref
	arrowF = new Array("imgforward","img/icon_arrow_right_"  + jsres + ".png","img/icon_arrow_right_dim_"  + jsres + ".png");
	imgcount = 7 - 1; // number of images minus one
	imgwidth = crf*107 + 2 ;//; resvalue(107 + 2,107 + 2,107 + 2);
	distance = imgwidth;
	startmove = 16;

	//g("imgGallery").src = arrPageImages[intImgGalleryIndexStart];

//	alert( g("imgGallery").src );

	fubar();

	CheckIfItemThumbnailsNeedScroller();
}

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()
{
	pngimg = document.getElementsByTagName("img");
	for(var i = 0, len = pngimg.length; i < len; i++)
	{
		if (pngimg[i].src.toLowerCase().indexOf(".png") > -1)
		{
			classname = pngimg[i].className.toLowerCase();
			if (classname.indexOf("nopng") == -1 && classname.indexOf("overlay") == -1)
			{
				pngimg[i].className += " overlay";
				pngimg[i].setAttribute("src", pngimg[i].src);
			}
		}
	}
}

function setupContents()
{

	try
	{
		intMenu = parseInt(rq("menu"));
	}
	catch (ex)
	{
		intMenu = null;
	}

	if (g("imgGradientGreen"))
	{
		g("imgGradientGreen").style.left = rxpos("divSite") + "px";
		g("imgGradientGreen").style.top  = rypos("divSite") + "px";

		if (g("imgGradientBrown"))
		{
			g("imgGradientBrown").style.left = rxpos("imgGradientGreen") + "px";
			g("imgGradientBrown").style.top  = rypos("imgGradientGreen") + g("imgGradientGreen").offsetHeight + "px";

			if (g("tblTabLeftGardenCalendar"))
			{
				g("tblTabLeftGardenCalendar").style.left = rxpos("imgGradientBrown") + "px";
				g("tblTabLeftGardenCalendar").style.top  = rypos("imgGradientBrown") + g("imgGradientBrown").offsetHeight + crf*20 + "px";

				/**/
				if (g("tblTabLeftAdviceGuide"))
				{
					g("tblTabLeftAdviceGuide").style.left = rxpos("tblTabLeftGardenCalendar") + "px";
					g("tblTabLeftAdviceGuide").style.top  = rypos("tblTabLeftGardenCalendar") + g("tblTabLeftAdviceGuide").offsetHeight + crf*3 + "px";
				}
				/**/
			}
		}


		if (g("imgFlower"))
		{
			g("imgFlower").style.left = rxpos("divSite") + g("divSite").offsetWidth - g("imgFlower").offsetWidth - crf*5 + "px";
			g("imgFlower").style.top  = rypos("imgGradientGreen") + g("imgGradientGreen").offsetHeight - g("imgFlower").offsetWidth + crf*10 + "px";
		}
	}

	if (g("imgIconPrint"))
	{

	g("imgIconPrint").style.left = rxpos("divSite") + g("divSite").offsetWidth - g("imgIconPrint").offsetWidth - crf*5 + "px";
	g("imgIconPrint").style.top  = rypos("divSite") + crf*4 + "px";


	g("divkortlogoer").style.left = rxpos("divSite") + g("divSite").offsetWidth - g("divkortlogoer").offsetWidth - crf*5 + "px";
	g("divkortlogoer").style.top  = rypos("divSite") + crf*(26) + "px";


		//g("imgIconPrint").style.left = rxpos("imgIconSitemap") - g("imgIconPrint").offsetWidth - crf*4 + "px";
		//g("imgIconPrint").style.top  = rypos("imgIconSitemap") + "px";

		if (g("imgIconHome"))
		{
			g("imgIconHome").style.left = rxpos("imgIconPrint") - g("imgIconHome").offsetWidth - crf*4 + "px";
			g("imgIconHome").style.top  = rypos("imgIconPrint") - crf*1 + "px";

			if (g("tblMenuTopBrown") && g("imgGradientGreen") && g("imgIconHome"))
			{
				g("tblMenuTopBrown").style.left = rxpos("imgIconHome") - g("tblMenuTopBrown").offsetWidth - crf*5 + "px";
				g("tblMenuTopBrown").style.top  = rypos("imgGradientGreen") + "px";

				
				if (g("tblMenuTopGreen") && g("imgGradientBrown"))
				{
					g("tblMenuTopGreen").style.left = rxpos("tblMenuTopBrown") + g("tblMenuTopBrown").offsetWidth - g("tblMenuTopGreen").offsetWidth - crf*20 + "px";
					g("tblMenuTopGreen").style.top  = rypos("imgGradientBrown") - g("tblMenuTopGreen").offsetHeight + crf*10 + "px";
				}
			

/*
				if (g("tblMenuTopGreen") && g("imgGradientBrown"))
				{
					g("tblMenuTopGreen").style.left = rxpos("tblMenuTopBrown") + g("tblMenuTopBrown").offsetWidth - g("tblMenuTopGreen").offsetWidth - crf*20 + "px";
					g("tblMenuTopGreen").style.top  = rypos("imgGradientBrown") - g("tblMenuTopGreen").offsetHeight + crf*10 + "px";

					intTabCount = 0;
					intMaxTabCount = 20;
					while ( g("tblTopMenuGreenTab" + intTabCount) )
					{
						g("tblTopMenuGreenTab" + intTabCount).style.zIndex = intMaxTabCount - intTabCount;
						intTabCount++;
					}
				}
				*/
			}
		}
	}


	if (g("imgLogoImage"))
	{
		g("imgLogoImage").style.left = rxpos("imgGradientGreen") + crf*5 + "px";
		g("imgLogoImage").style.top  = rypos("imgGradientGreen") + crf*5 + "px";

		if (g("imgLogoText"))
		{
			g("imgLogoText").style.left = rxpos("imgLogoImage") + g("imgLogoImage").offsetWidth - crf*20 + "px";
			g("imgLogoText").style.top  = rypos("imgLogoImage") + crf*(20+3) + "px";			
		}
	}

	if (g("divTooltip"))
	{
		//g("divTooltip").style.left = rxpos("divSite") + crf*(465 + 370) + "px";
		g("divTooltip").style.top  = rypos("tblMenuTopGreen") + crf*31 + "px";
	}

	if (blnShowTextMain == 1)
	{

		intMainDocumentOverrideWidth = 0;
		intMainDocumentOverrideHeight = 0;

		if (g("divMainText"))
		{
			intX = crf*216;
			intY = crf*403;
			intW = crf*391;
			intH = crf*157;

			if (rq("hk") != null)
			{
				intX = resvalue(200,250,313);
				intY = resvalue(180,225,281);
				intW = crf*400; //g("divSite").offsetWidth - intX*2;
				intH = g("divSite").offsetHeight - intY  - resvalue(20,20,20);
			}

			if (intPagetype == 1)
			{
				// article
				intMainDocumentOverrideWidth = crf*(270+65);

				intX = resvalue(200,250,313);
				intY = resvalue(180,225,281);
				intW = crf*(400); //g("divSite").offsetWidth - intX*2;
				intH = g("divSite").offsetHeight - intY  - resvalue(20,20,20);
			}

			if (intPagetype == 2)
			{
				// Show product/item

				extraHeight = resvalue(0,0,1);
				if (is_ie6)
				{
					extraHeight = resvalue(0,1,1);
				}

				intW = crf*293;
				intH = resvalue(316,399,502) + extraHeight;//crf*334;
				intX = g("divSite").offsetWidth - intBasketButtonWidth - intW - crf*19;
				intY = -rypos("divSite") + rypos("imgGradientBrown") + g("imgGradientBrown").offsetHeight + intBasketButtonHeight + resvalue(0,-4,-6) - 10;
				if (rq("shop"))
				{
					intY += 10;
				}

				//g("divMainText").style.backgroundColor = "#00ffff";

				g("divMainTextDocument").style.width = intW - 2*crf*20 + "px";
				g("divMainTextDocument").style.left = crf*20 + "px";
//				g("divMainTextDocument").style.top = crf*25 + "px";
//				g("divMainTextDocument").style.height = intH - crf*25 + "px";

				// here



				if (blnGetOptionsPreBasket == 1 && g("divMainTextQuantity"))
				{
					intH = resvalue(246,399+100,502);
				}

				if (rq("basket") && g("imgGradientBrown") && g("divGenericBackground"))
				{
//					alert("move it");

					//g("divGenericBackground").style.backgroundColor = "#0000ff";
					g("divGenericBackground").style.display = "block";
					g("divGenericBackground").style.visibility = "visible";
					g("divGenericBackground").style.border = "1px solid #562800";
					g("divGenericBackground").style.left   = rxpos("divSite") + resvalue(197,246,308) + "px";
					g("divGenericBackground").style.top    = rypos("imgGradientBrown") + g("imgGradientBrown").offsetHeight + resvalue(18,-1,0) + "px";
					g("divGenericBackground").style.width  = resvalue(622,777,970) + "px";
					g("divGenericBackground").style.height = resvalue(334,442,554) + "px";

					
					g("divMainTextDocument").style.marginTop = 10 + "px";
					
					intX = resvalue(198,247,313+1);
					intY = -rypos("divSite") + rypos("imgGradientBrown") + g("imgGradientBrown").offsetHeight + resvalue(240+15,300,375);
					intW = resvalue(450,562,622);
					intH = resvalue(100,120,150);

					if (g("divBasketLargeContainer"))
					{

						g("divBasketLargeContainer").style.left		= rxpos("divGenericBackground") + crf*20 + "px";
						g("divBasketLargeContainer").style.top		= rypos("divGenericBackground") + 1 + crf*15 + "px";
						g("divBasketLargeContainer").style.height	= resvalue(160,200,250) + "px";
						g("divBasketLargeContainer").style.width	= resvalue(480,600,750) + "px";
						g("divBasketLargeData").style.height		= g("divBasketLargeContainer").offsetHeight + "px";
						g("divBasketLargeData").style.width			= g("divBasketLargeContainer").offsetWidth + "px";;
						g("divBasketLargeDataDocument").style.width	= g("divBasketLargeData").offsetWidth + "px";
						g("tblBasketLargeData").style.width			= 100 + "%";

						intExtraY = 0;
						if (jsres == 0)
						{
							intExtraY = 11+2+10-2;
						}
						else if(jsres == 1)
						{
						    intExtraY = 5;
						}
						g("divPriceTotal").style.left = 0 + "px";
						g("divPriceTotal").style.top  = g("divBasketLargeContainer").offsetHeight + crf*(20+7) + intExtraY + "px";
						g("divPriceTotal").style.width			= g("divBasketLargeContainer").offsetWidth + "px";

						/*
						if (scrollerBasketLarge == null) scrollerBasketLarge = new textScroller(scrollerCount++);
						scrollerBasketLarge.masterobj		= 'divBasketLargeData';
						scrollerBasketLarge.scrollerobj		= 'divBasketLargeDataDocument';
						scrollerBasketLarge.scrollbar		= 'divScrollbarBasketLargeData';
						scrollerBasketLarge.arrowobj		= 'divScrollSliderBasketLargeData'; //fake shit
						scrollerBasketLarge.scrollslider	= 'divScrollSliderBasketLargeData';
						scrollerBasketLarge.prepare();

						if (g("divBasketLargeDataDocument").scrollHeight < g("divBasketLargeData").offsetHeight || intPagetype == 0)
						{
							// hide scrollbar
							g("divScrollbarBasketLargeData").style.display         = "none";
							g("divScrollSliderBasketLargeData").style.display      = "none";
							g("imgArrowScrolbarBasketLargeDataUp").style.display   = "none";
							g("imgArrowScrolbarBasketLargeDataDown").style.display = "none";
						}
						*/

					}


					if (g("divBasketButtonGoToCheckout"))
					{
						g("divBasketButtonGoToCheckout").style.left = rxpos("divGenericBackground") + g("divGenericBackground").offsetWidth - g("divBasketButtonGoToCheckout").offsetWidth  + "px";
						g("divBasketButtonGoToCheckout").style.top  = rypos("divGenericBackground") + g("divGenericBackground").offsetHeight - g("divBasketButtonGoToCheckout").offsetHeight - crf*50  + "px";


					}
				}
			}

			intSpace = 0;
			if (rq("pid"))
			{
				intSpace = crf*18;
			}


			/*
			// ORIGINAL CODE!

			if (rq("pay") != null)
			{
				intW = crf*600;
				intH = resvalue(420,476,595);
				intX = crf*200;
				intY = -intSpace + g("divSite").offsetHeight - intH;
				//g("divMainText").style.backgroundColor = "#00ff00";
				//g("divMainTextDocument").style.backgroundColor = "#00ff00";
				g("divMainTextDocument").style.marginTop = 0*crf*10 + "px";
				g("divMainTextDocument").style.width = crf*600 + "px";
				g("divMainTextDocument").style.height = crf*400 + "px";
				intMainDocumentOverrideWidth  = crf*600;
				intMainDocumentOverrideHeight = crf*380;

			}
			*/


			if (rq("pay") != null)
			{
				if (rq("pay") == "1" || rq("pay") == "2" || rq("pay") == "3")
				{
					intW = crf*600;
					intH = resvalue(420,476,595);
					intX = crf*200;
					intY = -intSpace + g("divSite").offsetHeight - intH - crf*15;
					//g("divMainText").style.backgroundColor = "#00ff00";
					//g("divMainTextDocument").style.backgroundColor = "#00ff00";
					g("divMainTextDocument").style.marginTop = 0*crf*10 + "px";
					g("divMainTextDocument").style.width = crf*600 + "px";
					g("divMainTextDocument").style.height = crf*400 + "px";
					intMainDocumentOverrideWidth  = crf*600;
					intMainDocumentOverrideHeight = crf*380;

					if (g("chkUseDelivery"))
					{
						g("chkUseDelivery").style.width = crf*12 + "px";
					}
	
					if (rq("pay") == "2")
					{
						if (g("divBasketButtonCompleteOrdre"))
						{
							g("divBasketButtonCompleteOrdre").style.left = right("divSite")  - g("divBasketButtonCompleteOrdre").offsetWidth  - crf * 150 + "px";
							g("divBasketButtonCompleteOrdre").style.top  = bottom("divSite") - g("divBasketButtonCompleteOrdre").offsetHeight - crf *  50 + "px";
						}
					}
					
				}
			}


			if (blnFrontpage == 1)
			{
				intH = resvalue(135,175,225);
				intMainDocumentOverrideWidth = 0;
				intMainDocumentOverrideHeight = 0;
			}


			//g("divMainText").style.backgroundColor = "#ff0000";
			//g("divMainTextDocument").style.backgroundColor = "#00ff00";
			g("divMainText").style.overflow = "hidden";
			g("divMainText").style.left     = rxpos("divSite") + intX + "px";
			g("divMainText").style.top      = 10 + rypos("divSite") + intY + intSpace + "px";
			g("divMainText").style.width    = intW + "px";
			g("divMainText").style.height   = intH + "px";


			if (intMainDocumentOverrideWidth  != 0) g("divMainTextDocument").style.width  = intMainDocumentOverrideWidth + "px";
			if (intMainDocumentOverrideHeight != 0) g("divMainTextDocument").style.height = intMainDocumentOverrideHeight + "px";
			
			if ( rq("item") && rq("shop") )
			{
				//g("divMainTextDocument").style.height = crf*100 + "px";
				if (is_ie)
				{
					intH = resvalue(180-20,260-50,355-60);
				} else {
					intH = resvalue(196-30,260-30,350-60);
					intY = resvalue(124,151,187);
				}

				g("divMainText").style.left     = rxpos("divSite") + intX + "px";
				g("divMainText").style.top      = rypos("divSite") + intY + intSpace + "px";
				g("divMainText").style.width    = intW + "px";
				g("divMainText").style.height   = intH + "px";

			
				if (g("divMainTextQuantity") && blnShowQuantity == 1)
				{
					//g("divGenericBackground").style.backgroundColor = "#ff0000";
					//g("divMainTextQuantity").style.backgroundColor = "#0000ff";
					
					g("divGenericBackground").style.display = "block";
					g("divGenericBackground").style.visibility = "visible";
					g("divGenericBackground").style.backgroundColor = "#f6e6cf";
					
					
//					g("divMainText").style.height   = resvalue(196,279,350) + "px";

					g("divGenericBackground").style.left   = rxpos("divMainText") + "px";
					g("divGenericBackground").style.top    = rypos("divMainText") + "px";
					g("divGenericBackground").style.width  = g("divMainText").offsetWidth + "px";
					g("divGenericBackground").style.height = resvalue(317,399,503) + "px";
					g("divGenericBackground").style.zIndex = 1;

					g("divMainTextQuantity").style.height = crf*150 + "px";
					g("divMainTextQuantity").style.width  = g("divMainText").offsetWidth + "px";
					g("divMainTextQuantity").style.left   = rxpos("divMainText") + 0.0*rxpos("divMainText") + "px";
					g("divMainTextQuantity").style.top    = rypos("divGenericBackground") + g("divGenericBackground").offsetHeight - g("divMainTextQuantity").offsetHeight - 1 + "px";
					//g("divMainTextQuantity").style.top    = rypos("divSite") + resvalue(0,418,0) + "px";
					
				}
			}



			if (g("tblQuantity"))
			{
				/*
				sels = g("tblQuantity").getElementsByTagName("select");
				for(i=0,len=sels.length;i<len;i++)
				{
					sels[i].style.width = resvalue(100,315-5,100) + "px";
				}
				*/

				/*
				if (is_firefox)
				{
					if ( g("spanBtnSubmitQuantity") )
					{
						g("spanBtnSubmitQuantity").style.position = "relative";
						g("spanBtnSubmitQuantity").style.top = resvalue(70,65,60) + "px";
					}
				}
				*/

				g("tblQuantity").style.width  = g("divMainText").offsetWidth - crf*20 + "px";

				if (g("divNoteTransportation"))
				{
					g("divNoteTransportation").style.left = rxpos("tblQuantity") + "px";
					g("divNoteTransportation").style.top  = rypos("tblQuantity") + crf*80 + "px";
					g("divNoteTransportation").style.width  = g("tblQuantity").offsetWidth - crf*28 + "px";

				}

				if (g("spanBtnSubmitQuantity"))
				{
					intX = 140;
					if (is_ie)
					{
						intX = resvalue(120,145,150);
					}

					g("spanBtnSubmitQuantity").style.left = crf*intX + "px";
					g("spanBtnSubmitQuantity").style.top  = crf*10 + "px";
				}

			}



			if (g("imgGallery") && !blnFrontpage && blnShowGalleryBack)
			{
				
				g("imgGallery").style.left = rxpos("divSite") + crf*197 + "px";
				g("imgGallery").style.top  = rypos("imgGradientBrown") + g("imgGradientBrown").offsetHeight - 1*0 + "px";
				//g("imgGallery").style.width  = resvalue(622,777,970) + "px";
				//g("imgGallery").style.height = resvalue(353,443,555) + "px";
				//alert(g("imgGallery").offsetHeight);

				if (g("divMainTextButtonShowHide"))
				{
					/*
					// - 0*g("divBoxBackground").offsetWidth
					//g("divMainTextButtonShowHide").style.zIndex = 999999999;
					//g("divMainTextButtonShowHide").style.width = crf*293 + "px";
					g("divMainTextButtonShowHide").style.right = document.body.offsetWidth - rxpos("divBoxBackground") - crf*293  + "px";
					g("divMainTextButtonShowHide").style.top = rypos("divBoxBackground") + "px";
					//g("divMainTextButtonShowHide").style.width = g("divBoxBackground").offsetWidth + "px";
					

					//document.title = "w: *" + g("divBoxBackground").offsetWidth + "*px";
					locate("divMainTextButtonShowHide");
					/**/

					intExtraLeft = 0;
					intExtraWidth = 0;

					if (is_firefox)
					{
						if (jsres == 2)
						{
							intExtraWidth = -1;
						}
					}

					// (is_ie?0:1)
//					g("divMainTextButtonShowHide").style.left = rxpos("divSite") + g("divSite").offsetWidth - g("divMainTextButtonShowHide").offsetWidth - 0*crf*247 + "px";
					g("divMainTextButtonShowHide").style.width = g("divMainText").offsetWidth + intExtraWidth + "px";
					g("divMainTextButtonShowHide").style.left = rxpos("divMainText") + intExtraLeft + "px";
					g("divMainTextButtonShowHide").style.top  = rypos("divSite") + crf* 124 + "px";

					//g("divMainTextButtonShowHide").style.left = rxpos("divMainText") + g("divMainText").offsetWidth - g("divMainTextButtonShowHide").offsetWidth + "px";
					//g("divMainTextButtonShowHide").style.top  = rypos("divMainText") + "px";
				}

				if (g("imgMiniProductPreview"))
				{
					if (g("imgMiniProductPreview").src.indexOf("x.gif") == -1)
					{
						g("imgMiniProductPreview").style.left = rxpos("imgGallery") + crf*18 + "px";
						g("imgMiniProductPreview").style.top  = rypos("imgGallery") + g("imgGallery").offsetHeight - g("imgMiniProductPreview").offsetHeight - crf*18 + "px";
					}
				}

			}

			if (g("divBoxGreenBottom"))
			{
				extraLeft = 0;
				extraTop  = 0;
				if (is_ie6 && jsres == 2) extraLeft = 1;

				g("divBoxGreenBottom").style.width    = resvalue(622,777,970) + "px";
				g("divBoxGreenBottom").style.height   = crf*100 + "px";
				g("divBoxGreenBottom").style.left     = rxpos("divSite") + crf*197 + extraLeft + "px";
				g("divBoxGreenBottom").style.top      = rypos("divSite") + g("divSite").offsetHeight - g("divBoxGreenBottom").offsetHeight + extraTop - resvalue(0,0,2) + "px";

				createLine(
					rxpos("divBoxGreenBottom"),
					rypos("divBoxGreenBottom") + crf*(15+4),
					g("divBoxGreenBottom").offsetWidth,
					1,
					"#562800",
					1,
					"lineImageBottom"
				);

				if (g("divNumberShop"))
				{
					g("divNumberShop").style.left     = rxpos("divBoxGreenBottom") + g("divBoxGreenBottom").offsetWidth - g("divNumberShop").offsetWidth  + "px";
					g("divNumberShop").style.top      = rypos("divBoxGreenBottom") + resvalue(0,0,0) + 130*0 + "px";
					

					if (is_ie)
					{
						intHeight = resvalue(18,22,28);
						
						if (is_ie6) 
							intHeight = resvalue(18,22,28);
						if (is_ie7) 
							intHeight = resvalue(18,22,28);

						td = g("divNumberShop").getElementsByTagName("td");
						for(i = 0, len = td.length; i < len; i++)
						{
							td[i].style.height = intHeight + "px";
						}
					}
				}

				if (g("divBoxGreenBottomContainer"))
				{
					g("divBoxGreenBottomContainer").style.left  = rxpos("lineImageBottom") + crf*33 - 5 + "px";
					g("divBoxGreenBottomContainer").style.top   = rypos("lineImageBottom") + "px";
					//g("divBoxGreenBottomContainer").style.width = g("divBoxGreenBottom").offsetWidth - crf*70 + resvalue(21,17,21*jsres) + "px";
					//g("tblBoxGreenBottomImages").style.width   = 20 + "px"; // rxpos("divBoxGreenBottom") + g("divBoxGreenBottom").offsetWidth - crf*28
				}

/*
				c = 1;
				space = crf*33;
				while( divImageBottom = g("divImageBottom" + c) )
				{
					g("divImageBottom" + c).style.left     = rxpos("divBoxGreenBottom") + space + "px";
					g("divImageBottom" + c).style.top      = rypos("lineImageBottom") + "px";
					space += crf*107 + 5;
					c++;
				}
*/

				if (g("imgImageBottomArrowLeft") && g("imgImageBottomArrowRight"))
				{
					g("imgImageBottomArrowLeft").style.left = rxpos("divBoxGreenBottom") + crf*10 + "px";
					g("imgImageBottomArrowLeft").style.top  = rypos("divBoxGreenBottom") + crf*45 + "px";
					
					g("imgImageBottomArrowRight").style.left = rxpos("divBoxGreenBottom") + g("divBoxGreenBottom").offsetWidth - crf*18 + "px";
					g("imgImageBottomArrowRight").style.top  = rypos("imgImageBottomArrowLeft") + "px";
				}


				if (g("imgImageBottomArrowLeftOpaque") && g("imgImageBottomArrowRightOpaque"))
				{
					g("imgImageBottomArrowLeftOpaque").style.left = rxpos("divSite") + crf*198 + "px";
					g("imgImageBottomArrowLeftOpaque").style.top  = rypos("divSite") + crf*270 + "px";
					
					g("imgImageBottomArrowRightOpaque").style.left = rxpos("divSite") + g("divSite").offsetWidth - crf*167 + "px";
					g("imgImageBottomArrowRightOpaque").style.top  = rypos("imgImageBottomArrowLeftOpaque") + "px";

					if (arrPageImages.length < 2)
					{
						g("imgImageBottomArrowLeftOpaque").style.display = "none";
						g("imgImageBottomArrowRightOpaque").style.display = "none";
					}
				}


				

				/*
				if (g("divImageBottom1"))
				{
					g("divImageBottom1").style.left     = rxpos("divBoxGreenBottom") + crf*30 + "px";
					g("divImageBottom1").style.top      = rypos("divBoxGreenBottom") + 0 + "px";
				}
				*/
			}
		}
	}


	if (blnFrontpage == 1)
	{
		g("divMainText").style.height = crf*145 + "px";
		g("divMainTextDocument").style.width = 100 + "%";
		g("divMainTextDocument").style.marginTop = 0 + "px";

	}

} // end function setupContents

function setupBoxGreenLeftBig()
{
	if (g("divGreenBoxLeftBig"))
	{
		g("divGreenBoxLeftBig").style.width  = resvalue(169,211,264) + "px";
		g("divGreenBoxLeftBig").style.height = resvalue(380,476,595) + "px";
		g("divGreenBoxLeftBig").style.left   = rxpos("divSite") + crf*13 + "px";
		g("divGreenBoxLeftBig").style.top    = rypos("divSite") + g("divSite").offsetHeight - g("divGreenBoxLeftBig").offsetHeight + "px";
	
		if (g("divGreenBoxLeftBigText"))
		{
			intMarginHorizontal = resvalue(8,10,13);
			intMarginVertical   = resvalue(12,12,12);
			//g("divGreenBoxLeftBigText").style.backgroundColor = "#ff0000";
			g("divGreenBoxLeftBigText").style.width  = g("divGreenBoxLeftBig").offsetWidth  - intMarginHorizontal * 2 + "px";
			g("divGreenBoxLeftBigText").style.height = g("divGreenBoxLeftBig").offsetHeight - intMarginVertical   * 2 + "px";
			g("divGreenBoxLeftBigText").style.left   = rxpos("divGreenBoxLeftBig") + intMarginHorizontal + "px";
			g("divGreenBoxLeftBigText").style.top    = rypos("divGreenBoxLeftBig") + intMarginVertical + "px";			
		}
	}
}

function setupBoxGreenLeftSmall()
{
	if (g("divGreenBoxLeftSmall"))
	{
		g("divGreenBoxLeftSmall").style.width  = resvalue(168,210,262) + "px";
		g("divGreenBoxLeftSmall").style.height = resvalue(156,195,244) + "px";
		g("divGreenBoxLeftSmall").style.left   = rxpos("divSite") + crf*13 + "px";
		g("divGreenBoxLeftSmall").style.top    = rypos("divSite") + g("divSite").offsetHeight - g("divGreenBoxLeftSmall").offsetHeight + "px";
	
		if (g("divGreenBoxLeftSmall") && g("divGreenBoxLeftSmallText"))
		{
			intMarginHorizontal = resvalue(8-8+2,10,13);
			intMarginVertical   = resvalue(12-5,12,12);
			//g("divGreenBoxLeftBigText").style.backgroundColor = "#ff0000";
			g("divGreenBoxLeftSmallText").style.width  = g("divGreenBoxLeftSmall").offsetWidth  - intMarginHorizontal * 2 + "px";
			g("divGreenBoxLeftSmallText").style.height = g("divGreenBoxLeftSmall").offsetHeight - intMarginVertical   * 2 + "px";
			g("divGreenBoxLeftSmallText").style.left   = rxpos("divGreenBoxLeftSmall") + intMarginHorizontal + "px";
			g("divGreenBoxLeftSmallText").style.top    = rypos("divGreenBoxLeftSmall") + intMarginVertical + "px";			
		}
	}
}


function setupBoxBaskets()
{
	if (g("divBasketButtonViewBasket"))
	{
		g("divBasketButtonViewBasket").style.overflow = "hidden";
		//g("divBasketButtonViewBasket").style.width    = resvalue(150,188,236) + "px";
		//g("divBasketButtonViewBasket").style.height   = resvalue(19,24,30) + "px";
		g("divBasketButtonViewBasket").style.left     = rxpos("divSite") + g("divSite").offsetWidth - g("divBasketButtonViewBasket").offsetWidth + "px";
		g("divBasketButtonViewBasket").style.top      = rypos("imgGradientBrown") + g("imgGradientBrown").offsetHeight + "px";

		if (g("tblBasketContents"))
		{
			g("tblBasketContents").style.width   = resvalue(132,165,206) + "px";
			g("tblBasketContents").style.height  = crf*50 + "px";
			g("tblBasketContents").style.left    = rxpos("divSite") + g("divSite").offsetWidth  - g("tblBasketContents").offsetWidth - resvalue(8,12,14) + "px";
			g("tblBasketContents").style.top     = rypos("divBasketButtonViewBasket") + g("divBasketButtonViewBasket").offsetHeight + crf*10 - resvalue(5,6,5) + "px";

			if (is_ie6)
			{
				g("tdBasketItemsSmall").style.height = resvalue(69,87,125) + "px";
			}

			if (g("tblBasketRelatedItems"))
			{
				g("tblBasketRelatedItems").style.width   = g("tblBasketContents").offsetWidth + "px";
				g("tblBasketRelatedItems").style.height  = 195 + "px";
				g("tblBasketRelatedItems").style.left    = rxpos("tblBasketContents") + "px";
				g("tblBasketRelatedItems").style.top     = rypos("tblBasketContents") + g("tblBasketContents").offsetHeight + crf*10 - resvalue(3,5,5) + "px";

				if (g("divBasketRelatedItems"))
				{
					g("divBasketRelatedItems").style.width   = crf*110 + "px";
					g("divBasketRelatedItems").style.height  = crf*250 + "px";
					g("divBasketRelatedItems").style.left    = rxpos("tblBasketRelatedItems") + "px";
					g("divBasketRelatedItems").style.top     = rypos("tblBasketRelatedItems") + crf*30 + "px";
				}
			}

			if (g("divBasketSmallMaster"))
			{
				g("divBasketSmallMaster").style.left = rxpos("tdBasketItemsSmall") + crf*5 + "px";
				g("divBasketSmallMaster").style.top  = rypos("tdBasketItemsSmall") + crf*2 + "px";

				createScrollbar(
					"BasketSmall",
					"divBasketSmallMaster",
					"divBasketSmallDocument",
					rxpos("divBasketSmallMaster") + g("divBasketSmallMaster").offsetWidth + crf*2 - crf*10,
					0
				);
			}
			//locate("divBasketSmallDocument");
			//locate("divBasketSmallMaster");


		}

		createLine(
			rxpos("divBasketButtonViewBasket"),
			rypos("divBasketButtonViewBasket"),
			1,
			g("divSite").offsetHeight - rypos("divBasketButtonViewBasket") + rypos("divSite"),
			"#562800",
			1,
			"lineBasketButtonViewBasket"
		);
	}
}

function setupFrontpage()
{
	// setup news
	if (g("divBoxNews"))
	{
		g("divBoxNews").style.width  = resvalue(317,395,494) + "px";
		g("divBoxNews").style.height = resvalue(156,194,243) + "px";
		g("divBoxNews").style.left   = rxpos("divSite") + g("divSite").offsetWidth - g("divBoxNews").offsetWidth - crf*13 + "px";
		g("divBoxNews").style.top    = rypos("divSite") + g("divSite").offsetHeight - g("divBoxNews").offsetHeight + "px";

		if (g("divBoxNewsHeadlineText"))
		{
			//g("divBoxNewsHeadlineText").style.width  = resvalue(317,210,262) + "px";
			//g("divBoxNewsHeadlineText").style.height = resvalue(156,195,244) + "px";
			g("divBoxNewsHeadlineText").style.left   = rxpos("divBoxNews") + crf*10 + "px";
			g("divBoxNewsHeadlineText").style.top    = rypos("divBoxNews") + crf*4 + "px";
		}

		if (g("divBoxNewsBodyText"))
		{
			//g("divBoxNewsBodyText").style.backgroundColor = "#ff0000";
			//g("divBoxNewsBodyText").style.height = resvalue(130,195,244) + "px";

			//g("divBoxNewsBodyText").style.height = resvalue(156,195,244) + "px";
			g("divBoxNewsBodyText").style.left   = rxpos("divBoxNews") + crf*10 + "px";
			g("divBoxNewsBodyText").style.top    = rypos("divBoxNews") + crf*(30-10*0) + "px";
			//g("divBoxNewsBodyText").style.width  = resvalue(317,210,262) - 2*(rxpos("divBoxNewsBodyText") - rxpos("divBoxNews")) + "px";
			g("divBoxNewsBodyText").style.width  = g("divBoxNews").offsetWidth - 2*crf*10 + "px";
		}
	}

	/**/
	if (g("divImagesMarquee") && g("tblTabLeftAdviceGuide"))
	{
		space = ( rxpos("divGreenBoxLeftSmall") - rxpos("divSite") ) / 2;
		g("divImagesMarquee").style.display = "block";
		g("divImagesMarquee").style.left = rxpos("divSite") - resvalue(1,0,0) + "px";
		g("divImagesMarquee").style.top  = rypos("tblTabLeftAdviceGuide") + g("tblTabLeftAdviceGuide").offsetHeight + crf*34 + "px";
		g("divImagesMarquee").style.width  = g("divSite").offsetWidth - space*(-0.5+2*0) - 0 + "px";
		g("divImagesMarquee").style.height  = crf*146 + "px";
		//if (is_firefox)
		//{
		//	g("divImagesMarquee").style.display = "none";
		//}
	}

	/**/

// image_container

			/*
	if ( 2 == 3 && ( g("divImagesMarquee") || g("image_container") ) && g("tblTabLeftGardenCalendar") && g("divGreenBoxLeftSmall"))
	{
		if (g("divImagesMarquee"))
		{
			space = ( rxpos("divGreenBoxLeftSmall") - rxpos("divSite") ) / 2;
			g("divImagesMarquee").style.left = rxpos("divSite") + space + "px";
			g("divImagesMarquee").style.top  = rypos("tblTabLeftGardenCalendar") + g("tblTabLeftGardenCalendar").offsetHeight + crf*56 + "px";
			g("divImagesMarquee").style.width  = g("divSite").offsetWidth - space*2 + "px";
			g("divImagesMarquee").style.height  = crf*146 + "px";
		}

		if (g("image_container"))
		{
			space = ( rxpos("divGreenBoxLeftSmall") - rxpos("divSite") ) / 2;
			g("image_container").style.position = "absolute";
			g("image_container").style.left = rxpos("divSite") + space + "px";
			g("image_container").style.top  = rypos("tblTabLeftGardenCalendar") + g("tblTabLeftGardenCalendar").offsetHeight + crf*56 + "px";
			g("image_container").style.width  = g("divSite").offsetWidth - space*2 + "px";
			g("image_container").style.height  = crf*146 + "px";
			locate("image_container");
		}
		
		scrolling_images.initialize(document.getElementById("image_container"), 550);
		for(i = 0, len = arrMarquee.length; i < len; i++)
		{
			item = arrMarquee[i].split("^");
			scrolling_images.addImage(item[0], item[1], "slidingImage");
		}
		scrolling_images.start(75);

	}

	if (g("divMainTextScroll"))
	{
		g("divMainTextScroll").style.display = "none";
	}

			*/

}

function createScrollbar(id, divMaster, divDocument, intX, intY)
{

	/*
		*** Arguments:

			* id: unique identifier for the scrollbar

			* divMaster: master (outer) box

			* divDocument: document (inner) box which scrolls

			* intX: integer, number of pixels off the right of divMaster

			* intY: integer, number of pixels off the top of divMaster
	*/


	strError = "";
	if (!id) strError += "* missing: id\n";
	if (!g(divMaster)) strError += "* Element not found: " + divMaster + "\n";
	if (!g(divMaster)) strError += "* Element not found: " + divDocument + "\n";
	if (strError != "")
	{
		alert(strError);
		return;
	}

	if (!intX) intX = rxpos(divMaster);
	if (!intY) intY = rypos(divMaster);

	// set scroll object
	var dynamic_scroller = null;
	dynamic_scroller = g("scroller" + id);


	if (dynamic_scroller == null) dynamic_scroller = new textScroller(scrollerCount++);
	dynamic_scroller.masterobj		= divMaster;
	dynamic_scroller.scrollerobj	= divDocument;
	dynamic_scroller.scrollbar		= 'divScrollbar' + id;
	dynamic_scroller.arrowobj		= 'divScrollSlider' + id; //fake shit
	dynamic_scroller.scrollslider	= 'divScrollSlider' + id;

	// create elements
	if (!g("divScrollbar" + id))
	{
		d = document.createElement("div");
		d.id = "divScrollbar" + id;
		d.className = "goaway";
		//d.style.display = "none";
		d.style.zIndex = 1;
		d.style.width = 1 + "px";
		d.style.height = 150 + "px";
		d.style.backgroundColor = "#000000";
		document.body.appendChild(d);
	}

	if (!g("divScrollSlider" + id))
	{
		d = document.createElement("div");
		d.id = "divScrollSlider" + id;
		d.className = "goaway";
		//d.style.display = "none";
		d.style.zIndex = 1;
		d.style.width = 7 + "px";
		d.style.height = 50 + "px";
		d.style.backgroundColor = "#000000";
		d.style.cursor = "pointer";
		document.body.appendChild(d);
	}

	if (!g("imgArrowScrolbar" + id + "Up"))
	{
		d = document.createElement("img");
		d.id = "imgArrowScrolbar" + id + "Up";
		d.className = "goaway overlay";
		d.style.cursor = "pointer";
		d.setAttribute("src", "img/icon_arrow_scroller_up_" + jsres + ".png");

		d.onmouseover = function() { dynamic_scroller.scrollUp(); }
		d.onmouseout = function() { dynamic_scroller.cancelScroll(); }
		d.onmousedown = function() { dynamic_scroller.alterSpeed(1); }
		d.onmouseup = function() { dynamic_scroller.alterSpeed(0); }

		document.body.appendChild(d);
	}

	if (!g("imgArrowScrolbar" + id + "Down"))
	{
		d = document.createElement("img");
		d.id = "imgArrowScrolbar" + id + "Down";
		d.className = "goaway overlay";
		d.style.cursor = "pointer";
		d.setAttribute("src", "img/icon_arrow_scroller_down_" + jsres + ".png");

		d.onmouseover = function() { dynamic_scroller.scrollDown(); }
		d.onmouseout = function() { dynamic_scroller.cancelScroll(); }
		d.onmousedown = function() { dynamic_scroller.alterSpeed(1); }
		d.onmouseup = function() { dynamic_scroller.alterSpeed(0); }

		document.body.appendChild(d);
	}

	// position elements:
	g("imgArrowScrolbar" + id + "Up").style.left = intX + "px";
	g("imgArrowScrolbar" + id + "Up").style.top  = intY + "px";

	g("imgArrowScrolbar" + id + "Down").style.left = rxpos("imgArrowScrolbar" + id + "Up") + "px";
	g("imgArrowScrolbar" + id + "Down").style.top  = bottom(divMaster) - d.offsetHeight + "px";

	g("divScrollbar" + id).style.left = rxpos("imgArrowScrolbar" + id + "Up") + ( g("imgArrowScrolbar" + id + "Up").offsetWidth / 2) - (g("divScrollbar" + id).offsetWidth / 2) + "px";
	g("divScrollbar" + id).style.top  = rypos("imgArrowScrolbar" + id + "Up") + g("imgArrowScrolbar" + id + "Up").offsetHeight + 1 + "px";
	if( (rypos("imgArrowScrolbar" + id + "Down") - rypos("imgArrowScrolbar" + id + "Up") - g("imgArrowScrolbar" + id + "Up").offsetHeight - 2) > 0)
		g("divScrollbar" + id).style.height = rypos("imgArrowScrolbar" + id + "Down") - rypos("imgArrowScrolbar" + id + "Up") - g("imgArrowScrolbar" + id + "Up").offsetHeight - 2 + "px";

	g("divScrollSlider" + id).style.left = rxpos("divScrollbar" + id) - g("divScrollSlider" + id).offsetWidth / 2 + "px";
	g("divScrollSlider" + id).style.top  = rypos("imgArrowScrolbar" + id + "Up") + g("imgArrowScrolbar" + id + "Up").offsetHeight + "px";
	



	g("imgArrowScrolbar" + id + "Up").style.zIndex = 99999;
	g("imgArrowScrolbar" + id + "Down").style.zIndex = 99999;
	g("divScrollbar" + id).style.zIndex = 99999;
	g("divScrollSlider" + id).style.zIndex = 99999;


	////scrollerDummy.prepare(); // prepare the scrollbar // works
	////eval("scroller" + id + ".prepare()"); // prepare the scrollbar // works
	dynamic_scroller.prepare(); // works



	if ( g(divDocument).scrollHeight < g(divMaster).offsetHeight )
	{
		g("imgArrowScrolbar" + id + "Up").style.display = "none";
		g("imgArrowScrolbar" + id + "Down").style.display = "none";
		g("divScrollbar" + id).style.display = "none";
		g("divScrollSlider" + id).style.display = "none";
	}
}


function setupScrollbars()
{

	if (blnHideScrollbars != 0) return;
	intSpace = -1;
	if (is_ie) intSpace = 0;

	if (
			   g("divMainText")
			&& g("divMainTextDocument")
			&& g("divScrollbarMainText")
			&& g("divScrollSliderMainText")
			&& g("imgArrowScrolbarMainTextUp")
			&& g("imgArrowScrolbarMainTextDown")
			&& blnFrontpage == 0
		)
	{

			// setup scrollbars

			// main text
			g("divScrollbarMainText").style.display         = "block";
			g("divScrollSliderMainText").style.display      = "block";
			g("imgArrowScrolbarMainTextUp").style.display   = "block";
			g("imgArrowScrolbarMainTextDown").style.display = "block";

			g("imgArrowScrolbarMainTextUp").style.left = rxpos("divMainText") + g("divMainText").offsetWidth + crf*10 + "px";
			g("imgArrowScrolbarMainTextUp").style.top  = top("divMainText") + "px";

			g("imgArrowScrolbarMainTextDown").style.left = rxpos("imgArrowScrolbarMainTextUp") + "px";
			g("imgArrowScrolbarMainTextDown").style.top  = bottom("divMainText") - g("imgArrowScrolbarMainTextDown").offsetHeight - crf*15 + "px";

			g("divScrollbarMainText").style.left   = rxpos("imgArrowScrolbarMainTextUp") + g("imgArrowScrolbarMainTextUp").offsetWidth/2 + intSpace + "px";
			g("divScrollbarMainText").style.top    = bottom("imgArrowScrolbarMainTextUp") + crf*10 + "px";
			g("divScrollbarMainText").style.height = top("imgArrowScrolbarMainTextDown") - bottom("imgArrowScrolbarMainTextUp") - crf*10*2 + "px";


			// large basket
			if (g("divBasketLargeContainer"))
			{
				// divBasketLargeDataDocument

				createScrollbar(
					"BasketLarge",
					"divBasketLargeData",
					"divBasketLargeDataDocument",
					rxpos("divBasketLargeContainer") + g("divBasketLargeContainer").offsetWidth + crf*10,
					0
				);
			}

			if (rq("pid") != null)
			{
				if (g("divMainTextButtonShowHide") && g("imgArrowScrolbarMainTextUp") && g("imgArrowScrolbarMainTextDown") && g("divMainText") && g("divMainTextDocument"))
				{
					g("imgArrowScrolbarMainTextUp").style.left = rxpos("divMainTextButtonShowHide") + g("divMainTextButtonShowHide").offsetWidth - crf*15 + "px";
					g("imgArrowScrolbarMainTextUp").style.top  = top("divMainTextDocument") + "px";

				
					//g("imgArrowScrolbarMainTextDown").style.left = left("imgArrowScrolbarMainTextUp") + "px";
					g("imgArrowScrolbarMainTextDown").style.left = rxpos("divMainTextButtonShowHide") + g("divMainTextButtonShowHide").offsetWidth - crf*15 + "px";
					g("imgArrowScrolbarMainTextDown").style.top  = bottom("divMainText") - crf*8 + "px";
			

					g("divScrollbarMainText").style.left = rxpos("imgArrowScrolbarMainTextUp") + g("imgArrowScrolbarMainTextUp").offsetWidth/2 + intSpace + "px";
					g("divScrollbarMainText").style.top    = bottom("imgArrowScrolbarMainTextUp") + crf*10 + "px";
					g("divScrollbarMainText").style.height = top("imgArrowScrolbarMainTextDown") - bottom("imgArrowScrolbarMainTextUp") - crf*10*2 + "px";

				}
			}

			if (rq("basket"))
			{
				//g("divMainText").style.backgroundColor = "#ff0000";
				g("divMainText").style.height = crf*85 + "px";
				g("divMainText").style.width  = crf*400 + "px";
				//g("divMainTextDocument").style.backgroundColor = "#00ff00";
				g("divMainTextDocument").style.width = 75 + "%";
				//g("imgArrowScrolbarMainTextUp").style.left = right("divMainTextButtonShowHide") - crf*15 + "px";
				//g("imgArrowScrolbarMainTextUp").style.top  = top("divMainTextDocument") + "px";
			}

			if (blnHideScrollbars == 0)
			{

				if (scrollerMainText == null) scrollerMainText = new textScroller(scrollerCount++);
				scrollerMainText.masterobj = 'divMainText';
				scrollerMainText.scrollerobj = 'divMainTextDocument';
				scrollerMainText.scrollbar = 'divScrollbarMainText';
				scrollerMainText.arrowobj = 'divScrollSliderMainText'; //fake shit
				scrollerMainText.scrollslider = 'divScrollSliderMainText';
				scrollerMainText.prepare();

				if (g("divMainTextDocument").scrollHeight < g("divMainText").offsetHeight || intPagetype == 0)
				{
					// hide scrollbar
					g("divScrollbarMainText").style.display         = "none";
					g("divScrollSliderMainText").style.display      = "none";
					g("imgArrowScrolbarMainTextUp").style.display   = "none";
					g("imgArrowScrolbarMainTextDown").style.display = "none";
				}

			}
		



	}

	if (g("divScrollbarBasketRelatedItems") && g("divScrollSliderBasketRelatedItems") && g("imgArrowScrolbarBasketRelatedItemsUp") && g("imgArrowScrolbarBasketRelatedItemsDown"))
	{
		if (g("divBasketRelatedItemsDocument").scrollHeight< g("divBasketRelatedItems").offsetHeight || intPagetype == 0)
		{
			// hide scrollbar
			g("divScrollbarBasketRelatedItems").style.display         = "none";
			g("divScrollSliderBasketRelatedItems").style.display      = "none";
			g("imgArrowScrolbarBasketRelatedItemsUp").style.display   = "none";
			g("imgArrowScrolbarBasketRelatedItemsDown").style.display = "none";
		} else {
			// setup scrollbar
			g("divScrollbarBasketRelatedItems").style.display         = "block";
			g("divScrollSliderBasketRelatedItems").style.display      = "block";
			g("imgArrowScrolbarBasketRelatedItemsUp").style.display   = "block";
			g("imgArrowScrolbarBasketRelatedItemsDown").style.display = "block";

			g("imgArrowScrolbarBasketRelatedItemsUp").style.left = rxpos("divBasketRelatedItems") + g("divBasketRelatedItems").offsetWidth + resvalue(10,8,10) + "px";
			g("imgArrowScrolbarBasketRelatedItemsUp").style.top  = top("divBasketRelatedItems") + "px";

			g("imgArrowScrolbarBasketRelatedItemsDown").style.left = rxpos("imgArrowScrolbarBasketRelatedItemsUp") + "px";
			g("imgArrowScrolbarBasketRelatedItemsDown").style.top  = bottom("divBasketRelatedItems") + "px";

			g("divScrollbarBasketRelatedItems").style.left   = rxpos("imgArrowScrolbarBasketRelatedItemsUp") + g("imgArrowScrolbarBasketRelatedItemsUp").offsetWidth/2 + intSpace + "px";
			g("divScrollbarBasketRelatedItems").style.top    = bottom("imgArrowScrolbarBasketRelatedItemsUp") + crf*10 + "px";
			g("divScrollbarBasketRelatedItems").style.height = top("imgArrowScrolbarBasketRelatedItemsDown") - bottom("imgArrowScrolbarBasketRelatedItemsUp") - crf*10*2 + "px";

			if (scrollerBasketRelatedItems == null)
			{
				scrollerBasketRelatedItems = new textScroller(scrollerCount++);
			}
//			scrollerBasketRelatedItems = new textScroller(scrollerCount++);
			scrollerBasketRelatedItems.masterobj = 'divBasketRelatedItems';
			scrollerBasketRelatedItems.scrollerobj = 'divBasketRelatedItemsDocument';
			scrollerBasketRelatedItems.scrollbar = 'divScrollbarBasketRelatedItems';
			scrollerBasketRelatedItems.arrowobj = 'divScrollSliderBasketRelatedItems'; //fake shit
			scrollerBasketRelatedItems.scrollslider = 'divScrollSliderBasketRelatedItems';
			scrollerBasketRelatedItems.prepare();
		}
	}
	
}

function setupFrontpageSlidingImages()
{




	/*
	for(i = 0, elm = document.getElementsByTagName("div"), len = elm.length; i < len; i++) if (elm[i].id != "image_container") elm[i].style.display = "none";

	for(i = 0, elm = document.getElementsByTagName("img"), len = elm.length; i < len; i++) if (elm[i].id != "image_container") elm[i].style.display = "none";

	for(i = 0, elm = document.getElementsByTagName("table"), len = elm.length; i < len; i++) if (elm[i].id != "image_container") elm[i].style.display = "none";
	*/


	if (2 == 3)
	{

		if (is_ie)
		{
			scrolling_images.initialize(document.getElementById("image_container"), 550);
			scrolling_images.addImage("http://test.danline/lyngenaturgoedningdk/img_fp/INT_img_fp__8_1.jpg", "index.asp", "slidingImage");
			scrolling_images.addImage("img/drw_02.jpg", "http://www.dr.dk/", "slidingImage");
			scrolling_images.addImage("img/drw_03.jpg", "http://www.dr.dk", "slidingImage");
			scrolling_images.addImage("img/drw_04.jpg", "http://www.dr.dk/", "slidingImage");
			scrolling_images.addImage("img/drw_05.jpg", "http://www.dr.dk/", "slidingImage");
			scrolling_images.start(75);
		} else {
			g("forFF").style.display = "block";
		}

	}
}


function showhideMainText()
{
	obj = g("divMainText");
	if (!obj) return;
	display = (obj.style.display == "none") ? "block": "none";

	// show/hide according to divMainText.style.display
	arrElements = "divMainText,imgArrowScrolbarMainTextUp,imgArrowScrolbarMainTextDown,divScrollbarMainText,divScrollSliderMainText,divMainTextQuantity";
	arrElements = arrElements.split(",");
	for(i = 0, len = arrElements.length; i < len; i++)
	{
		if ( g(arrElements[i]) )
		{
			if ( arrElements[i].toLowerCase().indexOf("scrol") > -1 )
			{
				if (display == "none")
				{
					g(arrElements[i]).style.display = display;
				} else {
					if (g("divMainTextDocument").offsetHeight > g("divMainText").offsetHeight)
					{
						g(arrElements[i]).style.display = display;
					}
				}
			} else {
				g(arrElements[i]).style.display = display;
			}
		}
	}

	obj = g("spanMainTextShowHide");
	if (obj) obj.innerHTML = ( display == "none" )?"Vis tekst":"Skjul tekst";

	obj = g("imgDotMainText");
	if (obj) obj.src = ( display =="none" )?"img/icon_dot_green_" + jsres + ".png":"img/icon_dot_orange_" + jsres + ".png";

	obj = g("divMainTextButtonShowHide");
	if (obj) obj.style.backgroundColor = (display == "none")? "transparent" : "#f6e6cf";

	obj = g("divGenericBackground");
	if (obj) obj.style.display = display;

//	obj = g("imgArrowScrolbarMainTextUp");
//	if (obj) obj.style.display = display;
	
//	obj = g("imgArrowScrolbarMainTextDown");
//	if (obj) obj.style.display = display;

//	obj = g("divScrollbarMainText");
//	if (obj) obj.style.display = display;

//	obj = g("divScrollSliderMainText");
//	if (obj) obj.style.display = display;

//	obj = g("divMainTextQuantity");
//	if (obj) obj.style.display = display;

}

function toggleBackgroundTabTopMenuGreen(obj,onoff,tooltip)
{

	if (is_firefox)
	{
		left	= obj.childNodes[0].childNodes[0].childNodes[1];
		middle	= obj.childNodes[0].childNodes[0].childNodes[3];
		right	= obj.childNodes[0].childNodes[0].childNodes[5];
	}

	if (is_ie)
	{
		left	= obj.childNodes[0].childNodes[0].childNodes[0];
		middle	= obj.childNodes[0].childNodes[0].childNodes[1];
		right	= obj.childNodes[0].childNodes[0].childNodes[2];
	}

	if (onoff == 1)
	{

		left.style.backgroundImage		= "url('img/tab_top_green_part_left_yellow_" + jsres + ".png')";
		middle.style.backgroundImage	= "url('img/tab_top_green_part_middle_yellow_" + jsres + ".png')";
		right.style.backgroundImage		= "url('img/tab_top_green_part_right_yellow_" + jsres + ".png')";
		
		var intExtra = 0;
		if (is_firefox)
		{
			if (is_firefox2) intExtra = resvalue(10,9,10);
			//if (is_firefox3) intExtra = resvalue(0,0,0);
		}

		if( tooltip != "")
		{
			g("divTooltip").style.display = "";
		} else {
			g("divTooltip").style.display = "none";
		}
		g("divTooltip").innerHTML = "- " + tooltip;
		g("divTooltip").style.left = rxposObj(obj) - intExtra + "px";

	} else {
		g("divTooltip").style.display = "none";

		left.style.backgroundImage		= "url('img/tab_top_green_part_left_green_" + jsres + ".png')";
		middle.style.backgroundImage	= "url('img/tab_top_green_part_middle_green_" + jsres + ".png')";
		right.style.backgroundImage		= "url('img/tab_top_green_part_right_green_" + jsres + ".png')";
	}
}

function toggleBackgroundTabTopMenuBrown(obj,onoff)
{
	if (is_firefox)
	{
		left	= obj.childNodes[0].childNodes[0].childNodes[1];
		middle	= obj.childNodes[0].childNodes[0].childNodes[3];
		right	= obj.childNodes[0].childNodes[0].childNodes[5];
	}

	if (is_ie)
	{
		left	= obj.childNodes[0].childNodes[0].childNodes[0];
		middle	= obj.childNodes[0].childNodes[0].childNodes[1];
		right	= obj.childNodes[0].childNodes[0].childNodes[2];
	}

	if (onoff == 1)
	{
		left.style.backgroundImage		= "url('img/tab_top_brown_part_left_yellow_" + jsres + ".png')";
		middle.style.backgroundImage	= "url('img/tab_top_brown_part_middle_yellow_" + jsres + ".png')";
		right.style.backgroundImage		= "url('img/tab_top_brown_part_right_yellow_" + jsres + ".png')";
		middle.getElementsByTagName("a")[0].style.color = "#562800";
	} else {
		left.style.backgroundImage		= "url('img/tab_top_brown_part_left_brown_" + jsres + ".png')";
		middle.style.backgroundImage	= "url('img/tab_top_brown_part_middle_brown_" + jsres + ".png')";
		right.style.backgroundImage		= "url('img/tab_top_brown_part_right_brown_" + jsres + ".png')";
		middle.getElementsByTagName("a")[0].style.color = "#ffffff";
	}
}


blnA = false;
function toggleBackgroundTabLeftBrown(obj,onoff,tabName)
{

	if (is_firefox)
	{
		left	= obj.childNodes[1].childNodes[0].childNodes[1];
		middle	= obj.childNodes[1].childNodes[0].childNodes[3];
		right	= obj.childNodes[1].childNodes[0].childNodes[5].childNodes[0];
	}

	if (is_ie)
	{
		left	= obj.childNodes[0].childNodes[0].childNodes[0];
		middle	= obj.childNodes[0].childNodes[0].childNodes[1];
		right	= obj.childNodes[0].childNodes[0].childNodes[2].childNodes[0];
	}

	if (onoff == 1)
	{
		left.style.backgroundImage		= "url('img/tab_left_brown_part_left_yellow_" + jsres + ".png')";
		middle.style.backgroundImage	= "url('img/tab_left_brown_part_middle_yellow_" + jsres + ".png')";
		right.setAttribute("src", "img/tab_left_brown_part_right_yellow_" + jsres + ".png");
		middle.childNodes[0].className = "lnk" + tabName + "Selected";
	} else {
		left.style.backgroundImage		= "url('img/tab_left_brown_part_left_brown_" + jsres + ".png')";
		middle.style.backgroundImage	= "url('img/tab_left_brown_part_middle_brown_" + jsres + ".png')";
		right.setAttribute("src", "img/tab_left_brown_part_right_brown_" + jsres + ".png");
		middle.childNodes[0].className = "lnk" + tabName;
	}
}

function preload_images()
{
	arrPreloadImages = new Array
	(
		"img/tab_top_green_part_left_yellow_"   + jsres + ".png",
		"img/tab_top_green_part_middle_yellow_" + jsres + ".png",
		"img/tab_top_green_part_right_yellow_"  + jsres + ".png"
	);

	for(i = 0, len = arrPreloadImages.length; i < len; i++)
	{
		m = new Image();
		m.setAttribute("src", arrPreloadImages[i]);
	}
}

function toggleBasketButton(obj)
{
	color = "";
	if (obj.style.backgroundImage == "url(img/button_orange_" + jsres + ".png)")
	{
		color = "green";
	} else {
		color = "orange";
	}
	obj.style.backgroundImage = "url('img/button_" + color + "_" + jsres + ".png')";
}

function highlightBackgroundColor(obj,color)
{
	if (obj && color)
	{
		obj.style.backgroundColor = color;
	}
}

function gotoLink(obj)
{

	if (obj)
	{
		if (obj.childNodes[0].tagName.toLowerCase() == "a") window.location.href = obj.childNodes[0].href;
	}
}

function showOverlay()
{
	g("divOverlay").style.visibility = "visible";
}

function hideZipCode()
{
	g("divOverlay").style.visibility = "hidden";
	g("divZipcode").style.display = "none";

}

function imagerotate(imgID, arr, direction)
{
	if ( g(imgID) && typeof(arr) != "undefined" && direction )
	{
		if (intImgGalleryIndexTemp == -1) intImgGalleryIndexTemp = intImgGalleryIndexStart;
		intImgGalleryIndexTemp = intImgGalleryIndexTemp + direction;

		if (intImgGalleryIndexTemp > arr.length - 1)
		{
			intImgGalleryIndexTemp = 0;
		} else if (intImgGalleryIndexTemp < 0)
		{
			intImgGalleryIndexTemp = arr.length-1;
		}
		g(imgID).src = arr[intImgGalleryIndexTemp];
		//document.title = intImgGalleryIndexTemp + ", " + arr[intImgGalleryIndexTemp];
	}
}

function fubar()
{
	f = document.getElementById("frmPayment");

	if (f)
	{
		el = f.elements;
		for(i = 0, len = el.length; i < el; i++)
		{
			if (el[i].type == "text")
			{
				el[i].text = i;
			}
		}
	}	
}





function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}


function validatePaymentForm(f)
{	

	// Postnummer tjek
	var zipIsNo = false
	zipIsNo = IsNumeric(f.tbxCustomerZipCode.value);
	if (!zipIsNo)
	{
	alert("Postnummer skal være et tal.");
	return false;		
	}


	// email tjek
	validate_email(f.tbxCustomerEmail,"Indtast venligst gyldig email.")
	if (f.chkUseDelivery.checked)
	{
	var emailOK = validate_email(f.tbxDeliveryCustomerEmail,"Indtast venligst gyldig email.")
	
		if (!emailOK){
		return false;
		}
	}


	// leveringsbetingelser tjek
	if (!f.chkConditions.checked)
	{
		alert("Du kan ikke fortsætte får du har accepteret salgs- og leveringsbetingelser.");
		return false;
	}

	// betalingsmetode tjek
	if (/*!f.rbtnPaymentMethod_1.checked && */!f.rbtnPaymentMethod_2.checked)
	{
		alert("Du har ikke valgt betalingsmetode.");
		return false;
	}

	// påkrævet tjek
	el = f.elements;

	//alert(f.tbxCustomerName.required);


	for (i = 0, len = el.length; i < len ; i++ )
	{
		if (el[i].value.length == 0 && el[i].name.indexOf("CompanyName") == -1 && el[i].name.indexOf("CustomerEmail") == -1 && el[i].name.indexOf("CustomerNote") == -1)
		{
			if (g("chkUseDelivery").checked && el[i].name.indexOf("Delivery") > -1)
			{
				alert("Udfylde venligst alle felter markeret med '(*)'");
				el[i].focus();
				return false;
			} else {
				if (el[i].name.indexOf("Delivery") == -1)
				{
					alert("Udfylde venligst alle felter markeret med '(*)'");
					el[i].focus();
					return false;
				}
			}
		}	
	}


	/*
	for(i = 0, len = el.length; i < len; i++)
	{
		c = el[i].parentNode.parentNode.childNodes[1].className.toLowerCase();
		if (c.indexOf("formpaymentrequired") > -1)
		{
			if (el[i].value.length == 0)
			{
				if (g("chkUseDelivery").checked && el[i].name.indexOf("Delivery") > -1)
				{
					alert("xUdfylde venligst alle felter markeret med '(*)'");
					return false;
				} else {
					if (el[i].name.indexOf("Delivery") == -1)
					{
						alert("Udfylde venligst alle felter markeret med '(*)', " + el[i].name);
						return false;
					}
				}
			}
		}
	}
	*/


	//return false; // --------------------------------- !!!!!!!!!!!
	return true;
}

function toggleFormElements(frm,chk,stat,word,deliveryZipcode)
{
	el = frm.elements;
	for(i=0,len=el.length;i<len;i++)
	{
		if (chk != null && el[i] != chk && el[i].name.indexOf(word) > -1) el[i].disabled = stat;
	}
	//JHA HOTFIX
	if(!stat){
		document.getElementById("tbxCustomerZipCode").readOnly = false;
	}
	else{
		document.getElementById("tbxCustomerZipCode").readOnly = true;
		document.getElementById("tbxCustomerZipCode").value = '' + deliveryZipcode;
	}
}

function calculatePrice()
{
	g("btnSubmitQuantity").disabled = false;
	strErrorMessage = "Fejl i indtastning";

	f = g("frmQuantity");
	if (f == null){ 
	
		g("btnSubmitQuantity").disabled = true;
		return;
	}
	
	q = "" + f.tbxQuantity.value;	
	q = q.replace(/ /gi,"");
	
	f.tbxQuantity.value = q;
	if (q.length == 0) {
		g("btnSubmitQuantity").disabled = true;
		return;
	}

	if ("" + q.substring(0,i) == "0")
	{
		alert(strErrorMessage + "\nAntal kan ikke starte med 0.");
		f.tbxQuantity.value = 1;
		return;
	}

    if (f.rbtnBasketTotalPrice[0].checked)
	{
		var grabCheckBox = g("chkGrab");
		if(grabCheckBox)
		{
		    grabCheckBox.disabled = true;
		    grabCheckBox.checked = false;
		}
	} else {
		
		var grabCheckBox = g("chkGrab");
		if(grabCheckBox)
		    grabCheckBox.disabled = false;
	}

	if (isNaN(q)) {
	
		g("btnSubmitQuantity").disabled = true;
		return;
	}
	
	if( parseFloat(q) > parseInt(q))
	{
		g("btnSubmitQuantity").disabled = true;
		return;
	}

	allowed = "1,2,3,4,5,6,7,8,9,0,";
	allowed = allowed.split(",");

	for(i = 0, len = q.length; i < len; i++)
	{
		blnDoContinue = false;
		cq = q.substring(i,1);
		for(j = 0, lenj = allowed.length; j < lenj; j++)
		{
			ca = allowed[j];
			if ("" + ca == "" + cq)
			{
				blnDoContinue = true;
				break;
			}
		}
		if (blnDoContinue == false)
		{
			alert(strErrorMessage);
			return;
		}
	}

	q = parseInt(q);
	priceForTruckLoads = 0;

	numberOfTruckLoads = 0;
	/* OLD - Before 24-09-2009
	if (f.chkGrab.checked)
	{

		numberOfTruckLoads = (q / intMaxDeliveryUnitPerTruck);
		if ( ("" + numberOfTruckLoads).indexOf(".") != -1)
		{
			s = "" + numberOfTruckLoads;
			digitLeft = s.substring(0, s.indexOf("."));
			digitRight = s.substring(s.indexOf(".")+1);
			if (digitLeft == 0)
			{
				digitLeft = 1;
				digitRight = 0;
			} else {
				digitRight = 1;
			}

			numberOfTruckLoads = parseInt(digitLeft) + parseInt(digitRight)
		}
	}

	g("basketPriceBigbag").innerHTML = (dblPricePerBigbagTotal * q) + " kr.";
	g("basketPriceTruck").innerHTML = (dblPricePerTruckTotal * q + (dblPriceGrab * numberOfTruckLoads) ) + " kr.&nbsp;&nbsp;";
    
    if (f.rbtnBasketTotalPrice[0].checked)
	{
		f.itemPrice.value = dblPricePerBigbagTotal;
		f.itemTotalPrice.value = dblPricePerBigbagTotal * q;
	} else {
		f.itemPrice.value = dblPricePerTruckTotal;
		f.itemTotalPrice.value = dblPricePerTruckTotal * q + (dblPriceGrab * numberOfTruckLoads);
	}
    */
    /***** START NEW *********************************/
    var totalTruckPrice = 0;
    
    numberOfTruckLoads = (q / intMaxDeliveryUnitPerTruck);
	if ( ("" + numberOfTruckLoads).indexOf(".") != -1)
	{
		s = "" + numberOfTruckLoads;
		digitLeft = s.substring(0, s.indexOf("."));
		digitRight = s.substring(s.indexOf(".")+1);
		if (digitLeft == 0)
		{
			digitLeft = 1;
			digitRight = 0;
		} else {
			digitRight = 1;
		}

		numberOfTruckLoads = parseInt(digitLeft) + parseInt(digitRight)
	}
	
	totalTruckPrice = 1.25 * ((dblPricePerTruck * q) + (dblPricePerTruckShipping * numberOfTruckLoads));
	
    if (f.chkGrab.checked)
	{
        totalTruckPrice += (dblPriceGrab * numberOfTruckLoads);	
	}//if

	g("basketPriceBigbag").innerHTML = (dblPricePerBigbagTotal * q) + " kr.";
	g("basketPriceTruck").innerHTML = totalTruckPrice + " kr.&nbsp;&nbsp;";
    
	if (f.rbtnBasketTotalPrice[0].checked)
	{
		f.itemPrice.value = dblPricePerBigbagTotal;
		f.itemTotalPrice.value = dblPricePerBigbagTotal * q;
	} else {
		f.itemPrice.value = dblPricePerTruck * 1.25;
		f.itemTotalPrice.value = totalTruckPrice;
	}
    /***** END NEW ***********************************/
}


/*
function basketMultiply(q, p, b, t)
{
	f = q.form;
	r = q.form.rbtnBasketTotalPrice;
	s = f.itemShippingModel;

	if ( q.value != "" && p && g(b) && g(t) && r && s)
	{
		intTrucks = Math.ceil ( (q.value / intMaxUnitsTruck) );

		dblPrice = intTrucks * dblShippingCost + (q.value * strItemPriceTruck)

		g(b).innerHTML = parseInt(q.value) * parseFloat( g(b).getAttribute("defvalue") ) ;
		//g(t).innerHTML = parseInt(q.value) * parseFloat( g(t).getAttribute("defvalue") ) ;

		g(t).innerHTML = dblPrice; //parseInt(q.value) * parseFloat( g(t).getAttribute("defvalue") ) ;
		
		if (r[0].checked)
		{
			f.itemTotalPrice.value = g(b).innerHTML;
			s.value = 0;
		} else {
			f.itemTotalPrice.value = g(t).innerHTML;
			s.value = 1;
		}
	}
}
*/

function validateFormZipcode(v)
{
	if (/^ *[0-9]+ *$/.test(v) == false)
	{
		alert("Ugyldigt postnummer");
		return false;
	} else {
		return true;
	}
}

function CheckIfItemThumbnailsNeedScroller()
{
	//return;
	/**/
	if ( g("imgImageBottomArrowLeft") && g("imgImageBottomArrowRight") && g("divBoxGreenBottomScroller") )
	{
		obj = g("divBoxGreenBottomScroller").getElementsByTagName("table");
		if (obj)
		{
			obj = obj[0].getElementsByTagName("a");
			//g("imgImageBottomArrowLeft").style.display = "none";
			if (obj.length < 6)
			{
				// hide arrows:
				g("imgImageBottomArrowLeft").style.display = "none";
				g("imgImageBottomArrowRight").style.display = "none";
			}
		}
	}
	/**/
}

function getElementWidth(element)
{
	if (element.style.pixelWidth) {
		return element.style.pixelWidth;
	} else {
		return element.offsetWidth;
	}
}

intBoxGreenBottomScrollerX = 0;
intBoxGreenBottomScrollerStartX = -999;
var intBoxGreenBottomScrollerPointer = 0;
function scrollThumbnailsBoxGreenBottom(dir)
{
	if (intBoxGreenBottomScrollerStartX == -999) intBoxGreenBottomScrollerStartX = rxpos("divBoxGreenBottomScroller");

	blnDoMove = true;
	intMoveBy = resvalue(107+9,133+10,167+12);

	if (dir == -1)
	{
		//if ( rxpos("divBoxGreenBottomScroller") + (intBoxGreenBottomScrollerX + intMoveBy*dir) < intMoveBy) //TODO...REDO
		if(intBoxGreenBottomScrollerPointer >= intGreenBottomScrollerImageCount - 5)
			blnDoMove = false;
		else
			intBoxGreenBottomScrollerPointer = intBoxGreenBottomScrollerPointer + 1;
	
	} else {
		
		//if ( rxpos("divBoxGreenBottomScroller") == intBoxGreenBottomScrollerStartX) ////TODO...REDO
		if(intBoxGreenBottomScrollerPointer == 0 )
			blnDoMove = false;
		else
			intBoxGreenBottomScrollerPointer = intBoxGreenBottomScrollerPointer - 1;
	}
	
	if (blnDoMove)
	{
		intBoxGreenBottomScrollerX += intMoveBy*dir;
		g("divBoxGreenBottomScroller").style.left = intBoxGreenBottomScrollerX + "px";
	}
	

	if (dir == -1)
	{
		if ( rxpos("divBoxGreenBottomScroller") + (intBoxGreenBottomScrollerX + intMoveBy*dir) < intMoveBy)
		{
			//g("imgImageBottomArrowLeft").style.display = "block";
			//g("imgImageBottomArrowRight").style.display = "none";
		}
	} else {
		if ( rxpos("divBoxGreenBottomScroller") == intBoxGreenBottomScrollerStartX)
		{
			//g("imgImageBottomArrowLeft").style.display = "none";
			//g("imgImageBottomArrowRight").style.display = "block";
		}
	}


}

function submitForm(frm)
{
	if (typeof(frm) == "string") frm = g(frm);
	frm.submit();
}

function setBackgroundColor(obj,color)
{
	if (typeof(obj) == "string") obj = g(obj)
	if (obj)
	{
		if (color.substring(0,1) != "#") color = "#" + color;
		obj.style.backgroundColor = color;
	}
}

function doPrint()
{
	//alert("printing...");

	strTitle = "Lynge Naturgødning";
	strContents = g("divMainTextDocument").innerHTML;
	strMainTop = "";
	strImageMini = "";

	switch (intPagetype)
	{
		case 0:
			// frontpage: Text only (bottom center) ?
			strTitle = "Velkommen til Lynge Naturgødning";
		break;
		
		case 1:
			// layout (article): text
			
		break;
		
		case 2:
			
			strImageTop = "";
			if (rq("basket"))
			{
				// tblBasketLargeData
				strTitle = "Indkøbskurven - Lynge Naturgødning";
				strContents = g("divMainTextDocument").innerHTML;
				g("printbasket").value = "1";
			} else {
				if (rq("item"))
				{
					///strImageTop = "" + g("imgGallery").getAttribute("src");
					


					strTmpImageTop = g("imgGallery").getAttribute("src"); //"http://test.danline/lyngenaturgoedningdk/dnmShop/img_prod/flis_pic2_7.jpg";
					if (strTmpImageTop.indexOf("_") != -1)
					{
						strImageTop = strTmpImageTop;
						strImageTop = strImageTop.substring(0, strImageTop.lastIndexOf("_") + 1)
						strImageTop = strImageTop + "8.";
						strImageTop = strImageTop + strTmpImageTop.substring(strTmpImageTop.lastIndexOf(".") + 1)
					}

					strTmpImageMini = "http://test.danline/lyngenaturgoedningdk/dnmShop/img_prod/DSCN0110.JPG_5.jpg";
					if (strTmpImageMini.indexOf("_") != -1)
					{
						strImageMini = strTmpImageMini;
						strImageMini = strImageMini.substring(0, strImageMini.lastIndexOf("_") + 1)
						strImageMini = strImageMini + "3.";
						strImageMini = strImageMini + strTmpImageMini.substring(strTmpImageMini.lastIndexOf(".") + 1)
					}
					
					// flis_pic2_6.jpg

					//alert(strImageMini);
					//return false;
					
					

					// image top, mini-preview below left, text below right:
					strContents =  '<div style="text-align: center"><img src="' + strImageTop + '" style=" width: 100%;"></div><br><br>';
					strContents += '<img src="' + strImageMini + '" style="float: right; margin-left: 30px; margin-bottom: 15px;">' + g("divMainTextDocument").innerHTML;
					// g("divMainTextDocument").innerHTML
					// imgMiniProductPreview
				} else {
					// image top, text below:
					strContents = '<div style="text-align: center"><img src="' + strImageTop + '"></div><br><br>' + strContents;
				}
				//alert(strContents);
			}

		break;
	}

	g("printtitle").value = strTitle;
	g("printcontents").value = strContents;
	//alert("strContents: *" + strContents + "*");
	g("frmPrint").submit();

	//alert("print done");

}

function winTC(url)
{
	w = window.open(url, "w", "width=" + crf*500 + ",height=" + crf*400);
}

function toggleDotImage(td,onoff)
{
	if (g("divMainText").style.display == "none") onoff = (onoff == 1)?0:1;
	img = td.childNodes[2];
	img.setAttribute('src', 'img/icon_dot_' + ( (onoff == 1)?'green':'orange') + '_' + jsres + '.png');
}