var p_days=p_hours=p_mins=0;
var lab='c_s2';

function loaded(i,f){
	if(document.getElementById && document.getElementById(i)!=null) f();
	else if(!p_load) setTimeout('loaded(\''+i+'\','+f+')',100);
}

function start(){countdown(st(month,day,hour,min,tz));}

window.onload = function(){p_load=1;}
loaded(lab,start);
var p_load=0;

function st(month,day,hour,min,tz){
	var toDate = new Date(2007,month,day,hour,min-((tz-2)*60),0);
	var fromDate = new Date(2007,i_month,i_day,i_hour,i_mins,i_secs+1);
	var diffDate = new Date(0);
	diffDate.setMilliseconds(toDate-fromDate);
	return Math.floor(diffDate.valueOf()/1000);
}

function countdown(countdn){
	if(countdn<0){
		document.getElementById('nextgp').style.display = 'none';
		return;
	}
	var secs=countdn%60;
	if(secs<10){
		document.getElementById('c_s1').style.backgroundPosition = '0 0';
		document.getElementById('c_s2').style.backgroundPosition = '-'+secs*9+'px 0';
	}else{
		document.getElementById('c_s1').style.backgroundPosition = '-'+(Math.floor(secs/10))*9+'px 0';
		document.getElementById('c_s2').style.backgroundPosition = '-'+(secs%10)*9+'px 0';
	}

	var countdn1=(countdn-secs)/60;
	var mins=countdn1%60;

	if(mins!=p_mins){
		if(mins<10){
			document.getElementById('c_m1').style.backgroundPosition = '0 0';
			document.getElementById('c_m2').style.backgroundPosition = '-'+mins*9+'px 0';
		}else{
			document.getElementById('c_m1').style.backgroundPosition = '-'+(Math.floor(mins/10))*9+'px 0';
			document.getElementById('c_m2').style.backgroundPosition = '-'+(mins%10)*9+'px 0';
		}
	}

	countdn1 = (countdn1-mins)/60;
	var hours = countdn1%24;
	var days = (countdn1-hours)/24;

	if(hours!=p_hours){
		if(hours<10){
			document.getElementById('c_h1').style.backgroundPosition = '0 0';
			document.getElementById('c_h2').style.backgroundPosition = '-'+hours*9+'px 0';
		}else{
			document.getElementById('c_h1').style.backgroundPosition = '-'+(Math.floor(hours/10))*9+'px 0';
			document.getElementById('c_h2').style.backgroundPosition = '-'+(hours%10)*9+'px 0';
		}
	}
	if(days!=p_days){
		if(days<10){
			document.getElementById('c_d1').style.backgroundPosition = '0 0';
			document.getElementById('c_d2').style.backgroundPosition = '-'+days*9+'px 0';
		}else{
			document.getElementById('c_d1').style.backgroundPosition = '-'+(Math.floor(days/10))*9+'px 0';
			document.getElementById('c_d2').style.backgroundPosition = '-'+(days%10)*9+'px 0';
		}
	}

	p_days = days;
	p_hours = hours;
	p_mins = mins;

	setTimeout('countdown('+(countdn-1)+');',999);
}