var currentGPOffset = 0;
var currentSessionOffset = 0;
var previousGPOffset = 0;
var now,nowfudge;

function QueryString(key)
{
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++)
	{
		if (QueryString.keys[i] == key)
		{
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}

QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse()
{
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;
		}
	}
}

QueryString_Parse();	

function getNow()
{
	now = new Date();
	if (QueryString("CURRENT_DATE") != null)
	{
		var querystring_current_date = unescape(QueryString("CURRENT_DATE").replace(/\+/g," ")) + " GMT";
		setInterval( "window.status = now.toUTCString()", 1000 );
		if (nowfudge == null)
		{
			nowfudge = now - new Date(querystring_current_date);
		}
		now.setTime(now.getTime() - nowfudge );
		now.setTime(now.getTime() + ((0 * 24 + 0) * 60 + 0) * 60 * 1000);
	}
}		
	
getNow();

function GPArrayItem(n, fn, id, c, t)
{
	this.name = n;
	this.fullname = fn;
	this.sessions = new Array();
	this.id = id;
	this.country = c;
	this.offset = t;
	return this;
}

function GPSArrayItem(s, d, l, bGP)
{
	this.session = s;
	this.start = new Date(d);
	this.end = new Date;
	this.end.setTime(this.start.getTime() + l * 60 * 1000);
	this.countdown = new Date(0);
	this.inProgress = false;
	this.isGP = bGP;
	return this;
}

function GPCurrent()
{
	return new findGPCurrent();
}

function findGPCurrent()
{
	var gp,s,gps,ss;
	var ret = this;
	
	for (; currentGPOffset < grand_prix.length; currentGPOffset++)
	{
		gp = grand_prix[currentGPOffset]
		gps = gp.sessions;
		ss = gps[gps.length-1];
		if ( ss.end >= now )
			break;
		previousGPOffset = currentGPOffset;
		currentSessionOffset = 0;
	}

	for (; currentSessionOffset < gps.length; currentSessionOffset++)
	{
		s = gps[currentSessionOffset];
		if (s.start > now)
		{
			ret.inProgress = false;
			break;
		}
		else if (s.end >= now)
		{
			ret.inProgress = true;
			break;
		}
	}

	ret.name = gp.name;
	ret.fullname = gp.fullname;
	ret.id = gp.id;
	ret.offset = gp.offset;
	ret.session = s.session;
	ret.start = s.start;
	ret.end = s.end
	ret.isGP = s.isGP;
	ret.countdown = new Date(ss.start - now);
	return this;
}

var grand_prix = new Array();

// First Parameter is "<GIF name>$<GP Title>$<Session Name>"
// Second Parameter is Date/Time in GMT of start of session
// Third Parameter is length of session in minutes
// Fourth Parameter is True/False if session is a GP.

grand_prix[0] = new GPArrayItem("secki", "secki", 731, "secki",-180);
grand_prix[0].sessions = new Array( 	new GPSArrayItem("secki", "22 Oct 2004 14:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "22 Oct 2004 17:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "23 Oct 2004 11:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "23 Oct 2004 12:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "23 Oct 2004 15:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "23 Oct 2004 16:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "24 Oct 2004 17:00:00 GMT", 120, true));

grand_prix[1] = new GPArrayItem("melbourne", "2005 Australian Grand Prix", 732, "australian",660);
grand_prix[1].sessions = new Array( 	new GPSArrayItem("secki", "04 Mar 2005 00:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "04 Mar 2005 03:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "04 Mar 2005 22:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "04 Mar 2005 23:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "05 Mar 2005 02:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "05 Mar 2005 23:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "06 Mar 2005 03:00:00 GMT", 120, true));

grand_prix[2] = new GPArrayItem("kuala_lumpur", "2005 Malaysian Grand Prix", 733, "malaysian",480);
grand_prix[2].sessions = new Array( 	new GPSArrayItem("secki", "18 Mar 2005 03:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "18 Mar 2005 06:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "19 Mar 2005 01:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "19 Mar 2005 02:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "19 Mar 2005 05:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "20 Mar 2005 03:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "20 Mar 2005 07:00:00 GMT", 120, true));

