var agt=navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var timerID = null;
var timerRunning = false;
var id,pause=0,position=0;

window.onload=function(){
  if(!NiftyCheck())
    return;
  var content = document.getElementById("content");
  var search = document.getElementById("searchform");
  var spacer = document.getElementById("spacer");
  var side = document.getElementById("sidebar");
  var sideBottom = side.offsetTop + side.offsetHeight;
  var contBottom = content.offsetTop + content.offsetHeight;
  // note the adjustments to these calculations are trial and error and off slightly based on browser.
  if (sideBottom > contBottom) {
    content.innerHTML +="<p style='height:" + (sideBottom - contBottom - 16) + "px;'></p>";
  }
  if (contBottom > sideBottom) {
    if (isNull(spacer)) search.innerHTML +="<p style='height:" + (contBottom - sideBottom -6 ) + "px;' ></p>";
    else spacer.innerHTML +="<p style='height:" + (contBottom - sideBottom ) + "px;'></p>";
  }
  Rounded("div#header","bottom","#D6DEEC","#84B7FF","smooth");
  Rounded("div#header h1","bottom","#84B7FF","#657DA6","small smooth");
  Rounded("div#nav","tr bottom","#D6DEEC","#95B3DE","smooth");
  Rounded("div#sidenotes","all","#D6DEEC","#B1C0D5","smooth");
  Rounded("div#spacer","top bl","#D6DEEC","#B1C0D5","smooth");
  Rounded("div#searchform","all","#D6DEEC","#B4CEF7","smooth");
  Rounded("blockquote","tr bl","#FFF","#CDFFAA","border #88D84F");
  Rounded("div#relax","all","#FFF","transparent");
  Rounded("div#footer","all","#D6DEEC","#CCCCCC","small border #fff");
  Rounded("div#content","tl bottom","#D6DEEC","#FFF","smooth");
}

function isNull(a) {
  return typeof a == 'object' && !a;
}

// The following sections are to make the footer text change and scroll out of view.
// ---------------------------------------------------------------------------------
var mfBanners = new Array();
mfBanners[0] = '<p>Help and support for Web and Desktop Developers</p>';
mfBanners[1] = '<p>Languages: ASP, ASP.Net, C#, Javascript, VB.Net, XHTML, SQL</p>';
mfBanners[2] = '<p>Be sure to look for new examples and tutorials in our <a href="tutorials/">Tutorials Section</a>.</p>';
mfBanners[3] = '<p>We recommend <a href="http://www.websupergoo.com/abcpdf-1.htm" target="_blank" title="In one day we were able to create dynamically generated PDF reports with graphical headers and footers thanks to this tool.">ABCpdf</a> ASP PDF generation component.</p>';

mfBannerPos = 0;
var mfBannerIndex = 0;
var scrollInterval;
setInterval("mfBannerChange()", 15000);

function mfBannerChange() {
  scrollInterval = setInterval("mfBannerScroll()",100);
}

function mfBannerScroll(i) {
  var footText = document.getElementById("footText");
  mfBannerPos --;
  footText.style.top = mfBannerPos + "px";
  if (mfBannerPos == -30) {
    clearInterval(scrollInterval)
    footText.innerHTML = mfBanners[mfBannerIndex];
    if(mfBannerIndex < mfBanners.length - 1) mfBannerIndex++;
    else mfBannerIndex = 0;
    footText.style.top = "0px";
    mfBannerPos = 0;
  }  
}
