var myPC="";var myDiv=null;var res="";var lightBoxTimeOut=1000;var xpart;var lbDiv=null;var lbLocation="";var timer1=null;var listenerDone=false;var safetoclose=false;var thisUrl=document.domain;if(thisUrl==""){thisUrl=parent.window.location.href}if(thisUrl.search("IIS")==-1){thisUrl="http://www.brightminds.co.uk"}else{thisUrl="http://www.brightminds.co.uk"}function mouseX(c){if(c.pageX){return c.pageX}else{if(c.clientX){return c.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft)}else{return null}}}function mouseY(c){if(c.pageY){return c.pageY}else{if(c.clientY){return c.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)}else{return null}}}function inLightBox(g){if(document.layers){var f=g.pageX;var d=g.pageY;var c=document.layers.lbDiv;if((f>c.left)&&(f<c.left+c.clip.width)&&(d>c.top)&&(d<c.top+c.clip.height)){return true}}else{if(document.all){var c=window.event.srcElement;while(c.parentElement!=null){if(c.id=="lbDiv"){return true}c=c.parentElement}}else{if(document.getElementById){var c=g.originalTarget;while(c.parentNode!=null){if(c.id=="lbDiv"){return true}c=c.parentNode}}}}}function tryHideLightBox(c){if(safetoclose&&!inLightBox(c)){lightBoxClose()}}function attachListener(){if(document.layers){document.captureEvents(Event.MOUSEUP)}window.oldOMU=document.onmousedown;if(window.oldOMU!=null){document.onmousedown=new Function("window.oldOMU(); tryHideLightBox();")}else{document.onmousedown=tryHideLightBox}}function lightBoxClose(){safetolcose=false;clearTimeout(timer1);lbDiv.style.display="none";if(lbLocation!=""){location=lbLocation}if((lbLocation=="")&&(ajaxRefresh!="")){location=ajaxRefresh}}function createLightBox(){if(lbDiv==null){lbDiv=document.createElement("div");lbDiv.setAttribute("id","lbDiv");lbDiv.setAttribute("name","lbDiv");lbDiv.className="lightBox";lbDiv.position="absolute";lbDiv.innerHTML="<div></div>";document.body.appendChild(lbDiv);attachListener()}}function showLightBox(f,d,e){safetoclose=false;createLightBox();el=lbDiv;el.className="lightBox";el.position="absolute";el.innerHTML='<div id="lightBoxC"><div id="lightBoxCpic"><div id="lbTxtHolder"><div id="lbTxtT">Adding...</div><div id="lbTxt">'+f+'</div><div id="lbTxtB">to your Basket</div><div id="lbTxtS"></div></div></div></div><div id="lightBoxR"></div><div id="lightBoxB"></div>';if(e){document.getElementById("lightBoxCpic").style.backgroundImage="url('http://www.brightminds.co.uk/products/images/small/"+e+".jpg')"}x=mouseX(d)-318;y=mouseY(d)-100;w=320;h=200;sw=-1;if(self.innerWidth){sw=self.innerWidth}else{if(document.documentElement&&document.documentElement.clientWidth){sw=document.documentElement.clientWidth}else{if(document.body){sw=document.body.clientWidth}}}wmin=(document.documentElement.scrollLeft?document.documentElement.scrollLeft:0);sw=sw+wmin;sh=-1;if(self.innerHeight){sh=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){sh=document.documentElement.clientHeight}else{if(document.body){sh=document.body.clientHeight}}}hmin=(document.documentElement.scrollTop?document.documentElement.scrollTop:0);sh=sh+hmin;if((sw>-1)){if(x<0){x=0}if((x+w)>sw-10){x=sw-w-10}}if((sh>-1)){if(y<0){y=0}if((y+h)>sh-10){y=sh-h-10}}if(x<wmin){x=wmin}if(y<hmin){y=hmin}el.style.left=x+"px";el.style.top=y+"px";el.style.display="block";clearTimeout(timer1)}function showAjaxErrorBox(d){createLightBox();safetolcose=false;clearTimeout(timer1);lbDiv.style.display="none";el=lbDiv;el.className="ajaxErrorBox";el.position="absolute";el.style.display="block";el.innerHTML='<div id="ajaxErrorBoxC"><div id="ajeb_heading">Please note:</div><div id="ajeb_body"><ul>'+d+'</ul></div><div id="ajeb_footer"><a href="javascript:lightBoxClose();"> Close Message Box</a></div></div>';x=10;y=10;w=el.offsetWidth;h=el.offsetHeight;w=document.getElementById("ajeb_body").offsetWidth+2;el.style.width=w;sw=-1;if(self.innerWidth){sw=self.innerWidth}else{if(document.documentElement&&document.documentElement.clientWidth){sw=document.documentElement.clientWidth}else{if(document.body){sw=document.body.clientWidth}}}wmin=(document.documentElement.scrollLeft?document.documentElement.scrollLeft:0);sw=sw+wmin;sh=-1;if(self.innerHeight){sh=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){sh=document.documentElement.clientHeight}else{if(document.body){sh=document.body.clientHeight}}}hmin=(document.documentElement.scrollTop?document.documentElement.scrollTop:0);sh=sh+hmin;x=(sw-w)/2;y=(sh-h-20)/2;if((sw>-1)){if(x<0){x=0}if((x+w)>sw-10){x=sw-w-10}}if((sh>-1)){if(y<0){y=0}if((y+h)>sh-10){y=sh-h-10}}if(x<wmin){x=wmin}if(y<hmin){y=hmin}el.style.left=x+"px";el.style.top=y+"px";document.getElementById("ajeb_footer").style.width=w+"px";document.getElementById("ajeb_heading").style.width=w+"px";document.getElementById("ajaxErrorBoxC").style.width=w-2+"px"}function buyOneAjax(d,f){var c=thisUrl+"/BUYajax.asp?part="+d+"&quantity=1";xpart=d;http.open("GET",c,true);pauseBuy(200);http.onreadystatechange=function(){getBuyRes()};http.send(null)}function buySomeAjaxDD(c,i,g,f){var d=document.getElementById("part1").value;buySomeAjax(c,d,g,f)}function buySomeAjax(u,l,F,f){if(u==""){a=1;f="NOPRESEL"}else{a=document.getElementById("qty"+u).value}b=parseInt(a);if(isNaN(b)){alert("ERROR - quantity entered - "+a+" - is INVALID");return false}var d="";var c=new Date();var n=thisUrl+"/BUYajax.asp?part="+l+"&quantity="+a+"&when="+c.getTime();var B;if(document.getElementById("gift_wrapYes")){B=document.getElementById("gift_wrapYes").checked}if(B){var m=document.getElementById("gift_msg").value;var k=document.getElementById("wrapSelect");for(var E=0;E<k.options.length;E++){if(k.options[E].selected){var g=k.options[E].value}}n=n+"&gift_wrap="+g+"&gift_msg="+m}var D;var C;var A;var z;var v;var t;var s;D="";var p;if(document.getElementById("personalisationYes")){C=document.getElementById("personalisationYes").checked}if(C){var r=document.getElementById("perso_number_count").value;var o=document.getElementById("perso_string_count").value;D=D+"&pnc="+r+"&psc="+o;for(p=1;p<=o;p++){if(document.getElementById("perso_string"+p)){z=document.getElementById("perso_string"+p).value;t=document.getElementById("perso_string_option"+p).value;D=D+"&ps"+p+"="+z+"&pso"+p+"="+t}}for(p=1;p<=r;p++){if(document.getElementById("perso_number"+p)){v=document.getElementById("perso_number"+p).value;s=document.getElementById("perso_number_option"+p).value;D=D+"&pn"+p+"="+v+"&pno"+p+"="+s}}if(document.getElementById("dDate")){A=document.getElementById("dDate").value;D=D+"&perso_date="+A}}n=n+D;xpart=l;if(f!="NOPRESEL"&&(document.getElementById("numPre"))){numPre=parseInt(document.getElementById("numPre").value);d="&preParts=";for(var E=0;E<numPre;++E){j=E+1;if(document.getElementById("buyPre0"+j).checked!=""){d=d+document.getElementById("partPre0"+j).value+"|"}}}n=n+d;http.open("GET",n,true);lbLocation="";showLightBox(a+" of "+l,F,l);pauseBuy(200);http.onreadystatechange=function(){getBuyRes()};http.send(null);return false}function getBuyRes(){if(http.readyState==1){res="Waiting for response................";if(document.getElementById("lbTxtS")){document.getElementById("lbTxtS").innerHTML=res}}if(http.readyState==4){res=http.responseText;if(res.search("#####")>-1){aaa=res.split("#####");document.getElementById("ajaxBasket").innerHTML=aaa[0];showAjaxErrorBox(aaa[1])}else{err="";if((res.substr(0,2)=="<%")||(res=="")){err="Y";res=""}if(err=="Y"){if(document.getElementById("lbTxtT")){document.getElementById("lbTxtT").innerHTML="Error:"}if(document.getElementById("lbTxtB")){document.getElementById("lbTxtB").innerHTML=""}if(document.getElementById("lbTxt")){document.getElementById("lbTxt").innerHTML="Server did not respond."}if(document.getElementById("lbTxtS")){document.getElementById("lbTxtS").innerHTML="Please try again in a few seconds."}}else{document.getElementById("ajaxBasket").innerHTML=res;if(document.getElementById("lbTxtT")){document.getElementById("lbTxtT").innerHTML="Added"}if(document.getElementById("lbTxtS")&&document.getElementById("basket_itemcount")){q=document.getElementById("basket_itemcount").innerHTML;if(q==1){q=q+" item"}else{q=q+" items"}document.getElementById("lbTxtS").innerHTML="Your basket now holds "+q}}clearTimeout(timer1);timer1=window.setTimeout("lightBoxClose()",lightBoxTimeOut);safetoclose=true}}}function getBuyAjax(){var d;try{d=new ActiveXObject("Msxml2.XMLHTTP")}catch(g){try{d=new ActiveXObject("Microsoft.XMLHTTP")}catch(f){try{d=new XMLHttpRequest()}catch(c){d=false}}}return d}function pauseBuy(e){var d=new Date();var c=null;do{c=new Date()}while(c-d<e)};