/*
   Copyright (c) 2010, Raleigh ISSA Chapter. All rights reserved. 

   sponsors.js 
   
   This javascript file contains the functions needed to produce an
   animated display of images. Each image item consists of an image
   file (gif, jpg, etc.), a uniform resource locator (URL), and a
   text discription of the image. 

   The image files described in the 'baner(i).src' array below are 
   all stored in a folder named 'images/sponsors/' in practice, this
   is a directory off of the directory where the Web pages that use 
   this javascript file are stored, such as 'http://httpdocs/'. 
   
   ADDING ANOTHER IMAGE 
   
   To add another banner to this file you must change the numeric
   value in the initialization statement for the variable 'i', which
   appears as the first line of code below. This value should always
   be set to the total number of images. 
   
   Say, var i = Math.round(Math.random()*11); when there are 11 images.

   Next add the following statements at the appropriate locations:
   
      bannerX = new Image();
      bannerX.src = "images/sponsors/yourFileName.gif";

      links[X] = "http://someplace.com"
   
      description[X] = "Your descriptive text here"
   
      if (i < ? ) { 

      where 'X' is the next available numeric value, say 12,
      and '?' is the value X-1, the total number of images to be
      displayed, minus one.

   HTML FILE IMPLEMENTATION

   To display the animated sequence in an HTML file, you must do add
   the following code to your markup:
   
   Between the <head> and </head> tags, add the following markup so 
   that the javascript code in this file will be available for use by
   the user's browser:
   
     <script type="text/javascript" src="sponsors.js"> </script>
   
   Include an 'onload' event in the <body> tag so that the animation
   will start when the Web page is loaded in the user's browser:
   
      <body onload="startTime();">

   At the location in your HTML file where you want the animated 
   sequenced to display, add the following markup:
   
      <a href="" 
         onclick="clickLink(); return false;" 
         onmouseOver="descript(); return true;" 
         onmouseOut="window.status=''">
         <img src="images/sponsors/someFileName.gif" name="banner">
      </a>
      
   Updated: February 15, 2010
   Contact: phil@phillipgriffin.com

*/
var i = Math.round(Math.random()*11);

banner0= new Image();
banner0.src = "images/sponsors/ncsu-ctu.gif";
banner1= new Image();
banner1.src = "images/sponsors/sas1.gif";
banner2 = new Image();
banner2.src = "images/sponsors/juniper3.gif";
banner3 = new Image();
banner3.src = "images/sponsors/forsythetptlogo.gif";
banner4 = new Image();
banner4.src = "images/sponsors/cadinc.gif";
banner5 = new Image();
banner5.src = "images/sponsors/qualys1.gif";
banner6 = new Image();
banner6.src = "images/sponsors/cisco1.gif";
banner7 = new Image();
banner7.src = "images/sponsors/fortinetlogo.gif";
banner8 = new Image();
banner8.src = "images/sponsors/checkpointlogo.gif";
banner9 = new Image();
banner9.src = "images/sponsors/edmzlogo.gif";
banner10 = new Image();
banner10.src = "images/sponsors/shavlik470x60logo.gif";
     
links = new Array
links[0] = "http://www.ncsu.edu/ctu"
links[1] = "http://www.sas.com"
links[2] = "http://www.juniper.net/products/integrated/"
links[3] = "http://www.forsythe.com"
links[4] = "http://www.cadinc.com"
links[5] = "http://www.qualys.com"
links[6] = "http://www.cisco.com"
links[7] = "http://www.fortinet.com"
links[8] = "http://www.checkpoint.com/"
links[9] = "http://www.e-dmzsecurity.com/"
links[10] = "http://www.shavlik.com/"

description = new Array
description[0] = "NC State Computer Training Unit"
description[1] = "SAS"
description[2] = "Juniper Networks"
description[3] = "Forsythe and TippingPoint"
description[4] = "Carolina Advanced Digital"
description[5] = "Qualys"
description[6] = "Cisco"
description[7] = "Fortinet"
description[8] = "Check Point Software Technologies, Inc."
description[9] = "e-DMZ Security"
description[10] = "Shavlik"
      
function startTime(){
   var time= new Date();
   hours= time.getHours();
   mins= time.getMinutes();
   secs= time.getSeconds();
   closeTime=hours*3600+mins*60+secs;
   closeTime+=3;  // How many seconds til the next rotation
   Timer();
}
      
function Timer(){
   var time= new Date();
   hours= time.getHours();
   mins= time.getMinutes();
   secs= time.getSeconds();
   curTime=hours*3600+mins*60+secs
   document.banner.src = eval("banner" + i + ".src");
   if (curTime>=closeTime) {
      if (i < 10) { // Set this numeric value to the number of images minus 1
         i++;
         document.banner.src = eval("banner" + i + ".src");
      } else {
         i = 0;
         document.banner.src = eval("banner" + i + ".src");
      }
      startTime();
   } else {
      window.setTimeout("Timer()",1000)
   }
}
      
function clickLink(){
   top.location = links[i]
}

function descript(){
  window.status = description[i]
}


function init() {
   /*
      Place any functions that need to be executed after the
      Web page loads here rather than in the page's <body> tag. 
   */
startTime();
}

window.onload = init; 
