var maxWidthFix=function(a){if(document.body.clientWidth>912){a.style.width="57em"}};(function(b){b.extend({ImportBasePath:"",__WaitingTasks:new Object(),__loadedSuccessfully:function(a){if(a in b.__WaitingTasks){if((b.__WaitingTasks[a].loading-=1)<1){var d=b.__WaitingTasks[a].task;if(typeof d=="function"){d()}delete b.__WaitingTasks[a]}}},fileinfo:function(d){d=d.replace(/^\s|\s$/g,"");var a;if(/\.\w+/.test(d)){a=d.match(/([^\/\\]+)\.(\w+)/);if(a){if(a[2].indexOf("js")!==-1){return{filename:a[1],ext:a[2],tag:"script"}}else{if(a[2].indexOf("css")!==-1){return{filename:a[1],ext:a[2],tag:"link"}}else{return{filename:a[1],ext:a[2],tag:null}}}}else{return{filename:null,ext:null}}}else{a=d.match(/([^\/\\]+)$/);if(a){return{filename:a[1],ext:null,tag:null}}else{return{filename:null,ext:null,tag:null}}}},fileExist:function(j,h,a){var g=document.getElementsByTagName(h);for(var i=0;i<g.length;i++){if(g[i].getAttribute(a)==b.ImportBasePath+j){return true}}return false},createElement:function(h,g){switch(g){case"script":if(!b.fileExist(h,g,"src")){var f=document.createElement(g);f.setAttribute("language","javascript");f.setAttribute("type","text/javascript");f.setAttribute("src",b.ImportBasePath+h);return f}else{return false}break;case"link":if(!b.fileExist(h,g,"href")){var a=document.createElement(g);a.setAttribute("type","text/css");a.setAttribute("rel","stylesheet");a.setAttribute("href",b.ImportBasePath+h);return a}else{return false}break;default:return false;break}},cssReady:function(g,f){function h(){if(document.styleSheets[g]){window.clearInterval(a);b.__loadedSuccessfully(f)}}var a=window.setInterval(h,200)},include:function(q,a){var l=document.getElementsByTagName("head")[0];var p=[];typeof q=="string"?p[0]=q:p=q;var i=new Date().getTime().toString();b.__WaitingTasks[i]={loading:p.length,task:a};for(var n=0;n<p.length;n++){var m=b.fileinfo(p[n]).tag;var s=[];if(m!==null){s[n]=b.createElement(p[n],m);if(s[n]){l.appendChild(s[n]);if(b.browser.msie){s[n].onreadystatechange=function(){if(this.readyState==="loaded"||this.readyState==="complete"){b.__loadedSuccessfully(i)}}}else{if(m=="link"){b.cssReady(n,i)}else{if(/WebKit/i.test(navigator.userAgent)){var o=setInterval(function(){if(/loaded|complete/.test(document.readyState)){b.__loadedSuccessfully(i)}},100)}s[n].onload=function(){b.__loadedSuccessfully(i)}}}}else{b.__loadedSuccessfully(i)}}else{return false}}}})})(jQuery);(function(b){b.alerts={verticalOffset:-75,horizontalOffset:0,repositionOnResize:true,overlayOpacity:0.01,overlayColor:"#FFF",draggable:true,okButton:"&nbsp;OK&nbsp;",cancelButton:"&nbsp;Cancel&nbsp;",dialogClass:null,alert:function(a,f,e){if(f==null){f="Alert"}b.alerts._show(f,a,null,"alert",function(c){if(e){e(c)}})},confirm:function(a,f,e){if(f==null){f="Confirm"}b.alerts._show(f,a,null,"confirm",function(c){if(e){e(c)}})},prompt:function(a,h,g,f){if(g==null){g="Prompt"}b.alerts._show(g,a,h,"prompt",function(c){if(f){f(c)}})},_show:function(k,l,n,a,e){b.alerts._hide();b.alerts._overlay("show");b("BODY").append('<div id="popup_container"><h1 id="popup_title"></h1><div id="popup_content"><div id="popup_message"></div></div></div>');if(b.alerts.dialogClass){b("#popup_container").addClass(b.alerts.dialogClass)}var j=(b.browser.msie&&parseInt(b.browser.version)<=6)?"absolute":"fixed";b("#popup_container").css({position:j,zIndex:99999,padding:0,margin:0});b("#popup_title").text(k);b("#popup_content").addClass(a);b("#popup_message").text(l);b("#popup_message").html(b("#popup_message").text().replace(/\n/g,"<br />"));b("#popup_container").css({minWidth:b("#popup_container").outerWidth(),maxWidth:b("#popup_container").outerWidth()});b.alerts._reposition();b.alerts._maintainPosition(true);switch(a){case"alert":b("#popup_message").after('<div id="popup_panel"><input type="button" value="'+b.alerts.okButton+'" id="popup_ok" /></div>');b("#popup_ok").click(function(){b.alerts._hide();e(true)});b("#popup_ok").focus().keypress(function(c){if(c.keyCode==13||c.keyCode==27){b("#popup_ok").trigger("click")}});break;case"confirm":b("#popup_message").after('<div id="popup_panel"><input type="button" value="'+b.alerts.okButton+'" id="popup_ok" /> <input type="button" value="'+b.alerts.cancelButton+'" id="popup_cancel" /></div>');b("#popup_ok").click(function(){b.alerts._hide();if(e){e(true)}});b("#popup_cancel").click(function(){b.alerts._hide();if(e){e(false)}});b("#popup_ok").focus();b("#popup_ok, #popup_cancel").keypress(function(c){if(c.keyCode==13){b("#popup_ok").trigger("click")}if(c.keyCode==27){b("#popup_cancel").trigger("click")}});break;case"prompt":b("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="'+b.alerts.okButton+'" id="popup_ok" /> <input type="button" value="'+b.alerts.cancelButton+'" id="popup_cancel" /></div>');b("#popup_prompt").width(b("#popup_message").width());b("#popup_ok").click(function(){var c=b("#popup_prompt").val();b.alerts._hide();if(e){e(c)}});b("#popup_cancel").click(function(){b.alerts._hide();if(e){e(null)}});b("#popup_prompt, #popup_ok, #popup_cancel").keypress(function(c){if(c.keyCode==13){b("#popup_ok").trigger("click")}if(c.keyCode==27){b("#popup_cancel").trigger("click")}});if(n){b("#popup_prompt").val(n)}b("#popup_prompt").focus().select();break}if(b.alerts.draggable){try{b("#popup_container").draggable({handle:b("#popup_title")});b("#popup_title").css({cursor:"move"})}catch(m){}}},_hide:function(){b("#popup_container").remove();b.alerts._overlay("hide");b.alerts._maintainPosition(false)},_overlay:function(a){switch(a){case"show":b.alerts._overlay("hide");b("BODY").append('<div id="popup_overlay"></div>');b("#popup_overlay").css({position:"absolute",zIndex:99998,top:"0px",left:"0px",width:"100%",height:b(document).height(),background:b.alerts.overlayColor,opacity:b.alerts.overlayOpacity});break;case"hide":b("#popup_overlay").remove();break}},_reposition:function(){var d=((b(window).height()/2)-(b("#popup_container").outerHeight()/2))+b.alerts.verticalOffset;var a=((b(window).width()/2)-(b("#popup_container").outerWidth()/2))+b.alerts.horizontalOffset;if(d<0){d=0}if(a<0){a=0}if(b.browser.msie&&parseInt(b.browser.version)<=6){d=d+b(window).scrollTop()}b("#popup_container").css({top:d+"px",left:a+"px"});b("#popup_overlay").height(b(document).height())},_maintainPosition:function(a){if(b.alerts.repositionOnResize){switch(a){case true:b(window).bind("resize",b.alerts._reposition);break;case false:b(window).unbind("resize",b.alerts._reposition);break}}}};jAlert=function(a,f,e){b.alerts.alert(a,f,e)};jConfirm=function(a,f,e){b.alerts.confirm(a,f,e)};jPrompt=function(a,h,g,f){b.alerts.prompt(a,h,g,f)}})(jQuery);(function(b){b.cookie=function(x,p,a){if(typeof p!="undefined"){a=a||{};if(p===null){p="";a=b.extend({},a);a.expires=-1}var u="";if(a.expires&&(typeof a.expires=="number"||a.expires.toUTCString)){var t;if(typeof a.expires=="number"){t=new Date();t.setTime(t.getTime()+(a.expires*24*60*60*1000))}else{t=a.expires}u="; expires="+t.toUTCString()}var i=a.path?"; path="+(a.path):"";var s=a.domain?"; domain="+(a.domain):"";var y=a.secure?"; secure":"";document.cookie=[x,"=",encodeURIComponent(p),u,i,s,y].join("")}else{var v=null;if(document.cookie&&document.cookie!=""){var o=document.cookie.split(";");for(var q=0;q<o.length;q++){var w=b.trim(o[q]);if(w.substring(0,x.length+1)==(x+"=")){v=decodeURIComponent(w.substring(x.length+1));break}}}return v}}})(jQuery);var r={bat:function(){var a=$("#search-options"),c=a.is(":visible")?1:0,b;$('<p class="toggler"><a href="#">toggle advanced search</a></p>').insertAfter(a).find("a").click(function(){a.toggle();if(!b){b=$("#fm-keywords")}b.focus();c=1-c;$.post("/baby-names/toggle/",{toggle:c});return false})},bys:function(){$("#years > li > a").mouseover(function(){$(this).parent().siblings().removeClass("current").end().addClass("current")})},cal:function(){$.include(["/js/jquery.datepicker.js","/css/jquery.datepicker.css"],function(){$("#content input:text.date").datepicker({dateFormat:"yy-mm-dd",changeMonth:true,changeYear:true,yearRange:"1900:2020",showOn:"button",buttonImage:"/img/16x16/calendar.png",buttonImageOnly:true})})},cnr:function(){try{if(document.body.style.MozBorderRadius!==undefined){return}}catch(b){}try{if(document.body.style.WebkitBorderRadius!==undefined){return}}catch(b){}var c=$('<b class="t"><b></b></b>'),a=$('<b class="b"><b></b></b>');$("#content div.section").each(function(){c.clone().prependTo(this);a.clone().appendTo(this)})},fav:function(){var e,c,d,f,b,a={add:{a:"del",v:"Remove from Favorites"},del:{a:"add",v:"Add to Favorites"}};$("#content p.favorites-toggler :submit").click(function(){var g=$(this);if(!c){e=g.closest("form");c=e.attr("action");d=e.find('> input:hidden[name="type"]:first').attr("value");f=e.find('> input:hidden[name="mode"]:first').attr("value")=="dynamic";b=$("#total-favorites")}var j=g.attr("name").match(/^(add|del)-([1-9][0-9]*)$/);if(!j){return}var i=j[1];var k=j[2];var h=g.closest("div[id]").toggleClass(d+"-favorite");if(f){h.fadeOut("normal",function(){$(this).remove()})}g.attr("name",a[i].a+"-"+k).attr("value",a[i].v);$.post(c,{action:i,id:k,type:d},function(l){if(!isNaN(l)){b.text(l)}});return false})},fac:function(){var a=$("#clear-favorites").click(function(){jConfirm("Are you sure you want to remove all of your favorites?","Confirmation Dialog",function(b){if(b){a.closest("form").submit()}});return false})},pag:function(){var b,c=1000,a="Enter the page number you would like to jump to";$("#content ul.pagination").each(function(){var d=$(this).append('<li class="jump"><a href="#">Jump</a></li>').find("> li:last a").click(function(){if(!b){var e=d.children("li.current[title]");if(e.length>0){var f=e.attr("title").match(/ page ([1-9][0-9]*) of ([1-9][0-9]*)$/);if(f){b=f[1]*1;c=f[2]*1;a="Enter a page number between 1 and "+c}else{b=-1}}else{b=-1}}jPrompt(a,"","Jump to a Page",function(g){if(g){if(isNaN(g)||g<1||g>c){jAlert("Please enter a valid page number.")}else{if(g==b){jAlert("You are already on page "+b)}else{$.post("/page-jumper/",{page:g,url:window.location.href},function(h){if(h!="0"){window.location.href=h}})}}}});return false}).end()})},pop:function(){var a={width:500,height:250,name:"win"};$('a[rel^="pu"]').click(function(){var h=$(this);var g=h.attr("rel").match(/\[(\d+)(?:,(\d+))?(?:,([A-Za-z0-9_\-]+))?\]$/);var b=a;if(g[1]){b.width=g[1]}if(g[2]){b.height=g[2]}if(g[3]){b.name=g[3]}else{var i=h.attr("id");if(i){b.name=i}}var e=(screen.width-b.width)/2;var c=(screen.height-b.height)/2;var d=["width=",b.width,",height=",b.height,",left=",e,",top=",c,",location=1,resizable=1,scrollbars=1"].join("");var f=window.open(h.attr("href"),b.name,d);if(window.focus){f.focus()}return false})},rat:function(){var a=[];a[1]={c:"success",m:"Thanks for voting!"};a[2]={c:"failure",m:"Already voted!"};a[3]={c:"failure",m:"Error occurred!"};$("#content div.rating ul").one("click",function(f){var d=$(this).find("a").remove().end(),b=$(f.target).text()*1,c=d.closest("div[id]").attr("id").match(/^([a-z]+)-([1-9][0-9]*)$/);$.post("/widgets/rate/",{type:c[1],id:c[2],rating:b},function(h){if(isNaN(h)){return false}var e=d.next("p");if(h==1){var j=e.find(".average");var l=parseFloat(j.text());var g=e.find(".votes");var i=parseInt(g.text(),10);var m=(((l*i)+b)/(i+1)).toFixed(2);var k=i+1;j.text(m);g.text(k+((k==1)?" vote":" votes"));d.children("li:first").css("width",(m*25)+"%")}e.append('<span class="'+a[h].c+'">'+a[h].m+"</span>")});return false})},sts:function(){$("#content table.graph").each(function(){var e=$(this);var d=e.attr("id").split("-");var c=d[0];var f=d[1];var b=[];var a=function(g){e.addClass("graph-loading");$.get("/baby-names/stats/",{year:g,gender:c,id:f},function(h){if(h!=="0"){e.nextAll("table.graph-"+c).remove();e.hide().after(h).next().click(function(){e.show();$(this).remove()})}else{jAlert("Sorry, no extended stats are available.")}e.removeClass("graph-loading")})};e.find("thead th a").each(function(g){var h=$(this);b[g]=h.text();h.click(function(){a(b[g]);return false})});e.find("tfoot th a").each(function(g){$(this).click(function(){a(b[g]);return false})});e.find("tbody td[title]").each(function(g){$(this).click(function(){a(b[g])})})})},tab:function(){$("ul.tabs").each(function(){var b=$(this);var a;b.find("a").each(function(d){var c=$(this);if(c.parent().hasClass("current")){a=d;b.nextAll().hide().eq(d).show()}c.click(function(){if(a==d){return false}else{a=d}c.parent().siblings().removeClass("current");c.parent().addClass("current");b.nextAll().hide().eq(d).show();return false})})})},usa:function(){var b=$("<p>&nbsp;</p>");var a=$("#usa-map").prepend(b).find("> map > area").hover(function(){b.html($(this).attr("title")||"&nbsp;")},function(){b.html("&nbsp;")}).end();$.include("/js/jquery.maphilight.js",function(){a.find("> img[usemap]").maphilight({fillColor:"FF0000",stroke:false})})}};$(function(){$.each($("body:first").attr("class").split(" "),function(b,a){switch(a){case"hp":r.tab();r.cnr();r.usa();break;case"ba":r.bat();r.fav();r.rat();r.pag();r.bys();break;case"mu":r.fav();r.rat();r.pag();break;case"nc":case"ck":r.pop();break;case"ml-welcome":r.usa();break;case"ba-meaning":r.sts();break;case"ba-favorites":case"mu-favorites":r.fac();break;case"ac-nc":r.cal();break}})});