/* CONFIG */
menuClassName = "menuNavigazione";
menuOn        = "subMenu-on";
menuOff       = "subMenu-off";
var link_foto = "";	

/* SCRIPT */
function closeSub(menu) {
	for (var i=0; i<menu.childNodes.length; i++)
		if (menu.childNodes[i].nodeName.toLowerCase()=="li") {
			li = menu.childNodes[i];
			li.onmouseover = li.onactivate = li.onfocus = function() { if (this.subMenu) 
			{
			    if (this.subMenu.className == menuClassName + " " + menuOff) {this.subMenu.className = this.subMenu.className + " " + menuOn;}
                else {this.subMenu.className = menuOn;}
			}}			
			li.onmouseout = li.ondeactivate = li.onblur = function() { if (this.subMenu) {closeSub(this.subMenu);} };
			for (j=0; j<li.childNodes.length; j++)
				if (li.childNodes[j].nodeName.toLowerCase()=="ul" || li.childNodes[j].nodeName.toLowerCase()=="ol") closeSub(li.subMenu = li.childNodes[j])
		}
    if (menu.className == menuClassName) {menu.className = menu.className + " " + menuOff;}
    else {menu.className = menuOff;}
}

/* ON LOAD */
window.onload = function() {
}

function carica_menu()
{
	if(tags_ = document.getElementsByTagName("ul"))
		for(i=0; i<tags_.length; i++) 
			if (tags_[i].className==menuClassName) closeSub(tags_[i]);
	if(tags_ = document.getElementsByTagName("ol"))
		for(i=0; i<tags_.length; i++) 
			if (tags_[i].className==menuClassName) closeSub(tags_[i]);
			
}


function dimensiona(dim1,dim2)
{
    var marginex;
    var marginey;
    var ratio;
    ratio = dim1/dim2;  
    if (dim2>470) 
    {
	dim2=470;
	dim1=470*ratio;
    }	
    if (dim1>625) 
    {
	dim1=625;
	dim2=625/ratio;
    }	    
    dim3=-dim2;
    elemento0 =  prendiElementoDaId("centro");
    elemento1 = prendiElementoDaId("foto");
    elemento2 = prendiElementoDaId("titolo");
    elemento3 = prendiElementoDaId("label_com");
    elemento4 = prendiElementoDaId("raccoglitore");
    elemento5 = prendiElementoDaId("tab_foto");    
    alt=document.body.clientHeight;
    alt=alt-80;
    document.foto.foto_att.width=dim1;
    document.foto.foto_att.height=dim2;   
    elemento1.style.width = dim1;
    elemento2.style.width = dim1-10;
    elemento3.style.width = dim1-10;	
    marginex = ((531 - dim1) / 2)-1;
    marginey = ((alt - dim2) / 2);
    marginey = marginey+"px";
    marginey = "0px";
    marginex = marginex+"px";    
    dim3     = dim3+"px";
    elemento4.style.width = dim1;
    elemento4.style.height = dim2;
    elemento5.style.margin = marginey+" 0px 0px 0px";   
    elemento1.style.margin = "0px 0px 0px 0px";
    elemento2.style.margin = dim3+" 0px 0px 0px";
    elemento3.style.margin = "-25px 0px 0px 0px";
}

