function hl_ut(){// dummy temp function for urchin links on cobrand
  return true;
}

String.prototype.trim = StringTrim;
function StringTrim(){
  var TestString = this;
  TestString = TestString.replace( /^\s+/g,"");
  TestString = TestString.replace( /\s+$/g,"");
  return TestString;
}

function hideAll()
{
  if(xGetElementById('menuimage-A')){
    hideIt(xGetElementById('menufull-A'), xGetElementById('menuimage-A'), xGetElementById('menu-A'));
  }
  if(xGetElementById('menuimage-B')){
    hideIt(xGetElementById('menufull-B'), xGetElementById('menuimage-B'), xGetElementById('menu-B'));
  }
  if(xGetElementById('menuimage-C')){
    hideIt(xGetElementById('menufull-C'), xGetElementById('menuimage-C'), xGetElementById('menu-C'));
  }
  if(xGetElementById('menuimage-D')){
    hideIt(xGetElementById('menufull-D'), xGetElementById('menuimage-D'), xGetElementById('menu-D'));
  }
}

function hideIt(menuOld, trgOld, trigdivOld){
  var openarrow = "/images/icon_showall.gif";
  xHide(menuOld);
  trigdivOld.style.backgroundColor = "#ffffff";
  var parent =  node_parent(trgOld);
  if (parent){
    if(node_after(parent).className == "clear"){
      node_after(parent).style.backgroundColor = "#ffffff";
    }
    var trgparentnodes = parent.childNodes;
    for (var i = 0; i < trgparentnodes.length; i++){
      if (trgparentnodes[i].nodeType == 1 && trgparentnodes[i].getAttribute("href") != null){
        trgparentnodes[i].style.background = "#ffffff";
      }
    }
  }
  var trgnodes = trgOld.childNodes;
  for (var i = 0; i < trgnodes.length; i++){
    if ((trgnodes[i].nodeType == 1) && (trgnodes[i].nodeName == "IMG")){
      trgnodes[i].src = openarrow;
    }
  }
}

function closeNavWidgetMenus(){
  if(xGetElementById('menuimage-A')){
    hideIt(xGetElementById('menufull-A'), xGetElementById('menuimage-A'), xGetElementById('menu-A'));
  }
  if(xGetElementById('menuimage-B')){
    hideIt(xGetElementById('menufull-B'), xGetElementById('menuimage-B'), xGetElementById('menu-B'));
  }
  if(xGetElementById('menuimage-C')){
    hideIt(xGetElementById('menufull-C'), xGetElementById('menuimage-C'), xGetElementById('menu-C'));
  }
  if(xGetElementById('menuimage-D')){
    hideIt(xGetElementById('menufull-D'), xGetElementById('menuimage-D'), xGetElementById('menu-D'));
  }
}

function xMenu1(triggerId, triggerDiv, menuId, mouseMargin, openColor){
  var trg = xGetElementById(triggerId);
  var trgdiv = xGetElementById(triggerDiv);
  var mnu = xGetElementById(menuId);
  var widgethead = openColor;
  var widgetbody = "#FFFFFF";
  var closearrow = "/images/icon_showless.gif";
  var openarrow = "/images/icon_showall.gif";
  var flag = xVisibility(mnu);
  closeNavWidgetMenus();
  if (flag == '' || flag == 'hidden'){
    xWidth(mnu, xWidth(trgdiv));
    xShow(mnu);
    trgdiv.style.backgroundColor = widgethead;
    if (trg.parentNode){
      if(node_after(trg.parentNode).className == "clear"){
        node_after(trg.parentNode).style.backgroundColor = widgethead;
      }
      var trgparentnodes = trg.parentNode.childNodes;
      for (var i = 0; i < trgparentnodes.length; i++){
        if (trgparentnodes[i].nodeType == 1 && trgparentnodes[i].getAttribute("href") != null){
          trgparentnodes[i].style.backgroundColor = widgethead;
        }
      }
    }
    var trgnodes = trg.childNodes;
    for (var i = 0; i < trgnodes.length; i++){
      if ((trgnodes[i].nodeType == 1) && (trgnodes[i].nodeName == "IMG")){
        trgnodes[i].src = closearrow;
      }
    }
  }
}

function morehealthmaps(link){
  if (xDisplay("healthmap_full") == "none"){
    xDisplay("healthmap_full", "block");
    link.innerHTML = "&laquo; less";
  } else {
    xDisplay("healthmap_full", "none");
    link.innerHTML = "more &raquo;";
  }
}

