function putHeadlineInTitle() {
  if (!(document.title)) return;
  var h = document.location.href;
  if (h.indexOf("/article/") != -1) {
    if (document.all) {
      if (document.body.innerHTML) {
        var markerLen = 22;
        var bodyHTML = document.body.innerHTML;
        var pos = bodyHTML.indexOf("<SPAN class=headline1>");
        if (pos == -1) { // Opera
          pos = bodyHTML.indexOf("<SPAN CLASS='headline1'>");
          markerLen = 24;
        }
        var pos2 = bodyHTML.indexOf("</SPAN>", pos);
        if ((pos != -1) && (pos2 != -1)) {
          document.title = "TCPalm: " + bodyHTML.substring(pos + markerLen, pos2).replace("&amp;","&");
        }
      }
    } else {
      if(document.getElementsByTagName) {
        var spanElements = document.getElementsByTagName('SPAN');
        for(var i = 0; i < spanElements.length; i++) {
          if(spanElements[i].getAttribute("class") == "headline1") {
            if(spanElements[i].childNodes[0].nodeValue) {
              var headline = spanElements[i].childNodes[0].nodeValue;
              headline = headline.replace(/\r/g, " ");
              headline = headline.replace(/\n/g, " ");
              headline = headline.replace("&amp;","&");
              document.title = "TCPalm: " + headline;
              return;
            }
          }
        } 
      }
    }
  }
}

putHeadlineInTitle();

function getContentAreaCell() {
  if(document.getElementsByTagName) {
    var tableElements = document.getElementsByTagName('TABLE');
    for(var i = 0; i < tableElements.length; i++) {
      if(tableElements[i].getAttribute("width") == "460") {
        var contentCell = tableElements[i].getElementsByTagName('TD')[0];
        if (contentCell.innerHTML.length < 125) return contentCell;
      }
    }
  }
  return null;
}

contentCell = getContentAreaCell();

if (contentCell != null) document.write("<scr" + "ipt src='http://web.tcpalm.com/js/404.js'></scr" + "ipt>");


function addPollFormValidation() {
  for(var i = 0; i < document.forms.length; i++) {
    var theForm = document.forms[i];
    if (theForm.name.indexOf("PollForm" != -1)) {
      var n = "document." + theForm.name;
      var optionValidation = "";
      var commentValidation = "";
      if (theForm.Rating) {
        if (theForm.PollType.value != "Rating") {
          theForm.Rating[0].checked = false;
          optionValidation = "var check = false; for(var i = 0; i < " + n + ".Rating.length; i++) { if(" + n + ".Rating[i].checked == true) { check = true; }} if(check == false) { alert('Please select an option.'); return false; } ";
        }
      }
      if (theForm.Comment) {
        commentValidation = "if (" + n + ".Comment.value.length > 240) { alert('Your comment is ' + " + n + ".Comment.value.length + ' characters, which is too long. Comments must be 240 characters or less to be posted.'); return false; } ";
      }
      if(theForm.vote) theForm.vote.onclick = new Function(optionValidation + commentValidation + "if (" + n + ".active.value==1) {" + n + ".active.value=0; this.disabled=true; " + n + ".submit();} else { return false; }");
    }
  }
}

addPollFormValidation();