// Simple timer script
// Author Thomas Cox - thomas@silverworks.com

var time1;
var time2;
var time3;
var loop;
var start;

function button1(){
	if(document.getElementById('homebanner').style.display == 'none')
	{
		document.getElementById('homebanner').style.display = 'block';
		document.getElementById('homebanner2').style.display = 'none';
		document.getElementById('homebanner3').style.display = 'none';
	}
}

function button2(){
	if(document.getElementById('homebanner2').style.display == 'none')
	{
		document.getElementById('homebanner2').style.display = 'block';
		document.getElementById('homebanner').style.display = 'none';
		document.getElementById('homebanner3').style.display = 'none';
	}
}

function button3(){
	if(document.getElementById('homebanner3').style.display == 'none')
	{
		document.getElementById('homebanner3').style.display = 'block';
		document.getElementById('homebanner').style.display = 'none';
		document.getElementById('homebanner2').style.display = 'none';
	}
}

function bannertimes()
{
	 time1 = setTimeout('button2()',4000); 
	 time2 = setTimeout('button3()',8000); 
	 time3 = setTimeout('button1()',12000);	
}

function bannerplay()
{
	 // ajax ready state can be used here rather than setting a time
	 loop = window.setInterval('bannertimes()',12000); 
}

function stopinterval()
{
		clearTimeout(time1);
		clearTimeout(time2);
		clearTimeout(time3);
		clearInterval(start);
		clearInterval(loop);
}

function addLoadEvent(func) {   
   var oldonload = window.onload;   
   if (typeof window.onload != 'function') {   
    window.onload = func;   
   } else {   
    window.onload = function() {   
      if (oldonload) {   
         oldonload();   
       }   
       func();   
     }   
   }   
 }   
   
 addLoadEvent(bannertimes);   
 addLoadEvent(bannerplay);  

