$(function() { var width = $("#menu").width(); var nav = $("#menu > ul > li"); nav.css("width", width / nav.size() - 17); $("#menu > ul > li > a").each(function() { var extra_top = ($(this).parent().height() - $(this).height()) / 2; $(this).css("margin-top", extra_top).css("margin-bottom", extra_top); }); $("#sidebar .hot_buttons h3 span").each(function() { var extra_top = ($(this).parent().height() - $(this).height()) / 2; $(this).css("top", extra_top); }); $("#menu > ul > li").mouseover(function() { $("#menu > ul > li > ul").hide(); $(this).children("ul").css("width", width / nav.size() + 1).show(); return false; }); $("#menu > ul > li > ul > li").hover(function() { $(this).addClass("hover"); }, function() { $(this).removeClass("hover"); }); $("#menu li").click(function() { var href = $(this).children("a").attr("href"); if (href) window.open(href, "_self"); }); $("body").click(function() { $("#menu > ul > li > ul").hide(); }); if ($("#content.home").size() + $("#content.ad").size() > 0) { var height = Math.max($("#sidebar").height(), $("#content").height()); $("#sidebar").add("#content").css("height", height); } else { var height = Math.max($("#sidebar").height(), $("#content").height() + 40); $("#sidebar").css("height", height); $("#content").css("height", height - 40); } function hotfield(field, holder) { return holder ? $("#" + field + "_holder") : $("#" + field); } $.each(["username", "password", "email"], function(idx, field) { hotfield(field, true).focus(function() { $(this).hide(); hotfield(field, false).show().focus(); }); hotfield(field, false).blur(function() { if ($(this).val() == "") { $(this).hide(); hotfield(field, true).show(); } }).keydown(function(e) { if (e.keyCode == 13) { this.form.submit(); } }); }); $(".subscribe").click(function() { var email = $("#email").val(); window.open("/users/add?" + email, "_self"); }); if ($("#UserEmail") && document.location.search) { var email = String(document.location.search).substring(1); $("#UserEmail").val(email); } $("a[href^=http://]").attr("target", "_blank"); $("a[href^=https://]").attr("target", "_blank"); });