﻿$(document).ready(function () {
    /* Accordion panel dropdown functionality */
    $("div.content div.column-2 ul.accordion li h4").click(
        function (e) {
            $(this).parent().toggleClass("active");
        }
    );
    /* External links open in a new window  */
    $("[rel='external']").click(function () {
        window.open(this.href);
        return false;
    });
    /* Login "Go" button */
    $("#investigator-button").click(function (e) {
        // redirect form
        $("#aspnetForm").attr("action", "http://www.tolerx.com/ipbeta/login.php");
        $("#aspnetForm").attr("name", "login");
        $("#aspnetForm").submit();
    });
    /* Login password field onEnter keypress */
    $("#investigator-password").keypress(function (e) {
        if (e.keyCode == 13) {
            // redirect form
            $("#aspnetForm").attr("action", "http://www.tolerx.com/ipbeta/login.php");
            $("#aspnetForm").attr("name", "login");
            $("#aspnetForm").submit();
        }
    });
    /* Investigator portal login/password fields */
    $("#investigator-username").click(function () {
        if ($(this).val() == "username")
            $(this).val('');
    });
    $("#investigator-password").click(function () {
        if ($(this).val() == "password")
            $(this).val('');
    });
    $("input.zip-search").keypress(function (e) {
        if (e.keyCode == 13) {
            $("input.go-search").click();
            e.preventDefault();
        }
    });
});