function hideHiddenFacets() {
  $('.hiddenfacet').hide();
  
  $('div.facet').each(function() {
    $('.hiddenfacet:last', this).after('<li><a class="facetshow" href="#" title="More">More&hellip;</a></li>');
    $('.facetshow', this).toggle(function() {
      $('.hiddenfacet', $(this).parent().parent()).slideDown("fast");
      $(this).attr('title', 'Less');
      $(this).html('Less&hellip;');
    }, function() {
      $('.hiddenfacet', $(this).parent().parent()).slideUp("fast");
      $(this).attr('title', 'More');
      $(this).html('More&hellip;');
    });
  });
}

$(document).ready(function() {
	  //Set QT search text
	  $("#searchForm button").click(function() {
		if ( $('#qt').val() ==  $('#qt').attr('title')) {$('#qt').val("");}
		if ( $('#loc').val() ==  $('#loc').attr('title')){$('#loc').val("");}
	});
	
	$("#searchForm #qt").click(function() {
		if ( $('#qt').val() ==  $('#qt').attr('title')) {$('#qt').val("");}
	});	
	
	$("#searchForm #loc").click(function() {	 	  
		if ( $('#loc').val() ==  $('#loc').attr('title')){$('#loc').val("");}
	});
	  // Add font controls
      $('#page_control_li').prepend('<p id="pagecontrols"><a href="#" class="fontdec" title="Decrease font size" accesskey="r">A</a>&nbsp;|&nbsp;<a href="#" class="fontreset" title="Reset font size" accesskey="y">A</a>&nbsp;|&nbsp;<a href="#" class="fontinc" title="Increase font size" accesskey="t">A</a>&nbsp;|&nbsp;<a class="print icon icon-print" href="#" title="Print this page">Print this page</a></p>');
      var cookieSize = $.cookie("oofontsize");
      if (cookieSize) {
        $('body').css('fontSize', cookieSize +'px');
      }

      $('p#pagecontrols a.fontdec').click(function() {
          var newSize = parseFloat($('body').css('fontSize'), 10) * 0.8;
          if (newSize < 10) { newSize = 10; }
          $('body').css('fontSize', newSize +'px');
          $.cookie("oofontsize", newSize, { expires: 7 });
      });
      $('p#pagecontrols a.fontinc').click(function() {
          var newSize = parseFloat($('body').css('fontSize'), 10) * 1.2;
          if (newSize > 18) { newSize = 18; }
          $('body').css('fontSize', newSize +'px');
          $.cookie("oofontsize", newSize, { expires: 7 });
      });
	  $('p#pagecontrols a.fontreset').click(function() {
          var newSize = 12.8;
          $('body').css('fontSize', newSize +'px');
          $.cookie("oofontsize", newSize, { expires: 7 });
      });

      // Contrast controls
      var contrastMode = $.cookie("oomode");
      if (contrastMode == 'lightondark') {
          $('link#lightondark').removeAttr('disabled');
          $('link#darkonlight').attr('disabled', 'disabled');
      }
      $('p#pagecontrols a.contrast-dark').click(function() {
          // Change mode to dark on light
          $('link#darkonlight').attr('disabled', 'disabled');
          $('link#lightondark').removeAttr('disabled');
          $.cookie("oomode", "lightondark", { expires: 7 });
	  });
	  $('p#pagecontrols a.contrast-light').click(function() {
          $('link#darkonlight').removeAttr('disabled');
          $('link#lightondark').attr('disabled', 'disabled');
          $.cookie("oomode", "darkonlight", { expires: 7 });
      });
	  
	  $('a.print').click(function() {
            window.print();            
        });
});
