// Only need to do onload stuff if
function testIsValidObject(objToTest)
    {
    if (objToTest == null || objToTest == undefined)
       {
       return false;
       }

    return true;
}

ShowFirstHideRest = function()
{

    for (var i = 0; i < arguments.length; ++i)
    {
       
        var oEl = document.all.item(arguments[i]);
               
        if (oEl != null)
        {

            if (i == 0)
            {
                oEl.style.display = "";
            }
            else if (!(oEl.id == arguments[0]))
            {
                oEl.style.display = "none";
            }
        }
    }
}


function blank(fld,val)
{
if (fld.value==val)
   {
   fld.value='';
   }
}

var hb1_delay=0;
var hb1_timer=0;
var hb1_active;
var hb1_nHeros = 0;
function hb1_init(){
    var t;
    while (true)
    {
        t = document.getElementById("hero1_"+hb1_nHeros);
        if (!t)
         break;
        hb1_nHeros++;
    }
    hb1_active=hb1_nHeros-1;
    hb1_show(hb1_active);
    hb1_counter();
}
function hb1_counter()
{
    hb1_hide(hb1_active);
    hb1_active = (hb1_nHeros+(hb1_active+1))%hb1_nHeros;
    hb1_show(hb1_active);
    hb1_delay=document.getElementById("hero1_"+hb1_active).pause * 1000;
    if (!hb1_delay)
       hb1_delay=5000;
       
    hb1_timer = window.setTimeout("hb1_counter()",hb1_delay);
}
function hb1_show(t){
    document.getElementById("hero1_"+t).style.display="";
}
function hb1_hide(t){
    document.getElementById("hero1_"+t).style.display="none";
}
function hb1_stop(){
    clearTimeout(hb1_timer);
    hb1_timer=0;
}
function hb1_move(w){
    hb1_hide(hb1_active);
    hb1_active = w?(hb1_nHeros+hb1_active+1)%hb1_nHeros:(hb1_nHeros+hb1_active-1)%hb1_nHeros;
    hb1_show(hb1_active);
    hb1_delay=document.getElementById("hero1_"+hb1_active).pause * 1000;
    if (!hb1_timer)
        hb1_timer = window.setTimeout("hb1_counter()",hb1_delay);
}

var hb2_delay=0;
var hb2_timer=0;
var hb2_active;
var hb2_nHeros = 0;
function hb2_init(){
    var t;
    while (true)
    {
        t = document.getElementById("hero2_"+hb2_nHeros);
        if (!t)
         break;
        hb2_nHeros++;
    }
    hb2_active=hb2_nHeros-1;
    hb2_show(hb2_active);
    hb2_counter();
}
function hb2_counter()
{
    hb2_hide(hb2_active);
    hb2_active = (hb2_nHeros+(hb2_active+1))%hb2_nHeros;
    hb2_show(hb2_active);
    hb2_delay=document.getElementById("hero2_"+hb2_active).pause * 1000;
    if (!hb2_delay)
       hb2_delay=5000;    
    
    hb2_timer = window.setTimeout("hb2_counter()",hb2_delay);
}
function hb2_show(t){
    document.getElementById("hero2_"+t).style.display="";
}
function hb2_hide(t){
    document.getElementById("hero2_"+t).style.display="none";
}
function hb2_stop(){
    clearTimeout(hb2_timer);
    hb2_timer=0;
}
function hb2_move(w){
    hb2_hide(hb2_active);
    hb2_active = w?(hb2_nHeros+hb2_active+1)%hb2_nHeros:(hb2_nHeros+hb2_active-1)%hb2_nHeros;
    hb2_show(hb2_active);
    hb2_delay=document.getElementById("hero2_"+hb2_active).pause * 1000;
    if (!hb2_timer)
        hb2_timer = window.setTimeout("hb2_counter()",hb2_delay);

}

var hb3_delay=0;
var hb3_timer=0;
var hb3_active;
var hb3_nHeros = 0;
function hb3_init(){
    var t;
    while (true)
    {
        t = document.getElementById("hero3_"+hb3_nHeros);
        if (!t)
         break;
        hb3_nHeros++;
    }
    hb3_active=hb3_nHeros-1;
    hb3_show(hb3_active);
    hb3_counter();
}
function hb3_counter()
{
    hb3_hide(hb3_active);
    hb3_active = (hb3_nHeros+(hb3_active+1))%hb3_nHeros;
    hb3_show(hb3_active);
    hb3_delay=document.getElementById("hero3_"+hb3_active).pause * 1000;
    if (!hb3_delay)
       hb3_delay=5000;    
    
    hb3_timer = window.setTimeout("hb3_counter()",hb3_delay);
}
function hb3_show(t){
    document.getElementById("hero3_"+t).style.display="";
}
function hb3_hide(t){
    document.getElementById("hero3_"+t).style.display="none";
}
function hb3_stop(){
    clearTimeout(hb3_timer);
    hb3_timer=0;
}
function hb3_move(w){
    hb3_hide(hb3_active);
    hb3_active = w?(hb3_nHeros+hb3_active+1)%hb3_nHeros:(hb3_nHeros+hb3_active-1)%hb3_nHeros;
    hb3_show(hb3_active);
    hb3_delay=document.getElementById("hero3_"+hb3_active).pause * 1000;
    if (!hb3_timer)
        hb3_timer = window.setTimeout("hb3_counter()",hb3_delay);

}



function showImage(src)
{
document.PictureFrame.src = src;
}

function CountDown(TargetDate,StartDate,id)
{
document.write("<span id='" + id + "' class=info></span>");

var dthen = new Date(TargetDate);
var dnow = new Date(StartDate);
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs,id);
}

function L(url,imageUrl) {
	document.write('<img border="0" src="'+imageUrl+'" alt="" onmouseout="this.style.cursor=\'default\'; " onmouseover="this.style.cursor=\'pointer\'; " onclick="javascript: window.location=\''+url+'\'; " />');
}

function La(url,imageUrl,x,y) {
	document.write('<img border="0" src="'+imageUrl+'" width="'+x+'" height="'+y+'" alt="" onmouseout="this.style.cursor=\'default\'; " onmouseover="this.style.cursor=\'pointer\'; " onclick="javascript: window.location=\''+url+'\'; " />');
}


function L1(url,name) {
		document.write('<span onclick="javascript: window.location=\''+url+'\';" onmouseover="this.style.cursor=\'pointer\'; "><a>'+name+'</a></span>');
}

function CountBack(secs,id)
{
  if (secs < 0) {
    document.getElementById(id).innerHTML = "Vehicle no longer for sale";
    return;
  }
  
  
  DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
  
  DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
  DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
  DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
  DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));

  document.getElementById(id).innerHTML = DisplayStr;
  
  setTimeout("CountBack(" + (secs-1) + ",'" + id + "')", 990);
}


function calcage(secs, num1, num2)
{
  s = ((Math.floor(secs/num1))%num2).toString();
  if (s.length < 2)
    s = "0" + s;
  return "<b>" + s + "</b>";
}

// Script End
