
var iImageOpacity = 100;
var bImageHidden = false;
var numberOfAttempts = 0;

secondaryFeature = function(url, imageSource, headline, description) {
this.url = url;
this.imageSource = imageSource;
this.headline = headline;
this.description = description;
}


function writeSubfeatures() {
var border = "";
var bottomSpacer = "";

for(var j=1; j<5; j++) {
  var slots = eval("slots_" + j);
  
  if(j < 4)
  {
   border = "border-right: 2px solid #f2f2f2;";
  }
  else
  {
   border = "";
  }
  
  document.write("<td align='center' class='recentFeatures'>");
   for(var i=0; i<slots.length; i++) {
    if(i == slots.length-1)
    {
     bottomSpacer = "";
    }
    else
    {
     bottomSpacer = "";
    }
    
    if(i==0) {
     document.write ("<a id='myLink_" + j + "' href='" + slots[i].url + "'><img id='mySubFeature_" + j + "' name='mySubFeature_" + j + "' border='0' src='" + slots[i].imageSource + "' alt='" + slots[i].headline + " - " + slots[i].description  + "'></a><br/><br/><table style='" + border + "' width='215' cellpadding='0' cellspacing='0' border='0'><tr><td class='recentFeatures' style='padding-left: 8px;'><a href=" + slots[i].url + " class=featureHeadline onMouseOver=showFeature(" + i + "," + j + ")>" + slots[i].headline + "</a><br/>" + slots[i].description + "</td></tr></table>");
    } else {
     document.write ("<table style='" + border + " padding-top: 10px;' width='215' cellpadding='0' cellspacing='0' border='0'><tr><td width='210' class='recentFeatures' style='padding-left: 8px;'><a href='" + slots[i].url + "' class=featureHeadline  onMouseOver=showFeature(" + i + "," + j + ")>" + slots[i].headline + "</a><br/>" + slots[i].description + bottomSpacer + "</td></tr></table>");
    
    }
   }
  document.write("</td>");
}
}

function showFeature(i, j) { //i is the story number in the slot, j is a reference to the correct slot
/*START: ORIGINAL CODE
var slots = eval("slots_" + j);
var subSlot = "mySubFeature_" + j;
var subLink = "myLink_" + j;
document.images[subSlot].src = slots[i].imageSource;
document.getElementById(subLink).href = slots[i].url; 
document.getElementById(subSlot).alt = slots[i].headline + " - " + slots[i].description; 
END: ORIGINAL CODE*/

var slots = eval("slots_" + j);
var subSlot = "mySubFeature_" + j;
var subLink = "myLink_" + j;

var oldImageName = document.images[subSlot].src.substr(document.images[subSlot].src.lastIndexOf("/") + 1, document.images[subSlot].src.length);
var newImageName = slots[i].imageSource.substr(slots[i].imageSource.lastIndexOf("/") + 1, slots[i].imageSource.length);

if(oldImageName != newImageName)
{
  changeImageOpacity(100, document.images[subSlot]);
  hideOldImage(document.images[subSlot]);
  setNewImage(i, j);
}
}
function setNewImage(i, j)
{
if(bImageHidden)
{
  setImageProperties(i, j);
  bImageHidden = false;
  numberOfAttempts = 0;
}
else
{ 
  if(numberOfAttempts < 50)
  {
   setTimeout("setNewImage(" + i + ", " + j + ")", 0);
   numberOfAttempts += 1;
  }
  else
  {
   setImageProperties(i, j);
  }
}
}
function setImageProperties(i, j)
{
var slots = eval("slots_" + j);
var subSlot = "mySubFeature_" + j;
var subLink = "myLink_" + j;
var imageID = "";
document.images[subSlot].src = slots[i].imageSource;
document.getElementById(subLink).href = slots[i].url; 
document.getElementById(subSlot).alt = slots[i].headline + " - " + slots[i].description;

imageID = document.images[subSlot].id;
//changeImageOpacity(100, document.images[subSlot]);

setTimeout("fadeInImage('" + imageID + "', 70)", 0);
}
function hideOldImage(image) {
iImageOpacity = 100;
var imageID = image.id;
setTimeout("fadeOutImage('" + imageID + "', " + iImageOpacity + ")", 0);
}
function fadeOutImage(imageID, iOpacity) {
var image = document.getElementById(imageID);
iOpacity -= 5;
changeImageOpacity(iOpacity, image);
if(iOpacity > 70) {
  setTimeout("fadeOutImage('" + imageID + "', " + iOpacity + ")", 25);
}
else 
{
  bImageHidden = true;
}
}
function fadeInImage(imageID, iOpacity) {
var image = document.getElementById(imageID);
iOpacity += 5;
changeImageOpacity(iOpacity, image);
if(iOpacity < 100) {
  setTimeout("fadeInImage('" + imageID + "', " + iOpacity + ")", 25);
}
else 
{
  //bImageHidden = true;
}
}
function changeImageOpacity(opacity, image) { 
image.style.opacity = (opacity / 100); 
image.style.MozOpacity = (opacity / 100); 
image.style.KhtmlOpacity = (opacity / 100); 
image.style.filter = "alpha(opacity=" + opacity + ")"; 
}


var feedURL = "../object/rss_nvidia_homepage";
var maxHeadlineLength = 90;


