


TimerVett = new Array(4)
for (i=0; i < 4; i++) 
	{
	TimerVett[i] = new Array(2)
	}
	
var VettIndex=0;
function Parti(n,arraystopy)
{	
if(n>=0)
{

	TimerVett[0][0]="setInterval(\"scrollbutton('bott0',"+arraystopy[0]+", 0)\", 10)";
	TimerVett[1][0]="setInterval(\"scrollbutton('bott1',"+arraystopy[1]+", 1)\", 10)";
	TimerVett[2][0]="setInterval(\"scrollbutton('bott2',"+arraystopy[2]+", 2)\", 10)";
	TimerVett[3][0]="setInterval(\"scrollbutton('bott3',"+arraystopy[3]+", 3)\", 10)";
	
	if (n==0)
	{
		for(i=0; i<4; i++)
		{
			TimerVett[i][1]=eval(TimerVett[i][0]);
		}	
	}
	else
	{	
		TimerSeq=setInterval("Sequenza()", n);		
	}
}
else
{
	$('bott0').style.top=arraystopy[0]+'px';
	$('bott1').style.top=arraystopy[1]+'px';
	$('bott2').style.top=arraystopy[2]+'px';
	$('bott3').style.top=arraystopy[3]+'px';

}

}

function Sequenza()
{	
	TimerVett[VettIndex][1]=eval(TimerVett[VettIndex][0]);
	//alert(Vett[VettIndex][0]);
	VettIndex++;
	lung=TimerVett.length;
	if (VettIndex==lung)
	{
		clearInterval(TimerSeq);
	}
}


function scrollbutton(bott, bottom, i)
{

	var butelem=$(bott);
	if(butelem.style.visibility=='hidden' || butelem.style.visibility=='')
		butelem.style.visibility=='visible';

	var butelemposy=butelem.offsetTop;
	butelemposy+=2;
	if (butelemposy>=bottom)
	{
		clearInterval(TimerVett[i][1]); 
		butelemposy=bottom;
	}
	butelem.style.top = butelemposy+'px';
	return 0;

}

