// JavaScript Document

var nGare = 2
var sfondoCorrente = 'sfondoAuto'

function cambiaSfondo (sfondo) {
	var html
	html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%">'
	html = html + '<param name="movie" value="/' + sfondo + '.swf" />'
	html = html + '<param name="quality" value="high" />'
	html = html + '<param name="wmode" value="opaque" />'
	html = html + '<embed src="/' + sfondo + '.swf" width="100%" height="100%" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>'
	html = html + '</object>'
	document.getElementById('sfondo').innerHTML = html;
	
    
}

function seleziona(nGara) {
	document.getElementById('gara'+nGara).style.backgroundImage='url("/bgBlackDark.png")';
}
function deseleziona(nGara) {
	if (document.getElementById('gara'+nGara+'_dett').style.display=='none') {
		document.getElementById('gara'+nGara).style.backgroundImage='url("/bgBlack.png")';
	}
}
function apriGara(nGara) {
	var i, sfondoNuovo
	
	for (i=1; i<=nGare; i++) {
		if (i!=nGara) {
			document.getElementById('gara'+i+'_dett').style.display='none'
			document.getElementById('gara'+i).style.backgroundImage='url("/bgBlack.png")';
		}
	}
	
	if (document.getElementById('gara'+nGara+'_dett').style.display=='none') {
		document.getElementById('gara'+nGara+'_dett').style.display='';
	} else {
		document.getElementById('gara'+nGara+'_dett').style.display='none'
	}
	
	sfondoNuovo = 'sfondoAuto';
	switch (nGara) {
		case 1: sfondoNuovo = 'sfondoMoto'; break;
		case 2: sfondoNuovo = 'sfondoAuto'; break;
		case 3: sfondoNuovo = 'sfondoAuto'; break;
	}
	
	if (sfondoCorrente!=sfondoNuovo) {
		cambiaSfondo(sfondoNuovo);
		sfondoCorrente = sfondoNuovo;
	}
}

function apriDettaglio(layer, nGara) {
	if (document.getElementById(layer+'_gara'+nGara).style.display=='') {
		document.getElementById(layer+'_gara'+nGara).style.display='none';
	} else {
		document.getElementById(layer+'_gara'+nGara).style.display=''
	}
}