/*
0892.35.00.73
Du lundi au Vendredi : de 8h30 � 20h00
Et le Samedi : de 8h30 � 19h00

Modif du 07.0.10 :
 soit 9h � 19h du Lundi au Vendredi et  9h � 18h le samedi
 
---------------------------
Boutique de Lyon :
Du lundi au Vendredi : de 10h00 � 12h00 et de 13h30 � 18h30
Et le Samedi : de 10h00 � 13h00 et de 13h30 � 17h30
 ---------------------------
Boutique de Marseille :
Du lundi au Vendredi : de 09h00 � 12h00 et de 14h00 � 18h30
Et le Samedi : de 09h00 � 12h00
 ---------------------------
Boutique de Nice :
Du lundi au Vendredi : de 09h15 � 12h00 et de 14h15 � 18h30
Et le Samedi : de 09h00 � 12h30
 ---------------------------

 M�thode pour mettre sur le serveur :
 1.0 direct en prod, editer le code html du template par defaut pour les heures cot� affichage et non cot� v�rif
 1.1 changer le lien dans document.write
 2. renommer en agences.js.gif
 3. uploader par media de joomla

*/
var heure_semaine = new Array(
	new Array("09:00","19:00"),
	new Array("10:00","12:00","13:30","18:30"), 
	new Array("09:00","12:00","14:00","18:30"), 
	new Array("09:15","12:00","14:15","18:30")
	);
var heure_samedi = new Array(
	new Array("09:00","18:00"),
	new Array("10:00","13:00","13:30","17:30"), 
	new Array("09:00","12:00"), 
	new Array("09:00","12:30")
	);

var currentDate = new Date();
var jour_dans_semaine = currentDate.getDay();

/*-----------------------------------------------------------------*/
function agence_horaire(id,path)
	{
	path = path || '';
	var status = check_horaire(id);
	//alert("status="+status);
	if(status==true) img="open";
		else img="close";
	// document.write("<img src='/pcv/joomla/pleinvent/images/commun/b-"+img+".gif'>");
	// document.write("<img src='http://test.pleinvent.com/www/fileadmin/sites/www/templates/css/header/b-"+img+".gif'>");
// alert(document.URL);
	document.write("<img src='"+path+"fileadmin/sites/www/templates/css/header/b-"+img+".gif'>");
	//document.write("<img src='/images/stories/b-"+img+".gif'>");
	}

/*-----------------------------------------------------------------*/
function check_horaire(id)
	{
	//----------------------- TEST JOUR DE LA SEMAINE
	if(jour_dans_semaine==0) return false;
		else
			{
			if(jour_dans_semaine==6)	// Si samedi
				horaires = heure_samedi;
			else
				horaires = heure_semaine;
			}
	//alert("jour_dans_semaine="+jour_dans_semaine+" horaires="+horaires);

	//----------------------- TEST HEURES
	flag_heure1 = compare(horaires[id][0], horaires[id][1], id);

	if(typeof horaires[id][2]!='undefined')
		{
		flag_heure2 = compare(horaires[id][2], horaires[id][3], id);
			
		if(flag_heure1==true || flag_heure2==true) return true;
			else return false;
		}
	else
		{
		if(flag_heure1==true) return true;
			else return false;
		}
	
	//alert("flag_heure1="+flag_heure1+" flag_heure2="+flag_heure2);
	
	if(flag_heure1==true || flag_heure2==true) return true;
		else return false;
	}

/*-----------------------------------------------------------------*/
function compare(heure_start, heure_stop, id)
	{
	FutureStart = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
	FutureEnd = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());

	FutureStart.setHours( heure_start.substring(0,2) );
	FutureStart.setMinutes( heure_start.substring(3,5) );
	//alert("heure_start="+heure_start+" heure_stop="+heure_stop+"\n currentDate="+currentDate+"\r\n FutureStart="+FutureStart+"\r\n\ FutureEnd="+FutureEnd+" \r\n\r\ncurrentDate.time="+currentDate.getTime()+ " FutureStart.time="+FutureStart.getTime());

	FutureEnd.setHours( heure_stop.substring(0,2) );
	FutureEnd.setMinutes( heure_stop.substring(3,5) );
	//alert("heure_start="+heure_start+" heure_stop="+heure_stop+"\n currentDate="+currentDate+"\r\n FutureStart="+FutureStart+"\r\n\ FutureEnd="+FutureEnd+" \r\n\r\ncurrentDate.time="+currentDate.getTime()+ " FutureStart.time="+FutureStart.getTime());
	
	//if(id==1) alert("heure_start="+heure_start+" heure_stop="+heure_stop+"\n currentDate="+currentDate+"\r\n FutureStart="+FutureStart+"\r\n\ FutureEnd="+FutureEnd+" \r\n\r\ncurrentDate.time="+currentDate.getTime()+ " FutureStart.time="+FutureStart.getTime());
	if(currentDate<=FutureEnd && currentDate>=FutureStart) 
		{
		//if(id==1) alert("true");
		return true; 
		}
	else 
		{
		//alert("false");
		return false;
		}
	}

/*-----------------------------------------------------------------*/
function open_div(num)
	{
	isIE = (document.all)
	isNN6 = (!isIE) && (document.getElementById)
	if(isIE) menu = document.all[num];
	if(isNN6) menu = document.getElementById(num);
	if(menu.style.display == "none") menu.style.display = "block";
	 else menu.style.display = "none";
	}
