
// Affichage ou non du bloc contenant les horaires de la ligne
function displayHoraire(id_horaire){
	
	if($('ligne_hor_' + id_horaire).style.display == "") $('ligne_hor_' + id_horaire).style.display = "none";
	if($('horaire_' + id_horaire + '_0').style.display == "") $('horaire_' + id_horaire + '_0').style.display = "none";
	
	if($('ligne_hor_' + id_horaire).style.display == "none"){
		$('ligne_hor_' + id_horaire).style.display = "block";
		$('horaire_' + id_horaire + '_0').style.display = "block";
		$('img_' + id_horaire).innerHTML = '<img src="images/picto_haut.png" />';
		
		for(i=1;i<=16;i++) // Fermeture des autres blocs
			if(i != id_horaire && $('ligne_hor_' + i)){
				$('ligne_hor_' + i).style.display = "none";
				$('horaire_' + i + '_0').style.display = "none";
				if($('horaire_' + i + '_1')) $('horaire_' + i + '_1').style.display = "none";
				$('img_' + i).innerHTML = '<img src="images/picto_bas.png" />';
			}
	}
	else{
		
		$('ligne_hor_' + id_horaire).style.display = "none";
		$('horaire_' + id_horaire + '_0').style.display = "none";
		$('img_' + id_horaire).innerHTML = '<img src="images/picto_bas.png" />';
	}
	
	if($('horaire_' + id_horaire + '_1')) $('horaire_' + id_horaire + '_1').style.display = "none";
}

// Affichage du bloc contenant les horaires de la ligne dans le sens souhaité
function displayHoraireSens(id_horaire, id_sens){
	$('horaire_' + id_horaire + '_' + id_sens).style.display = "block";
	$('horaire_' + id_horaire + '_' + (id_sens == 1 ? 0 : 1)).style.display = "none";
}


function displayAlertVideo(){
	$('bloc_alert_video').style.display = "block";
	$('bloc_alert_video_anim').innerHTML = '<iframe src="video/video.php"></iframe>';
}
function clearAlertVideo(){
	$('bloc_alert_video').style.display = "none";
	$('bloc_alert_video_anim').innerHTML = '';
}