var lastcolor;
var lastlen;
function checklength(obj, len, id) {
  var color = "#666640";
  var count = "";
  if (obj.value.length >= len) {
    color = "red";
    obj.value = obj.value.substring(0, len);
  } else if (len - obj.value.length < len * 0.25)
    color = "#666640";

  if (obj.value.length != lastlen) {
    count = len - obj.value.length;
    document.getElementById(id).innerHTML = count;
  }
  if (color != lastcolor) {
    lastcolor = color;
    document.getElementById(id).style.color = color;
  }
}

function setParameter(textareaobj){
  checklength(textareaobj, 4000, 'desclength');
  setFocus();
}

function validateemail(strValue) {
  var objRegExp  = new RegExp("^[a-z0-9][a-z0-9_.-]*[a-z0-9_]@[a-z0-9][a-z0-9-]*[a-z0-9](\\.[a-z0-9][a-z0-9-]*[a-z0-9])+\\.?$","i");
  return objRegExp.test(strValue);
}

function validatescreenname(strValue) {
  if (strValue.length < 3) {
    return false;
  }
  var objRegExp  = new RegExp("[<>&\\\\]", "i");
  return !objRegExp.test(strValue);
}

function validatezip(strValue) {
  var objRegExp  = new RegExp("^[0-9]{5}$", "i");
  return objRegExp.test(strValue);
}

function validfield(strValue){
  var objRegExp = new RegExp("[^ \t\n]");
  return objRegExp.test(strValue);
}

function validname(strValue){
  var objRegExp  = new RegExp("[<>&\\\\]", "i");
  return !objRegExp.test(strValue);
}

function validphone(strValue){
  return (/\([0-9]{3}\)\s?[0-9]{3}\-[0-9]{4}/.test(strValue));
}

function is_all_ws(nod){
  return !(/[^\t\n\r ]/.test(nod.data));
}

function is_ignorable(nod){
  return ( nod.nodeType == 8) || ( (nod.nodeType == 3) && is_all_ws(nod) );
}

function node_parent(child){
 var parent = window.event ? child.parentElement : child.parentNode;
  return parent;
}

function node_before(sib){
  while ((sib = sib.previousSibling)){
    if (!is_ignorable(sib))
      return sib;
  }
  return null;
}

function node_after(sib){
  while ((sib = sib.nextSibling)){
    if (!is_ignorable(sib))
      return sib;
  }
  return null;
}

function last_child(par){
  var res=par.lastChild;
  while (res) {
    if (!is_ignorable(res)) return res;
    res = res.previousSibling;
  }
  return null;
}

function first_child(par){
  var res=par.firstChild;
  while(res){
    if (!is_ignorable(res))
      return res;
    res = res.nextSibling;
  }
  return null;
}

function data_of(txt){
  var data = txt.data;
  data = data.replace(/[\t\n\r ]+/g, " ");
  if (data.charAt(0) == " ")
    data = data.substring(1, data.length);
  if (data.charAt(data.length - 1) == " ")
    data = data.substring(0, data.length - 1);
  return data;
}

function kwbold(el,keyword) {
  for (var i = 0; i < el.length; i++) {
    if (window.RegExp) {
      var rawq = keyword;
      var rawarr = rawq.split(/\s+/);
      for (x = 0; x < rawarr.length; x++) {
        var regline = new RegExp("\\b" + rawarr[x] + "\\b", "i");
        for (y = 1; y < 4; y++) {
          if (y == 1) {
            strline = el[i].line1;
          }
          else if (y == 2) {
            strline = el[i].line2;
          }
          else {
            strline = el[i].line3;
          }
          if (matchfound = regline.exec(strline)) {
            for (var j = 0; j < matchfound.length; j++) {
              if (y == 1) {
                google_ads[i].line1 = strline.replace(matchfound[j], "<strong>" + matchfound[j] + "</strong>");
              }
              else if (y == 2) {
                google_ads[i].line2 = strline.replace(matchfound[j], "<strong>" + matchfound[j] + "</strong>");
              }
              else {
                google_ads[i].line3 = strline.replace(matchfound[j], "<strong>" + matchfound[j] + "</strong>");
              }
            }
          }
        }
      }
    }
  }
}

