
function window_onscroll()
{if(ctrlToShow)
{var offsetTop=document.documentElement.clientHeight-(document.documentElement.clientHeight/2)-(ctrlToShow.offsetHeight/2);var offsetLeft=document.documentElement.clientWidth-(document.documentElement.clientWidth/2)-(ctrlToShow.offsetWidth/2);document.getElementById('backgroundBlanket').style.top=document.documentElement.scrollTop;ctrlToShow.style.top=document.documentElement.scrollTop+offsetTop;ctrlToShow.style.left=offsetLeft;}
if(document.getElementById('backgroundBlanket').style.display=='block')
{var offsetTop=document.documentElement.clientHeight-(document.documentElement.clientHeight/2)-(ctrlToShow.offsetHeight/2);var offsetLeft=document.documentElement.clientWidth-(document.documentElement.clientWidth/2)-(ctrlToShow.offsetWidth/2);document.getElementById('backgroundBlanket').style.top=document.documentElement.scrollTop;ctrlToShow.style.top=document.documentElement.scrollTop+offsetTop;ctrlToShow.style.left=offsetLeft;}}
var mode=0;function getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
return[pageWidth,pageHeight];}
var searchString='';var cover=false;function performSearch(){var elem=document.getElementById('query');if(elem.value==searchString){if(mode==0){RunSearch(elem);}
else{RunThumbSearch(elem);}}}
function checkCancel(elem){var isIE=(navigator.appName=="Microsoft Internet Explorer");var IEversion=navigator.appVersion;if(isIE){IEversion=parseInt(IEversion.substr(IEversion.indexOf("MSIE")+4));}else{IEversion=8;}
if(IEversion>8)
{if(elem.value.length>0){if(cover==false){var arrayPageSize=getPageSize();document.getElementById('overlay').style.width=arrayPageSize[0]+'px';document.getElementById('overlay').style.height=arrayPageSize[1]+'px';document.getElementById('overlay').style.display='block';document.getElementById('searchresults').style.display='block';document.getElementById('reset_search').className='bps-header-search-reset';cover=true;}
clearResult();document.getElementById('searchLoading').style.display='block';searchString=elem.value;setTimeout(performSearch,500);}
else{if(cover==true){hideAll();}}}}
function thumbnailView(elem){standard=false;thumb=true;document.getElementById('tabbackground').src='/images/tab2.png';clearResult();mode=1;document.getElementById('searchLoading').style.display='block';RunThumbSearch();}
function StandardView(elem){standard=true;thumb=false;document.getElementById('tabbackground').src='/images/tab1.png';clearResult();mode=0;document.getElementById('searchLoading').style.display='block';RunSearch();}
function hideAll()
{if(document.getElementById('overlay').style.display!='none')
{document.getElementById('searchresults').style.display='none';document.getElementById('overlay').style.display='none';document.getElementById('reset_search').className='bps-header-search-right';cover=false;setTimeout(clearScreen,400);}}
function clearScreen()
{document.getElementById('overlay').style.display='none';}
function LoadResults(res)
{document.getElementById('searchLoading').style.display='none';Results=res;showResult(res);}
function clearResult(res)
{while(document.getElementById('searchresultitems').childNodes.length>=2){if(document.getElementById('searchresultitems').firstChild.id=='searchLoadingWapper')
{document.getElementById('searchresultitems').removeChild(document.getElementById('searchresultitems').lastChild);}
else
{document.getElementById('searchresultitems').removeChild(document.getElementById('searchresultitems').firstChild);}
count=0;}}
var timer;var count=0;var Results;var colCount=0;var rowCount=0;var thumbtable;function LoadThumbResults(res){document.getElementById('searchLoading').style.display='none';clearResult();Results=res;thumbtable=document.createElement("table");var tr;var td;colCount=0;rowCount=0;thumbtable.style.cellSpacing='1';thumbtable.style.cellPadding='1';thumbtable.style.fontSize='1.2em';thumbtable.style.fontWeight='1.2em';thumbtable.style.width='100%';for(i=0;i<4;i++){tr=document.createElement("tr");for(p=0;p<5;p++){td=document.createElement("td");td.style.width='100px';td.style.height='110px';td.style.textAlign='center';tr.appendChild(td);}
thumbtable.appendChild(tr);}
document.getElementById('searchresultitems').appendChild(thumbtable);showThumbResults(res);}
function showThumbResults(res){if(thumb){if(count<Results.length){objResult=eval('('+Results[count]+')');var td=thumbtable.childNodes[rowCount].childNodes[colCount];td.vAlign='Top';var div=document.createElement("div");div.style.height='100px';div.style.width='100px';div.id='prod'+objResult.mintId;var a=document.createElement("a");a.href='/default.aspx/Page/97/Product/'+objResult.mintId;a.style.position='relative';a.style.display='block';a.style.height='100px';a.style.width='100px';a.style.color='#000';a.style.padding='5px';a.style.borderBottom='2px solid #fff';a.style.borderLeft='2px solid #fff';a.style.borderTop='2px solid #fff';a.style.borderRight='2px solid #fff';a.style.fontWeight='bold';a.style.fontSize='0.7em';var d=document.createElement("div");d.style.height="100px";d.style.width="100px";d.style.textAlign='center';d.className='box';d.style.display="none";var s=document.createElement("div");s.style.padding="0.5em";s.innerHTML=objResult.mstrName;s.style.fontWeight='bold';d.appendChild(s);s=document.createElement("div");s.style.paddingLeft="0.5em";s.style.paddingRight="0.5em";s.innerHTML='£'+objResult.mstrPrice;s.style.fontWeight='bold';d.appendChild(s);a.appendChild(d);a.onmouseout=function(){};a.onmouseover=function(){};div.appendChild(a);var img=document.createElement("img");img.align='top';img.src="/Applications/SharedControls/ImageServe.aspx?Id="+objResult.mintImageId+"&h=100&w=100";img.style.border='0px';img.alt=" ";a.appendChild(img);a.onmouseout=function(){d.style.display='none';img.style.display='block';};a.onmouseover=function(){img.style.display='none';d.style.display='block';};colCount+=1;if(colCount==5){colCount=0;rowCount+=1;}
td.appendChild(div);div.style.display='none';div.style.display='block';count+=1;if(count<Results.length){setTimeout(showThumbResults,100);}}}}
var standard=true;var thumb=false;function showResult(res){if(standard){if(count<Results.length){objResult=eval('('+Results[count]+')');var div=document.createElement("div");div.style.height='75px';div.style.borderBottom='1px dotted #bbb';div.id='prod'+objResult.mintId;var a=document.createElement("a");a.href='/default.aspx/Page/97/Product/'+objResult.mintId;a.style.position='relative';a.style.display='block';a.style.height='65px';a.style.color='#000';a.style.padding='5px';a.style.fontWeight='bold';a.style.fontSize='0.6em';a.onmouseout=function(){this.style.background='#fff';};a.onmouseover=function(){this.style.background='lightyellow';};var table=document.createElement("table");var tr=document.createElement("tr");var td=document.createElement("td");td.style.width='60px';table.style.cellSpacing='1';table.style.cellPadding='1';table.style.fontSize='1.2em';table.style.fontWeight='1.2em';table.style.width='100%';td.rowSpan="4";var img=document.createElement("img");img.align='top';img.src="/Applications/SharedControls/ImageServe.aspx?Id="+objResult.mintImageId+"&h=60&w=60";img.style.border='0px';td.appendChild(img);tr.appendChild(td);td=document.createElement("td");td.innerHTML=objResult.mstrName;tr.appendChild(td);td=document.createElement("td");td.style.width='165px';td.align='right';td.innerHTML='£'+objResult.mstrPrice;tr.appendChild(td);table.appendChild(tr);tr=document.createElement("tr");td=document.createElement("td");td.style.fontWeight='normal';td.style.fontSize='0.8em';td.rowSpan='2';td.vAlign='Top';td.innerHTML=objResult.mstrDesc;tr.appendChild(td);td=document.createElement("td");td.align='right';td.innerHTML='In Stock';img=document.createElement("img");img.src='/images/instock.gif';img.style.border='0px';img.align='absmiddle';img.style.marginLeft='0.5em';td.appendChild(img);tr.appendChild(td);table.appendChild(tr);tr=document.createElement("tr");td=document.createElement("td");td.align='right';img=document.createElement("img");img.src='/images/addtocart.gif';img.style.border='0px';tr.appendChild(td);table.appendChild(tr);a.appendChild(table);div.appendChild(a);div.style.display='none';document.getElementById('searchresultitems').appendChild(div);div.style.display='block';count+=1;if(count<Results.length){a=setTimeout(showResult,100);}
else
{a=null;}}}}
var a;function DisplayProduct(elem)
{GreenStore.EcommerceService.GetProduct(elem.parentNode.id.replace('prod',''),LoadProduct);}
function LoadProduct(res)
{objResult=eval('('+res+')');}
function RunThumbSearch(elem){GreenStore.EcommerceService.GetProducts(document.getElementById('query').value,LoadThumbResults);}
function RunSearch(elem)
{GreenStore.EcommerceService.GetProducts(document.getElementById('query').value,LoadResults);}
IE4=document.all;function newConfirm(title,mess,icon,defbut,mods){if(IE4){icon=(icon==0)?0:2;defbut=(defbut==0)?0:1;retVal=makeMsgBox(title,mess,icon,4,defbut,mods);retVal=(retVal==6);}
else{retVal=confirm(mess);}
return retVal;}
var rowColor=null;var browserName=navigator.appName;function showWindow(url){if(browserName=="Netscape")
{window.open(url,"Link","toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1");}
else
{if(browserName=="Microsoft Internet Explorer")
{window.open(url,"Link","toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1");}}}
function showControlledWindow(url){if(browserName=="Netscape")
{window.open(url,"Link","toolbar=0,location=0,height=600,width=800,directories=0,status=1,menubar=0,scrollbars=1,resizable=1");}
else
{if(browserName=="Microsoft Internet Explorer")
{window.open(url,"Link","toolbar=0,height=600,width=800,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1");}}}
var pageTracker=_gat._getTracker("UA-1772677-1");pageTracker._initData();pageTracker._trackPageview();









