﻿// JScript File

function BlurSearchControl()
{
    oControlObj = document.getElementById('kpbsdBasicKeywords');
    
    if(oControlObj.value == "")
    {
        oControlObj.value = "Search our site";
        oControlObj.style.color = "#999999";
    }
}

function FocusSearchControl()
{
    oControlObj = document.getElementById('kpbsdBasicKeywords');
    
    if(oControlObj.value == "Search our site")
    {
        oControlObj.value = "";
        oControlObj.style.color = "#000000";
    }
}

function checkKeycode(e) {
   var keycode;
   if (window.event) // IE
        keycode = e.keyCode;
   else if (e.which) // Netscape/Firefox/Opera
        keycode = e.which;
   if (keycode==13)
   { 
      CallSearch();
      return false;
   }
}

function CallSearch()
{
   var objsearchText = document.getElementById('kpbsdBasicKeywords');
   var searchText;
   if ((objsearchText!=null))
   {
       searchText = objsearchText.value;
       searchText = searchText.replace(/>/gi, " >");
       searchText = searchText.replace(/</gi, "< ");
       objsearchText.value = searchText;
   }
   
   // 20090102 ERS - Changed from a relative link to a full link to fix GetTemplate()'d sites on Internal.
   var proto = window.location.protocol;
   if (proto == "") { proto = "http"; }

   window.location.href = proto + "//www.kpbsd.k12.ak.us/search.aspx?searchtext=" + searchText.replace('alert','').replace('confirm','');
   //Load the page with the websearch server control in the bottom frame using Javascript
   //Set websearch properties using querystring parameters
   //Properties set here- search text,Orderby, FolderId, and SearchFor
   //SearchFor can be a value from all/html/documents/images/multimedia/discussionForum
   //Orderby can be one of these - editor,id,rank,title,datecreated,datemodified
   //OrderDirection can be ascending or descending
}