// Affiche le plan google map des différentes adresses de Verdie (page contact)
function displayPlan(id, texte_agrandissement){
	
	switch(id){
		case 0 :
			$('plan').innerHTML = '<iframe width="330" height="430" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.fr/maps?f=q&amp;source=s_q&amp;hl=fr&amp;geocode=&amp;q=Rue+de+la+Ferronnerie+12000+RODEZ&amp;sll=47.15984,2.988281&amp;sspn=18.23844,44.648438&amp;ie=UTF8&amp;ll=44.388777,2.552261&amp;spn=0.052748,0.056648&amp;z=13&amp;output=embed"></iframe><br /><small><a href="http://maps.google.fr/maps?f=q&amp;source=embed&amp;hl=fr&amp;geocode=&amp;q=Rue+de+la+Ferronnerie+12000+RODEZ&amp;sll=47.15984,2.988281&amp;sspn=18.23844,44.648438&amp;ie=UTF8&amp;ll=44.388777,2.552261&amp;spn=0.052748,0.056648&amp;z=13">' + texte_agrandissement + '</a></small><br /><a href="images/etablissements/aveyron.jpg" rel="lightbox"><img src="images/etablissements/aveyron-th.jpg" />';
			break;
		case 1 :
			$('plan').innerHTML = '<iframe width="330" height="430" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.fr/maps?f=q&amp;source=s_q&amp;hl=fr&amp;geocode=&amp;q=Avenue+de+la+Mouyssaguese+31280+DREMIL+LAFAGE&amp;sll=44.37378,2.543842&amp;sspn=0.009356,0.021801&amp;g=Rue+de+la+Ferronnerie+12000+RODEZ&amp;ie=UTF8&amp;ll=43.595964,1.592674&amp;spn=0.026729,0.028324&amp;z=14&amp;output=embed"></iframe><br /><small><a href="http://maps.google.fr/maps?f=q&amp;source=embed&amp;hl=fr&amp;geocode=&amp;q=Avenue+de+la+Mouyssaguese+31280+DREMIL+LAFAGE&amp;sll=44.37378,2.543842&amp;sspn=0.009356,0.021801&amp;g=Rue+de+la+Ferronnerie+12000+RODEZ&amp;ie=UTF8&amp;ll=43.595964,1.592674&amp;spn=0.026729,0.028324&amp;z=14">' + texte_agrandissement + '</a></small><br /><a href="images/etablissements/dremil.jpg" rel="lightbox"><img src="images/etablissements/dremil-th.jpg" />';
			break;
		case 2 :
			$('plan').innerHTML = '<iframe width="330" height="430" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.fr/maps?f=q&amp;source=s_q&amp;hl=fr&amp;geocode=&amp;q=102+Route+de+Toulouse+31270+CUGNAUX&amp;sll=43.595812,1.595264&amp;sspn=0.009479,0.021801&amp;ie=UTF8&amp;ll=43.558998,1.362476&amp;spn=0.026745,0.028324&amp;z=14&amp;output=embed"></iframe><br /><small><a href="http://maps.google.fr/maps?f=q&amp;source=embed&amp;hl=fr&amp;geocode=&amp;q=102+Route+de+Toulouse+31270+CUGNAUX&amp;sll=43.595812,1.595264&amp;sspn=0.009479,0.021801&amp;ie=UTF8&amp;ll=43.558998,1.362476&amp;spn=0.026745,0.028324&amp;z=14">' + texte_agrandissement + '</a></small><br /><a href="images/etablissements/cugnaux.jpg" rel="lightbox"><img src="images/etablissements/cugnaux-th.jpg" />';
			break;
		case 3 :
			$('plan').innerHTML = '<iframe width="330" height="430" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.fr/maps?f=q&amp;source=s_q&amp;hl=fr&amp;geocode=&amp;q=Avenue+de+Cahuzac+32200+GIMONT&amp;sll=43.551122,1.353718&amp;sspn=0.009487,0.021801&amp;ie=UTF8&amp;ll=43.638187,0.872383&amp;spn=0.02671,0.028324&amp;z=14&amp;iwloc=addr&amp;output=embed"></iframe><br /><small><a href="http://maps.google.fr/maps?f=q&amp;source=embed&amp;hl=fr&amp;geocode=&amp;q=Avenue+de+Cahuzac+32200+GIMONT&amp;sll=43.551122,1.353718&amp;sspn=0.009487,0.021801&amp;ie=UTF8&amp;ll=43.638187,0.872383&amp;spn=0.02671,0.028324&amp;z=14&amp;iwloc=addr">' + texte_agrandissement + '</a></small>';
			break;
		case 4 :
			$('plan').innerHTML = '<iframe width="330" height="430" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.fr/maps?f=q&amp;source=s_q&amp;hl=fr&amp;geocode=&amp;q=La+Capelette+46100+CAPDENAC&amp;sll=44.588389,2.06028&amp;sspn=0.07164,0.174408&amp;ie=UTF8&amp;ll=44.603057,2.062941&amp;spn=0.026278,0.028324&amp;z=14&amp;output=embed"></iframe><br /><small><a href="http://maps.google.fr/maps?f=q&amp;source=embed&amp;hl=fr&amp;geocode=&amp;q=La+Capelette+46100+CAPDENAC&amp;sll=44.588389,2.06028&amp;sspn=0.07164,0.174408&amp;ie=UTF8&amp;ll=44.603057,2.062941&amp;spn=0.026278,0.028324&amp;z=14">' + texte_agrandissement + '</a></small><br /><a href="images/etablissements/lot.jpg" rel="lightbox"><img src="images/etablissements/lot-th.jpg" />';
			break;
		case 5 :
			$('plan').innerHTML = '<iframe width="330" height="430" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.fr/maps?f=q&amp;source=s_q&amp;hl=fr&amp;geocode=&amp;q=42+Chemin+des+Pins+81570+CUQ+LES+VIELMUR&amp;sll=44.595627,2.058699&amp;sspn=0.009321,0.021801&amp;ie=UTF8&amp;ll=43.645082,2.10989&amp;spn=0.026707,0.028324&amp;z=14&amp;output=embed"></iframe><br /><small><a href="http://maps.google.fr/maps?f=q&amp;source=embed&amp;hl=fr&amp;geocode=&amp;q=42+Chemin+des+Pins+81570+CUQ+LES+VIELMUR&amp;sll=44.595627,2.058699&amp;sspn=0.009321,0.021801&amp;ie=UTF8&amp;ll=43.645082,2.10989&amp;spn=0.026707,0.028324&amp;z=14">' + texte_agrandissement + '</a></small>';
			break;
		case 6 :
			$('plan').innerHTML = '<iframe width="330" height="430" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.fr/maps?f=q&amp;source=s_q&amp;hl=fr&amp;geocode=&amp;q=Rue+de+la+Ferronnerie+12000+RODEZ&amp;sll=47.15984,2.988281&amp;sspn=18.23844,44.648438&amp;ie=UTF8&amp;ll=44.388777,2.552261&amp;spn=0.052748,0.056648&amp;z=13&amp;output=embed"></iframe><br /><small><a href="http://maps.google.fr/maps?f=q&amp;source=embed&amp;hl=fr&amp;geocode=&amp;q=Rue+de+la+Ferronnerie+12000+RODEZ&amp;sll=47.15984,2.988281&amp;sspn=18.23844,44.648438&amp;ie=UTF8&amp;ll=44.388777,2.552261&amp;spn=0.052748,0.056648&amp;z=13">' + texte_agrandissement + '</a></small>';
			break;
	}
	
}