function createmenubar(startbutton,noloadlogorollover)
{



	var logoimg= new Image();
	logoimg.src="./images/logo.jpg";
	
	var tableattribute={'style':'text-align:center','border':'0','cellpadding':'0','cellspacing':'0'};
	var tdattributearray= new Array();
	tdattributearray[0]={'style':'border:0px solid #0000FF;padding:3px 0px 3px 0px;margin:0px 0px 0px 0px;line-height : 12px;'};
	
	
	tdattributearray[3]={'id':'menuleft','style':'text-align:left;vertical-align:bottom;border:0px solid #0000FF;height:290px;padding:0px 0px 0px 0px;margin:0px 0px 0px 0px;'};
	
	var elemmatrix= new Array()
	elemmatrix[0]=new Array();
	elemmatrix[0][0]=new Element('a',{ 'href': 'default.htm'}).update('<img name="t" src="./images/logo.jpg" border="0" alt="Autocarrozzeria Distefano">');
	elemmatrix[1]=new Array();
	elemmatrix[1][0]=new Element('font',{ 'style': 'font-family:arial;font-size:10pt;color:#808080;'}).update('Autorizzata<br>Abarth Alfa Fiat Lancia');
	elemmatrix[2]=new Array();
	elemmatrix[2][0]="<IMG SRC='./images/logo_abarth_alfa_fiat_lancia_small.jpg' alt='Abarth Alfa Fiat Lancia'>";
	elemmatrix[3]=new Array();
	elemmatrix[3][0]="<IMG SRC='./images/banda.jpg'>";
	elemmatrix[4]=new Array();
//	elemmatrix[4][0]=new Element('div',{ 'href': 'default.htm'}).update('<img name="t" src="./images/logo.jpg" border="0" alt="Autocarrozzeria Distefano">');
	if(!noloadlogorollover)
		elemmatrix[4][0]=new Element('div',{ 'style': 'margin:2px auto;width:121px;vertical-align:middle;height:50px;padding:7px 0px 7px 0px;border:1px solid #5C5C5C;'}).update('<IMG SRC="./images/loghi.gif" alt="Ripariamo anche Ferrari, BMW, Porsche, Audi, Volkswagen, Maserati" title="Ripariamo anche Ferrari, BMW, Porsche, Audi, Volkswagen, Maserati">');
	
	elemmatrix[5]=new Array();
/*elemmatrix[5][0]="<b><i><font face=arial color=#FF0000 style='font-size:7pt;'>creazione</font></i></b>\
<b><font face=impact style='font-size:8pt;'><a  target='_top' href='HTTP://www.joinsnc.com' style='text-decoration:none;color:#000000;' onMouseMove='alert(\"1\")'>join</a></font>";
*/

	elemmatrix[5][0]="<b><i><font face=arial color=#FF0000 style='font-size:7pt;'>creazione</font></i></b>\
			<b><font face=impact style='font-size:8pt;'><a  target='_top' href='HTTP://www.joinsnc.com' style='text-decoration:none;color:#000000;'\
			onMouseMove='window.status=\"sito realizzato da JOIN s.n.c. (www.joinsnc.com) mail:join@joinsnc.com\"' \
			onMouseOut='window.status=\"\"'>join</a></font>";


	elemmatrix[3]=new Array();
	elemmatrix[3][0]=new Element('div',{'style':'margin:2px auto 0px auto;border:1px solid #5C5C5C;width:121px;height:190px;background:#FFFFFF;'}).update('<img name="t" src="./images/banda.jpg" border="0" USEMAP="#MenuMap">');
	var videobox=new Element('div',{'style':'margin:2px auto 0px auto;border:1px solid #5C5C5C;width:121px;height:100px;background-color:#FFFFFF;cursor:hand;','id':'player'}).update('<img name="t" src="./images/logo.jpg" border="0" alt="Autocarrozzeria Distefano">');
	var testflashbox=new Element('div',{'style':'display:none;margin:2px auto 0px auto;border:1px solid #5C5C5C;width:121px;background-color:#FFFFFF;font-family:arial;font-size:9px;','id':'testflash'});

	var tablelist=createTableObj(elemmatrix,null,null,tableattribute,tdattributearray);

	$('leftbar').insert(tablelist);
	$('menuleft').insert(videobox);
	$('menuleft').insert(testflashbox);

	var bottoni="<DIV class=bottoni id=bott0><a href='chi_siamo.htm' ><img src='./images/chi_siamo.jpg' border=0 alt='Chi siamo'></a></DIV>\
<DIV class=bottoni id=bott1><a href='come_trovarci.htm' ><img src='./images/come_trovarci.jpg' border=0 alt='Come trovarci'></a></DIV>\
<DIV class=bottoni id=bott2><a href='mail.htm''><img src='./images/mail.jpg' border=0 alt='Mail'></a></DIV>\
<DIV class=bottoni id=bott3><a href='servizi.htm''><img src='./images/servizi.jpg' border=0 alt='Servizi'></a></DIV>"


var menuMap='<MAP NAME="menuMap">\
    <AREA SHAPE="rect" COORDS="0,27,121,41"\
        HREF="chi_siamo.htm" alt="Chi siamo" title="Chi siamo">\
    <AREA SHAPE="rect" COORDS="0,66,121,80"\
        HREF="come_trovarci.htm" alt="Come trovarci" title="Come trovarci">\
    <AREA SHAPE="rect" COORDS="0,104,121,118"\
        HREF="mail.htm" alt="Come trovarci" title="Come trovarci">\
    <AREA SHAPE="rect" COORDS="0,143,121,157"\
        HREF="servizi.htm" alt="Servizi" title="Servizi">\
</MAP>';

	//$('leftbar').insert(bottoni);
	$('leftbar').insert(menuMap);

	var arraystopy= new Array();
	arraystopy[0]=189;
	arraystopy[1]=225;
	arraystopy[2]=262;
	arraystopy[3]=300;

	//Parti(startbutton,arraystopy);



createFlowPalyers();
startVideo();
	return ;
	

}


