<!--//

var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;

var banner_loop = 0;
var prev_banner = 99;
var banner_ids = new Array();
var banner_files = new Array();
var banner_titles = new Array();


function popupWindow(root,fa,id) {

   var q = '';
   var url = root;

  if(fa == 'b_wa'){
    h = 400;
    w = 600;
    leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    topPosition = (screen.height) ? (screen.height-h)/2 : 0;
  }else{
    h = 0;
    w = 0;
    leftPosition = 0;
    topPosition = 0;
  }


   // set the location
   url += '/popup_url.html?fa=' + fa + '&bid=' + id ;
   cs_win = window.open(url, 'popup_window', 'left=' + leftPosition + ',top=' + topPosition + ', toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width=' + w + ',height=' + h + ',resizable=yes');
  if(fa == 'd_wa'){
    cs_win.focus();
  }
}

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    SetRandomBanner();
    secs = 10;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        //alert("You have just wasted 10 seconds of your life.");

        SetRandomBanner();
        secs = 10;
        StartTheTimer();
    }
    else
    {
       // self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}

function SetRandomBanner()
{
      banner_txt = "";

      if(banner_ids.length > 1){
            randomnumber = prev_banner;
            while (randomnumber==prev_banner)
            {
                randomnumber = Math.floor(Math.random()*banner_ids.length);
            }
            prev_banner = randomnumber;
      }else{
            randomnumber = 0;
      }
      banner_txt = '<img src="/images/banners/' + banner_ids[randomnumber] + '/' + banner_files[randomnumber] + '" alt="' + banner_titles[randomnumber] +'" width="120" height="600" border="0" '; // />';
      banner_txt = banner_txt + 'onclick="popupWindow(\'\',\'b_wa\',\'' + banner_ids[randomnumber] +'\');return false;" />';
//      alert(banner_txt);
       setLabel('banner',banner_txt);
}
//-->