function LookupPostCode(strPostCode)
{
var loading=document.getElementById('postcodeLoading');
loading.style.visibility='visible';
GreenStore.EcommerceService.LookupPostCode(strPostCode,PostCodeReturned);
}

function PostCodeReturned(res)
{
var loading=document.getElementById('postcodeLoading');
loading.style.visibility='hidden';
var objResult;
var cell=document.getElementById('lstAddresses');
if(cell.hasChildNodes())
{
while(cell.childNodes.length>=1)
{
cell.removeChild(cell.firstChild);
}
}
if(res.length>0)
{
document.getElementById('lstAddresses').options[document.getElementById('lstAddresses').options.length]=new Option(res.length+" Addresses Found. Please Select...","-1");
}
else
{
document.getElementById('lstAddresses').options[document.getElementById('lstAddresses').options.length]=new Option("No Addresses Found! Check the Postcode","-1");
}
for(i=0;i<res.length;i++)
{
objResult=eval('('+res[i]+')');
document.getElementById('lstAddresses').options[document.getElementById('lstAddresses').options.length]=new Option(objResult.nameField,objResult.idField);
}
document.getElementById('lstAddresses').style.display='block';
}

function GetAddress(strAddressId)
{
var loading=document.getElementById('postcodeLoading');
if(strAddressId!="-1")
{
loading.style.visibility='visible';
GreenStore.EcommerceService.GetAddressResult(strAddressId,AddressReturned);
}
}

