// Ensure school search box is only enabled after DOM is loaded &
// set the placeholder text.
(function($){
	var search_prompt = "school name";
	var $searchBox = $('form#basic_school_search input');

    if( $searchBox.length > 0 )
    {
        $searchBox.val(search_prompt);
        $($searchBox + ":disabled").removeAttr('disabled');
        $searchBox
            .focus(function(){
                if( $searchBox.val() == search_prompt ) $searchBox.val('');
            })
            .blur(function(){
                if( $searchBox.val() == '' ) $searchBox.val(search_prompt);
            });
    }

    // Hide the Plus One button if the add this button is hovered
    $("a.addthis_button_compact").mouseover(function() {
        $("div table.gc-bubbleDefault").hide();
    });

    $("a.addthis_button_google_plusone").mouseover(function() {
        $("div table.gc-bubbleDefault").show();
    });
})(jQuery);


// Set event listener for flash message "close" buttons.
(function($){
	$('span.closeMe').live('click', function(){
		$(this).parents('div.flash').fadeOut('normal', function(){
			$(this).remove();
		});
		
		$(this).parents('div.featured_school_call_to_action').fadeOut('normal', function(){
			// Set cookie so the call to action isn't displayed after user dismisses it.
			$.cookie('displayFeaturedSchoolCTA', 0, {expires: 90});
		});
	});
})(jQuery);

function getQueryParams() {
	var hash;
	var vars = [];
	
	var hashes = window.location.href.slice(window.location.href.indexOf('?') +1).split('&');
	for( var i=0; i < hashes.length; i++ ) {
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
	
	return vars;
}
