/* Headline Rotator */
var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

$(document).ready(function()
{
  headline_count = $("div.headline").size();
  $("div.headline:eq(" + current_headline + ")").css('top', '5px');
  headline_interval = setInterval(headline_rotate, 10000);
  $('#scrollup').hover(function()
  {
    clearInterval(headline_interval);
  }, function()
  {
    headline_interval = setInterval(headline_rotate, 10000);
    headline_rotate();
  });
});

function headline_rotate()
{
  current_headline = (old_headline + 1) % headline_count;
  $("div.headline:eq(" + old_headline + ")").animate({ top: -205 }, "slow", function()
  {
    $(this).css('top', '210px');
  });
  $("div.headline:eq(" + current_headline + ")").animate({ top: 5 }, "slow");
  old_headline = current_headline;
}

/* Image Rotator */

var iCurrent = 0;

function imgRotate(sRotation)
{
  if (sRotation != undefined && sRotation.length != '')
  {
    var aRotation = new Array();
    aRotation = sRotation.split(",");
    iRotation = aRotation.length;

    var aAttributes = new Array();
    aAttributes = aRotation[iCurrent].split("|");
    iID = aAttributes[0];
    sType = aAttributes[1];
    iWidth = aAttributes[2];
    iHeight = aAttributes[3];
    sLink = aAttributes[4];

    if (sType == "i")
    {
      document.getElementById('divAdvertisment').innerHTML = '<a href=\'' + sLink + '\' target=\'_blank\'><img src=\'BannerView.asp?banner=' + iID + '\' alt=\'\' width=\'' + iWidth + '\' height=\'' + iHeight + '\' /></a>';
    }
    else if (sType == "a")
    {
      sObject = '<a href=\'' + sLink + '\' target=\'_blank\'>';
      sObject = '<object width=\'' + iWidth + '\' height=\'' + iHeight + '\' width=\'' + iWidth + '\' height=\'' + iHeight + '\' classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\' id=\'RCC_Advertisement\'>';
      sObject = sObject & '<param name=\'movie\' value=\'BannerView.asp?banner=' + iID + '\' />';
      sObject = sObject & '<param name=\'bgcolor\' value=\'#ffffff\' />';
      sObject = sObject + '<embed src=\'BannerView.asp?banner=' + iID + '\' bgcolor=\'#ffffff\' width=\'' + iWidth + '\' height=\'' + iHeight + '\' type=\'application/x-shockwave-flash\' pluginspage=\'http://www.macromedia.com/go/getflashplayer\' />';
      sObject = sObject & '</object>';
      sObject = sObject + '</a>';
      document.getElementById('divAdvertisment').innerHTML = sObject;
    }
    ++iCurrent;
    if (iRotation > 1)
    {
      window.setInterval('imgSwap(\'' + aRotation + '\', ' + iRotation + ')', 5000);
    }
  }
}

function imgSwap(aRot, iRot)
{
  aRotator = new Array();
  aRotator = aRot.split(",");

  aAtt = new Array();
  aAtt = aRotator[iCurrent].split("|");
  iID = aAtt[0];
  sType = aAtt[1];
  iWidth = aAtt[2];
  iHeight = aAtt[3];
  sLink = aAtt[4];

  if (sType == "i")
  {
    document.getElementById('divAdvertisment').innerHTML = '<a href=\'' + sLink + '\' target=\'_blank\'><img src=\'BannerView.asp?banner=' + iID + '\' alt=\'\' width=\'' + iWidth + '\' height=\'' + iHeight + '\' /></a>';
  }
  else if (sType == "a")
  {
    sObject = '<a href=\'' + sLink + '\' target=\'_blank\'>';
    sObject = sObject + '<object width=\'' + iWidth + '\' height=\'' + iHeight + '\' classid=\'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\' codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0\' id=\'RCC_Advertisement\'>';
    sObject = sObject + '<param name=\'movie\' value=\'BannerView.asp?banner=' + iID + '\' />';
    sObject = sObject + '<param name=\'bgcolor\' value=\'#ffffff\' />';
    sObject = sObject + '<embed src=\'BannerView.asp?banner=' + iID + '\' bgcolor=\'#ffffff\' width=\'' + iWidth + '\' height=\'' + iHeight + '\' type=\'application/x-shockwave-flash\' pluginspage=\'http://www.macromedia.com/go/getflashplayer\' />';
    sObject = sObject + '</object>';
    sObject = sObject + '</a>';
    document.getElementById('divAdvertisment').innerHTML = sObject;
  }

  ++iCurrent;
  if (iCurrent >= iRot)
  {
    iCurrent = 0;
  }
}

