function Menu_Select(a){document.getElementById(a).style.backgroundColor="#a5eefd";document.getElementById(a).style.color="#f00";SetTitles()}function SetTitles(){for(var a=0;a<document.images.length;a++)if(0<document.images[a].alt.length)document.images[a].title=document.images[a].alt}
function SetNumeric(){for(var a=/android|iphone|ipad|ipod|blackberry|mini|palm/i.test(navigator.userAgent.toLowerCase()),b=document.getElementsByTagName("input"),c=0;c<b.length;c++){var e=b[c];if("text"==e.type){if("Num"==e.className)e.onkeypress=CheckNumeric;else if("Imp"==e.className)e.onkeypress=CheckImperial;if(a)e.type="number"}}}
function CheckNumeric(a){if(document.all){var b=event.keyCode;return 0==event.srcElement.id.indexOf("_")&&46==b&&-1==event.srcElement.value.indexOf(".")?!0:47<b&&58>b?!0:!1}b=a.which;if(0==a.target.id.indexOf("_")&&46==b&&-1==a.target.value.indexOf("."))return!0;if(47<b&&58>b||0==b||8==b)return!0;a.preventDefault()}
function CheckImperial(a){var b=document.all?event.srcElement.value:a.target.value,c=document.all?event.keyCode:a.which;if(47<c&&58>c||8==c)return!0;if(46==c&&-1==b.indexOf(".")&&0<b.length)return!0;if(32==c&&" "!=b.substring(b.length-1)&&0<b.length)return!0;if(47==c&&-1==b.indexOf("/")&&0<b.length)return!0;if(document.all)return!1;a.preventDefault()}
function Help_onclick(a,b){window.open("Help/"+a+".aspx",null,"height="+b+",width=650,scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no").focus()}if(top!=self)top.location=self.document.location;var dloc=document.location.toString().toLowerCase();if(-1==dloc.indexOf("blocklayer.com")&&-1==dloc.indexOf("localhost")||-1<dloc.indexOf("file:"))location.replace("http://www.blocklayer.com?ax=1"),document.write('<a href="http://www.blocklayer.com"><h1>Blocklayer.com</h1></a>');
function ConEng(a,b){if(0==a)return"0";var c=Math.round(a),e=0,f=0;b?(e=Math.floor(c/384),f=Math.floor(c/32)%12):f=Math.floor(c/32);for(var c=c%32,h=32;0==c%2&&1<c;)c/=2,h/=2;var g="";0<e&&(g=e+"'");0<f&&(g+=f);0<f&&0<c&&(g+="~");0<c&&(g+=c.toString()+"/"+h.toString());if(0<f||0<c)g+='"';return g}
function BookmarkPage(){var a=document.location.href;0<a.indexOf("?")&&(a=a.substring(0,a.indexOf("?")));if(document.all)window.external.AddFavorite(a,document.title);else if(window.sidebar)window.sidebar.addPanel(window.document.title,a,"");else{alert("Sorry! Your browser doesn't appear to support this function.\n\r\n\rYou can Bookmark this page manually by clicking your Browsers' Bookmark icon.");return}(new Image).src="http://www.blocklayer.com/Logger.ashx?p="+escape(document.location.href.substring(11))+
"&a=Bookmarked"}function TellAFriend(){window.open("TellFriend.aspx",null,"height=380,width=640,scrollbars=0,resizable=1,status=0,toolbar=0,menubar=0,location=0").focus()}function CommaFormat(a){x=(a+"").split(".");x1=x[0];x2=1<x.length?"."+x[1]:"";for(a=/(\d+)(\d{3})/;a.test(x1);)x1=x1.replace(a,"$1,$2");return x1+x2}var logged=!1;function LogUser(a){if(!logged)logged=!0,(new Image).src="http://www.blocklayer.com/Logger.ashx?p="+escape(document.location.href.substring(11))+"&a="+a}
function RoundTo(a,b){if(0==b)return Math.round(a);b=Math.pow(10,b);return d=Math.round(a*b)/b}function ConvertTo32nds(a){if(0==a.length)return 0;a=a.replace(/\s+$/,"");if(-1<a.indexOf("."))return 32*a;-1<a.indexOf("/")&&(a=a.replace("/"," "));var b=a.split(" ");if(1==b.length)return 32*a;if(2==b.length)return 32/b[1]*b[0];return 3==b.length?(a=32*b[0],a+=32/b[2]*b[1]):0}
function OpenSave(){window.open("LocalStorage.aspx",null,"width=440,height=280,scrollbars=1,location=no,menubar=no,toolbar=no,left=10,top=10").focus()}window.onbeforeprint=NoPrint;function NoPrint(){0<document.getElementsByTagName("canvas").length&&0<document.getElementsByTagName("canvas").length&&9>IsIE()&&alert("IE"+IsIE()+" may not print this page correctly\n\nPlease use IE9 or later, Firefox or Chrome to print\n\n\nSorry for the inconvenience")}
function IsIE(){var a=navigator.userAgent;return-1<a.indexOf("IE")&&null!=/MSIE ([0-9]{1,}[.0-9]{0,})/.exec(a)?parseFloat(RegExp.$1):100}function QRBevel2(a,b,c){OpenQR("http://blocklayer.mobi/bevel-gauge.aspx?ba="+b+":"+c,"Bevel Gauge Setter")}function QRBevel(a,b){OpenQR("http://blocklayer.mobi/bevel-gauge.aspx?ba="+b,"Bevel Gauge Setter")}
function RunTalkQR(a,b,c){-1<a.indexOf("Imperial")?(a+="<br />Centers "+ConEng(b,!0)+" Start at "+ConEng(c,!0),b/=32,c/=32):a+="<br />Centres "+RoundTo(b,1)+" Start at "+RoundTo(c,1);OpenQR("http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=http://blocklayer.mobi/android.aspx%3Fi%3D"+b+"%26sa%3D"+c,a)}
function BuildQR(a,b){var c=a.innerHTML.replace(/\s+/g,"").replace(/'+/g,"f").replace(/"+/g,"i").replace(/(<([^>]+)>)/ig,"");OpenQR("http://blocklayer.mobi/rundisplay.aspx?r="+c,"Running Setout<br />"+b)}
function OpenQR(a,b){var c=window.open("","","width=460,height=520,location=no,status=no,resizable=yes");c.document.body.setAttribute("style","text-align:center;");c.document.title="Blocklayer.com QR Code";var e=c.document.createElement("span");e.setAttribute("style","font-size:18px;font-family:verdana;");e.innerHTML=b;var f=c.document.createElement("img");f.src="http://www.blocklayer.com/images/close.png";f.setAttribute("onclick","window.close()");f.setAttribute("style","cursor:pointer;float:right");
c.document.body.appendChild(f);c.document.body.appendChild(e);c.document.body.appendChild(c.document.createElement("br"));c.document.body.appendChild(c.document.createElement("br"));e=c.document.createElement("img");e.src="http://www.blocklayer.com/images/print.jpg";e.setAttribute("onclick","window.print()");e.setAttribute("style","cursor:pointer");c.document.body.appendChild(e);c.document.body.appendChild(c.document.createElement("br"));e=300+Math.round(a.length/5);f=c.document.createElement("img");
f.src="http://chart.apis.google.com/chart?cht=qr&chs="+e+"x"+e+"&chl="+a;f.setAttribute("onclick","window.print()");f.setAttribute("style","cursor:pointer");c.document.body.appendChild(f);c.focus()}function FindPos(a){var b=y=0;if(a.offsetParent){do b+=a.offsetLeft,y+=a.offsetTop;while(a=a.offsetParent)}return{top:y,left:b}}function SetEnter(){document.onkeydown=SetCalcEnter}function SetCalcEnter(a){13==(a.keyCode?a.keyCode:a.which?a.which:a.charCode)&&Calculate()}
function DrawHR(){for(var a=document.getElementsByTagName("canvas"),b=0;b<a.length;b++)if(0==a[b].id.indexOf("cnvsHR")){var c=a[b],e=c.getContext("2d");e.strokeStyle="#888";var f=c.height-10;e.shadowOffsetY=4;e.shadowOffsetX=4;e.shadowBlur=4;e.shadowColor="#c0c0c0";e.beginPath();e.moveTo(0,f/2);for(var h=0;h<c.width;)h+=4+4*Math.random(),e.lineTo(h,Math.random()*f);e.stroke()}};
