window.onload = init;

function init() {
  blurLinks();
};

/* ASSIGN BLUR ON HYPERLINKS */
function blurLinks() {
  theLinks = document.getElementsByTagName('a');
  for(i = 0; i < theLinks.length; i++) {
    theLinks[i].onfocus = function() { this.blur(); };
  }
};

/*  FRAMESET SEARCH MENU  */
function show(id) {
  var anchorTags = document.getElementsByTagName("li");
  for (var i = 0; i < anchorTags.length ; i++) {
    anchorTags[i].className= "";
  }
  document.getElementById(id).className=  "current";
};

/* FRAMESET LOAD URL */
function loadUrl(url) {
  parent.location.href= url;
};

/* Removes spaces from the beginning and the end ot the text. */
function trim(text){
    // Removes spaces from the beginning of the text.
    var re = /^ /;
    while(re.test(text)){
        text = text.replace(re, "");
    }

    // Removes spaces from the end of the text.
    var re1 = / $/;
    while(re1.test(text)){
        text = text.replace(re1, "");
    }

    return text;
};
/*
 * Checks if the search field is empty or less than 3 characters.
 */

function SubmitSearch(url) {
      var site    = trim(document.govidForm.site.value);
      var v    = trim(document.govidForm.query.value);
	  v    = v.replace(/\'/gi, '');
	  v    = v.replace(/\"/gi, '');
	  v    = v.replace(/\|/gi, '');
	  v    = v.replace(/\`/gi, '');
	  v    = v.replace(/\//gi, '');
      v    = v.replace(/\!/gi, '');
      var new_url = url + site + "/" + v + "/";
      parent.location= new_url;
      return false;

};
