function countdown(){
if (true) {
		milDif=(racestart-adesso)
		adesso.setSeconds(adesso.getSeconds()+1);
		giorni=parseInt(milDif/86400000);  
		milDif=milDif-(giorni*86400000);
		ore=parseInt(milDif/3600000);
		milDif=milDif-(ore*3600000);
		minuti=parseInt(milDif/60000);
		milDif=milDif-(minuti*60000);
		secondi=parseInt(milDif/1000);
		milDif=milDif-(secondi*1000);
		var ttrstext='';
		if  (giorni > 1) {
			ttrstext='<span class="datanmb">'+giorni+'</span>days';
		} else if (giorni == 1) {
			ttrstext='<span class="datanmb">'+giorni+'</span>day';
		}
		ttrstext=ttrstext+' <span class="datanmb">'+ore+'</span>h <span class="datanmb">'+minuti+'</span>m <span class="datanmb">'+secondi+'</span>s';
		if ((ore < 1)&&(minuti < 1)) {
			ttrstext='<span class="datanmb">Race in progress</span>';
		}
		if (ore <= -1) {
			ttrstext='<span class="datanmb">Race finished</span>';
		}
		//Togliere
		//ttrstext='Race cancelled';
		//Fine
		cdtext.innerHTML=ttrstext;
		setTimeout("countdown()",1000);
	} else {
		alt2009(0);
	}
}

function setPictures(tsid,offset)
{	
	if (parseInt(offset)==tsarray[parseInt(tsid)-1].length) {
		offset = '4';
	}
	document.getElementById('tsdivpic').src = './images/photos/'+tsarray[parseInt(tsid)-1][parseInt(offset)];
	if (tsarray[parseInt(tsid)-1].length>5) {
		t = setTimeout("setPictures('"+tsid+"','"+(parseInt(offset)+1)+"')",4000);
	}
}

function changetopstory(storyid)
{	
	var elementid = 0;
	for (var i=1; i<4; i++) {
		elementid = document.getElementById('ts'+i);
		if (parseInt(storyid)==i) {
			elementid.className = 'topstoryboxactive';
			//elementid.style.backgroundImage='url(./images/layout/bkg_active_b.gif)';
			document.getElementById('tstitle'+i).className='topstorytitleactive';
			document.getElementById('tsbigdate').innerHTML = tsarray[i-1][1];
			document.getElementById('tsbigtitle').innerHTML = tsarray[i-1][2];
			document.getElementById('tsbigtitle').href = 'newsdetail.asp?newsid=' + tsarray[i-1][0];
			document.getElementById('tslink').href = 'newsdetail.asp?newsid=' + tsarray[i-1][0];
			clearTimeout(t);
			setPictures(storyid,'4');
		} else {
			elementid.className = 'topstorybox';
			//elementid.className = 'topstorybox' + i +'off';
			//elementid.style.backgroundImage='url(./images/layout/bkg_' + i + 'off_b.gif)';
			document.getElementById('tstitle'+i).className='topstorytitle';
		}
	}
	document.getElementById('tsbkg').style.display = 'block';
	document.getElementById('tslink').style.display = 'block';
}

function setNewsPic(tsid,offset)
{	
	if (parseInt(offset)==tsarray[parseInt(tsid)-1].length) {
		offset = '4';
	}
	document.getElementById('newspic'+tsid).src = 'images/imgwrite.asp?imgurl=photos£'+tsarray[parseInt(tsid)-1][parseInt(offset)]+'&imgwdt=210';
	if (tsarray[parseInt(tsid)-1].length>5) {
		t = setTimeout("setNewsPic('"+tsid+"','"+(parseInt(offset)+1)+"')",4000);
	}
}

function setTopSlide(offset)
{	
	if (parseInt(offset)==topslide.length) {
		offset = '0';
	}
	document.getElementById('tsdivpic').src = './images/photos/'+topslide[parseInt(offset)];
	if (topslide.length>1) {
		t = setTimeout("setTopSlide('"+(parseInt(offset)+1)+"')",4000);
	}
}

function setLinkId() {
	document.getElementById('newsid1a').href = 'newsdetail.asp?newsid='+tsarray[0][0];
	document.getElementById('newsid1b').href = 'newsdetail.asp?newsid='+tsarray[0][0];
	document.getElementById('newsid2a').href = 'newsdetail.asp?newsid='+tsarray[1][0];
	document.getElementById('newsid2b').href = 'newsdetail.asp?newsid='+tsarray[1][0];
	document.getElementById('newsid3a').href = 'newsdetail.asp?newsid='+tsarray[2][0];
	document.getElementById('newsid3b').href = 'newsdetail.asp?newsid='+tsarray[2][0];
}

function swapelements(id1,id2)
{	
	var elementid = 0;
	elementid = document.getElementById(id2);
	elementid.style.display = 'none';
	elementid = document.getElementById(id1);
	elementid.style.display = 'block';
}

