
$(document).ready(function() {
    
    /* focus on first empty, non-hidden form input on page or an error if we have one */  
    if ($('.error:visible').length > 0) {
       $('.error:visible:first').focus();
    } else if ($('input[value=""]:visible')) {
       $('input[value=""]:visible:first').focus();
    } else if ($('input:visible').length > 0)  {
       $('input:visible:first').focus();
    }
    
    $(".back_button").live("click",function() {
        history.go(-1);
    });
    
    $("#reset_link").click(function() {
        if ($("#email").val() != "") {
            var href = $(this).attr("href");
            $(this).attr("href",href+"?email="+$("#email").val());
        }
    });
    
    $("#twitter_link").live("click", function() {
        window.location = "http://twitter.com/leehoo";
    });
    
    $("#demo_video").live("click", function() {
        window.location = "video-demo.html";
    });

    
    /* demo JS */
    var default_url_txt = $("#url").val();
    var default_url_color = $("#url").css("color");
    
    $("#url").focus(function() {
        $("#url").val("").css("color","#666");
    });
    $("#url").blur(function() {
        $("#url").val(default_url_txt).css("color",default_url_color);
    });
 
});


