// 
//  transparency.js
//  transparency
//  
//  Created by Jay Roberts on 2009-02-16.
//  Copyright 2009 DesignHammer. All rights reserved.
// 
$(document).ready(function() {

   // Search box auto clear behavior
   $('#dh-search-input').focus(function() {
      if ($(this).val() == 'Search') {
         $(this).val('');
      }
   });
   $('#dh-search-input').blur(function() {
      if ($(this).val() == '') {
         $(this).val('Search');
      }
   });

	// Search box, add query to url when submitting
	$('#dh-search-form').submit(function() {
		var action_url = $(this).attr('action');
		
		if ($('#dh-search-input').val() != '') {
			// Convert spaces to '%20', strip out any other non alphanumerics
			action_url += '/' + $('#dh-search-input').val().replace(/[\s]+/g, '%20').replace(/[^a-z0-9%]+/g, '');
		}

		$(this).attr('action', action_url);
	})
   
});

