willow.grotonSearch = function(){
	willow.getLinks(15639, function(data){
		//Added custom search to go to a specific page if nothing was entered or go to a particular page according to link group
		var $obj = $("#search");
		$obj.pdSearch({showButton: true,showButtonClass: 'searchButton',showButtonText: ''});
		$obj.unbind();
		$obj.bind('submit', function() {
			var q = $.trim($(this).val()).toLowerCase();
			var options = {
				contentId:-1,
				persistUrlContentId:false,
				clearHistory: true,
				taskName:'Search',
				useAutoComplete:true
			};
			
			for(var i = 0; i < data.link.length; i++){ // If title of link group item is equal to what user searched for, go to a specific page
				if(q === $.trim(data.link[i].title).toLowerCase()){window.location.href = data.link[i].url;return;}
			}
			
			if(q === "search our site" || q === ""){
				window.location.href = '/about';
			}
			else{
				if ((q != null) && (q.length > 0)) {
					q = q.replace(/~/g, '');
					var ctQ = '';
					var ct = '';
					if (options.persistUrlContentId) {
						ct = getParameterByName('ct');
					}
					if (ct.length == 0 && options.contentId != -1) {
						ct = options.contentId.toString();
					}
					if (ct.length > 0 && ct != '-1') {
						ctQ = '&ct=' + ct;
					}
					if (window.pdGlobal && pdGlobal.userLoggedIn == true) {
						__pdL(52830, options.taskName, 1, 'q=' + q + ctQ.replace('&', '~'), '', options.clearHistory, 0, '', '');
					} else {
						window.location.href = '/podium/default.aspx?t=52830&q=' + escape(q) + ctQ;
					}
				}
			}
		});
		
		$obj.keypress(function(e){
			var c = e.which ? e.which : e.keyCode;
			if (c == 13) {
				$obj.submit();
				e.preventDefault();
				return false;
			}
		}); 
	});
}