var slots_1 = new Array(
new secondaryFeature("geforce_8800.html", "../docs/CP/1/sf_products_8800gts_320.jpg", "NVIDIA GeForce 8800 GTS", "Introducing the 320 MB version"),
new secondaryFeature("pp_preface.html", "../docs/CP/1/sf_featured_preface.jpg", "NVIDIA PREFACE", "The Best Vista Experience - In and Out of the Box"),
new secondaryFeature("goforce_6100.html", "../docs/CP/1/sf_featured_goforce6100.jpg", "Mobile Multimedia Solutions. Redefined.", "Featuring NVIDIA GoForce 6100")


);

var slots_2 = new Array(
//new secondaryFeature("../object/nvidia_nasdaq.html", "../docs/CP/1/sf_whatsnew_nasdaq.jpg", "NVIDIA Opens NASDAQ", "NVIDIA Quadro® drives graphics for NASDAQ MarketSite Tower and Video Wall"),
new secondaryFeature("../../www.nzone.com/content/nzone/srl/nzone_srl.asp@gameid=3596", "../docs/CP/1/sf_whatsnew_vista_analyze.jpg", "Can your PC run Windows Vista?", "Analyze your computer in just seconds!"),

new secondaryFeature("../../store.nvidia.com/servlet/ControllerServlet@Action=DisplayPage&Env=BASE&Locale=en_US&SiteID=nvidia&id=ProductDetailsPage&productID=58708300", "../docs/CP/1/sf_whatsnew_store.jpg", "NVIDIA Edition Computer Case", "Get this SLI-ready case at the NVIDIA store today!"),

new secondaryFeature("../../www.nzone.com/object/nzone_buyLAN07_home.html", "../docs/CP/1/sf_whatsnew_buyLAN.jpg", "Buy.com LAN", "Catch NVIDIA, EVGA & XFX"),

new secondaryFeature("../../developer.nvidia.com/object/cuda.html", "../docs/CP/1/sf_wn_cuda.jpg", "CUDA Software Developer Kit and <br>C-compiler", "Download beta version now!")
//new secondaryFeature("../object/iD_tech_camp.html", "../docs/CP/1/sf_whatsnew_idtechcamps.jpg", "iD Tech Camps", "Gaming Camps are all the rage!")
//new secondaryFeature("../../store.nvidia.com/DRHM/servlet/SecureControllerServlet@Action=DisplayHomePage&SiteID=nvidia", "../docs/CP/1/sf_whatsnew_gifts.jpg", "Get Your Holiday Gifts Now!", "Free shipping, special offers and more"),
//new secondaryFeature("../object/motorazr_sweepstakes.html", "../docs/CP/1/sf_featured_motorazr.jpg", "Sweepstakes!", "Enter for a chance to win a free Motorola V3XX")
);

var slots_3 = new Array(
new secondaryFeature("../../www.slizone.com/object/slizone_sli_giveaway.html", "../docs/CP/1/sf_giveaway_evga.jpg", "Win this EVGA GeForce 8800 GTS", "And $100,000 in other prizes..."),
new secondaryFeature("../../www.slizone.com/marketplace", "../docs/CP/1/sf_zones_marketplace.jpg", "Build. Buy. Sell.", "Visit the new NVIDIA SLI Marketplace today!"),
new secondaryFeature("../../www.nzone.com/object/nzone_worldinconflict_home.html", "../docs/CP/1/sf_zones_worldinconflict.jpg", "World in Conflict", "DX10 gaming has arrived!"),
new secondaryFeature("gz_home.html", "../docs/CP/1/sf_zones_gelatozone.jpg", "Gelato Zone", "A new site for the rendering community")
);

var slots_4 = new Array(
new secondaryFeature("../object/sony_pictures_success.html", "../docs/CP/1/sf_whynv_sony_picture.jpg", "NVIDIA and Sony Pictures Animation", "Pioneering film animation with <i>Open Season</i>"),
new secondaryFeature("../object/testimonial_cyberlink.html", "../docs/CP/1/sf_whynv_cyberlink.jpg", "NVIDIA and CyberLink", "Delivering tomorrow's high-definition video technology today"),
new secondaryFeature("channel.html", "../docs/CP/1/sf_whynvidia_partnerforce.jpg", "NVIDIA PartnerForce Program", "Join our Reseller community ")
);











function menuInit()
{
listInit();
}

function onMouseOver(imageID)
{
var image = document.getElementById(imageID);
image.src = image.getAttribute("mouseOverImage");
}

function onMouseOut(imageID)
{
var image = document.getElementById(imageID);
image.src = image.getAttribute("mouseOutImage");
}

function listInit() 
{
if (document.all && document.getElementById) 
{
  var level1MenuItems = document.getElementsByTagName("li");
  
  for(var i = 0; i < level1MenuItems.length; i++)
  {
   if(level1MenuItems[i].name == "menuLevel1Item")
   {
    level1MenuItems[i].onmouseover=function() 
    {
     this.className+=" over";
     var image = this.getElementsByTagName("img");
     var imageNumber;
     
     if(image != null && image != "undefined")
     {
      image[0].src = image[0].getAttribute("mouseOverImage");
     }
    }
    
    level1MenuItems[i].onmouseout=function() 
    {
     this.className=this.className.replace(" over", "");
     var image = this.getElementsByTagName("img");
     var imageNumber;
   
     if(image != null && image != "undefined")
     {
      image[0].src = image[0].getAttribute("mouseOutImage");
     }
    }
   }
  }
}
}

   window.onload = init;
   
   function init()
   {
    menuInit();
    rssTicker_rssHeadlineInit();
   }
