﻿
// ------- UNIVERSAL PAGE CODE FOR EACH LOAD, RICHARDS LAYTON & FINGER
$(document).ready(function () {
    // configure enter-to-submit on our sidebar searches
    $('.sharedsidesearchsection').each(function () {
        $(this).find('input.sharedtextinput').satEnterSubmit($(this).find('input.sharedsidesearchsubmit'));
    });

    // hide the feature section if it is empty!
    $('div.pagefeature:empty').hide();

    // show the 'back to top' link if the page is kinda long
    if ($(document).height() > 1400) {
        $('#pagefootertoplink').show();
    }

    // configure email-this-page links, same as the old site did it
    $('a.pagetoolemail').click(function () {
        var a = window.location.href;
        window.location = "mailto:?body=" + escape(a);
        return false;
    });

    // configure mailto: links to have a disclaimer, like the old site
    var WARNINGTEXT = "Transmitting information to us by E-mail does not establish an attorney-client relationship. As a result, you should not send us any information that you would want treated confidentially.";
    $('a[href^="mailto:"]').click(function () {
        if (confirm(WARNINGTEXT)) {
            window.location = $(this).attr('href');
        }
        return false;
    });
});


// add enter-to-submit functionality to an element
// pass in the element you wish to be 'clicked' when enter is pressed
jQuery.fn.satEnterSubmit = function (submitelement) {
    jQuery(this).keypress(function (e) {
        if (e.keyCode == 13) {
            jQuery(submitelement).click();
            return false;
        }
    });
    return jQuery(this);
};

// auto-hint functionality for textboxes
// crafted by Brian 07/26/2010, tweaked 01/14/2011, tested on jQuery 1.4.2
jQuery.fn.autoHint = function () {
    // loop through all our items and set them up one by one
    jQuery(this).each(function (idx) {
        var mytextbox = jQuery(this);
        var myhint = mytextbox.attr('placeholder');
        // needs a title attribute to be set to the hint value
        if (myhint) {
            // on focus, automatically clear the hint
            mytextbox.bind('focus', function () {
                if (jQuery(this).val() == myhint) {
                    jQuery(this).val('');
                }
            });

            // on blur, replace the hint if we have no text
            mytextbox.bind('blur', function () {
                if (jQuery(this).val() == '') {
                    jQuery(this).val(myhint);
                }
            });

            // force focus loss to initialize
            mytextbox.blur();
        }
    });
    return jQuery(this);
};

// set up the auto-hints on any input textbox with a placeholder attribute defined!
jQuery(document).ready( function() {
    jQuery('input[placeholder]').autoHint();
});



