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;
   }
   else
        return true;
}

function remove_s_hint(targetInput) {

    if (targetInput.value == "") {
        targetInput.value = "Enter Keyword(s)...";
    }
    else if (targetInput.value=="Enter Keyword(s)...")
        targetInput.value="";
}


function CallSearch()
{

   var objsearchText = document.getElementById('txtSearchText');
   var searchText;
   if ((objsearchText!=null))
   {
       searchText = objsearchText.value;
       searchText = searchText.replace(/>/gi, " >");
       searchText = searchText.replace(/</gi, "< ");
       objsearchText.value = searchText;
   }

   //This cookie is used for the backbutton to work in search on postback
   //This cookie must be cleared to prevent old search results from displayed

   document.cookie='postbackcookie=';
   var this_url = "/search.aspx?searchtext=" + searchText.replace('alert','').replace('confirm','');
   document.location.href = this_url;

   //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
}

// Changes links to point to staging site while on staging server. 
// CMS should be doing this automatically but its not always doing it. 
// For example menu items that are also folders or menu items that are using absolute paths.
// This also changes all the link to point to development while on development server
// This should not effect production at all.
function fixlinks() {
    var hostname = ""

   


    if (document.location.hostname.substr(0,4) == 'dev.')
    {	
	    for (var i = 0; i < document.links.length; i++) {
		    hostname = document.links[i].hostname;

		    if (hostname == 'www.hawaiipacifichealth.org' ||
		        hostname == 'www.kapiolani.org' ||
		        hostname == 'www.palimomi.org' ||
		        hostname == 'www.straubhealth.org' ||
		        hostname == 'www.wilcoxhealth.org' ||
		        hostname == 'www.kapiolaniwoman.org')

		    {
			    document.links[i].href = document.links[i].href.replace("www.", "dev.");
			    document.links[i].href = document.links[i].href.replace("https:", "http:");
		    }

		    if (hostname == 'stage.hawaiipacifichealth.org' ||
		        hostname == 'stage.kapiolani.org' ||
		        hostname == 'stage.palimomi.org' ||
		        hostname == 'stage.straubhealth.org' ||
		        hostname == 'stage.wilcoxhealth.org' ||
		        hostname == 'stage.kapiolaniwoman.org')

		    {
			    document.links[i].href = document.links[i].href.replace("stage.", "dev.");
			    document.links[i].href = document.links[i].href.replace("https:", "http:");
		    }
		    
		    if (hostname.substr(0,4) == 'dev.')
			    document.links[i].href = document.links[i].href.replace("https:", "http:");
	    }
    }

    if (document.location.hostname.substr(0,6) == 'stage.')
    {
	    for (var i = 0; i < document.links.length; i++) {
		    hostname = document.links[i].hostname;

		    if (hostname == 'www.hawaiipacifichealth.org' ||
		        hostname == 'www.kapiolani.org' ||
		        hostname == 'www.palimomi.org' ||
		        hostname == 'www.straubhealth.org' ||
		        hostname == 'www.wilcoxhealth.org' ||
		        hostname == 'www.kapiolaniwoman.org')

		    {
			    document.links[i].href = document.links[i].href.replace("www.", "stage.");
			    document.links[i].href = document.links[i].href.replace("https:", "http:");
		    }
		    
		    if (hostname.substr(0,6) == 'stage.')
			    document.links[i].href = document.links[i].href.replace("https:", "http:");
	    }
    }
}