// This function handles the Search box default text
function intSearch(e,flag) {
   var color = e.style.color;
   var value = trimAll(e.value)
   if (flag == 0 && value == "") {
      e.style.color = "silver";
      e.value = "search this website";
   }
   else if (flag == 1 && value == "search this website") {
      e.value = "";
      e.style.color = "#000";
   }
}

function trimAll(sString) {
   while (sString.substring(0,1) == ' ') { 
      sString = sString.substring(1, sString.length);
   }
   while (sString.substring(sString.length-1, sString.length) == ' ') {
      sString = sString.substring(0,sString.length-1);
   }
   return sString;
}

// This bit of code will eliminate the JS errors you get while hovering
// over the ypSlideOutMenus on page load.
// In fact we are basically dismissing all JS errors with this bit of code

function silentHandler()  {
	return true
}

window.onerror = silentHandler

// This is a work around for external links and XHTML 1.1

function externalLinks() {
    if(!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for(var i=0; i<anchors.length; i++) {
        var anchor = anchors[i];
        if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
            anchor.onclick = function(){window.open(this.href);return false;};
        }
    }
}

window.onload = externalLinks;

