/**
 * Hide the submit button
 * Add submit functionality to select box
 * don't change
 */
Drupal.behaviors.siteCustomizationsExposedFilter = function(context) {

  // Hide the submit button
  $("#views-exposed-form-how-do-i-page-1 #edit-submit").hide();  
  
  // add submit functionaity to select box
  $('#edit-term-node-tid-depth:not(.siteCustomizationsExposedFilter-processed)', context)
  .addClass('siteCustomizationsExposedFilter-processed')
  // bind on change event
  .bind("change", function() {
    // Execute the submit function on the form
    $("#views-exposed-form-how-do-i-page-1").submit();
    return true;
  })
};

function OnSubmitForm() {
  val = $('#edit-site_customizations-search-type').val();
  //alert(val);
  switch (val) {
    case "0" : /* aquabrowser */
  		document.myform.action="http://aquabrowser.rivlib.com";
		  document.myform.method="get";
		  document.myform.target="_blank";
		  document.myform.submit();		
    break;
    case "1" : /* website */
		  window.location ="http://rivlib.info/riverside-county-library-system/search/node/"+document.myform.q.value;
    break;
    case "2" : /* Google */
      document.myform.action="http://google.com/search";
		  document.myform.query.value=document.myform.q.value;
		  document.myform.q.value="";
		  document.myform.method="get";
		  document.myform.target="_blank";
		  document.myform.submit();		
    break;
    case "3" : /* Bing */
 		  document.myform.action="http://bing.com";
		  document.myform.query.value=document.myform.q.value;
		  document.myform.method="get";
		  document.myform.target="_blank";
		  document.myform.submit();		
    break;
    case "4" : /* Yahoo */
 		  document.myform.action="http://search.yahoo.com/search";
		  document.myform.query.value=document.myform.q.value;
		  document.myform.method="get";
		  document.myform.target="_blank";
		  document.myform.submit();		
    break;
    case "5" : /* classic database */
		  document.myform.action="http://www.inlandlibrary.com/web2/tramp2.exe/do_keyword_search/guest";	
		  document.myform.method="post";
		  document.myform.query.value=document.myform.q.value;
	    document.myform.setting_key.value = "english";
	    document.myform.servers.value = "1home";
	    document.myform.query_screen.value = "Home.html";
	    document.myform.useSessions.value = "1";
      document.myform.search_type["0"].value="";
		  document.myform.target="_blank";
		  document.myform.submit();
    break;
  }  
};
