

var txtSubscribe = 'Subscribe to this feed:';
var txtContentHeader = 'Newsreader/Aggregator:';
var txtWhatIsThis = 'What is this?';
var txtVersion = "0.3.1";

// Internal vars
var oFrame = self;
var oDiv = null;
var oTimer = null;


// Determine browser type
var ns4 = (navigator.appName == 'Netscape' && parseInt(navigator.appVersion) == 4);
var ns6 = (document.getElementById)? true:false;
var ie4 = (document.all)? true:false;
var opera = (navigator.appName == 'Opera');

if (ie4 && ns6)
  ns6 = false;


function showOptionsXML (oLink, sURL) {

  oFrame = self;

  if (ns4)
    oDiv = oFrame.document.popup;
  if (ie4)
    oDiv = oFrame.popup;
  if (ns6)
    oDiv = oFrame.document.getElementById('popup');

  var sHTML;

  sHTML = '<div class="title">Other Search Feeds</div><div class="links">';
  sHTML += '<a href="#">RSS 2.0</a><br />';
  sHTML += '<a href="#">Atom 0.3</a><br />';
  sHTML += '<a href="#">OPML 1.0</a><br />';
  sHTML += '<a href="#">Email Subscription</a><br />';
  sHTML += '<a href="#">podOmatic Subscription</a>';
  sHTML += '</div>';

  layerWrite(sHTML);
  placeLayer(oLink, 2);
  showObject(oDiv, 1);

}

function showOptionsResult (oLink, sURL) {

  oFrame = self;

  if (ns4)
    oDiv = oFrame.document.popup;
  if (ie4)
    oDiv = oFrame.popup;
  if (ns6)
    oDiv = oFrame.document.getElementById('popup');

  var sHTML;

  sHTML = '<div class="title">Other Result Options</div><div class="links">';
  sHTML += '<a href="#">Hide This Feed\'s Posts</a><br />';
  sHTML += '<a href="#">Show This Feed\'s Posts</a><br />';
  sHTML += '<a href="#">Get This Feed\'s XML</a><br />';
  sHTML += '</div>';

  layerWrite(sHTML);
  placeLayer(oLink, 1);
  showObject(oDiv, 1);

}


function placeLayer (oLink, iAlign) {

  var iLeft, iTop, iOffset, aPosition;

  if (iAlign != 0) {

    aPosition = findPosition(oLink, iAlign);

    iLeft = eval(aPosition[0]);
    iTop = eval(aPosition[1]);

    if (ie4) {
      if (iAlign == 2)
        oDiv.style.left = (iLeft - 150) + 'px';
      else
        oDiv.style.left = iLeft + 'px';
      oDiv.style.top = iTop + 'px';
    }
    else if (ns4) {
      if (iAlign == 2)
        oDiv.left = iLeft;
      else
        oDiv.left = iLeft;
      oDiv.top = iTop;
    }
    else if (ns6) {
      if (iAlign == 2)
        oDiv.style.left = (iLeft - oDiv.offsetWidth) + 'px';
      else
        oDiv.style.left = iLeft + 'px';
      oDiv.style.top = iTop + 'px';
    }
  }
  else {
    if ((ns4) || (ie4)) {
      oDiv.left = (ie4 ? '0px' : 0);
      oDiv.top = (ie4 ? '0px' : 0);
    }
    else if (ns6) {
      oDiv.style.left = '0px';
      oDiv.style.top = '0px';
    }
  }

}


function layerWrite (txt) {

  if (ns4) {
//    var lyr = oFrame.document.quickSub.document;
    var lyr = oDiv.document;
    lyr.write(txt);
    lyr.close();
  }
  else if (ie4) {
//    oFrame.document.all["quickSub"].innerHTML = txt;
    oDiv.innerHTML = txt;
  }
  else if (ns6) {
    range = oFrame.document.createRange();
    range.setStartBefore(oDiv);
    var domfrag = range.createContextualFragment(txt);
    while (oDiv.hasChildNodes()) {
      oDiv.removeChild(oDiv.lastChild);
    }
    oDiv.appendChild(domfrag);
  }
}

function showObject (oObject, iVisible) {

  if (iVisible) {
    if (ns4)
      oObject.visibility = 'show';
    else if (ie4)
      oObject.style.visibility = 'visible';
    else if (ns6)
      oObject.style.visibility = 'visible';
  }
  else {
    if (ns4)
      oObject.visibility = 'hide';
    else if (ie4)
      oObject.style.visibility = 'hidden';
    else if (ns6)
      oObject.style.visibility = 'hidden';
  }

}


function findPosition (oLink, iAlign) {

  var iPosX = 0, iPosY = 0;
  var iHeight, iWidth;

  if (oLink.offsetHeight) {
    iHeight = oLink.offsetHeight;
    iWidth = oLink.offsetWidth;
  }
  else {
    iHeight = oLink.height;
    iWidth = oLink.width;
  }

  if (oLink.offsetParent) {
    for (; oLink.offsetParent; oLink = oLink.offsetParent) {
      iPosX += oLink.offsetLeft;
      iPosY += oLink.offsetTop;
    }
  }
  else {
    iPosX = oLink.x;
    iPosY = oLink.y;
  }

  if (opera)
    iPosY += (iHeight * 2);
  else
    iPosY += iHeight;
    
  if (iAlign == 2)
    iPosX += iWidth;

  return [iPosX, iPosY];

}

function timePopup () {

  if (!ns4) {

    var iDelay = 250;

    if (oTimer)
      clearTimeout(oTimer);

    if ((ie4 && oDiv.style.visibility != 'hidden') || (ns6 && oDiv.style.visibility != 'hidden'))
      oTimer = setTimeout(hidePopup, iDelay);

  }
  else {
//    (ns4 && oDiv.visibility != 'hide')
  }

}

function hidePopup () {

  if (oTimer)
    clearTimeout(oTimer);

  closePopup();

}

function delayPopup () {

  if (oTimer)
    clearTimeout(oTimer);

}

function closePopup () {

  if (oDiv != null)
    showObject(oDiv, 0);

}


//dynamic explanation
function showexplanation() {
  obj = document.getElementById("explanation"); obj.style.display = "block";
  obj = document.getElementById("show_explanation"); obj.style.display = "none";
}
    
    
    
function hideexplanation() {
  obj = document.getElementById("explanation"); obj.style.display = "none";
  obj = document.getElementById("show_explanation"); obj.style.display = "block"; 
}




function showthought() {
  obj = document.getElementById("thought"); obj.style.display = "block";
    obj = document.getElementById("show_thought"); obj.style.display = "none";
    }
    function hidethought() {
      obj = document.getElementById("thought"); obj.style.display = "none";
        obj = document.getElementById("show_thought"); obj.style.display = "block"; 
        }
