var showFlash = false;

// The current value of the thermometer
var thermoCurrentValue = 35761;

// The thermometer URL
var thermoSrc = "http://www.usafundraising.com/php/thermored.php?max=100000&current=" + thermoCurrentValue + "&unit=36";

/**
 * Function to print the header pictures
 */
function printHeaderPic()
{
   var headerPicContent = "<img src=\"img/sres_sign_109h.png\" alt=\"School Image\" height=\"109\"/>\n" +
                          "<img src=\"img/school_pic_cmp_lab1_109.jpg\" alt=\"School Image\" height=\"109\"/>\n" +
                          "<img src=\"img/header_pe1_109.png\" alt=\"School Image\" height=\"109\"/>\n" +
                          "<img src=\"img/header_pe2_109.png\" alt=\"School Image\" height=\"109\"/>\n" +
                          "<img src=\"img/school_pic_cmp_lab2_109.jpg\" alt=\"School Image\" height=\"109\"/>\n" +
                          "<img src=\"img/school_pic2_109.jpg\" alt=\"School Image\" height=\"109\"/>\n";
   document.write(headerPicContent);
}

function showPayPalConfirm()
{
   return window.confirm("Please note that a PayPal account is required for the Payment Plan option.\n\nWould you like to continue?");
}


var sponsorData = [
   {
      linkHref : "http://www.northcountycu.org",
      linkTitle : "North County Credit Union",
      imageSrc : "img/corp/nccu.gif",
      imageAlt : "North County Credit Union Image",
      imageTitle : "North County Credit Union"
   },
   {
      linkHref : "http://www.savvyinteriors.com/",
      linkTitle : "Savvy Interiors - Smart Stylish Solutions",
      imageSrc : "img/corp/savvyinteriors.jpg",
      imageAlt : "Savvy Interiors - Smart Stylish Solutions Image",
      imageTitle : "Savvy Interiors - Smart Stylish Solutions"
   }
];

var sponsorIndex = 0;

function sponsorAd()
{
   //alert("sponsorAd");
   setInterval("changeSponsorAd()", 10000);
}

function changeSponsorAd()
{
   //alert("changeSponsorAd");
   if (sponsorIndex + 1 >= sponsorData.length)
   {
      sponsorIndex = 0;
   }
   else
   {
      sponsorIndex++;
   }

   if (document.getElementById("sponsorLink") != null &&
       document.getElementById("sponsorImage") != null)
   {
      document.getElementById("sponsorLink").href = sponsorData[sponsorIndex].linkHref;
      document.getElementById("sponsorLink").title = sponsorData[sponsorIndex].linkTitle;

      document.getElementById("sponsorImage").src = sponsorData[sponsorIndex].imageSrc;
      document.getElementById("sponsorImage").alt = sponsorData[sponsorIndex].imageAlt;
      document.getElementById("sponsorImage").title = sponsorData[sponsorIndex].imageTitle;
   }
}


function setThermoSrc()
{
   if (document.getElementById("imgThermoRed") != null)
   {
      document.getElementById("imgThermoRed").src = thermoSrc;
   }
   else
   {
      // Wait and try again
      setTimeout("setThermoSrc()", 1500);
   }
}

function doPageLoad()
{
   setThermoSrc();
   sponsorAd();
}

function addLoadEvent(func)
{
   var oldonload = window.onload;
   if (typeof window.onload != 'function')
   {
      window.onload = func;
   }
   else
   {
      window.onload = function()
      {
         oldonload();
         func();
      }
   }
}

addLoadEvent(doPageLoad());
