/*
Author: Wilson Yang

This script will redirect user to the site root "/" in 5 seconds

To use it , need to put

<div id="redirect"></div>

between <body></body>
*/

var lab = 'redirect';  // id of the entry on the page where the counter is to be inserted
var countdown=5;   //wait for 5 seconds

function start() {
	displayCountdown(countdown,lab);
	}
loaded(lab,start);

var pageLoaded = 0; 
window.onload = function() {pageLoaded = 1;}
function loaded(i,f) 
{
	if (document.getElementById && document.getElementById(i) != null) 
	f(); 
	else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100);
}


function displayCountdown(countdn,cd) 
{
	if (countdn==0) 
	{
	    document.getElementById(cd).innerHTML = "Redirecting...."; 
		window.location="/";
	}
	else {
		var secs = countdn % 60; 
		if (secs < 10) secs = '0'+secs;
		document.getElementById(cd).innerHTML ="Browser will redirect to the Home page after <span style='color:#ff0000;'>"+secs+ "</span> seconds...";
		setTimeout('displayCountdown('+(countdn-1)+',\''+cd+'\');',999);
		}
}
