
    
/**********************  SCROLL TESTO  *****************************************/
/*
var posizione;
posizione=1; 
*/
// posizione iniziale dalla quale parte il ciclo delle news. Il punto (0) � il top del div che contiene le news

var velocita_expl; // velocit� di scorrimento delle news x EXPLORER E NETSCAPE 7.0
velocita_expl=15; // NB: X AUMENTARE LA VELOCITA' DIMINUIRE il valore


/**************************************************

guardare e non toccare � una cosa da imparare !!!

***************************************************/

var altezza;

function su(c,p,b){
    //alert(c);
    con=c;
    par=p;
    inp=b;
	via_su=window.setInterval('muovi_su(con,par,inp)',velocita_expl);
}
	

function muovi_su(c,p,b){
    //alert(c);
    div_cont=document.getElementById(p);
    alt_vis=parseInt(document.getElementById(c).style.height);
   // alert(alt_vis);
    	
	altezza=div_cont.offsetHeight; // altezza del contenuto del div
	alt_neg=-altezza;
    posizione=document.getElementById(b).value;
	posizione--
    document.getElementById(b).value=posizione;
    //document.forms[0].box1.value=posizione;
		if (posizione<(alt_neg+(alt_vis-10))){ // news finite
			//posizione=riparti;
		    clearTimeout(via_su);
        } else{
		  div_cont.style.top=posizione+"px";
          
		}
}  // end muovi_su()


function giu(c,p,b){
    //alert(p);
    con=c;
    par=p;
    inp=b;
	via_giu=window.setInterval('muovi_giu(con,par,inp)',velocita_expl);
}
	

function muovi_giu(c,p,b){
    div_cont=document.getElementById(p);	
	altezza=div_cont.offsetHeight; // altezza del contenuto del div
	alt_pos=altezza;
    posizione=document.getElementById(b).value;
	posizione++
    document.getElementById(b).value=posizione;
		if (posizione>=1){ // news finite
            posizione=1;
            document.getElementById(b).value=posizione;
			clearTimeout(via_giu);
		} else{
		  div_cont.style.top=posizione+"px";
		}
        
}  // end muovi_su()

		
function stop_su(){
	clearTimeout(via_su)
}

function stop_giu(){
	clearTimeout(via_giu)
}
/**********************  FINE SCROLL TESTO  *****************************************/




function roll(q,e){
    var evento=e;
    var img_src=document.getElementById(q).src;
    var lung_str=img_src.length;
    var inizio_img=img_src.lastIndexOf("_")+1; // inizio nome img
    var lung_nome=lung_str-inizio_img; // lunghezza nome img
    var nome_img=img_src.substr(inizio_img,lung_nome); // nome esatto img + .ext
    var loc_img=img_src.substr(0,inizio_img);  // percorso img
    var pto=img_src.lastIndexOf(".");
    var ext=img_src.substr(pto+1,lung_str); // .ext 
    document.getElementById(q).src=loc_img+evento+"."+ext;
 }
 
 function bgmntop(q,i,e){
    nome_img="mntop_"+i;
    immagine=document.getElementById(i).src;
    str_preslash=immagine.substring(0,immagine.lastIndexOf("/")+1);
    if (e=='on'){
        q.style.background="#E5E5E5";
        document.getElementById(i).src=str_preslash+nome_img+"_on.gif";
        
    }else{
        q.style.background="";
        document.getElementById(i).src=str_preslash+nome_img+"_off.gif";
    }
 }
 
 
 /**********************  MENU SINISTRA  *****************************************/
 
 
 // cambio la classe css di un elemento
function menusx(voce){
	sottomenu="smn-"+voce;
	brw=navigator.appName.indexOf("Expl");
	if (brw!=-1){ // explorer
		var att="className";
	} else{
		var att="class";
	}
	status=document.getElementById(voce).getAttribute(att); // vedo se la voce � accesa o no
	if (status=="menu-sx-fliv") { // � spenta e la accendo
		document.getElementById(voce).setAttribute(att,"menu-sx-fliv-on");
		document.getElementById(sottomenu).style.display=""
	} else {   
		document.getElementById(voce).setAttribute(att,"menu-sx-fliv");
		document.getElementById(sottomenu).style.display="none"
	}
	
} 

/**********************  FINE MENU SINISTRA  *****************************************/


