/*
 * Pinpoint javascripts
 *
 * These are javascripts used by pinpoint for behavior and display.
 *
 */

// TODO Document all of these

function saveSearchAndGo(destination)
        {
            if (document.forms['SearchForm']) {
                document.forms['SearchForm'].destinationPage.value = destination;
		        document.forms['SearchForm'].goSearch.value = "";
    			document.forms['SearchForm'].submit();
                return true;
            }
            else {
                return false;
            }
        }
function saveSourcesAndGo(destination)
        {
            if (document.forms['SourcesForm']) {
                document.forms['SourcesForm'].destinationPage.value = destination;
    			document.forms['SourcesForm'].submit();
                return true;
            }
            else {
                return false;
            }
        }

function clearLibraryAdvancedForm()
        {
            document.SearchForm.searchTerm1.value = "";
            document.SearchForm.searchTerm2.value = "";
            document.SearchForm.searchTerm3.value = "";
            document.SearchForm.searchLimit1.options[3].selected = true;
            document.SearchForm.searchLimit2.options[3].selected = true;
            document.SearchForm.searchLimit3.options[3].selected = true;
            document.SearchForm.searchOperator1[0].checked = "1";
            document.SearchForm.searchOperator2[0].checked = "1";
            document.SearchForm.searchTerm1.focus();
        }

function clearAllInfoAdvancedForm(infoType, level)
        {
            document.SearchForm.searchTerm1.value = "";
            document.SearchForm.searchTerm2.value = "";
            document.SearchForm.searchTerm3.value = "";
            document.SearchForm.searchOperator1[0].checked = "1";
            document.SearchForm.searchOperator2[0].checked = "1";
            document.SearchForm.searchTerm1.focus();
        }

function clearForm()
    {
	    document.SearchForm.reset();
    	document.SearchForm.searchTerm1.focus();
    }


function resetAllInfoSourcesForm()
{
	document.ViewAllInfoSourcesForm.status.value="RESET";
	document.ViewAllInfoSourcesForm.submit();
}

function openPinpointWindow (URL) {
            pinpointWindow = window.open(URL,"pinpointWindow","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=600");
           if (pinpointWindow.focus) { pinpointWindow.focus(); }
       }

function showDiv(layerName)
 {
  if (navigator.appName == "Netscape") {
        if(document.getElementById) {
            document.getElementById(layerName).style.visibility="visible";
            }
        else if(document.layers) {
                document.layers[layerName].visibility="visible";
                  }
       }
       else{
      if(document.getElementById) {
            document.getElementById(layerName).style.visibility="visible";
            }
     }

  }  //end show div

  function showHelp(jspfile,admin)
        {
         //find help file for current jsp file
         var helppath="";
          var helpfile="";
         if(admin == 1){
            //assign admin path
            helppath="../ppadminhelp/";
         }else{
            helppath="pinpoint_patron_help/";
            }

         var helpmap =  "allinfosearchform=ab_q_sch_pg,"+
                        "librarysearchform=ab_q_sch_pg_lib,"+
                        "allinfoadvancedsearchform=ab_a_sch_pg,"+
                        "libraryadvancedsearchform=ab_a_sch_pg_lib,"+
                        "libraryfulldisplay=ab_full_disp_pg,"+
                        "mybibliography=ab_mybib_pg,"+
                        "mylibraryinfo=ab_mylibinfo_pg,"+
                        "readingprogramsearchform=ab_r_sch_pg,"+
                        "searchresults=ab_sch_res_pg,"+
                        "viewallinfosources=ab_view_sch_sc,"+
                        "authenticateuser=lib_info_view,"+
                        "viewlibrarysources=ab_view_lib_sc,"+
                        "changeegemssettings=ab_ch_clip_pg,"+
                        "changemasterpassword=ab_ch_m_pwd_pg,"+
                        "patronaccessoptions=ab_ch_p_opts_pg,"+
                        "maintaindistrictsources=ab_d_sc_pg,"+
                        "editlibrarysources=ab_ed_lib_sc_pg,"+
                        "editinternetsources=ab_ed_int_sc_pg,"+
                        "editz39source=ab_ed_z_sc_pg,"+
                        "maintainsites=ab_maint_site_pg,"+
                        "editsites=ab_site_info_pg,"+
                        "districtsystemname=ab_dist_sys_name_pg,"+
                        "deletesite=site_delete,"+
                        "changeproxysettings=ab_proxy_pg,"+
                        "maintaingroups=ab_maint_grps_pg,"+
                        "changeemailsettings=ab_adm_email_pg,"+
                        "citationplugin=clip_plugin,";

         fileindex=helpmap.indexOf(jspfile.toLowerCase());
         if(fileindex > -1)
            {
            temp=helpmap.substring(fileindex,helpmap.indexOf(",",fileindex));
            helpfile=temp.split("=")[1];
            }
          if(helpfile==""){
                helpfile="index.htm";
                }else{
                helpfile="index.htm#"+helpfile+".htm";

                }

          eval("window.open('"+helppath+helpfile+"', 'PinpointHelp','width=772,height=450')");
         }