function popUp(strURL,strType,strWidth,strHeight){
  var strOptions="";
  if (strType=="news") strOptions="toolbar,menubar,scrollbars,resizable,location,status,titlebar,height="+strHeight+",width="+strWidth+",top=100,left=100";
  else if (strType=="symptomsearchresult") strOptions="toolbar,menubar,scrollbars,resizable,location,status,titlebar,height="+strHeight+",width="+strWidth+",top=100,left=100";
  window.open(strURL, 'newWin', strOptions);
}

function tohtmlchars(objValue){
  var strValue = objValue;
  strValue = strValue.replace(/[\<]+/g,"&lt;");
  strValue = strValue.replace(/[\>]+/g,"&gt;");
  return strValue;
}

HL_healthmap = function(p_oEvent){
  return{
    success:function(o){
      xGetElementById('healthmap').style.display = "block";
      xGetElementById('healthmap').innerHTML = o.responseText;
    },

    failure:function(o){
      alert('Could not retrieve HealthMap. Please try again later.');
    },

    close:function(o){
      xGetElementById('healthmap').style.display = "none";
    },

    startRequest:function(nodeId) {
      YAHOO.util.Connect.asyncRequest('GET', '/hmap.jsp?node=' + nodeId, HL_healthmap, null);
    }
  };
}();

HL_newhealthmap = function(p_oEvent){
  var healthmapcontainer;
  var healthmapid;
  var zedohtml = "";
  var zedomargin = "";
  return{
    success:function(o){
      JSONobj = eval('(' + o.responseText + ')');
      if (JSONobj.healthmap.zedo) {
        zedohtml = "<iframe src=\"" + JSONobj.healthmap.zedo + "\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" allowTransparency=\"true\" width=\"120\" height=\"90\" style=\"float:left\"></iframe>";
        zedomargin = "style=\"margin-top:30px\"";
      }
      healthmaphtml = zedohtml + "<div class=\"hmap-close\"><a href=\"javascript:HL_newhealthmap.close();\"><img src=\"/images/close_hmap.gif\" alt=\"\" border=\"0\"/></a></div><div class=\"hmap-title\">" + JSONobj.healthmap.name + " HealthMap &reg;</div><div class=\"hmap-directions div-margin-medium\">Click a box to search the web</div>" +
                      "<div " + zedomargin + "><OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" WIDTH=\"500\" HEIGHT=\"725\" id=\"" + JSONobj.healthmap.node + "\">" +
    "<PARAM NAME=movie VALUE=\"/healthmapflash/" + JSONobj.healthmap.map + "/" + JSONobj.healthmap.map + ".swf?node=" + JSONobj.healthmap.node + "&\">" +
    "<PARAM NAME=quality VALUE=high>" +
    "<PARAM NAME=wmode VALUE=transparent>" +
    "<PARAM NAME=bgcolor VALUE=#FFFFFF>" +
    "<EMBED src=\"/healthmapflash/" + JSONobj.healthmap.map + "/" + JSONobj.healthmap.map + ".swf?node=" + JSONobj.healthmap.node + "&\" quality=high bgcolor=#FFFFFF WIDTH=\"500\" HEIGHT=\"725\"" +
    "NAME=\"" + JSONobj.healthmap.map + "\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" wmode=\"transparent\"" +
    "PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT></div>" +
      "<div class=\"div-margin-medium text-align-center\">Copyright &copy; 2005-2006 Healthline Networks, Inc. All Rights Reserved Worldwide.</div>" +
      "<div class=\"hmap-close\"><a href=\"javascript:HL_newhealthmap.close();\"><img src=\"/images/close_hmap.gif\" alt=\"\" border=\"0\"/></a></div>";
      healthmapdiv.innerHTML = healthmaphtml;
    },
    failure:function(o){
      if (document.getElementById("healthmap-div")) {
        healthmapcontainer.removeChild(healthmapcontainer.lastChild);
      }
    },
    close:function(o){
      if (document.getElementById("healthmap-div")) {
        healthmapcontainer.removeChild(healthmapcontainer.lastChild);
      }
    },
    startRequest:function(nodeId,position) {
      healthmapcontainer = document.getElementById("healthmap-container-"+position);
      healthmapdiv = document.createElement("div");
      healthmapdiv.id = "healthmap-div";
      healthmapdiv.className = "healthmap-div";
      healthmapdiv.innerHTML = "<img src=\"/images/loading.gif\" align=\"center\"/>";
      healthmapcontainer.appendChild(healthmapdiv);

      YAHOO.util.Connect.initHeader('X-Requested-With', 'XMLHttpRequest', true);
      YAHOO.util.Connect.asyncRequest('GET', '/v2/hmap?node=' + nodeId, HL_newhealthmap, null);
    }
  };
}();