function popup(str,w,h) {
window.open(str,'nome','scrollbars=no,resizable=no,width='+w+',height='+h+',status=no,location=no,toolbar=no');
}

function popup2(str,nome,w,h,scrl) {
window.open(str,''+nome+'','scrollbars='+scrl+',resizable=no,width='+w+',height='+h+',status=no,location=no,toolbar=no');
}

/****************** PACCHETTI TURISTICI **************/

function pacchetti(id,cat,subcat,num){ 
    document.getElementById("id_art").value=id;
    document.getElementById("cat").value=cat;
    document.getElementById("subcat").value=subcat;
    document.getElementById("num").value=num;
    // inserisco il livello per far accendere il menu di sx
    if (subcat=="novita"){
        document.getElementById("divposition").action="pacchetti_dett.php?liv=2";
    }else{
        document.getElementById("divposition").action="pacchetti_dett.php?liv=3";
    }
    document.getElementById("divposition").submit();
}

function hideScrollPacchetti(){
	if(document.getElementById("paragpacch1").offsetHeight>205){
        document.getElementById("scrollPacchetti").style.visibility="visible";
     }else{
        document.getElementById("scrollPacchetti").style.visibility="hidden";
     }
}

function addTopToHref(q){
	var topDiv=parseInt(document.getElementById("paragpacch1").style.top);
	q.href=q.href+"&topDiv="+topDiv;

}



var altezzaPacchetti;

function suPacchetti(){
    via_suPacchetti=window.setInterval('muovi_suPacchetti()',velocita_expl);
}
	

function muovi_suPacchetti(){
    //alert(c);
	
    div_cont=document.getElementById("paragpacch1");
    alt_vis=parseInt(document.getElementById("pacch1").style.height);
   // alert(alt_vis);
    	
	altezza=div_cont.offsetHeight; // altezza del contenuto del div
	alt_neg=-altezza;
    posizione=parseInt(div_cont.style.top);
	posizione--
    //document.forms[0].box1.value=posizione;
		if (posizione<(alt_neg+(alt_vis-10))){ // news finite
			//posizione=riparti;
		    clearTimeout(via_suPacchetti);
        } else{
		  div_cont.style.top=posizione+"px";
          
		}
}  // end muovi_su()


function giuPacchetti(){
    //alert(p);
   
	via_giuPacchetti=window.setInterval('muovi_giuPacchetti()',velocita_expl);
}
	

function muovi_giuPacchetti(){
    div_cont=document.getElementById("paragpacch1");	
	altezza=div_cont.offsetHeight; // altezza del contenuto del div
	alt_pos=altezza;
    posizione=parseInt(div_cont.style.top);
	posizione++
		if (posizione>=1){ // news finite
            posizione=1;
//            document.getElementById(b).value=posizione;
			clearTimeout(via_giuPacchetti);
		} else{
		  div_cont.style.top=posizione+"px";
		}
        
}  // end muovi_su()

		
function stop_suPacchetti(){
	clearTimeout(via_suPacchetti)
}

function stop_giuPacchetti(){
	clearTimeout(via_giuPacchetti)
}

/****************** FINE PACCHETTI TURISTICI **************/

/******************** CARTOLINE *****************/



 function chg_img(a){
    var foto;
    var foto_src=document.getElementById("foto").src;  
    var loc_img="foto_stat/cartoline/";
    var num_foto=parseInt(foto_src.substr(foto_src.lastIndexOf('/') + 1,foto_src.lastIndexOf('.')));
    
        if (a=='p'){  /* prev */
            foto=num_foto-1;
            if (num_foto==1){
                foto=12;
            }
        } else{ /* next */
            foto=num_foto+1;
            if (num_foto==12){
                foto=1;
            }
        }
   document.getElementById("foto").src=loc_img+foto+".jpg";
   document.forms[0].foto_scelta.value=foto+".jpg";
   document.forms[0].dida.value=foto;
 }
    
 function pag_stampa(){
    var foto=document.forms[0].foto_scelta.value;
    var lingua=document.forms[0].lingua.value;
    var pag="print.php?foto="+foto+"&lingua="+lingua; 
    window.open(pag,'stampa','scrollbars=no,resizable=no,width=400,height=600,status=no,location=no,toolbar=no');
    
 }  
   
