/* Copyright (C) 2010 tagfire.com */
if(top!=self){top.location.href=self.location.href}curCar=0;function pop(a,b,c){var d="new_wnd";var e=1;var f=0;var g=0;var h=0;if(screen){g=(screen.width/2)-(b/2);h=(screen.height/2)-(c/2)}var i=window.open("/pop.html?"+a,d,"height="+c+",width="+b+",status=0,toolbar=0,resizable="+e+",scrollbars="+f+",menubar=0,location=0,directories=0,left="+g+",top="+h+"")}function showStock(a,b,c){var d="new_wnd";var e=1;var f=0;var g=0;var h=0;if(screen){g=(screen.width/2)-(b/2);h=(screen.height/2)-(c/2)}var i=window.open("/stockpop.php?s="+a,d,"height="+c+",width="+b+",status=0,toolbar=0,resizable="+e+",scrollbars="+f+",menubar=0,location=0,directories=0,left="+g+",top="+h+"")}function formatCurrency(a){var b=new RegExp("(-?[0-9]+)([0-9]{3})");a=a.toString().replace(/\,/g,"");a=!isNaN(a)?Math.round(a*100)/100:0;while(/\.\d{0,1}$/.test(a)){a+="0"}while(b.test(a)){a=a.toString().replace(b,"$1,$2")}return a}function calc(){var a=document.getElementById("fields").value.split(",");var b=parseFloat(document.getElementById("baseprice").value);for(var i=0;i<a.length;i++){if(document.getElementById(a[i]).checked){b=b+parseFloat(document.getElementById(a[i]).value)}}document.getElementById("total").innerHTML="&pound;"+formatCurrency(b)}function calc2(){var a=document.getElementById("fields").value.split(",");var b=parseFloat(document.getElementById("baseprice").value);for(var i=0;i<a.length;i++){if(document.getElementById(a[i]).checked){b=b+parseFloat(document.getElementById(a[i]).value)}}document.getElementById("total").innerHTML="&pound;"+formatCurrency2(b)}function formatCurrency2(a){var b=new RegExp("(-?[0-9]+)([0-9]{3})");a=a.toString().replace(/\,/g,"");a=!isNaN(a)?Math.round(a*100)/100:0;a.toString().indexOf(".")==-1?a+=".00":void 0;while(/\.\d{0,1}$/.test(a)){a+="0"}while(b.test(a)){a=a.toString().replace(b,"$1,$2")}return a}function clearField(a,b){if(document.getElementById(a).value==b){document.getElementById(a).value=""}}function leaveField(a,b){if(document.getElementById(a).value==""){document.getElementById(a).value=b}}function listFind(a,b){var c=a.split(",");var d=false;for(var i=0;i<c.length;i++){if(c[i]==b){d=true}}return d}function DisplayMainCover(){var a=document.getElementById("cover");var b=(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;a.style.width=Math.max(b.scrollWidth,b.clientWidth,document.scrollWidth||0)-1+"px";a.style.height=Math.max(b.scrollHeight,b.clientHeight,document.scrollHeight||0)-1+"px";var c=document.getElementById("covercontent");c.style.top="-99999px";c.style.left="-999999px";a.style.display="block";document.getElementById("coverhorizon").style.display="block";var d=getPageSize();var e=getScrollPos();var f=getElementSize(c);var x=Math.round((d.width-f.width)/2+e.scrollX);var y=Math.round((d.height-f.height)/2+e.scrollY);if(c.offsetLeft){x-=c.offsetLeft}if(c.offsetTop){y-=c.offsetTop}if(c.style.left){x+=parseInt(c.style.left)}if(c.style.top){y+=parseInt(c.style.top)}x-=10;c.style.top=y+"px";c.style.left=x+"px"}function getPageSize(){return {width:window.innerWidth||(document.documentElement&&document.documentElement.clientWidth)||document.body.clientWidth,height:window.innerHeight||(document.documentElement&&document.documentElement.clientHeight)||document.body.clientHeight}}function getScrollPos(){var a=document.documentElement;return {scrollX:document.body.scrollLeft||window.pageXOffset||(a&&a.scrollLeft),scrollY:document.body.scrollTop||window.pageYOffset||(a&&a.scrollTop)}}function getElementSize(a){return {width:a.offsetWidth||a.style.pixelWidth,height:a.offsetHeight||a.style.pixelHeight}}function closeCover(){document.getElementById("cover").style.display="none";document.getElementById("coverhorizon").style.display="none"}function getOptionIdx(a){var b=0;for(var i=0;i<data.length;i++){if(data[i]["optionid"]==a){b=i;break}}return b}function buildMsg(a,b){var c=a;if(c.length){c=c+"<br />"}c=c+b;return c}function config(a){var b=getOptionIdx(a);var c=data[b]["exclusions"];var d=data[b]["inclusions"];var e=c?c.split(","):null;var f=d?d.split(","):null;var g=parseFloat(document.getElementById("baseprice").value);var h="";var i="";var j="";var k="";var l="";if(c){for(var m=0;m<e.length;m++){if(document.getElementById("opt"+e[m]).checked&&document.getElementById("opt"+a).checked){document.getElementById("opt"+e[m]).checked=false;h=buildMsg(h,data[getOptionIdx(e[m])]["optionname"])}}}for(var m=0;m<data.length;m++){if(data[m]["inclusions"]&&listFind(data[m]["inclusions"],a)&&document.getElementById("opt"+data[m]["optionid"]).checked){document.getElementById("opt"+data[m]["optionid"]).checked=false;h=buildMsg(h,data[m]["optionname"])}}if(d){for(var m=0;m<f.length;m++){if(!document.getElementById("opt"+f[m]).checked&&document.getElementById("opt"+a).checked){document.getElementById("opt"+f[m]).checked=true;i=buildMsg(i,data[getOptionIdx(f[m])]["optionname"])}}}for(var m=0;m<data.length;m++){if(data[m]["exclusions"]&&document.getElementById("opt"+data[m]["optionid"]).checked){if(l.length){l=l+","}l=l+data[m]["exclusions"]}}if(combos){for(var m=0;m<combos.length;m++){comboOptionsSelected=0;for(var n=0;n<combos[m].length;n++){if(document.getElementById("opt"+combos[m][n]).checked){comboOptionsSelected++}else{unselectedComboOption=combos[m][n]}}if(comboOptionsSelected==combos[m].length-1){document.getElementById("opt"+unselectedComboOption).checked=false;if(l.length){l=l+","}l=l+unselectedComboOption}if(comboOptionsSelected==combos[m].length){for(var n=0;n<combos[m].length;n++){j=buildMsg(j,data[getOptionIdx(combos[m][n])]["optionname"])}}}}for(var m=0;m<data.length;m++){if(listFind(l,data[m]["optionid"])){greyout(data[m]["optionid"])}else{ungreyout(data[m]["optionid"])}}for(var m=0;m<data.length;m++){if(document.getElementById("opt"+data[m]["optionid"]).checked){g=g+parseFloat(document.getElementById("opt"+data[m]["optionid"]).value)}}if(h.length){k="The following options were deselected automatically:<br /><br />"+h}if(i.length){if(k.length){k=k+"<br /><br />"}k=k+"The following options were selected automatically:<br /><br />"+i}if(j.length){if(k.length){k=k+"<br /><br />"}k=k+"The following combination of options is not available - please amend your selection:<br /><br />"+j}if(k.length){showInfo(k)}document.getElementById("total").innerHTML="&pound;"+formatCurrency(g)}function greyout(a){document.getElementById("lbl"+a).className="greyed";document.getElementById("prc"+a).className="greyed"}function ungreyout(a){document.getElementById("lbl"+a).className="";document.getElementById("prc"+a).className=""}function showInfo(a){a="<p>"+a+"</p>";a=a+'<input type="button" name="closebutton" id="closebutton" value="Continue" onclick="closeCover();" />';document.getElementById("covercontent").innerHTML=a;DisplayMainCover();document.getElementById("closebutton").focus()}
