$( function() {
	
	/**
	 * Causes links with the class "external" to open in a new window. This
	 * simulates the behavior of target="_blank" (which is illegal in XHTML
	 * Strict).
	 * @author Travis Miller <travis@electrumdigital.com>
	 */

	$("a.external").click( function( e ) {
		e.preventDefault();
		window.open( this.href );
	} );

	/**
	 * Unobtrusively set up placeholder behaviors on all text inputs for which
	 * the title attribute has been set. The title text will be used as the
	 * placeholder text.
	 * @author Travis Miller
	 * @link http://www.electrumdigital.com/
	 */
	
    $("input[type=text][title],textarea[title]")
    .each( function() {
        showPlaceholder( $(this) ); // initialize each control on page load
    } )
    .blur( function() {
        showPlaceholder( $(this) );
    } )
    .focus( function() {
        var $input = $(this);
        if ( $input.val() === $input.attr("title") ) {
            $input.removeClass("placeholder");
            $input.val("");
        }
    } );

	function showPlaceholder( $input ) {
	    var placeholderText = $input.attr("title");
	    if ( $input.val() === "" || $input.val() === placeholderText ) {
	        $input.addClass("placeholder");
	        $input.val(placeholderText);
	    }
	};

	/**
	 * Showcase lightboxes (in sidebar and main showcase page)
	 */
	
	var $showcaseLinks = $("#showcase-index a,#showcase-index-sidebar a"); 
	
	if ( $showcaseLinks.length ) {
		$showcaseLinks.fancybox( {
			type: "iframe",
			width: 880,
			height: $(window).height(),
			overlayOpacity: 0.6,
			overlayColor: "#000",
			centerOnScroll: true,
			padding: 1
		} );
	}
	
} );
