//**********************************************************************************************************************
/**
* DOCUMENT: search.front.js
* DEVELOPED BY: Ryan Stemkoski
* COMPANY: Zipline Interactive
* EMAIL: ryan@gozipline.com
* PHONE: 509-321-2849
* DATE: 4/28/2010
* DESCRIPTION: This document contains programming required for the CMS login.  Requires the jQuery library.
*/
//***********************************************************************************************************************


//***********************************************************************************************************************
//ON DOCUMENT READY FUNCTIONS
//***********************************************************************************************************************
$(function() {

	//HANDLE FOCUS / BLUR OF SEARCH FIELD
	$(".search").focus(function() {
		var term = $('.search').val();
		if(term == "search") {
			$('.search').val("");
		} 
		$('.search').bind('keypress',function(e) { if(e.keyCode == 13) { do_search(); }});
	}).blur(function() {
		var term = $('.search').val();
		if(term == "") {
			$('.search').val("search");
		} 
		$('.search').unbind('keypress');
	});
	
	//DO THE SEARCH
	function do_search() {
	
		//GET THE SEARCH TERM
		var term = $('.search').val();
		
		//CHECK TO MAKE SURE IT ISN'T EMPTY OR SET TO SEARCH
		if(term != "" && term != "search") {
		
			//REDIRECT TO SEARCH
			window.location = "/search/" + escape(term) + "/";
		
		}
		
	}

});