/*FUNZIONI SUPPORTO*/
function createTableObj(elemmatrix,titlearray,id_formcontainer,tableattributes,tdbodyattributes,tdheaderattributes)
{
	
	var table=new Element('table');
	if(tableattributes && tableattributes!=null)
		table.writeAttribute(tableattributes);
	var tbody=new Element('tbody');
	
	var form=new Element('form',id_formcontainer);
	tbody.insert(form);
	
	if(id_formcontainer && id_formcontainer!=null)
	{
		form.writeAttribute({'id':id_formcontainer});
	}	
	
	if(titlearray && titlearray!=null)
	{	
		var tr= new Element('tr');	
		for(j=0;j<titlearray.length;++j)
		{
			if(titlearray[j] && titlearray[j]!=null)
			{
				var td= new Element('td');
				if(!tdheaderattributes && tdattributes)
					tdheaderattributes=tdbodyattributes;
		
				if(tdheaderattributes)
				{
					if(tdheaderattributes.constructor== Array)
					{
						
						if(tdheaderattributes[i] )	
						{
							if(tdheaderattributes[i].constructor== Array && tdheaderattributes[i][j])
							{
								td.writeAttribute(tdheaderattributes[i][j]);
							}
							else
							{
								td.writeAttribute(tdheaderattributes[i]);
							}
						}
					}
					else 
						td.writeAttribute(tdheaderattributes);
				}
				td.insert(titlearray[j]);
				tr.insert(td);
			}
		}
		tbody.insert(tr);
	}
	


	for(i=0;i<elemmatrix.length;++i)
	{
		var tr= new Element('tr');
		var eleminfoarray=elemmatrix[i];
		for(j=0;j<eleminfoarray.length;++j)
		{
			if(titlearray==null || (titlearray!=null && titlearray[j] && titlearray[j]!=null))
			{
				var td= new Element('td');
				if(tdbodyattributes)
				{
					if(tdbodyattributes.constructor== Array)
					{
						
						if(tdbodyattributes[i] )	
						{
							if(tdbodyattributes[i].constructor== Array && tdbodyattributes[i][j])
							{
								td.writeAttribute(tdbodyattributes[i][j]);
							}
							else
							{
								td.writeAttribute(tdbodyattributes[i]);
							}
						}
					}
					else 
						td.writeAttribute(tdbodyattributes);
				}
				td.insert(eleminfoarray[j]);
				tr.insert(td);
			}
			else
				form.insert(eleminfoarray[j]);
		}
		tbody.insert(tr);
	}
	table.insert(tbody);
	return table;

}