function AddressReturned(res)
{
var loading=document.getElementById('postcodeLoading');
loading.style.visibility='hidden';
var objResult;for(i=0;i<res.length;i++)
{
objResult=eval('('+res[i]+')');
var currentControl;
currentControl=txtOrganisation;
if(objResult.organisationNameField.length>0)
{
currentControl.value=objResult.organisationNameField;currentControl=txthouseNameNo;
}

if(objResult.buildingNumberField!="0")
{
currentControl.value=objResult.buildingNameField+" "+objResult.buildingNumberField+' '+objResult.streetField;
}
else
{
currentControl.value=objResult.buildingNameField+' '+objResult.streetField;
currentControl=txtStreet;
}
txtStreet=objResult.areaField;
txtTown.value=objResult.townField;
txtCounty.value=objResult.countyField;
txtPostCode.value=objResult.postCodeField;
document.getElementById('lstAddresses').style.display='none';
validateForm();
}
}








txtTracking.setAttribute("autocomplete","off");document.getElementById("query").onkeydown=function(e){var e=window.event||e
var keyunicode=e.charCode||e.keyCode
return(keyunicode>=65&&keyunicode<=122||keyunicode==8||keyunicode==32)}
document.getElementById('query').setAttribute("autocomplete","off");










function PanelToggle(elem)
{
    var toggle;
    toggle=document.getElementById(elem+'Toggle');
    if(document.getElementById(elem).style.display=='none')
    {
        document.getElementById(elem).style.display='block';
       // document.getElementById(elem).show("normal");
        if(toggle)
        {
            toggle.src='/images/collapse.png';toggle.alt='Expand';
        }
    }
    else
    {
    
  //  document.getElementById(elem).hide();
       document.getElementById(elem).style.display='none';
        if(toggle)
        {
            toggle.src='/images/Expand.png';toggle.alt='Collapse';
        }
    }
}



function ProcessClick(e)
{

if (!e) e = window.event;

   if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

  if (e)
  { 
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mousex = e.pageX;
      mousey = e.pageY;
 
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      // Note: I am adding together both the "body" and "documentElement" scroll positions
      //       this lets me cover for the quirks that happen based on the "doctype" of the html page.
      //         (example: IE6 in compatibility mode or strict)
      //       Based on the different ways that IE,FF,Moz,Opera use these ScrollValues for body and documentElement
      //       it looks like they will fill EITHER ONE SCROLL VALUE OR THE OTHER, NOT BOTH 
      //         (from info at http://www.quirksmode.org/js/doctypes.html)
      mousex = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
      mousey = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;

    }
  }

if (typeof mousex != 'undefined')
{

//GreenStore.EcommerceService.TrackClick(mousex,mousey,document.getElementById('VisitorId').value,window.location);
GreenStore.EcommerceService.TrackClick(mousex- document.getElementById('wrapper').offsetLeft,mousey,document.getElementById('VisitorId').value,window.location.href,screen.width,screen.height);
}

}


    document.onmousedown=ProcessClick;
    