function swapElements3(id1,id2,id3)
{	
	document.getElementById(id1).style.display = 'block';
	document.getElementById(id2).style.display = 'none';
	document.getElementById(id3).style.display = 'none';
	document.getElementById('promo').style.display = 'none';
}

function swapElements4(id1,id2,id3,id4)
{	
	document.getElementById(id1).style.display = 'block';
	document.getElementById(id2).style.display = 'none';
	document.getElementById(id3).style.display = 'none';
	document.getElementById(id4).style.display = 'none';
}

function swapElements5(id1,id2,id3,id4,id5)
{	
	document.getElementById(id1).style.display = 'block';
	document.getElementById(id2).style.display = 'none';
	document.getElementById(id3).style.display = 'none';
	document.getElementById(id4).style.display = 'none';
	document.getElementById(id5).style.display = 'none';
}

function showPromo()
{	
	document.getElementById('video1').style.display = 'none';
	document.getElementById('video2').style.display = 'none';
	document.getElementById('video3').style.display = 'none';
	document.getElementById('promo').style.display = 'block';
	swfobject.embedSWF('flv/promo2010_small.swf', 'moviepromo', '292', '204', '9.0.0');
}

function topstoryboxMOver(id){
	if(document.getElementById('ts'+id).className != "topstoryboxactive"){
		document.getElementById('ts'+id).style.backgroundImage='url(./images/layout/bkg_'+id+'on_b.gif)'
	}
}

function topstoryboxMOut(id){
	if(document.getElementById('ts'+id).className != "topstoryboxactive"){
		document.getElementById('ts'+id).style.backgroundImage='url(./images/layout/bkg_'+id+'off_b.gif)'
	}
}

function viewVideo(url, w, h, vTitle){
	swfobject.embedSWF(url, 'video', w, h, '9.0.0', '', {}, {allowScriptAccess:'sameDomain',wmode:'transparent'});
	document.getElementById('videoTitle').innerHTML = vTitle;
}

function alternatePic(divid,arrayid,picid) {
	if (eval(picid)==eval(arrayid+'.length')) {
		eval(picid+'=0');
	}
	document.getElementById(divid).src = eval(arrayid+'['+eval(picid)+']');
	eval(picid+'='+picid+'+1');
	setTimeout("alternatePic('"+divid+"','"+arrayid+"','"+picid+"')",4000);
}

function mediaAssociates() {
	if (maid==maarray.length) {
		maid = 0;
	}
	document.getElementById('mapic').src = maarray[maid][0];
	document.getElementById('maanchor').href = maarray[maid][1];
	maid = maid + 1;
	if (maarray.length>1) {
		setTimeout("mediaAssociates()",4000);
	}
}

function openStats(pilotid) {
	document.getElementById('pilot'+pilotid).style.display = 'block';
}

function closeStats(pilotid) {
	document.getElementById('pilot'+pilotid).style.display = 'none';
}

function changeDay(dayid) {
	for (var j=1; j<4; j++) {
		if (dayid==j) {
			document.getElementById('day'+j).style.display='block';
			document.getElementById('daytitle'+j).className='racedayactive';
		} else {
			document.getElementById('day'+j).style.display='none';
			document.getElementById('daytitle'+j).className='raceday';
		}
	}	
}

function openDownload(fileid) {
	window.open('filedownload.asp?nomefile='+fileid,'download','width=100,height=100');
}

var s2009 = new Array();
s2009[0] = ['RIO DE JANEIRO, BRAZIL','26 - 28 MARCH 2010'];
s2009[1] = ['ARENDAL, NORWAY','16 - 18 JULY 2010'];
s2009[2] = ['UDDEVALLA, SWEDEN','6 - 8 AUGUST 2010'];
s2009[3] = ['CONSTANTA, ROMANIA','27 - 29 AUGUST 2010'];
s2009[4] = ['STRESA, ITALY','1 - 3 OCTOBER 2010'];
s2009[5] = ['ABU DHABI, U.A.E.','18 - 20 NOVEMBER 2010'];
s2009[6] = ['DUBAI, U.A.E.','9 - 11 DECEMBER 2010'];

function alt2009(venueid) {
	if (false) {
		if (venueid==7) {
			venueid=0;
		}
		document.getElementById('2009location').innerHTML = s2009[venueid][0];
		document.getElementById('2009date').innerHTML = s2009[venueid][1];
		venueid=venueid+1;
		setTimeout("alt2009("+venueid+")",4000);
	}
}

var maarray = [['/images/layout/logo_aquatoria_w105.gif','http://eng.aquatoria.info'],['/images/layout/logo_barche.jpg','http://www.barcheisp.com'],['/images/layout/logo_boote.jpg','http://www.boote-magazin.de'],['/images/layout/logo_h2omagazin_w105.jpg',''],['/images/layout/logo_worldofpowerboats.jpg','http://www.worldofpowerboats.com'],['/images/layout/logo_yc_w105.jpg','http://www.yachtonline.it/'],['/images/layout/logo_yachtmagazin_w105.jpg','http://www.yacht-magazin.hu']];
var maid = 0;

