// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Description : This library should contain ROOMS~specific functions.
// This file is NOT Velocitized
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Supervisor: Dave Dean
// Programmer: Jeremy Ford
// Date: *before* December 5, 2003
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



   function isDebug()
   {
        return false;
   }



function doSearch(theForm) {
//   var searchType = theForm.search_type.options[theForm.search_type.selectedIndex].value
   var searchType = theForm.search_type.value;
   
   if(searchType == "SingleSearch") {
     var f = document.SingleSearchForm;
     f.queryStatement.value = theForm.query.value;
     beforeSubmit(f);
     f.submit();
   } else if (searchType == "Lucene") {
     var f = document.RoomsSearchForm;
     f.query.value = theForm.query.value;

     f.submit();
   }
}

function framedRedirect(url,openInPopup) {
    var f = document.FramedRedirectForm;
    
    if (f.open_in_popup == null) {
        //consolidated view
        if (openInPopup == "false") {
            window.open(url,"MainRoomsWindow");
        }
        else {
            window.open(url,"_blank");
        }
    }

    else {
    
        f.target="";
        f.open_in_popup.value = "no";
        f.url.value = url;
    
        if((openInPopup == "yes") || (openInPopup == "true")) {
            f.target="_blank";
            f.open_in_popup.value = "yes";
        }
    
        f.submit();
    }
}

function framedRedirectRateIt(url, openInPopup, id, score, votes) {
    var f = document.FramedRedirectForm;

    f.target="";
    f.open_in_popup.value = "no";
    f.url.value = url;
    f.id.value = id;
    f.score.value = score;
    f.votes.value = votes;

    if((openInPopup == "yes") || (openInPopup == "true")) {
        f.target="_blank";
        f.open_in_popup.value = "yes";
    }
    
	f.submit();
}

var myWindow;
function openChild(myURL, myName, myParams) { 
    if(myWindow && !myWindow.closed) { 
        myWindow.location = myURL; 
        setWindowFocus(myWindow);
    } else { 
        myWindow = window.open(myURL, myName, myParams);
    }
}

function setStatus(msg) {
    window.status=msg;
}

function setHash(hash) {
  document.location.hash= hash;
}


function addEngine(basePath, plugin)
{
  if ((typeof window.sidebar == "object") &&
      (typeof window.sidebar.addSearchEngine == "function")) {
      window.sidebar.addSearchEngine(basePath + 'plugins/' + plugin + '.src',
                                     basePath + 'pugins/' + plugin + '.jpg',
                                     'Academic',
                                     'Academic');
      
  } else {
      alert("Cannot add Search Engine");
  }
}