grand_prix[3] = new GPArrayItem("bahrain", "2005 Bahrain Grand Prix", 734, "bahrain",180);
grand_prix[3].sessions = new Array( 	new GPSArrayItem("secki", "01 Apr 2005 08:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "01 Apr 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "02 Apr 2005 06:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "02 Apr 2005 07:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "02 Apr 2005 10:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "03 Apr 2005 07:30:00 GMT", 60, false),
	new GPSArrayItem("secki", "03 Apr 2005 11:30:00 GMT", 120, true));

grand_prix[4] = new GPArrayItem("imola", "2005 San Marino Grand Prix", 735, "san_marino",120);
grand_prix[4].sessions = new Array( 	new GPSArrayItem("secki", "22 Apr 2005 09:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "22 Apr 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "23 Apr 2005 07:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "23 Apr 2005 08:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "23 Apr 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "24 Apr 2005 08:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "24 Apr 2005 12:00:00 GMT", 120, true));

grand_prix[5] = new GPArrayItem("catalunya", "2005 Spanish Grand Prix", 736, "spanish",120);
grand_prix[5].sessions = new Array( 	new GPSArrayItem("secki", "06 May 2005 09:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "06 May 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "07 May 2005 07:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "07 May 2005 08:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "07 May 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "08 May 2005 08:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "08 May 2005 12:00:00 GMT", 120, true));

grand_prix[6] = new GPArrayItem("monte_carlo", "2005 Monaco Grand Prix", 737, "monaco",120);
grand_prix[6].sessions = new Array( 	new GPSArrayItem("secki", "19 May 2005 09:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "19 May 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "21 May 2005 07:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "21 May 2005 08:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "21 May 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "22 May 2005 08:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "22 May 2005 12:00:00 GMT", 120, true));

grand_prix[7] = new GPArrayItem("nurburgring", "2005 European Grand Prix", 738, "european",120);
grand_prix[7].sessions = new Array( 	new GPSArrayItem("secki", "27 May 2005 09:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "27 May 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "28 May 2005 07:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "28 May 2005 08:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "28 May 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "29 May 2005 12:00:00 GMT", 120, true));

grand_prix[8] = new GPArrayItem("montreal", "2005 Canadian Grand Prix", 739, "canadian",-240);
grand_prix[8].sessions = new Array( 	new GPSArrayItem("secki", "10 Jun 2005 15:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "10 Jun 2005 18:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "11 Jun 2005 13:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "11 Jun 2005 14:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "11 Jun 2005 17:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "12 Jun 2005 17:00:00 GMT", 120, true));

grand_prix[9] = new GPArrayItem("indianapolis", "2005 United States Grand Prix", 740, "united_states",-300);
grand_prix[9].sessions = new Array( 	new GPSArrayItem("secki", "17 Jun 2005 16:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "17 Jun 2005 19:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "18 Jun 2005 14:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "18 Jun 2005 15:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "18 Jun 2005 18:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "19 Jun 2005 18:00:00 GMT", 120, true));

grand_prix[10] = new GPArrayItem("magny_cours", "2005 French Grand Prix", 741, "french",120);
grand_prix[10].sessions = new Array( 	new GPSArrayItem("secki", "01 Jul 2005 09:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "01 Jul 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "02 Jul 2005 07:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "02 Jul 2005 08:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "02 Jul 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "03 Jul 2005 12:00:00 GMT", 120, true));

grand_prix[11] = new GPArrayItem("silverstone", "2005 British Grand Prix", 742, "british",60);
grand_prix[11].sessions = new Array( 	new GPSArrayItem("secki", "08 Jul 2005 10:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "08 Jul 2005 13:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "09 Jul 2005 08:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "09 Jul 2005 09:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "09 Jul 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "10 Jul 2005 12:00:00 GMT", 120, true));

grand_prix[12] = new GPArrayItem("hockenheim", "2005 German Grand Prix", 743, "german",120);
grand_prix[12].sessions = new Array( 	new GPSArrayItem("secki", "22 Jul 2005 09:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "22 Jul 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "23 Jul 2005 07:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "23 Jul 2005 08:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "23 Jul 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "24 Jul 2005 12:00:00 GMT", 120, true));

grand_prix[13] = new GPArrayItem("secki", "secki", 744, "secki",120);
grand_prix[13].sessions = new Array( 	new GPSArrayItem("secki", "06 Nov 2005 03:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "29 Jul 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "30 Jul 2005 07:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "30 Jul 2005 08:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "30 Jul 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "06 Nov 2005 03:00:00 GMT", 120, true));

grand_prix[14] = new GPArrayItem("istanbul", "2005 Turkish Grand Prix", 745, "turkish",180);
grand_prix[14].sessions = new Array( 	new GPSArrayItem("secki", "19 Aug 2005 08:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "19 Aug 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "20 Aug 2005 06:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "20 Aug 2005 07:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "20 Aug 2005 10:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "21 Aug 2005 12:00:00 GMT", 120, true));

grand_prix[15] = new GPArrayItem("monza", "2005 Italian Grand Prix", 746, "italian",120);
grand_prix[15].sessions = new Array( 	new GPSArrayItem("secki", "02 Sep 2005 09:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "02 Sep 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "03 Sep 2005 07:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "03 Sep 2005 08:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "03 Sep 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "04 Sep 2005 12:00:00 GMT", 120, true));

grand_prix[16] = new GPArrayItem("spa", "2005 Belgian Grand Prix", 747, "belgian",120);
grand_prix[16].sessions = new Array( 	new GPSArrayItem("secki", "09 Sep 2005 09:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "09 Sep 2005 12:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "10 Sep 2005 07:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "10 Sep 2005 08:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "10 Sep 2005 11:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "11 Sep 2005 12:00:00 GMT", 120, true));

grand_prix[17] = new GPArrayItem("sao_paulo", "2005 Brazilian Grand Prix", 748, "brazilian",-180);
grand_prix[17].sessions = new Array( 	new GPSArrayItem("secki", "23 Sep 2005 14:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "23 Sep 2005 17:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "24 Sep 2005 12:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "24 Sep 2005 13:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "24 Sep 2005 16:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "25 Sep 2005 17:00:00 GMT", 120, true));

grand_prix[18] = new GPArrayItem("suzuka", "2005 Japanese Grand Prix", 749, "japanese",540);
grand_prix[18].sessions = new Array( 	new GPSArrayItem("secki", "07 Oct 2005 02:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "07 Oct 2005 05:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "08 Oct 2005 00:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "08 Oct 2005 01:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "08 Oct 2005 04:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "09 Oct 2005 05:30:00 GMT", 120, true));

grand_prix[19] = new GPArrayItem("shanghai", "2005 China Grand Prix", 750, "china",480);
grand_prix[19].sessions = new Array( 	new GPSArrayItem("secki", "14 Oct 2005 03:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "14 Oct 2005 06:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "15 Oct 2005 01:00:00 GMT", 45, false),
	new GPSArrayItem("secki", "15 Oct 2005 02:15:00 GMT", 45, false),
	new GPSArrayItem("secki", "15 Oct 2005 05:00:00 GMT", 60, false),
	new GPSArrayItem("secki", "16 Oct 2005 06:00:00 GMT", 120, true));

function getClockPath(s)
{
	if ( s == 10 )
		return "/saat/blank.gif";
	else
		return "/saat/" + s + ".gif";
	//return "/saat" + s + ".gif";
}

function getClockImage(s)
{
	var x;
	x = new Image();
	x.src = getClockPath(s);
	
	return x;
}
	
var clockImage = new Array();
for (i = 0; i <= 9; i++)
	clockImage[i] = getClockImage(i);

function getElement(o)
{return MM_findObj(o);
	if (document.getElementById)
		return document.getElementById(o);
	else if (document.all)
		return document.all[o];
}

function setVisibility(o, b)
{
	v = getElement(o);
	if ( v == null )
		return;
	v = v.style
	var s = (b)?"block":"none";
	if (v.display != s)
		v.display = s;
}

function setNumber( s, m )
{
	setNumber2(s,m,11);
}

function setNumber2( s, m, nn )
{
	var v,n,o,ss;
	for ( n = 0; n < nn; n++ )
	{
		o = s + n;
		v = getElement(o);
		if ( v == null )
			continue;
		v = v.style;
		ss = (n==m)?"inline":"none";
		if (v.display != ss)
			v.display = ss;
	}
}

var clockMode = 0;

function updateClock()
{
	getNow();

	var gp = GPCurrent();

	if (gp)
	{
		if (!gp.inProgress)
		{
			var x, y, n;

			if ( clockMode != 1 )
			{
				n = "/saat/" + gp.name + ".gif";
				document.images.cdgp.src = n
				setVisibility("seckion", false);
				setVisibility("endseason", false);
				setVisibility("countdown", true);
			}

			do
			{
			y = gp.countdown.getUTCSeconds();
			n = y % 10;
			setNumber( "cds1-", n );
			if ( n != 9 && clockMode == 1 ) break;
			n = Math.floor(y / 10);
			setNumber( "cds2-", n );
			if ( n != 5 && clockMode == 1 ) break;

			y = gp.countdown.getUTCMinutes();
			n = y % 10;
			setNumber( "cdm1-", n );
			if ( n != 9 && clockMode == 1 ) break;
			n = Math.floor(y / 10);
			setNumber( "cdm2-", n );
			if ( n != 5 && clockMode == 1 ) break;

			y = gp.countdown.getUTCHours();
			setNumber( "cdh1-", y % 10 );
			setNumber( "cdh2-", Math.floor(y / 10) );

			y = Math.floor(gp.countdown.getTime() / (24*3600000));
			n = y % 10;
			setNumber( "cdd1-", n );

			n = Math.floor(y / 10) % 10;
			if (n == 0) {
//			REMOVED PFW 16-11-04: Middle digit showing blank between 109 and 100
//				n = 10;
			}
			setNumber( "cdd2-", n );

			n = Math.floor(y / 100);
			if (n == 0)
				n = 10;
			setNumber( "cdd3-", n );
			} while(0);
			clockMode = 1;
		}
		else
		{
			if ( clockMode != 2 )
			{
				setVisibility("seckion", true);
				setVisibility("endseason", false);
				setVisibility("countdown", false);
			}
			clockMode = 2;
		}
	}
	else
	{	
		if ( clockMode != 3 )
		{
			setVisibility("seckion", false);
			setVisibility("endseason", true);
			setVisibility("countdown", false);
		}
		clockMode = 3;
	}

	setTimeout("updateClock()", 1001 - (new Date()).getMilliseconds());
}

function cd_DrawNumber(s)
{
var x;
for(x=0;x<11;x++)
	document.write( '<img style="display:' + (x==0?"inline":"none") + '" src="' + getClockPath(x) + '" width="11" height="27" alt="" id="cd' + s + '-' + x + '"/>');
//	<img src="/images/countdown_clock/numbers/0.gif" width="11" height="27" alt="" />
}

function cd2_DrawNumber(s)
{
var x;
for(x=0;x<10;x++)
	document.write( '<img style="display:' + (x==0?"inline":"none") + '" src="/images/home/live_timing/left_panel2/pre/session_countdown_clock/numbers/' + x + '.gif" width="9" height="22" alt="" id="cd2' + s + '-' + x + '" border="0" />');
//<img src="/images/home/live_timing/left_panel2/pre/session_countdown_clock/numbers/0.gif" alt="0" width="9" height="22" border="0" />
}

var homepage;

function updateHomePage()
{
	getNow();

	var gp = GPCurrent();
	var iTimeout = 0, n;
	if (gp)
	{
		if (gp.inProgress)
		{
			//secki - InProgress
			setVisibility("Home_seckiOn", true );
			setVisibility("Home_Postsecki", false );
			setVisibility("Home_Presecki", false );
			setVisibility("Home_AnimationOn", true );
			setVisibility("Home_AnimationOff", false );
			homepage = 'seckion';
			iTimeout = gp.end.getTime() - now.getTime();
		}
		else
		{
			n = gp.countdown;
			pgp = grand_prix[previousGPOffset];
			prs = pgp.sessions[pgp.sessions.length-1];
			PrevseckiTime = new Date(now - prs.start);
			if ( PrevseckiTime.getUTCDate() < 2 || ( PrevseckiTime.getUTCDate() == 2 && now.getUTCDay() == 1 ) )
			{ // just after secki
				n = getElement('Home_topflag');
				n.src= '/images/home/live_timing/left_panel2/grand_prix_name/' + grand_prix[previousGPOffset].country + '.gif';
				n = getElement('back_live_timing');
				n.src = '/images/home/live_timing/left_panel2/post/back_buttons/' + grand_prix[previousGPOffset].country + '_off.gif';
				n = getElement('back_live_timing_link');
				n.onclick = function(){window.open('/archive/grandprix/livetiming/popup/' + grand_prix[previousGPOffset].id + '/8.html','liveTimingWIN','width=610,height=530,history=no,resizable=no,status=no,scrollbars=no,menubar=no'); return false;}
				n.href = '/archive/grandprix/livetiming/popup/' + grand_prix[previousGPOffset].id + '/8.html'
				setVisibility("Home_Postsecki", true );
				setVisibility("Home_Presecki", false );
				setVisibility("Home_seckiOn", false );
				setVisibility("Home_AnimationOn", false );
				setVisibility("Home_AnimationOff", true );
				homepage = 'postsecki';
				iTimeout = 3600000;
			}
			else if ( n.getUTCMonth() > 1 || n.getUTCDate() > 6 || ( n.getUTCDate() == 6 && now.getUTCDay() == 1 ) )
			{ // 6 days before next secki
			//POST
				n = getElement('Home_topflag');
				if (n) {
					n.src= '/images/home/live_timing/left_panel2/grand_prix_name/' + grand_prix[currentGPOffset].country + '.gif';
				}
				n = getElement('back_live_timing');
				if (n) {
					n.src = '/images/home/live_timing/left_panel2/post/back_buttons/' + grand_prix[previousGPOffset].country + '_off.gif';
				}
				n = getElement('back_live_timing_link');
				if (n) {
					n.onclick = function(){window.open('/archive/grandprix/livetiming/popup/' + grand_prix[previousGPOffset].id + '/8.html','liveTimingWIN','width=610,height=530,history=no,resizable=no,status=no,scrollbars=no,menubar=no'); return false;}
					n.href = '/archive/grandprix/livetiming/popup/' + grand_prix[previousGPOffset].id + '/8.html'
				}
				setVisibility("Home_Postsecki", true );
				setVisibility("Home_Presecki", false );
				setVisibility("Home_seckiOn", false );
				setVisibility("Home_AnimationOn", false );
				setVisibility("Home_AnimationOff", true );
				homepage = 'postsecki';
				iTimeout = 3600000;
			}
			else
			{
				if ( homepage != gp.session )
				{
				//PRE
					homepage = gp.session;
					setVisibility("Home_Presecki", true );
					setVisibility("Home_seckiOn", false );
					setVisibility("Home_Postsecki", false );
					setVisibility("Home_AnimationOn", false );
					setVisibility("Home_AnimationOff", true );
					n = getElement('Home_session');
					if (n) {
						n.src = '/images/home/live_timing/left_panel2/pre/session/' + homepage.toLowerCase().replace(/ /g,'_') + '.gif';
					}
				}
				n = new Date( now.getTime() + gp.offset * 60000 );
				var ns = new Date( gp.start.getTime() + gp.offset * 60000 );
				ns.setUTCHours(0,0,0,0);
				if ( n.getTime() < ns.getTime() )
				{
					setVisibility("session_countdown_clock", false);
					setVisibility("session_countdown_space", true);
					iTimeout = ns.getTime() - n.getTime();
				}
				else
				{
					n = new Date( gp.start - now );
					setVisibility("session_countdown_clock", true);
					setVisibility("session_countdown_space", false);
					setNumber2( 'cd2s1-', n.getUTCSeconds() % 10, 10 );
					setNumber2( 'cd2s2-', Math.floor(n.getUTCSeconds() / 10 ), 6);
					setNumber2( 'cd2m1-', n.getUTCMinutes() % 10, 10 );
					setNumber2( 'cd2m2-', Math.floor(n.getUTCMinutes() / 10 ), 6);
					setNumber2( 'cd2h1-', n.getUTCHours() % 10, 10);
					setNumber2( 'cd2h2-', Math.floor(n.getUTCHours() / 10 ), 3);
					setNumber2( 'cd2d1-', (n.getUTCDate()-1) % 10, 10);
					iTimeout = 1001 - (new Date()).getMilliseconds();
				}
			}
		}
	}
	if ( iTimeout < 500 )
		iTimeout += 1000;
	setTimeout( "updateHomePage();", iTimeout );
}


function MM_swapImage2(i)
{
	MM_swapImage(i, '', getElement(i).src.replace(/off.gif/g,'over.gif') );
}
