﻿// JScript File

function BlurSearchControl()
{
    oControlObj = document.getElementById('kpbsdBasicKeywords');
    
    if(oControlObj.value == "")
    {
        oControlObj.value = "Search the site";
        oControlObj.style.color = "#888";
    }
}

function FocusSearchControl()
{
    oControlObj = document.getElementById('kpbsdBasicKeywords');
    
    if(oControlObj.value == "Search the site")
    {
        oControlObj.value = "";
        oControlObj.style.color = "#888";
    }
}

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)
   {
       if (objsearchText.value != 'Search the site')
       {
           searchText = objsearchText.value;
           searchText = searchText.replace(/>/gi, " >");
           searchText = searchText.replace(/</gi, "< ");
           objsearchText.value = searchText;
       }
       else
       {
           searchText = '';
           searchText = searchText.replace(/>/gi, " >");
           searchText = searchText.replace(/</gi, "< ");
           objsearchText.value = '';
       }
   }
   
   // 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 + "//localhost/search.aspx?searchtext=" + searchText.replace('alert','').replace('confirm','');
   window.location.href = "/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
}
