(function($){
    
    //<!--NOTE: if this is included, must also include guidedSearchForm-->
    $.navMap = {
        'Watch the Intro' : 'intro',
        'Read the Stories' : 'articles',
        'See the Map' : 'where',
        'Explore Connections' : 'who',
        'Search the Data': 'dig'
    }
    $(document).ready(function() {
        $('input.tsaSearch').focus(function() {
            if( this.value == this.defaultValue ) {
                this.value = "";
            }

        });

        // $("a.modalInput").overlay({
        //     top: 15,
        //     left: 23,
        //     absolute: true,
        //     closeOnClick: true,
        //     onBeforeLoad: function(evt){
        //         var $el = null;
        //         $el = $(evt.srcElement); // webkit, ie
        //         if (typeof evt.srcElement == 'undefined'){
        //             $el = $(evt.originalTarget); // gecko
        //         }
        //         var origId = null;
        //         $('#noRoll').each(function(){
        //             $(this).attr('id', $.navMap[$(this).attr('title')]);
        //             origId = $(this).attr('id');
        //         })
        //         $el.data('realId', $el.attr('id'));
        //         $el.data('origId', origId);
        //         $el.attr('id', 'noRoll');
        //     },
        //     onLoad: function() {
        //             ;
        //         if ((typeof (thisMovie("video-player.swf"))) != "undefined") {
        //             sendToActionScript("video-player.swf","stopVideo");
        //         }   
        //         // hide flash ads
        //         $('#profile div.right object, #profile div.right embed').hide();
        //     },
        //     onBeforeClose: function(evt){
        //         $el = $('#noRoll');
        //         $el.attr('id', $el.data('realId'));
        //         $('#' + $el.data('origId')).attr('id', 'noRoll');
        //     },
        //     onClose: function(){
        //         // show flash ads
        //         $('#profile div.right object, #profile div.right embed').show();
        //     }
        // });


        $("form.tsaToolbarSearch").submit(function(e) {
        var formMethod = "GET";
        var formAction = "/top-secret-america/search/";
            // close the overlay
            // if ($("a.modalInput")) {
            //     $("a.modalInput").overlay().close();
            // }

            // get user input
            var input = this.keywords.value;
            
            $(this).attr("method",formMethod)
                .attr("action",formAction)
                .attr("target","_top");
        // do not submit the form
       // return e.preventDefault();
        });

    });
    
})(jQuery);