var article = window.article || {};
article.jsfunctions = function(){
  return{
    disclaimer: function() {
      disclaimtext = "<p class=\"disclaim\">"+
      "The Healthline Site, its content, such as text, graphics, images, search "+
      "results, HealthMaps, Trust Marks, and other material contained on the "+
      "Healthline Site (\"Content\"), its services, and any information or material "+
      "posted on the Healthline Site by third parties are provided for informational "+
      "purposes only.  None of the foregoing is a substitute for professional medical "+
      "advice, examination, diagnosis, or treatment.  Always seek the advice of a "+
      "physician or other qualified healthcare provider with any questions you may "+
      "have regarding a medical condition. Never disregard professional medical advice "+
      "or delay in seeking it because of something you have read on the Healthline "+
      "Site. If you think you may have a medical emergency, call your doctor or 911 "+
      "immediately.  Please read the <a href=\"/popup_termsofservice.jsp\" onclick=\"popUp(this.href,'news',640,480);return false;\">Terms of Service</a> for more information regarding "+
      "use of the Healthline Site."+
      "</p>";
      return (disclaimtext);
    }
  };
}();

function closehealthmap(){
  xGetElementById('healthmap').style.display = "none";
}

function sw_form(thisform){
  var count = 0;
  if(thisform.symptom0 != null){
    if(thisform.symptom0.checked){
      thisform.action += "&addterm=" + thisform.symptom0.value;
      count++;
    }
  }
  if(thisform.symptom1 != null){
    if(thisform.symptom1.checked){
      thisform.action += "&addterm=" + thisform.symptom1.value;
      count++;
    }
  }
  if(thisform.symptom2 != null){
    if(thisform.symptom2.checked){
      thisform.action += "&addterm=" + thisform.symptom2.value;
      count++;
    }
  }
  if(count > 0){
    location.href = thisform.action;
  }
  else{
    alert("Please check one or more boxes, then press search.")
  }
}

HL_pasteHealthmap = function(){
  var healthmapContainerId = "healthmap-container";
  return{
    pasteMap:function(imuid, display, cfUrl){

      var healthmapHtml = "<div class=\"hmap-close\"><a href=\"javascript:HL_pasteHealthmap.closeMap();\"><img src=\"/images/close_hmap.gif\" alt=\"\" border=\"0\"/></a></div><div class=\"hmap-title\"> " + display + " : HealthMap &reg;</div><div class=\"hmap-directions div-margin-medium\">Click a box to search the web</div>" +
        "<div id=\"map_layer\"><OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\" WIDTH=\"750\" HEIGHT=\"550\" id=\"" + imuid + "\">" +
        "<PARAM NAME=movie VALUE=\"/corporate/test/usnews_map.swf?imuid=" + imuid + "\">" +
        "<PARAM NAME=quality VALUE=high>" +
        "<PARAM NAME=wmode VALUE=transparent>" +
        "<PARAM NAME=bgcolor VALUE=#FFFFFF>" +
        "<EMBED src=\"/corporate/test/usnews_map.swf?imuid=" + imuid +"\" quality=high bgcolor=#FFFFFF WIDTH=\"750\" HEIGHT=\"550\"" +
        "NAME=\"" + imuid + "\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" wmode=\"transparent\"" +
        "PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT></div>" +
        "<div id=\"dfp-hmap-ad-lb2\"></div>"+
        "<div class=\"div-margin-medium text-align-center\">Copyright &copy; 2005-2008 Healthline Networks, Inc. All Rights Reserved Worldwide.</div>" +
        "<div class=\"hmap-close\"><a href=\"javascript:HL_pasteHealthmap.closeMap();\"><img src=\"/images/close_hmap.gif\" alt=\"\" border=\"0\"/></a></div>";

      var healthmapContainerObj = document.getElementById(healthmapContainerId);
      var healthmapDiv = document.createElement("div");
      healthmapDiv.id = "healthmap-div";
      healthmapDiv.className = "healthmap-div";
      healthmapDiv.innerHTML = healthmapHtml;
      healthmapContainerObj.appendChild(healthmapDiv);
      //getHmapAd(imuid);
    },
    closeMap:function(){
      var healthmapContainerObj = document.getElementById(healthmapContainerId);
      if (healthmapContainerObj) {
         healthmapContainerObj.removeChild(healthmapContainerObj.lastChild);
      }
    }
  };
}();