function createFlowPalyers()
{
var FlashVersionArray= new Array();
FlashVersionArray[0]=9
FlashVersionArray[1]=115

flashembed("testflash", {

	src:"",
	// we need at least this version
	version: [FlashVersionArray[0],FlashVersionArray[1]],

	// older versions will see a custom message
	onFail: function()  {
		var container=this.getContainer(); 
		var installVersion=this.getVersion();
		var alertStr="Versione del plugin flash presente: <b>"+installVersion[0]+","+installVersion[1]+"</b><br>Per motivi di sicurezza si consiglia di aggiornarlo.<br>E' possibile scaricarlo <a style='text-decoration:none;color:#ff0000;' href='http://get.adobe.com/flashplayer/'>quì</a>"
		if(installVersion[0]==0)
			var alertStr="per una visione completa è necessario installare il <b>plugin di flash</b><br>E' possibile scaricarlo <a style='text-decoration:none;color:#ff0000;' href='http://get.adobe.com/flashplayer/'><b>quì</b></a>";
			
		container.innerHTML="<p style='margin:0px;padding:6px;'>"+alertStr+"</p>";
		container.style.display='block';

	}

	// here is our third argument which is the Flowplayer configuration
});

flowplayer(
	"player", 
	"flash/flowplayer-3.1.0.swf",
	{
		clip: {      
				//duration: 5,
				baseUrl: '../video/',
				//url: 'teoria_relativitapiccolo.flv',     
				url: 'distefanonoaudiopiccolo.flv',     
				autoPlay: true,
				onPause : function() {openOverlay();},
				onFinish : function() {resetPlayer();}

			},

		canvas: {
			      	// use a wicked backgound color
				backgroundColor: '#FFFFFF;'
				/*,
				//a gradient
				backgroundGradient: 'medium',
				// and "curved" corners
				borderRadius: 20 */
			},

		screen: {
				width:100,
				height:86,
				top:'50%',
				right:'50%'     
			},

		plugins: {      // the default controlbar is called "controls". by tweaking this, you can modify the default controlbar     
				controls: null,
				c1: {
					url:'flowplayer.content-3.1.0.swf',
					html: '<a href="javascript:function(){return false;}"><img src="./images/logo.jpg" border="0" title="Autocarrozzeria Distefano"></a>',  
					style: {
						".contenuto": {fontWeight:'bold',fontSize:12, color:'#ff0000',padding:0},
						a: {color:'#008eff'}
					},
					top:0,
					left:0,
					width: 119,
					height:100,
					padding:0,
					margin:0,
					opacity:0,
					background:'#FFFFFF',
					backgroundGradient:'low',

					onClick:function() {openOverlay();}

					
					
				}			
			}

	}
	);

flowplayer(
	"playerbig", 
	"flash/flowplayer-3.1.0.swf",
	{
		clip: {      
				//duration: 5,
				baseUrl: '../video/',
//				url: 'teoria_relativitagrande.flv',     
				url: 'distefanogrande.flv',     
				autoPlay: false
				
			},
			canvas: {
			      	// use a wicked backgound color
				backgroundColor: '#FFFFFF;',
				//a gradient
				backgroundGradient: 'medium'
				
				
				
			},
			screen: {
				width:592,
				height:496,
				top:'0',
				left:'0'     
			},
			plugins: {
				controls: {
						top:460
					}
			}
	}
	);
}

function resetPlayer()
{
	$f("player").unload();
	startVideo()
}

function startplay()
{	
	try{
		$f("player").play();
	}
	catch(e)
	{
		
	}
}

function startVideo()
{
	window.setTimeout(startplay,0);	
}

function openOverlay() { 

	var pathname=location.pathname.substring(location.pathname.lastIndexOf("/")+1);
	var pathname=pathname.substring(0,pathname.lastIndexOf("."));

	if(pathname=="chi_siamo" && fadeImage)
	{
		fadeImage=false; //serve per bloccare il fading nel chi siamo
	}
	$f("player").stop();
	$f("player").unload();
	// get access to the overlay API     
	var overlay_api = JQ("#overlay").overlay();
	// call it's open() method
	overlay_api.load();             
	$f("playerbig").play();
           
}

function closeOverlay() { 
	JQ.expose.close();
	$f("player").load();
	$f("playerbig").stop();
	var pathname=location.pathname.substring(location.pathname.lastIndexOf("/")+1);
	var pathname=pathname.substring(0,pathname.lastIndexOf("."));
	if(pathname=="chi_siamo" && !fadeImage)
	{
		fadeImage=true;
		changeimage(); //serve per bloccare il fading nel chi siamo
	}
}

function setExpose()
{
	var overlay_api = JQ("#overlay").overlay(); 
	overlay_api.getBackgroundImage().expose(
							{
								color: '#ffffff',
								closeOnClick: false
							}
						);
}

JQ(function() 
	{     
		JQ("#overlay").overlay(
			{
				closeOnClick: false, 
				onBeforeLoad: function() {	
							setExpose();
							},
				onLoad: function() {
			  					$f("playerbig").load();
								
							}
				,onClose: function(){ 
								closeOverlay(); 
							} 

				//,finish: {top:'50%', left:'50%'}
				//,onLoad: function() { 
				//			relativize(); 
				//			} 
			}
		);             
	}
);
function relativize()
{
	
	
}