// Scripts ancien site

var thedate = new Date();
var theyear = thedate.getFullYear( );
var themonth = thedate.getMonth( );
var theday = thedate.getDate( );

var date_arr = new Array;
var days_arr = new Array;

date_arr[0]=new Option("Janvier",31);
date_arr[1]=new Option("Février",28);
date_arr[2]=new Option("Mars",31);
date_arr[3]=new Option("Avril",30);
date_arr[4]=new Option("Mai",31);
date_arr[5]=new Option("Juin",30);
date_arr[6]=new Option("Juillet",31);
date_arr[7]=new Option("Août",31);
date_arr[8]=new Option("Septembre",30);
date_arr[9]=new Option("Octobre",31);
date_arr[10]=new Option("Novembre",30);
date_arr[11]=new Option("Décembre",31);

function fill_select(f, s)
{
		months = eval('f.'+s+'mois');
		for(x=0;x<12;x++) 
                document.writeln("<OPTION value=\""+x+"\">"+date_arr[x].text);
		months.options[themonth].selected=true;
}

function update_days(f, s)
{
        days = eval('f.'+s+'jour');
		months = eval('f.'+s+'mois');
		years = eval('f.'+s+'annee');
	
        temp=days.selectedIndex; 
        for(x=days_arr.length;x>0;x--)
        {
                days_arr[x]=null;
                days.options[x]=null;
        }
        selection=parseInt(date_arr[months.selectedIndex].value);
        ret_val = 0;
		if(years.selectedIndex < 0) years.selectedIndex = 0;
		if(date_arr[months.selectedIndex].value == 28)
        {
                year=parseInt(years.options[years.selectedIndex].value);
                if (year % 4 != 0 || year % 100 == 0 ) ret_val=0;
                else
                        if (year % 400 == 0)  ret_val=1;
                        else
                                ret_val=1;
        }
		selection = selection + ret_val;        
        for(x=1;x < selection+1;x++) 
        {
                days_arr[x-1]=new Option(x);            
                days.options[x-1]=days_arr[x-1];
        } 
        if (temp == -1) days.options[theday-1].selected=true;
        else
             days.options[temp].selected=true;

		if(f.dannee && f.rannee && f.dannee.selectedIndex>=0 && f.rannee.selectedIndex>=0) {
			datefrom = f.dannee[f.dannee.selectedIndex].value + '-' + formatNumber((f.dmois.selectedIndex+1), "00") + '-' + formatNumber((f.djour.selectedIndex+1), "00");
			dateto = f.rannee[f.rannee.selectedIndex].value + '-' + formatNumber((f.rmois.selectedIndex+1), "00") + '-' + formatNumber((f.rjour.selectedIndex+1), "00");
		
		var now = new Date()
		
		today = now.getFullYear() + '-' + formatNumber(now.getMonth()+1, "00") + '-' + formatNumber(now.getDate(), "00");
		
		if(datefrom < today) {
			f.dmois.selectedIndex = now.getMonth();
			f.djour.selectedIndex = now.getDate()-1;
			datefrom = today;
		}
		
		if(dateto < datefrom) {
			f.rannee.selectedIndex = f.dannee.selectedIndex;
			f.rmois.selectedIndex = f.dmois.selectedIndex;
			f.rjour.selectedIndex = f.djour.selectedIndex;
		}
		}
}       

function year_install(f, s)
{
	for(x=theyear;x<theyear+6;x++) document.writeln("<OPTION value=\""+x+"\">"+x);
	update_days(f, s);
}

function fill_default(f, s, a, m, j)
{
	days = eval('f.'+s+'jour');
	months = eval('f.'+s+'mois');
	years = eval('f.'+s+'annee');
	
	for(i=0; i<years.length; i++) {
		if(years.options[i].value == a) years.selectedIndex= i;
	}
	
	months.selectedIndex = m-1;
	days.selectedIndex = j-1;
}