	function clearText(field){
	 
	    if (field.defaultValue == field.value) field.value = '';
	    else if (field.value == '') field.value = field.defaultValue;
	 
	} 	
	$(document).ready(
	    function(){
			// ##################################
			// setup search paging links
			setPagingLinks();			
	    }
	);
	
	function goToPage (page){
		$("#top_search_form #page").val(page);
		$("#top_search_form #search_text1").val(decodeSearchTerm(searchTerm));
		$('#search_button').click();
	}
	
	function searchAgain (term) { 
		$("#top_search_form #page").val('1');
		$("#top_search_form #search_text1").val(term);
		$("#top_search_form #bn_if").val('');
		$("#top_search_form #bn_af").val('');
		$('#search_button').click();
	}
	
	function didYouMeanSearch (term) {
		term = decodeSearchTerm(term);
		$("#top_search_form #page").val('1');
		$("#top_search_form #search_text1").val(term);
		$('#search_button').click();
	}
	
	function decodeSearchTerm(term) {
		return term.replace(/&quot;/g, '\"');
	}
	
	var resultsTotal = 0;
	var resultsReturned = 0;
	function setPagingLinks() {
	    if (resultsTotal == 0) return "";
	    
	    var linkHTML = "";
	    var iPage = page;
	    // numItemsPerPage is set in the JHTML
	    var count = Math.ceil(resultsTotal / numItemsPerPage);
	    var iPages = count;
	    var iNumCount = 10;
	    var iPageStart = 1;
	    if (iPages < 11) iPageStart = 1;
	    else if (iPage-5 < 1) iPageStart = 1;
	    else if (iPage-5 > 0) iPageStart = iPage - 5;
	    
	    if (iPages == 0) return "";
	    
	    if (iPage != 1) {
	    	linkHTML += '<a href="javascript:goToPage(' + (iPage - 1) + ');"><strong style="color:#365ebf">Previous</strong></a>';
	    }
	    
	    for (i = iPageStart; i < (iPageStart + iNumCount) && i < iPages + 1; i++){
	    	if (i != iPage) {
	    		linkHTML += ' | <a href="javascript:goToPage(' + i + ');">' + i + '</a>';
	    	} else {
	    		linkHTML += ( i!=1 ? ' | ' : '') + i ;
	    	}
	    }
	    
	    if (iPage != iPages) {
	    	linkHTML += ' | <a href="javascript:goToPage(' + (iPage + 1) + ');"><strong style="color:#365ebf">Next</strong></a>';
	    }
		linkHTML = '<div class="clear"></div><div class="searchFooterBox"><div class="searchFooterNav">' + linkHTML + '</div>';
		
		// add in the matches text	
		var firstResultNum = (page * numItemsPerPage) - (numItemsPerPage - 1);
		var lastResultNum = firstResultNum + (numItemsPerPage - 1);
		if(lastResultNum > resultsTotal)
			lastResultNum = resultsTotal;
			
		linkHTML += '<div class="searchFooter">' + firstResultNum + ' - ' + lastResultNum + ' of ' + resultsTotal + ' matches</div>';
		
		$('.results_nav').html(linkHTML);
	}