/*
 *  install.js - A javascript abstraction library which makes it easy
 *               to integrate in-page browserplus installation.
 * 
 *  Usage:
 *
 *  BPTool.installer.show() is a drop in replacement for BrowserPlus.init()
 * 
 *  the former will display an in page installation flow in the event
 *  browserplus is not installed
 *  
 *  (c) Yahoo! Inc 2008-2009 All rights reserved
 */
if(typeof BPTool=="undefined"||!BPTool){var BPTool={}}BPTool.Installer=typeof BPTool.Installer!="undefined"&&BPTool.Installer?BPTool.Installer:function(){var Z=false;var W="bpt_install_overlay";var m="bpt_install_dialog";var b="http://bp.yahooapis.com/toolbox/installer/1.0.11/assets/";var n="http://l.yimg.com/a/i/us/bp/s/1.4/site/site-sprite.png";var K=null;var p=null;var t=null;var L=null;var V='<a href="http://developer.yahoo.net/forum/index.php?showforum=83">BrowserPlus Forums</a>';var Y='<a href="http://browserplus.yahoo.com/support/">Support page</a>';var i="http://browserplus.yahoo.com/dist/v2/installer/";var h="Installing BrowserPlus&trade;";var O="Internet Explorer, Firefox, Safari and Chrome";var g="Windows XP and Windows Vista";var N="Firefox and Safari";var d="Mac OS X (Intel)";var T="BrowserPlus&trade;";var S={s_select:{display:"inline-block",border:"1px solid rgb(200, 210, 230)",padding:"1px 0 0 4px",fontFamily:"Arial",fontSize:"smaller",position:"relative",top:"1px"},s_overlay:{background:"#000",opacity:"0.33",position:"fixed",top:"0px",left:"0px",width:"100%",height:"100%",display:"none"},s_dialog:{background:"#fff",position:"absolute",zIndex:"999",top:"0px",left:"0px",width:"550px",display:"none",padding:"0",margin:"0",fontFamily:"Arial, Helvetica, Verdana, sans-serif",border:"1px solid #666"}};var E={s_p:"margin:1em 0;",s_div:"border:8px solid #639; position:relative;text-align:left;background:#fff;",s_body:"font-size:9pt; padding:0 10px;",s_note:"font-size:8pt; padding:5px 10px 2px 10px;",s_title:"font-size: 12pt; margin: 10px 0 5px 0;",s_step1:"background:url("+b+"bullet_1.gif) 0 1em no-repeat;",s_step2:"background:url("+b+"bullet_2.gif) 0 1em no-repeat;",s_step3:"background:url("+b+"bullet_3.gif) 0 1em no-repeat;",s_step4:"background:url("+b+"bullet_4.gif) 0 1em no-repeat;",s_steps:"margin:0;padding:0 10px 0 0;",s_num:"background:#f57208;padding:1px 4px;color:white;font-weight:bold;",s_numdiv:"margin:4px 0;",s_step_li:"padding:5px 0 0 35px; margin:0;min-height:35px; list-style:none; font-size:9pt; color:#333;",s_error:"padding:8px; background:#f9e5f0; border:2px solid #d00; font-family:monospace;",s_bt:"width:90px; height:20px; display:block; border:1px solid #666; text-decoration:none; text-align:center; margin:auto; font-size:9pt;",s_bt_cancel:"visibility:hidden; position:absolute; top:8px; left:280px; background:#999 url("+n+") 0 -700px repeat-x;",s_bt_ok:"visibility:hidden; position:absolute; top:8px; left:380px; background:#ff800e url("+n+") 0 -655px repeat-x;",s_bt_span:"font:bold 100% arial, sans-serif; line-height:20px; color:#fff;",s_ft:"position:relative; height:38px; margin:0; font-size:8pt; border-top:1px solid #ccc;background: #fff url("+b+"bp-logo-sm.gif) 5px 8px no-repeat;",s_st_con:"margin-top:10px;width:510px;height:15px;border:1px solid #333;",s_st_bar:"width:0%;height:15px;background-color:#b67cd1;"};var e='<div style="{s_div}">  <div style="{s_body}"><h1 style="{s_title}">{title}</h1>{body}</div>  <div id="installNoteId" style="{s_note}">{note}</div>  <div style="{s_ft}">    <a id="bpt_install_bt_cancel" style="{s_bt}{s_bt_cancel}" href="#"><span style="{s_bt_span}">{bt1}</span></a>    <a id="bpt_install_bt_ok" style="{s_bt}{s_bt_ok}" href="#"><span id="bstart" style="{s_bt_span}">{bt2}</span></a>  </div></div>';var l='<li style="{s_step_li}{s_step1}"><p style="{s_p}">Click <b>Start Install</b> to begin BrowserPlus installation.  Installation should take less than a minute, and you won\'t even need to restart your browser. </p></li>';var D={MacJava:{stateText1:'<li style="{s_step_li}{s_step1}"><p style="{s_p}">Click <b>Start Install</b> to run the installer. </p></li><p style="{s_p}">You will be prompted to verify you trust software signed by Yahoo!, click the <b>Trust</b> button.</p><center><img src="'+b+'java_trust.jpg" /></center></li>',stateText2:'<li style="{s_step_li}{s_step2};"><p style="{s_p}">In just a moment the installer will open. Click <b>Install</b> to complete your installation.</b></p><center><img src="'+b+'install_begin.jpg" /></center></li><div id="statusBarContainer" style="{s_st_con}">  <div id="statusBarProgress" style="{s_st_bar}"></div></div>'},MacFirefox:{stateText1:'<li style="{s_step_li}{s_step1}"><p style="{s_p}">Click <b>Start Install</b> to begin your download.</p></li><li style="{s_step_li}{s_step2}"><p style="{s_p}">Firefox will prompt you confirm the download.  Click <b>OK</b> to continue.</p><img src="'+b+'save_file_macfirefox.jpg" /></li>',stateText2:'<li style="{s_step_li}{s_step3};"><p style="{s_p}"><div style="{s_numdiv}"><span style="{s_num}">1</span> <b>Double-click</b> BrowserPlus Installer.</div><div style="{s_numdiv}"><span style="{s_num}">2</span> Choose to <b>Open</b> the application.</div><div style="{s_numdiv}"><span style="{s_num}">3</span> Press <b>Install</b>.</div></p></li><img src="'+b+'mac_open_install.jpg" />'},MacSafari:{stateText1:'<li style="{s_step_li}{s_step1}"><p style="{s_p}">Click <b>Start Install</b> to begin your download.</p><img src="'+b+'mac_package.jpg" /></li>',stateText2:'<li style="{s_step_li}{s_step2};"><p style="{s_p}"><div style="{s_numdiv}"><span style="{s_num}">1</span> <b>Double-click</b> BrowserPlus Installer.</div><div style="{s_numdiv}"><span style="{s_num}">2</span> Choose to <b>Open</b> the application.</div><div style="{s_numdiv}"><span style="{s_num}">3</span> Press <b>Install</b>.</div></p></li><img src="'+b+'mac_open_install.jpg" />'},WindowsJava:{stateText1:'<li style="{s_step_li}{s_step1}"><p style="{s_p}">Click <b>Start Install</b> to run the installer. </p></li><p style="{s_p}">You will be prompted to verify you trust software signed by Yahoo!, click the <b>Trust</b> button.</p><center><img src="'+b+'java_trust.jpg" /></center></li>',stateText2:'<li style="{s_step_li}{s_step2}"><p style="{s_p}">In just a moment the installer will open. Click <b>Install</b> to complete your installation.</b></p><center><img src="'+b+'install_begin.jpg" /></center></li><div id="statusBarContainer" style="{s_st_con}">  <div id="statusBarProgress" style="{s_st_bar}"></div></div>'},WindowsChrome:{stateText1:'<li style="{s_step_li}{s_step1}"><p style="{s_p}">Click <b>Start Install</b> to begin your download.</p></li><li style="{s_step_li}{s_step2}"><p style="{s_p}">When the download is complete, click on the icon in the bottom bar:</p><img src="'+b+'chrome_save.jpg" /></li>',stateText2:'<li style="{s_step_li}{s_step3}"><p style="{s_p}">Once you click on the downloaded installer, Chrome will confirm that you wish to run the '+T+" installation. Click <b>Run</b> to begin the installation.  After installation, <b>restart</b> your browser for "+T+' to take effect.</p><img src="'+b+'chrome_security.jpg" /></li>'},WindowsSafari:{stateText1:'<li style="{s_step_li}{s_step1}"><p style="{s_p}">Click <b>Start Install</b> to begin your download.</p></li><li style="{s_step_li}{s_step2}"><p style="{s_p}">A Security Warning like the one below will appear. Click <b>Run</b> to confirm the download.</p><img src="'+b+'run_file_winsafari.jpg" /></li>',stateText2:'<li style="{s_step_li}{s_step3}"><p style="{s_p}">When the installer opens, click <b>Install</b> to complete your installation.</b></p><center><img src="'+b+'win_install_begin.jpg" /></center></li>'},WindowsFirefox:{stateText1:'<li style="{s_step_li}{s_step1}"><p style="{s_p}">Click <b>Start Install</b> to begin your download.</p></li><li style="{s_step_li}{s_step2}"><p style="{s_p}">Firefox will prompt you confirm the download. Click <b>Save File</b> to continue.</p><img src="'+b+'save_file_winfirefox.jpg" /></li>',stateText2:'<li style="{s_step_li}{s_step3}"><p style="{s_p}">Firefox is downloading the installer.  Click <b>Save File</b> to continue.</p><img src="'+b+'save_file_2_winfirefox.jpg" /></li><li style="{s_step_li}{s_step4}"><p style="{s_p}">Once the download has completed, click <b>Open</b> in the Downloads window to start the installer. (<b>Note</b>: if the Downloads window does not appear, type Ctrl+J). A dialog may prompt you to confirm that you want run the installer.</p><img src="'+b+'open_exe_winfirefox.jpg" /></li>'},WindowsExplorer:{stateText1:'<li style="{s_step_li}{s_step1}"><p style="{s_p}">Click <b>Start Install</b> to begin your download.</p></li><li style="{s_step_li}{s_step2}"><p style="{s_p}">A Security Warning like the one below will appear. Click <b>Run</b> to confirm the download.</p><img src="'+b+'run_file_winie7.jpg" /></li>',stateText2:'<li style="{s_step_li}{s_step3}"><p style="{s_p}">Internet Explorer is downloading the installer.  After the first Security Warning, a second warning will appear.  Click <b>Run</b> a second time to start the installer.</p><img src="'+b+'run_signed_file_winie7.jpg" /><p style="{s_p}">After the install is complete the Information Bar may appear to confirm you want to use '+T+'. Choose <b>Run ActiveX Control</b> from the info bar and confirm any other security dialogs that result.</p><img src="'+b+'activex_infobar_winie7.jpg" /></li>'}};var r=function(u,y){var w="<applet ";for(var x in u){w+=(" "+x+'="'+u[x]+'"')}w+=">";if(y!="undefined"&&y!=null){var v=false;for(var AB in y){if(AB=="codebase_lookup"){v=true}w+='<param name="'+AB+'" value="'+y[AB]+'">'}if(!v){w+='<param name="codebase_lookup" value="false">'}}w+="</applet>";var AA=document.createElement("div");AA.style.visibility="hidden";try{AA.style.borderStyle="hidden"}catch(z){}AA.style.width=0;AA.style.height=0;AA.style.border=0;AA.style.position="absolute";AA.style.top=0;AA.style.left=0;AA.innerHTML=w;document.body.appendChild(AA)};var H=function(v){try{document.body.removeChild(document.getElementById(v))}catch(u){try{console.log("couldn't remove applet tag: "+u)}catch(u){}}};var j=function(){var w={ie:0,opera:0,gecko:0,webkit:0};var v=navigator.userAgent,u;if((/KHTML/).test(v)){w.webkit=1}u=v.match(/AppleWebKit\/([^\s]*)/);if(u&&u[1]){w.webkit=parseFloat(u[1])}if(!w.webkit){u=v.match(/Opera[\s\/]([^\s]*)/);if(u&&u[1]){w.opera=parseFloat(u[1])}else{u=v.match(/MSIE\s([^;]*)/);if(u&&u[1]){w.ie=parseFloat(u[1])}else{u=v.match(/Gecko\/([^\s]*)/);if(u){w.gecko=1;u=v.match(/rv:([^\s\)]*)/);if(u&&u[1]){w.gecko=parseFloat(u[1])}}}}}return w}();var Q=j.ie;var A=j.opera;var s=function(AH,w){var AA,z,y,AD,AE,AG,AC=[],x,AB=" ",u="{",AF="}";for(;;){AA=AH.lastIndexOf(u);if(AA<0){break}z=AH.indexOf(AF,AA);if(AA+1>=z){break}x=AH.substring(AA+1,z);AD=x;AG=null;y=AD.indexOf(AB);if(y>-1){AG=AD.substring(y+1);AD=AD.substring(0,y)}AE=w[AD];AH=AH.substring(0,AA)+AE+AH.substring(z+1)}for(AA=AC.length-1;AA>=0;AA=AA-1){AH=AH.replace(new RegExp("~-"+AA+"-~"),"{"+AC[AA]+"}","g")}return AH};var q=function(u){return(u&&u.nodeType)?u:document.getElementById(u)};var k=function(u,v,w){u=q(u);switch(v){case"opacity":if(Q){if(R(u.style.filter)){u.style.filter="alpha(opacity="+w*100+")";if(!u.currentStyle||!u.currentStyle.hasLayout){u.style.zoom=1}}}else{u.style.opacity=w}break;case"z-index":u.style[v]=w;u.style.zIndex=w;break;case"float":v=Q?"styleFloat":"cssFloat";u.style[v]=w;break;default:u.style[v]=w;break}};var R=function(u){return typeof u==="string"};function X(v,w){var u;for(u in w){if(w.hasOwnProperty(u)){k(v,u,w[u])}}}var I=function(w,v,u){if(R(w)){w=q(w)}if(w.addEventListener){w.addEventListener(v,u,false)}else{if(w.attachEvent){w.attachEvent("on"+v,u)}}};var C=function(w,v,u){if(R(w)){w=q(w)}if(w.removeEventListener){w.removeEventListener(v,u,false)}else{if(w.detachEvent){w.detachEvent("on"+v,u)}}};var M=function(){var u=self.innerHeight;var v=document.compatMode;if((v||Q)&&!A){u=(v=="CSS1Compat")?document.documentElement.clientHeight:document.body.clientHeight}return u};var U=function(){var u=self.innerWidth;var v=document.compatMode;if(v||Q){u=(v=="CSS1Compat")?document.documentElement.clientWidth:document.body.clientWidth}return u};var c=function(){var y=window.XMLHttpRequest===null?document.documentElement.scrollLeft:0;var x=window.XMLHttpRequest===null?document.documentElement.scrollTop:0;var z=q(m);var v=z.offsetHeight;var u=z.offsetWidth;z.style.left=Math.floor(Math.max((y+(U()-u)/2),0))+"px";z.style.top="100px"};var J=function(){var w,v=document.getElementsByTagName("select");for(w=0;w<v.length;w++){var u=v[w];if(u.clientWidth===0||u.clientHeight===0||u.nextSibling===null||u.nextSibling.className==="selectReplacement"){continue}var x=document.createElement("span");x.style.height=(u.clientHeight-4)+"px";x.style.width=(u.clientWidth-6)+"px";x.className="selectReplacement";X(x,S.s_select);x.innerHTML=u.options[u.selectedIndex].innerHTML+'<img src="'+b+'select_arrow.gif" alt="drop down" style="position: absolute; right: 1px; top: 1px;" />';u.cachedDisplay=u.style.display;u.style.display="none";u.parentNode.insertBefore(x,u.nextSibling)}};var o=function(){var w,v=document.getElementsByTagName("select");for(w=0;w<v.length;w++){var u=v[w];if(u.clientWidth===0||u.clientHeight===0||u.nextSibling===null||u.nextSibling.className!="selectReplacement"){continue}u.parentNode.removeChild(u.nextSibling);u.style.display=u.cachedDisplay}};var F=function(){if(t){C("bpt_install_bt_ok","click",t)}if(L){C("bpt_install_bt_cancel","click",L)}};var f=function(w,AB){var y={codebase:"http://bp.yahooapis.com/toolbox/installer/1.0.11/assets/",code:"com.yahoo.browserplus.installer.bplusloader.class",archive:"bplusloader_signed.jar",width:0,height:0,id:"bplusInstallerApplet"};var AF={installerBaseURL:i};r(y,AF);F();var AA='<ul style="{s_steps}">'+D[AB].stateText2+"</ul>";var AC="Waiting for installation to complete...";L=null;t=B;var AE=h+' <img src="'+b+'waiting-ball-sm.gif">';var z=true;var AD=-1;var v;var u;var x=setInterval(function(){var AG,AK,AJ=document.getElementById("bplusInstallerApplet");try{AK=AJ.status().percent;AG=String(AJ.status().status);if(z){a(m,{title:AE,body:AA,note:AC,okLabel:"Cancel"});v=document.getElementById("installNoteId");u=document.getElementById("statusBarProgress");z=false}if(AK!=AD){AD=AK;k(u,"width",AK+"%")}}catch(AI){AG="error"}if(v){v.innerHTML=AG}if(AG==="error"||AG==="complete"){clearInterval(x)}if(AG==="error"){var AH=BrowserPlus.clientSystemInfo();AB=AH.os+AH.browser;P(w,AB)}},200);BrowserPlus.initWhenAvailable({},function(AG){if(AG.success){B();K(AG)}else{G(AG,false)}})};var P=function(w,v){F();var u='<ul style="{s_steps}">'+D[v].stateText2+"</ul>";var y="Waiting for installation to complete...";L=null;t=B;var z=h+' <img src="'+b+'waiting-ball-sm.gif">';a(m,{title:z,body:u,note:y,okLabel:"Cancel"});BrowserPlus.initWhenAvailable({},function(AA){if(AA.success){B();K(AA)}else{G(AA,false)}});if(w){var x=document.createElement("iframe");x.src=w;x.style.display="none";document.body.appendChild(x)}};var B=function(){H("bplusInstallerApplet");F();C(window,"resize",c);if(window.XMLHttpRequest===null){o()}k(W,"display","none");k(m,"display","none")};var a=function(w,x){var v;w=q(w);var y={title:x.title,body:x.body,note:x.note,bt1:(x.cancelLabel||"Cancel"),bt2:(x.okLabel||"OK")};for(v in E){if(E.hasOwnProperty(v)){y[v]=E[v]}}w.innerHTML=s(e,y);if(x.okAction){k("bpt_install_bt_ok","visibility","visible");I("bpt_install_bt_ok","click",x.okAction);t=x.okAction}else{k("bpt_install_bt_ok","visibility","hidden")}if(x.cancelAction){k("bpt_install_bt_cancel","visibility","visible");I("bpt_install_bt_cancel","click",x.cancelAction);L=x.cancelAction}else{try{k("bpt_install_bt_cancel","visibility","hidden")}catch(u){}}};var G=function(z,v){var w,u="";var AA=BrowserPlus.clientSystemInfo();var AB={browser:"",title:"",body:"",note:"",cancelAction:null,cancelLabel:"Cancel",okAction:B,okLabel:"OK",error:false};if(AA.os==="Mac"){w=i+"osx/";u="At this time, "+T+" supports "+N+" on "+d}else{if(AA.os==="Windows"){w=i+"win32/";u="At this time, "+T+" supports "+O+" on "+g}}if(z.error==="bp.notInstalled"||z.error==="bpPlugin.platformBlacklisted"){AB.browser=AA.os+"Java";if(AA.supported==="unsupported"){AB.title=T+" Unavailable";AB.body='<p style="{s_p}">At this time, '+T+" is only supported on "+d+", "+g+". Please see our "+Y+" for more information.</p>"}else{if(!D[AB.browser]){AB.title=T+" Unavailable";AB.body='<p style="{s_p}">'+u+'.</p> <p style="{s_p}">Please see the '+Y+" for more information.</p>";AB.note='<b>Note:</b> If you still wish to download the installer for use with other browsers on your computer, you can <a href="'+w+'">download the installer</a>.'}else{if(z.error==="bpPlugin.platformBlacklisted"){AB.title=T+" Update Required";AB.body='<p style="{s_p}">Security updates require that you install a new version of '+T+"</b>.</p>"}else{AB.title=h}AB.body+=l;AB.okLabel="Start Install";AB.okAction=function(){if(v){document.getElementById("bstart").innerHTML="Downloading";f(w,AB.browser)}else{var AC=BrowserPlus.clientSystemInfo();currentBrowser=AC.os+AC.browser;P(w,currentBrowser)}};AB.cancelAction=B}}}else{AB.title="Error Loading "+T;AB.body+='<p style="{s_p}">A problem occured when trying to initialize browserplus.</p><p style="{s_error}">'+z.error+(z.verboseError?": "+z.verboseError:"")+'</p><p style="{s_p}">You can report this problem on the '+V+'.</p><p style="{s_p}">You can try reinstalling the software by <a href="'+w+'">downloading the installer</a> and restarting your web browser.</p>';AB.error=true}var x,y;if(!Z){Z=true;x=document.createElement("div");x.id=W;X(x,S.s_overlay);document.body.appendChild(x);y=document.createElement("div");y.id=m;X(y,S.s_dialog);document.body.appendChild(y)}else{x=q(W);y=q(m)}k(x,"display","block");if(window.XMLHttpRequest===null){J()}a(y,AB);k(y,"display","block");c();I(window,"resize",c)};return{show:function(w,x,v){var u=v||{};BrowserPlus.init(w,function(y){var z=BrowserPlus.clientSystemInfo();var AA;if(y.success){x(y)}else{p=w;K=x;if(z.os==="Mac"&&z.browser!=="Safari"){AA=(u.macJava!==false)}else{if(z.os==="Mac"){AA=(u.macJava===true)}else{AA=(u.winJava===true)}}AA=false;G(y,AA)}})}}}();
