var g_maxchars=0,g_maxcharsmatch=0,g_menuwidth=0,g_menuwidthmatch=0,g_menus=[],g_menutitles=[],g_menuspeed=1E4,g_hoverrow=null,g_autoclickenabled=false;function onheightmenu(){return getBG().getmenuheight(true,true,true,g_browseraction)}function oninitmenu(){}function onshowmenu(){rebuildmenu();setTimeout("menuconnectevents()",100)}function onhidemenu(){$("#menu").html("")}
function getSiteMenuTitle(b,d){var a=d?getusernamefromacct(b):b.username,c=b.name+(a==""?"":" ("+a+")");if(c.length>g_maxcharsmatch){c=b.name;if(c.length>37)c=c.substring(0,40)+"...";if(a.length>=g_maxcharsmatch-c.length-3)a=a.substring(0,g_maxcharsmatch-c.length-3)+"...";c=c+(a==""?"":" ("+a+")")}return c}
function menuaction(b,d){L("TSM : menuaction cmd="+b);g_hoverrow=null;var a=getBG();if(a){var c="",h="",f="";if(b.indexOf("identity")==0&&b!="identityadd"){h=b.substring(8);if(h=="all")h="";b="identityswitch"}if(b.indexOf("matchopen")==0){c=b.substring(9);L("menuopen: "+c+" title: "+d);menuopen("match"+c,"match",d)}else if(b.indexOf("opendelete")==0){a=b.substring(10);menuopendelete(a,d)}else{if(b.indexOf("matchedit")==0){c=b.substring(9);b="matchedit"}else if(b.indexOf("matchfill")==0){c=b.substring(9);
b="matchfill"}else if(b.indexOf("matchcopyusername")==0){c=b.substring(17);b="matchcopyusername"}else if(b.indexOf("matchcopypassword")==0){c=b.substring(17);b="matchcopypassword"}else if(b.indexOf("matchcopynote")==0){c=b.substring(13);b="matchcopynote"}else if(b.indexOf("matchdelete")==0){c=b.substring(11);b="matchdelete"}else if(b.indexOf("matchgotourl")==0){c=b.substring(12);b="matchgotourl"}if(b.indexOf("recentlyused")==0){c=b.substring(12);b=c=="clear"?"clearrecent":"site"}else if(b.indexOf("site")==
0&&b!="siteadd"){c=b.substring(4);b="site"}else if(b.indexOf("note")==0&&b!="noteadd"){c=b.substring(4);b="note"}else if(b.indexOf("applicationlaunch")==0){c=b.substring(17);b="applicationlaunch"}else if(b.indexOf("applicationcopyusername")==0){c=b.substring(23);b="applicationcopyusername"}else if(b.indexOf("applicationcopypassword")==0){c=b.substring(23);b="applicationcopypassword"}else if(b.indexOf("applicationedit")==0){c=b.substring(15);b="applicationedit"}else if(b.indexOf("applicationdelete")==
0){c=b.substring(17);b="applicationdelete"}else if(b.indexOf("fillforms")==0){f=b.substring(9);b="fillforms"}else if(b.indexOf("editprofile")==0){f=b.substring(11);b="editprofile"}switch(b){case "logoff":a.loggedOut(false,"menu");break;case "vault":a.openvault();break;case "openfavorites":a.openfavorites();break;case "preferences":a.openprefs();break;case "help":a.openhelp();break;case "premium":a.openpremium();break;case "entconsole":a.openentconsole();break;case "server":a.upgradetoserver();break;
case "saveall":a.saveall();break;case "tools":case "feedback":a.openfeedback();break;case "generate":if(g_browseraction){hidemenu();openmole("lpgenerate");return}else a.opengenpw();break;case "search":a.opensearch();break;case "recheck":a.recheckpage();break;case "refresh":a.refreshsites();break;case "importgooglechrome":a.openimportchrome();break;case "lpimport":a.openimport();break;case "importfirefoxgo":break;case "importfirefoxhelp":break;case "import1passwordgo":break;case "import1passwordhelp":break;
case "importkeepassgo":break;case "importkeepasshelp":break;case "importlastpassgo":break;case "importlastpasshelp":break;case "importmsipasswordkeepergo":break;case "importmsipasswordkeeperhelp":break;case "importmypasswordsafego":break;case "importmypasswordsafehelp":break;case "importpasspackgo":break;case "importpasspackhelp":break;case "importpasswordagentgo":break;case "importpasswordagenthelp":break;case "importpasswordkeepergo":break;case "importpasswordkeeperhelp":break;case "importpasswordsafego":break;
case "importpasswordsafehelp":break;case "importroboformgo":break;case "importroboformhelp":break;case "importturbopasswordsgo":break;case "importturbopasswordshelp":break;case "importcsvgo":break;case "importcsvhelp":break;case "exportchrome":break;case "exportcsv":a.openexport();break;case "exportlastpass":a.openlastpassexport();break;case "printsites":a.openprint(false);break;case "printnotes":a.openprint(true);break;case "update":hidemenu();a.checkforupdates();if(g_isopera)break;else return;case "clear":a.clearCache(false);
break;case "sessions":a.opensessions();break;case "seccheck":a.openseccheck();break;case "about":a.openabout();break;case "addsite":a.openaddsite();break;case "addnote":a.openaddsecurenote();break;case "clearrecent":a.clearrecent();break;case "identityswitch":a.switch_identity(h);break;case "identityadd":a.add_identity();break;case "site":a.launch(c);break;case "siteadd":a.openaddsite();break;case "note":a.launch(c);break;case "noteadd":a.openaddsecurenote();break;case "applicationlaunch":a.launch("app"+
c);break;case "applicationcopyusername":a.copyusername("app"+c);break;case "applicationcopypassword":a.copypassword("app"+c);break;case "applicationedit":a.editAid("app"+c);break;case "applicationdelete":a.deleteAid("app"+c);break;case "fillforms":a.fillform(f);break;case "editprofile":a.editprofile(f);break;case "addprofile":a.addprofile();break;case "addcreditcard":a.addcreditcard();break;case "clearforms":a.clearforms();break;case "chooseprofilecc":if(g_browseraction){hidemenu();openmole("lpchooseprofilecc");
return}else a.openchooseprofilecc();break;case "matchedit":a.editAid(c);break;case "matchfill":a.fillaid(c);break;case "matchcopyusername":a.copyusername(c);break;case "matchcopypassword":a.copypassword(c);break;case "matchcopynote":a.copynote(c);break;case "matchdelete":a.deleteAid(c,null);break;case "matchgotourl":a.gotourl(c,null);break;default:L("TSM : INVALID MENU ACTION cmd="+b)}closemole()}}}function deletenever(b){b=getBG().getnevers()[b];getBG().deleteNever(b);closemole()}
function rightclickmenuaction(b){var d="";if(b.indexOf("site")==0&&b!="siteadd"){d=b.substring(4);b="match_noautofill"+d}else if(b.indexOf("recentlyused")==0){d=b.substring(12);b="match_noautofill"+d}else if(b.indexOf("note")==0&&b!="noteadd"){d=b.substring(4);b="match_note"+d}else return true;menuopen(b,"match","");return false}
function getmenu(){var b=getBG(),d="";if(b.g_identity=="")d=gs("All");else for(var a in b.g_identities)if(b.g_identities[a].iid==b.g_identity){d=b.g_identities[a].deciname;break}var c={identityall:{title:gs("All")}};if(b.g_identity=="")c.identityall.icon="images/checkmark.gif";for(a in b.g_identities){c["identity"+b.g_identities[a].iid]={title:b.g_identities[a].deciname};if(b.g_identities[a].iid==b.g_identity)c["identity"+b.g_identities[a].iid].icon="images/checkmark.gif"}c.linebreak0=null;c.identityadd=
{title:gs("Add Identity")};var h={},f=b.lpGetPref("showAcctsInGroups",1)==1,g={},l,e,i=false,n=[],k=[],q=false;for(l in b.g_sites)if(b.check_ident_aid(l))if(b.g_sites[l].url!="http://group"){i=true;e=b.g_sites[l].group;if(e==null||e=="")e=gs("(none)");var m=e.split("\\"),j="";for(a=0;a<m.length;a++){if(a==0&&e[0]=="\\"){j+="\\";a++}else if(j!="")j+="\\";j+=m[a];lp_in_array(j,n)||(n[n.length]=j)}k[k.length]=b.g_sites[l];if(b.g_sites[l].fav=="1")q=true}n.sort(function(r,s){return r.toLowerCase()<s.toLowerCase()?
-1:1});var o=f&&(q||n.length>1);if(o&&q)g[gs("favorites")]={title:gs("favorites"),children:{}};var u=n.length;m=[];for(a=0;a<u;a++){e=n[a];var p=e.lastIndexOf("\\");j=p==-1||p==0?e:e.substring(p+1);j={title:j,children:{}};m[e]=j;if(p==-1||p==0){if(o)g[e+"sites"]=j}else m[e.substring(0,p)].children[e.replace(/\\/g,"~|~")+"sites"]=j}k.sort(function(r,s){return r.last_touch>s.last_touch?-1:1});e=b.getClearRecentTime();u=b.lpGetPref("recentUsedCount",10);for(a=0;a<k.length&&a<u;a++)k[a].last_touch<e||
(h["recentlyused"+k[a].aid]={title:getSiteMenuTitle(k[a],true),icon:b.geticonurl(k[a].fiid,true)});if(array_length(h)==0)h.recentlyused0={title:gs("None Available")};else{h.linebreak0=null;h.recentlyusedclear={title:gs("Clear Recent")}}k.sort(function(r,s){return r.name.toLowerCase()<s.name.toLowerCase()?-1:1});for(a=0;a<k.length;a++){if(o&&k[a].fav=="1")if(typeof g[gs("favorites")]!="undefined")g[gs("favorites")].children["site"+k[a].aid]={title:getSiteMenuTitle(k[a],true),icon:b.geticonurl(k[a].fiid)};
e=k[a].group;if(e==null||e=="")e=gs("(none)");j={title:getSiteMenuTitle(k[a],true),icon:b.geticonurl(k[a].fiid)};if(o){if(typeof m[e]!="undefined")m[e].children["site"+k[a].aid]=j}else g["site"+k[a].aid]=j}if(i)g.linebreak0=null;g.siteadd={title:gs("Add Site")};k={};i=false;n=[];o=[];for(l in b.g_securenotes)if(b.check_ident_aid(l)){i=true;e=b.g_securenotes[l].group;if(e==null||e=="")e=gs("(none)");if(e!=gs("Secure Notes")){m=e.split("\\");j="";for(a=0;a<m.length;a++){if(j!="")j+="\\";j+=m[a];lp_in_array(j,
n)||(n[n.length]=j)}}o[o.length]=b.g_securenotes[l]}n.sort(function(r,s){return r.toLowerCase()<s.toLowerCase()?-1:1});var t=f&&n.length>1;m=[];for(a=0;a<n.length;a++){e=n[a];p=e.lastIndexOf("\\");j=p==-1?e:e.substring(p+1);j={title:j,children:{}};m[e]=j;if(p==-1){if(t)k[e+"notes"]=j}else m[e.substring(0,p)].children[e.replace(/\\/g,"~|~")+"notes"]=j}o.sort(function(r,s){return r.name.toLowerCase()<s.name.toLowerCase()?-1:1});for(a=0;a<o.length;a++){e=o[a].group;if(e==null||e=="")e=gs("(none)");if(t&&
e!=gs("Secure Notes"))m[e].children["note"+o[a].aid]={title:o[a].name,icon:b.geticonurl(o[a].fiid)}}for(a=0;a<o.length;a++){e=o[a].group;if(!t||e==gs("Secure Notes"))k["note"+o[a].aid]={title:o[a].name,icon:b.geticonurl(o[a].fiid,true)}}if(i)k.linebreak0=null;k.noteadd={title:gs("Add Secure Note")};o=false;t={};n=[];i=[];for(l in b.g_applications)if(b.check_ident_appaid(l)){o=true;e=b.g_applications[l].group;if(e==null||e=="")e=gs("(none)");if(e!=gs("Applications")){m=e.split("\\");j="";for(a=0;a<
m.length;a++){if(j!="")j+="\\";j+=m[a];lp_in_array(j,n)||(n[n.length]=j)}}i[i.length]=b.g_applications[l]}n.sort(function(r,s){return r.toLowerCase()<s.toLowerCase()?-1:1});f=f&&n.length>1;m=[];for(a=0;a<n.length;a++){e=n[a];p=e.lastIndexOf("\\");j=p==-1?e:e.substring(p+1);j={title:j,children:{}};m[e]=j;if(p==-1){if(f)t[e+"applications"]=j}else m[e.substring(0,p)].children[e.replace(/\\/g,"~|~")+"applications"]=j}i.sort(function(r,s){return r.name.toLowerCase()<s.name.toLowerCase()?-1:1});for(a=0;a<
i.length;a++){e=i[a].group;if(e==null||e=="")e=gs("(none)");if(f&&e!=gs("Applications")){m[e].children["application"+i[a].appaid]={title:i[a].name,icon:b.geticonurlfromrecord(i[a]),children:{}};if(b.g_is_win&&getBG().have_nplastpass())m[e].children["application"+i[a].appaid].children["applicationlaunch"+i[a].appaid]={title:gs("Launch")};if(b.can_copy_to_clipboard()){m[e].children["application"+i[a].appaid].children["applicationcopyusername"+i[a].appaid]={title:gs("Copy Username")};m[e].children["application"+
i[a].appaid].children["applicationcopypassword"+i[a].appaid]={title:gs("Copy Password")}}m[e].children["application"+i[a].appaid].children["applicationedit"+i[a].appaid]={title:gs("Edit")};m[e].children["application"+i[a].appaid].children["applicationdelete"+i[a].appaid]={title:gs("Delete")}}}for(a=0;a<i.length;a++){e=i[a].group;if(!f||e==gs("Applications")){t["application"+i[a].appaid]={title:i[a].name,icon:b.geticonurlfromrecord(i[a]),children:{}};if(b.g_is_win&&getBG().have_nplastpass())t["application"+
i[a].appaid].children["applicationlaunch"+i[a].appaid]={title:gs("Launch")};if(b.can_copy_to_clipboard()){t["application"+i[a].appaid].children["applicationcopyusername"+i[a].appaid]={title:gs("Copy Username")};t["application"+i[a].appaid].children["applicationcopypassword"+i[a].appaid]={title:gs("Copy Password")}}t["application"+i[a].appaid].children["applicationedit"+i[a].appaid]={title:gs("Edit")};t["application"+i[a].appaid].children["applicationdelete"+i[a].appaid]={title:gs("Delete")}}}f={};
e=l=i=false;for(a in b.g_formfills)if(b.check_ident_ffid(b.g_formfills[a].ffid)){i=true;f["fillforms"+b.g_formfills[a].ffid]={title:b.g_formfills[a].decprofilename};if(b.g_formfills[a].profiletype==0)l=true;if(b.g_formfills[a].ccnum!="")e=true}if(i){f.linebreak0=null;f.editprofiles={title:gs("Edit"),children:{}};for(a in b.g_formfills)if(b.check_ident_ffid(b.g_formfills[a].ffid))f.editprofiles.children["editprofile"+b.g_formfills[a].ffid]={title:b.g_formfills[a].decprofilename}}f.addprofile={title:gs("Add Profile")};
f.addcreditcard={title:gs("Add Credit Card")};f.clearforms={title:gs("Clear Forms")};if(l&&e)f.chooseprofilecc={title:gs("Choose Profile and Credit Card")};a=b.g_identity!=""?" ("+d+")":"";b={logoff:{icon:"images/power_off.png",title:gs("Logoff:")+" "+b.g_username+a,cmd:"logoff"},linebreak1:null,vault:{icon:"images/icon_vault.png",title:gs("My LastPass Vault"),hotkey:"Ctrl+Alt+H",cmd:"vault"},recent:{icon:"images/icon_recent.png",title:gs("Recently Used"),children:h},sites:{icon:"images/icon_sites.png",
title:gs("Sites"),children:g},notes:{icon:"images/icon_notes.png",title:gs("Secure Notes"),hidden:b.g_hidenotes,children:k},applications:{icon:"images/icon_applications.png",title:gs("Applications"),hidden:!o,children:t},openfavorites:{icon:"images/icon_favorites.png",title:gs("Open Favorites"),cmd:"openfavorites",hidden:!q},formfill:{icon:"images/icon_formfill.png",title:gs("Fill Forms"),children:f},preferences:{icon:"images/icon_preferences.png",title:gs("Preferences"),cmd:"preferences"},help:{icon:"images/icon_help.png",
title:gs("Help..."),cmd:"help"},tools:{icon:"images/icon_tools.png",title:gs("Tools"),children:{generate:{icon:"images/keyboard.png",title:gs("Generate Secure Password"),key:"Alt+G"},identities:{icon:"images/icon_identities.png",title:gs("Identities")+" ("+d+")",hidden:b.g_hideidentities,children:c},search:{icon:"images/search-icon-blue.gif",title:gs("Site Search"),key:"Alt+W"},recheck:{icon:"images/page_gear.png",title:gs("Recheck Page"),key:"Alt+I"},refresh:{icon:"images/reload.gif",title:gs("Refresh Sites"),
hidden:b.LPISLOC},lpimport:{icon:"images/import.png",title:gs("Import"),hidden:!g_isopera},importmenu:{icon:"images/import.png",title:gs("Import From"),hidden:b.g_hideimport||g_isopera,children:{importgooglechrome:{title:gs("Google Chrome Password Manager"),hidden:!b.g_is_win&&!b.g_is_mac&&!b.g_is_linux},lpimport:{title:gs("Other"),hidden:b.LPISLOC}}},lpexport:{icon:"images/export.png",title:gs("Export To"),hidden:b.g_hideexport,children:{exportcsv:{title:gs("LastPass CSV File")},exportlastpass:{title:gs("LastPass Encrypted File"),
hidden:g_isopera}}},print:{icon:"images/printer.png",title:gs("Print"),hidden:b.g_hideprint,children:{printsites:{title:gs("Sites")},printnotes:{title:gs("Secure Notes")}}},update:{icon:"images/exclamation.png",title:gs("Check For Updates"),hidden:g_isopera},clear:{icon:"images/computer_delete.png",title:gs("Clear Local Cache"),hidden:b.LPISLOC},seccheck:{icon:"images/tick.png",title:gs("Security Check"),hidden:b.LPISLOC},sessions:{icon:"images/group_key.png",title:gs("Other Sessions"),hidden:b.LPISLOC},
about:{icon:"images/icon16.png",title:gs("About...")},linebreak0:null,addsite:{icon:"images/icon_saveall.png",title:gs("Add Site")},addnote:{icon:"images/note_add.png",title:gs("Add Secure Note"),hidden:b.g_hidenotes}}},entconsole:{icon:"images/lock.png",title:gs("Enterprise Console"),cmd:"entconsole",hidden:!b.g_iscompanyadmin},linebreak2:null,premium:{icon:"images/icon_premium.png",title:gs("Go Premium!"),cmd:"premium",hidden:b.LPISLOC},server:{icon:"images/icon_premium.png",title:gs("Upgrade to LastPass Online!"),
cmd:"server",hidden:!b.LPISLOC},saveall:{icon:"images/icon_saveall.png",title:gs("Save All Entered Data"),cmd:"saveall"},matchscroll:null};0==u&&delete b.recent;return b}
function rebuildmenu(){var b=g_isopera?"overflow-x:hidden;min-width:400px;":"";g_hoverrow=null;var d="";d+='<div id="menutitle" style="display:none;margin:0 5px 1px 5px;padding:0 5px;cursor:pointer;background:url(menuheader.png) repeat-x;color:#fff;text-align:center;height:20px;line-height:20px;vertical-align:middle;font-weight:bold;"></div>';d+='<div id="backbutton1" class="backbutton" style="display:none;margin:0px 5px;padding:0 5px;cursor:pointer;background:url(backbg.png) repeat-x;color:#fff;text-align:center;height:20px;line-height:20px;vertical-align:middle;font-weight:bold;"><img src="backarrow.png"/> BACK</div>';
d+='<table cellspacing="0"><tr>';d+='<td>&nbsp;<div id="menu0" style="overflow-y:auto;overflow-x:hidden;max-height:400px;"></div></td>';d+='<td>&nbsp;<div id="menu1" style="overflow-y:auto;overflow-x:hidden;max-height:400px;width:0px;display:none;"></div></td>';d+="</tr></table>";d+='<div id="backbutton2" class="backbutton" style="display:none;margin:10px 5px 0 5px;padding:0 5px;cursor:pointer;background:url(backbg.png) repeat-x;color:#fff;text-align:center;height:20px;line-height:20px;vertical-align:middle;font-weight:bold;"><img src="backarrow.png"/> BACK</div>';
$("#menucontainer").html(d);$(".backbutton").hover(function(){g_hoverrow=$(this).attr("id");setTimeout(function(){menuautoclick(g_hoverrow)},1E3);$(this).css({background:"url(backbgover.png) repeat-x"})},function(){g_hoverrow=null;$(this).css({background:"url(backbg.png) repeat-x"})}).click(function(){popmenu()});var a=getmenu();g_maxchars=40;g_maxcharsmatch=33;g_menuwidth=9*g_maxchars;g_menuwidthmatch=9*g_maxcharsmatch;if(getBG().lpGetPref("language","en-US")=="en-US")g_maxcharsmatch=50;d="";var c,
h,f;for(c in a)if(c=="matchscroll"){f=getBG().getnevers();h=true;for(c in f){if(h){h=false;d+='\n<div style="height:1px;margin:5px 0;background:#ccc;"></div>'}var g=gs("Never Add Site");if(f[c].type=="neverautologins")g=gs("Never AutoLogin");if(f[c].type=="nevergenerates")g=gs("Never Generate Password");if(f[c].type=="neverformfills")g=gs("Never Fill Forms");if(f[c].domain==1)g+=" "+gs("(domain)");d+='<div style="'+b+'">';d+='<div class="newmenurow" style="float:left;color:#000;padding:1px 5px;" onclick="menuaction(\''+
("opendelete"+c)+"','"+ofa(addslashes(g))+"');\">";d+='<div style="min-height:16px;float:left;width:'+g_menuwidth+'px;cursor:pointer;overflow:hidden;background:url(close.png) no-repeat;padding-left:20px;padding-top:2px;">'+g+"</div>";d+='<img src="arrow.png">&nbsp;';d+="</div>";d+='<div style="clear:both;"></div>';d+="</div>"}f=getBG().getmatchingsites();if(f.length>0){d+='\n<div style="height:1px;margin:5px 0;background:#ccc;"></div>';for(c in f){h="match"+f[c].aid;g=getSiteMenuTitle(f[c],false);
d+='<div style="'+b+'">';d+='<div id="menurow'+ofa(h)+'" class="newmenurow" style="float:left;color:#000;padding:1px 5px;" onclick="menuaction(\''+("matchopen"+f[c].aid)+"','"+ofa(addslashes(g))+"');\">";d+='<div style="min-height:16px;float:left;width:'+g_menuwidthmatch+"px;cursor:pointer;overflow:hidden;background:url("+getBG().geticonurl(f[c].fiid)+') no-repeat;padding-left:20px;padding-top:2px;">'+ofa(g)+"</div>";d+='<img src="arrow.png" alt="expand"/>&nbsp;';d+='<div style="clear:both;"></div>';
d+="</div>";d+='<img src="fill.png" alt="autofill" style="cursor:pointer;" title="AutoFill" onclick="menuaction(\''+("matchfill"+f[c].aid)+"');\"/>&nbsp;";if(getBG().can_copy_to_clipboard()){d+='<img src="copyusername.png" alt="copyusername" style="cursor:pointer;" title="Copy Username" onclick="menuaction(\''+("matchcopyusername"+f[c].aid)+"');\"/>&nbsp;";d+='<img src="copypassword.png" alt="copypassword" style="cursor:pointer;" title="Copy Password" onclick="menuaction(\''+("matchcopypassword"+
f[c].aid)+"');\"/>&nbsp;"}d+="&nbsp;&nbsp;&nbsp;&nbsp;";d+='<div style="clear:both;"></div>';d+="</div>"}}}else if(a[c]==null)d+='\n<div style="height:1px;margin:5px 0;background:#ccc;"></div>';else if(!(a[c].cmd=="premium"&&(getBG().g_premium_exp>lp_get_local_timestamp()||getBG().g_enterpriseuser))){g=a[c].title;if(g.length>g_maxchars)g=g.substring(0,g_maxchars-3)+"...";f="";if(typeof a[c].children!="undefined")f=" onclick=\"menuopen('"+ofa(c)+"',null,'"+ofa(addslashes(g))+"')\"";else if(typeof a[c].cmd!=
"undefined")f=" onclick=\"menuaction('"+es(a[c].cmd)+"')\"";h="";if(a[c].hidden)h="display: none;";d+='<div id="menurow'+ofa(c)+'" class="newmenurow" style="'+b+"color:#000;padding:1px 5px;"+h+'"'+f+">";d+='<div style="min-height:16px;float:left;width:'+g_menuwidth+"px;cursor:pointer;overflow:hidden;background:url("+a[c].icon+') no-repeat;padding-left:20px;padding-top:2px;">'+of(g)+"</div>";if(typeof a[c].children!="undefined")d+='<img src="arrow.png" alt="expand"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
d+='<div style="clear:both;"></div>';d+="</div>"}d+="<div><br/><br/><br/></div>";pushmenu(d,"")}
function pushmenu(b,d){var a=$("#menu0"),c=$("#menu1"),h=c.width(),f=false;if(b){g_menus.push(b);if(g_menus.length==1){a.html(b);return}c.html(b)}var g=Math.abs(parseInt(a.css("margin-left").replace("px","")));if(g<g_menuwidth){g=g+g_menuspeed<g_menuwidth?g+g_menuspeed:g_menuwidth;a.css("margin-left",-g+"px");if(g==g_menuwidth)a.hide();else f=true}if(g_menus.length!=2)if(h<g_menuwidth){h==0&&c.show();h=h+g_menuspeed<g_menuwidth?h+g_menuspeed:g_menuwidth;c.width(h);f=true}if(f)setTimeout(function(){pushmenu(null,
es(d))},0);else{a.html(c.html()).css("margin-left","0px");c.hide().html("").css("width","0px");a.show();setTimeout("menuconnectevents()",100);g_menutitles.push(d);$("#menutitle").html(of(d)).show();$(".backbutton").show()}}
function popmenu(b){var d=$("#menu0"),a=$("#menu1"),c=a.width(),h=false;if(!b){d.hide().html(g_menus[g_menus.length-2]).css("margin-left",g_menuwidth+"px");a.css("width",g_menuwidth+"px").html(g_menus[g_menus.length-1]).show();g_menus.pop();c=g_menuwidth}if(c>0){c=c-g_menuspeed>0?c-g_menuspeed:0;a.width(c);if(c==0)a.hide();else h=true}b=Math.abs(parseInt(d.css("margin-left").replace("px","")));b==g_menuwidth&&d.show();if(b>0){b=b-g_menuspeed>0?b-g_menuspeed:0;d.css("margin-left",-b+"px");h=true}if(h)setTimeout("popmenu(1)",
0);else{a.html("");setTimeout("menuconnectevents()",100);g_menutitles.pop();if(g_menus.length==1){$("#menutitle").hide().html("");$(".backbutton").hide()}else $("#menutitle").html(of(g_menutitles[g_menutitles.length-1]))}}
function menuconnectevents(){$(".newmenurow").hover(function(){g_hoverrow=$(this).attr("id");setTimeout(function(){menuautoclick(g_hoverrow)},1E3);$(this).css({background:"#316AC5",color:"#fff"}).children("img").attr("src","arrowon.png")},function(){g_hoverrow=null;$(this).css({background:"#fff",color:"#000"}).children("img").attr("src","arrow.png")})}
function menuautoclick(b){if(g_autoclickenabled)if(b==g_hoverrow){g_hoverrow=null;if(b=="backbutton1"||b=="backbutton2")$("#"+b).click();else{var d=b.substring(7),a=d.indexOf("match")==0?"match":null;getmenuchildren(d,a)!=null&&$("#"+b).click()}}}
function menuopen(b,d,a){var c=g_isopera?"overflow-x:hidden;min-width:400px;":"";L("menuopen cmd="+b+" menutitle="+a);d=getmenuchildren(b,d);if(d==null)L("No children for cmd="+b+" menutitle="+a);else{b="";var h,f,g,l;for(l in d){f=d[l];if(f==null)b+='\n<div style="height:1px;margin:5px 0;background:#ccc;"></div>';else{g=f.title;if(g.length>g_maxchars)g=g.substring(0,g_maxchars-3)+"...";h=typeof f.children!="undefined"?" onclick=\"menuopen('"+ofa(l)+"',null,'"+ofa(addslashes(g))+"')\"":" onclick=\"menuaction('"+
ofa(l)+"','"+ofa(addslashes(g))+"')\" onContextMenu=\"return rightclickmenuaction('"+es(l)+"')\"";bgicon=typeof f.icon!="undefined"?"background:url("+f.icon+") no-repeat;":"";var e="";if(f.hidden)e="display: none;";b+='<div id="menurow'+ofa(l)+'" class="newmenurow" style="'+c+"color:#000;padding:1px 5px;"+e+'"'+h+">";b+='<div style="min-height:16px;float:left;width:'+g_menuwidth+"px;cursor:pointer;overflow:hidden;"+bgicon+'padding-left:20px;padding-top:2px;">'+ofa(g)+"</div>";if(typeof f.children!=
"undefined")b+='<img src="arrow.png" alt="expand"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';b+='<div style="clear:both;"></div>';b+="</div>"}}pushmenu(b,a)}}function addslashes(b){return b.replace(/'/,"\\'")}
function menuopendelete(b,d){var a="",c=gs("Delete"),h=" onclick=\"deletenever('"+es(b)+"')\"";a+='<div id="menurow'+es(b)+'" class="newmenurow" style="color:#000;padding:1px 5px;"'+h+">";a+='<div style="min-height:16px;float:left;width:'+g_menuwidth+'px;cursor:pointer;overflow:hidden;padding-left:20px;padding-top:2px;">'+ofa(c)+"</div>";a+='<div style="clear:both;"></div>';a+="</div>";pushmenu(a,d)}
function getmenuchildren(b,d){var a=null;if(d=="match"){a=findmatchmenuchildren(b);if(a!=null)return a}return findmenuchildren(b)}function findmenuchildren(b,d){var a,c=typeof d=="undefined"?getmenu():d,h;for(h in c){if(h==b)return c[h]==null||typeof c[h].children=="undefined"?null:c[h].children;if(c[h]!=null&&typeof c[h].children!="undefined"){a=findmenuchildren(b,c[h].children);if(a!=null)return a}}return null}
function findmatchmenuchildren(b){if(b.indexOf("match")!=0)return null;var d=true,a=true,c=false,h=true,f=false,g=null;if(b.indexOf("match_noautofill")==0){d=false;f=true;g=b.substring(16)}else if(b.indexOf("match_note")==0){a=d=false;c=true;h=false;f=true;g=b.substring(10)}else g=b.substring(5);b="matchedit"+g;var l="matchfill"+g,e="matchcopyusername"+g,i="matchcopypassword"+g,n="matchcopynote"+g,k="matchdelete"+g;g="matchgotourl"+g;var q={};if(f)q[b]={title:gs("Edit")};if(d)q[l]={title:gs("AutoFill")};
if(a&&getBG().can_copy_to_clipboard()){q[e]={title:gs("Copy Username")};q[i]={title:gs("Copy Password")}}if(c&&getBG().can_copy_to_clipboard())q[n]={title:gs("Copy Note")};f||(q[b]={title:gs("Edit")});if(h)q[g]={title:gs("Go to URL")};q[k]={title:gs("Delete")};return q};