function reset_fields(){
    document.forms[0].recipient_name.value="";
    document.forms[0].recipient_mail.value="";
}

function popup_cartoline(str,w,h) {
window.open(str,'nome','scrollbars=yes,resizable=no,width='+w+',height='+h+',status=no,location=no,toolbar=no');
}


/******************** FINE CARTOLINE *****************/



function popup_reg(){
    var email_reg;
    email_reg=document.getElementById("emailreg").value;
    lk="registrati.php?em="+email_reg;
    window.open(lk,'nome','scrollbars=yes,resizable=no,width=422,height=520,status=no,location=no,toolbar=no');

}

function popup_area_riservata(lang){
    var email_reg;
    email_reg=document.getElementById("emailreg").value;

	var language = lang.substr(0,2);
	
    lk="users/index.php?page=Personal.Login&lang="+language;
    window.open(lk,'nome','scrollbars=yes,resizable=no,width=620,height=600,status=no,location=no,toolbar=no');

}

function popup_registrazione(lang){
    var email_reg;
    email_reg=document.getElementById("emailreg").value;

	var language = lang.substr(0,2);

    lk="users/index.php?page=Personal.Register&rg=1&em="+email_reg+"&lang="+language;
    window.open(lk,'nome','scrollbars=yes,resizable=no,width=620,height=600,status=no,location=no,toolbar=no');

}


/******************** METEO *****************/

function no_scroll_div(q,h){
     // document.getElementById("parag").offsetHeight>200;
     if(document.getElementById(q).offsetHeight>parseInt(h)){
        document.getElementById("frecce_scroll").style.visibility="visible";
     }else{
        document.getElementById("frecce_scroll").style.visibility="hidden";
     }
      

}

/*
function no_scroll_msp(){
     // document.getElementById("parag").offsetHeight>200;
     if(document.getElementById("parag").offsetHeight>200){
        document.getElementById("frecce_scroll").style.visibility="visible";
     }else{
        document.getElementById("frecce_scroll").style.visibility="hidden";
     }
      

}
*/


/* *** FOCUS E NEWS*****/

function muovi(f,n){
    parti=window.setInterval("scorri("+f+","+n+")",6000);
}

function stopfn(f,n){
    clearTimeout(parti);
}

/*
function muovi_news(qn){
    qtan=qn;
    via_news=window.setInterval('scorri_news(qtan)',500);
}
 */   
function scorri(qf,qn){
    var tot_focus;
    var tot_news;
    var id_div_act_focus;
    var id_div_act_news;
    var id_div_next_focus;
    var id_div_next_news;
    var id_focus_visibile;
    var id_news_visibile;
    var next_focus;
    var next_news;
    tot_focus=qf;
    tot_news=qn;
    id_focus_visibile=document.forms[0].focus_vis.value;
    id_news_visibile=document.forms[0].news_vis.value;
    id_div_focus_attuale="elfocus"+id_focus_visibile;
    id_div_news_attuale="elnews"+id_news_visibile;
    next_focus=parseInt(id_focus_visibile)+1;
    next_news=parseInt(id_news_visibile)+1;
    id_div_focus_next="elfocus"+next_focus;
    id_div_news_next="elnews"+next_news;
    // alert(tot_focus);
    // alert(tot_news);
    if (next_focus<=tot_focus){
        document.getElementById(id_div_focus_attuale).style.display="none"; 
        document.getElementById(id_div_focus_next).style.display=""; 
        document.forms[0].focus_vis.value=next_focus;
    }else{
        next_focus=1;
            if (tot_focus>1){
                document.getElementById(id_div_focus_attuale).style.display="none";
                document.getElementById("elfocus1").style.display="block";
            }else{
                	document.getElementById("elfocus1").style.display="block";
            }
        document.forms[0].focus_vis.value=next_focus;
    }
    
    if (next_news<=tot_news){
        document.getElementById(id_div_news_attuale).style.display="none"; 
        document.getElementById(id_div_news_next).style.display=""; 
        document.forms[0].news_vis.value=next_news;
    }else{
            next_news=1;
            if (tot_news>1){
                document.getElementById(id_div_news_attuale).style.display="none";
                document.getElementById("elnews1").style.display="block";
            }else{
                document.getElementById("elnews1").style.display="block";
            }
        document.forms[0].news_vis.value=next_news;
    }
    
    
}    