function dimensiona_biker(dim1,dim2)
{
    var marginex;
    var marginey;
    ratio = dim1/dim2;
    if (dim2>470) 
    {
	dim2=470;
	dim1=470*ratio;
    }	
    if (dim1>512) 
    {
	dim1=512;
	dim2=512/ratio;
    }	    
    elemento4 = prendiElementoDaId("raccoglitore");
//    marginex = ((515 - dim1) / 2)-1;
//    marginey = ((480 - dim2) / 2);
    alt=document.body.clientHeight;
    alt=alt-80;
    marginex = ((531 - dim1) / 2)-1;
    marginey = ((alt - dim2) / 2);
    marginey = marginey+"px";
    marginey = "0px";
    marginex = marginex+"px";    


    elemento4.style.width = dim1;
    elemento4.style.height = dim2;
    document.box_foto.foto_biker.width = dim1;  
    document.box_foto.foto_biker.height = dim2;
   // elemento4.style.margin = marginey+" 0px 0px 0px";   
}

	
function carica_commento(commento1,commento2)
{	
	var im_height;
	
    if (link_foto == "")
    { 
     im_height = 0;
    }
    else
    { 
     im_height = 25;
    }    
    commento1 = commento1.replace(/ç/g,"<a class=tipo1 href=?tipo_pag=galleria&tipo_gal=9&perc_gal=");
    commento1 = commento1.replace(/@/g,">");    
    commento1 = commento1.replace(/#/g,"</a>");
    elemento = prendiElementoDaId("titolo");
    elemento.innerHTML = commento1.replace(/£/g," ");
    elemento = prendiElementoDaId("label_com");
    elemento.innerHTML = '<img class="zoom" align="left" title="Clicca per ingrandire la foto in una nuova finestra" src="gif/zoom.gif" height="'+im_height+'" onclick="return apri_ext()">'+commento2.replace(/£/g," ");
    //document.foto.foto_att.title = commento2.replace(/£/g," ");       
}				

function apri_ext()
{	
    if (link_foto!="") window.open(link_foto); 
}				

function carica_foto(foto, foto2)
{	

    document.foto.foto_att.src = foto;      
    link_foto = foto2;
    
}				

function carica_video(video)
{	
alert(document.foto.test1.data);	
alert(document.foto.test2.src);

    document.foto.test1.data = "http://www.youtube.com/watch?v=" + video;
    document.foto.test2.src = "http://www.youtube.com/watch?v=" + video;

    
alert(document.foto.test1.data);	
alert(document.foto.test2.src);
    
}				

function carica_link(foto2)
{	
    link_foto = foto2;
}				


function carica_scheda(info1,info2,info3,info4,info5,info6,info7,info8,info9,info10,foto,nome)
{
    elemento = prendiElementoDaId("01b");
   	elemento.innerHTML = info1.replace(/£/g," ");
    elemento = prendiElementoDaId("02b");
    elemento.innerHTML = info2.replace(/£/g," ");
	elemento = prendiElementoDaId("03b");	
    elemento.innerHTML = info3.replace(/£/g," ");
	elemento = prendiElementoDaId("04b");
    elemento.innerHTML = info4.replace(/£/g," ");
	elemento = prendiElementoDaId("05b");
    elemento.innerHTML = info5.replace(/£/g," ");
	elemento = prendiElementoDaId("06b");
    elemento.innerHTML = info6.replace(/£/g," ");
	elemento = prendiElementoDaId("07b");
    elemento.innerHTML = info7.replace(/£/g," ");
	elemento = prendiElementoDaId("08b");
    elemento.innerHTML = info8.replace(/£/g," ");
	elemento = prendiElementoDaId("09b");
	if (info9.replace(/£/g," ") == "-")
    	elemento.innerHTML = info9.replace(/£/g," ");
    else
    	elemento.innerHTML = "<a class='tipo1' title='"+info9.replace(/£/g," ")+"' href='mailto:"+info9.replace(/£/g," ")+"'>"+info9.replace(/£/g," ")+"</a>";
    elemento = prendiElementoDaId("10b");
    elemento.innerHTML = info10.replace(/£/g," ");
    document.box_foto.foto_biker.src = foto;       
    document.box_foto.foto_biker.title = nome;       
}				

function prendiElementoDaId(id_elemento) 
{
	var elemento;
	if(document.getElementById)
		elemento = document.getElementById(id_elemento);
	else
		elemento = document.all[id_elemento];
	return elemento;
}

function visua()
{
	var ora = new Date();
	var aa = ora.getDate();
	var mm = ora.getMonth() + 1;
	var yy = ora.getFullYear();
	var oo = ora.getHours();
	var mn = ora.getMinutes();
	var sc = ora.getSeconds();
	var dd = ora.getDay();
	var aa2  = ((aa < 10) ? "0" : "");
	var mm2  = ((mm < 10) ? "0" : "");
	var oo2  = ((oo < 10) ? "0" : "");
	var mn2  = ((mn < 10) ? "0" : "");
	var sc2  = ((sc < 10) ? "0" : "");
	var Data = aa2 + aa + "/" + mm2 + mm + "/" + yy;
	var ora = oo2 + oo + ":" + mn2 + mn + ":" + sc2 + sc;

	if(document.all)
	{
		document.all.datario.innerHTML = Data;
		document.all.orario.innerHTML  = ora;						
	}
	else if(document.getElementById)
	{
		document.getElementById('datario').innerHTML = Data;
		document.getElementById('orario').innerHTML  = ora;				
	}
	window.setTimeout("visua()",1000);
}

function setActiveStyleSheet(titolo)
{
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
	{	
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title"))
		{
			a.disabled = true;
			if(a.getAttribute("title") == titolo) a.disabled = false;
		}
	}
}


function Mostra() {
        if (document.getElementById) {
                document.getElementById("s1").style.visibility="visible";
                document.getElementById("s2").style.visibility="visible";
                document.getElementById("s3").style.visibility="visible";                                
        } else if (document.all) {
                document.all.s1.style.visibility="visible";
                document.all.s2.style.visibility="visible";
                document.all.s3.style.visibility="visible";                                
        }
}

function Nascondi() {
	
        if (document.getElementById) {
                document.getElementById("s1").style.visibility="hidden";
                document.getElementById("s2").style.visibility="hidden";
                document.getElementById("s3").style.visibility="hidden";                                
        } else if (document.all) {
                document.all.s1.style.visibility="hidden";
                document.all.s2.style.visibility="hidden";
                document.all.s3.style.visibility="hidden";                                
        }
}


function dimensiona_div() {
	
			    elemento1  = prendiElementoDaId("sfondo");
			    elemento2  = prendiElementoDaId("corpo");
			    elemento3  = prendiElementoDaId("sx");
			    elemento4  = prendiElementoDaId("centro");
                            elemento5  = prendiElementoDaId("dx");
                            elemento6  = prendiElementoDaId("sx2");
                            elemento7  = prendiElementoDaId("sx_bis");
                            elemento8  = prendiElementoDaId("centro2");
                            elemento9  = prendiElementoDaId("centro3");    
                            elemento10 = prendiElementoDaId("centro4"); 
                            elemento11 = prendiElementoDaId("comm2");                        
			    elemento12 = prendiElementoDaId("sx3");
                            elemento13 = prendiElementoDaId("map");			    
			    elemento14 = prendiElementoDaId("eventi");
                            elemento15 = prendiElementoDaId("compleanni_completo");			    
                            a=document.body.clientHeight; 
                            a=a-10;
                            if (a<580) a=580;  
                            m1=(a-80)+"px";
                            m2=(a-84)+"px";
                            m3=(a-84-40-6)+"px";
                            m4=(a-84-165)+"px";                            
                            m5=(a-84)+"px";
                            m6=(a-80-123)+"px"
                            
                              elemento1.style.height=a;  
                            if (elemento2!=null)  elemento2.style.height=m1;  
                            if (elemento3!=null)  elemento3.style.height=m2;  
                            if (elemento4!=null)  elemento4.style.height=m6;
                            if (elemento5!=null)  elemento5.style.height=m1; 
                            if (elemento6!=null)  elemento6.style.height=m3;    
                            if (elemento7!=null)  elemento7.style.height=m2;
                            if (elemento8!=null)  elemento8.style.height=m2;
                            if (elemento9!=null)  elemento9.style.height=m2;
                            if (elemento10!=null) elemento10.style.height=m2;
                            if (elemento11!=null) elemento11.style.height=m4;
                            if (elemento12!=null) elemento12.style.height=m2;  
                            if (elemento13!=null) elemento13.style.height=m2;
                            if (elemento14!=null) elemento14.style.height=m2;  
                            if (elemento15!=null) elemento15.style.height=m2;  
}

function ruota(){
	elemento  = prendiElementoDaId("logo");
        if (elemento.src.indexOf("testata")>0)
        {
        	  
         elemento.src = "gif/logo.gif";
        }
        else 
        {
         elemento.src = "jpg/testata.jpg";
        }
	window.setTimeout("ruota()",3000);
}

//**********************************************************************************************
// DA IL FOCUS ALL'OGGETTO SPECIFICATO
//**********************************************************************************************
function sf(oggetto)
{	
	oggetto.focus();
}


function showItems(div_id)
{
  var d = document.getElementById(div_id);
  
  if (d.style.display == "block") d.style.display = "none";
  else d.style.display = "block";
  return false;
}
