function popMailWin() {
 var pageURL = document.URL;
 if (pageURL.substring(pageURL.length-1)=="#") {
 pageURL = pageURL.substring(0, pageURL.length-1);
 }
 var pageTitle = escape(self.document.title);
 var formURL = "http://cgi.health.com/cgi-bin/mail/mailurl2friend.cgi?path=/health/emailfriend/&url=" + pageURL + "&group=health6&title=" + pageTitle;
 //var formURL = "http://cp.timeinc.net/cgi-bin/mail/mailurl2friend.cgi?path=/health/emailfriend/&url=" + pageURL + "&group=health6&&title=" + pageTitle;
 showCenteredPopup('emailpop', formURL, 'scrollbars=1', 600, 600);
 return false;
}

function showCenteredPopup(name, url, features, width, height) {
 var top = (window.screen.height / 2) - height / 2;
 var left = (window.screen.width / 2) - width / 2;
 if (features == null || features == '') {
 features = "scrollbars=yes,toolbar=no,menubar=no,status=no,location=no";
 }
 window.open (url, name.replace (' ', '_'), features + ",top=" + top + ",left=" + left + ",width=" + width + ",height=" + height);
}

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 hl_ut(){// dummy temp function for urchin links on cobrand
  return true;
}

function submitEmailAfriendForm(){
document.emailafriend.submit();
}

function goHlPrint() {
var preUrl = window.location.href
return preUrl.indexOf("?") > 1 ? preUrl + "&print=true" : preUrl + "?print=true";
}

function showShare() {
document.getElementById('shareBox').style.display='block';
posX = YAHOO.util.Dom.getX('shareBox');
posY = YAHOO.util.Dom.getY('shareBox');
ie6LayerFix(posX-2,posY,200,147,true);
}

function hideShare() {
document.getElementById('shareBox').style.display='none';
ie6LayerFix(0,0,0,0,false);
}

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

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.")
  }
}

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

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 hlToArray(object) {
  if (typeof(object.length) == "number") {
    return object;
  }
  var array = new Array();
  array.push(object);
  return array;
}

function kwbold(el,keyword) {
  for (var i = 0; i < el.length; i++) {
    if (window.RegExp && el[i].type == 'text') {
      var rawq = keyword.replace("'","&#39;");
      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>");
              }
            }
          }
        }
      }
    }
  }
}





var msie = navigator.appVersion.match('MSIE') ? !navigator.appVersion.match('MSIE 7.0') : false;

function ie6LayerFix(x,y,width,height,TurnOn){
  if(msie){
   var ie6Layer=document.getElementById('ieFix');
   ie6Layer.className = TurnOn ? '':'hidden';
   ie6Layer.style.left = x + "px";
   ie6Layer.style.top = y + "px";
   ie6Layer.style.width = width + "px";
   ie6Layer.style.height = height + "px";
   ie6Layer.style.backgroundColor = '#ccc';
  }
}
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 is_ignorable(nod){
  return ( nod.nodeType == 8) || ( (nod.nodeType == 3) && is_all_ws(nod) );
}
function is_all_ws(nod){
  return !(/[^\t\n\r ]/.test(nod.data));
}

var input_buttons = {
  init: function() {
    inputDiv = document.getElementById('input-buttons');
    YAHOO.util.Event.addListener(inputDiv,'mouseover',input_buttons.hover);
    YAHOO.util.Event.addListener(inputDiv,'mouseout',input_buttons.clear);
  },
  hover: function(e) {
    var elTarget = YAHOO.util.Event.getTarget(e);
    while (elTarget.id != inputDiv.id) {
      if(elTarget.nodeName.toUpperCase() == "BUTTON") {
        YAHOO.util.Dom.addClass(elTarget,'button-hover');
        break;
      } else {
        elTarget = elTarget.parentNode;
      }
    }
  },
  clear: function(e) {
    var elTarget = YAHOO.util.Event.getTarget(e);
    while (elTarget.id != inputDiv.id) {
      if(elTarget.nodeName.toUpperCase() == "BUTTON") {
        if (YAHOO.util.Dom.hasClass(elTarget,'button-hover')) {
          YAHOO.util.Dom.removeClass(elTarget,'button-hover')
        }
        break;
      } else {
        elTarget = elTarget.parentNode;
      }
    }
  }
}