/////////////////////////////////////////////////////////////////////////////////////
// SCRIPT : fonctionnalités de base du site
/////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////
// SOMMAIRE :
// Fonctions générales
// FAQ
// Notre offre 
// Circuit Label qualité
// Nos implantations
/////////////////////////////////////////////////////////////////////////////////////
window.addEvent('domready',function(){
	SqueezeBox.assign($$('a[rel=boxed]'));
		   
});

/////////////////////////////////////////////////////////////////////////////////////
// Fonctions générales
///////////////////////////////////////////////////////////////////////////////////////
/* Sous menus */
function afficheSous(div){
	masqueSous(div);
	document.getElementById(div).style.display = 'block';
}
function masqueSous(div){
	document.getElementById(div).style.display = 'none';
}

/* Mailto */
function encodeMailto(leNom, leDomaine, laClasse, laPhrase){
	var tg = "<";
	var name = leNom;
	var at = "@";
	var host = leDomaine;
	var text = laPhrase;
	document.write(tg+"a hr"+"ef=mai"+"lto:"+name);
	document.write(at+host+" class='"+laClasse+"'>"+text+tg+"/a>");
}

/* Ajouter au favoris */
function favoris() {
	/* IE */
	if ( navigator.appName != 'Microsoft Internet Explorer' ){ 
		window.sidebar.addPanel("titre","http://url/",""); 
	}
	/* FireFox */
	else { 
		window.external.AddFavorite("http://url/","titre"); 
	} 
}
/* Vider champ */
function clearRecherche(message){
	if(document.getElementById('recherche').value==message){
		document.getElementById('recherche').value="";
	}
}
function clearTel(message){
	if(document.getElementById('inputTel').value==message){
		document.getElementById('inputTel').value="";
	}
}
/* Popup image centré + lien fermer */
function PopupImage(img) {
	titre="Agrandissement";
	w=open("popup-agrandissement.php?img="+img,"image","width=400,height=400,toolbar=no,scrollbars=no,resizable=no,top=0,left=0");
	w.document.close();
}
/* Chargement des pages à partir d'un menu Flash */
function chargePage(page) {
	top.location.href=page+".php";
}
/* Validation javascript du mail */
function arobaceok(email)
{
	if(document.formVousEtes.email.value == ""){
		alert("Il manque votre adresse e-mail!");
		return false;
	}
	var a=document.forms[0].email.value;
	var test="" + a;
	for(var k = 0; k < test.length;k++)
		{
		var c = test.substring(k,k+1);
		if(c == "@")
		{
		return true;
		}
	}
	alert("La syntaxe de votre e-mail est incorrect !");
	return false;
}


/////////////////////////////////////////////////////////////////////////////////////
// faq accordeon
/////////////////////////////////////////////////////////////////////////////////////
var myAccordion;
var reloadParent;
var loaderContent;
var closerPopup;
var ouvrirAccordeon;
var autoPrint;
window.addEvent('domready', function() {	
	if($('faq')){
		myAccordion = new Accordion($('faq'), 'div.question', 'div.content', {
			display: -1,
			alwaysHide: true,
			opacity: false,
			onActive: function(toggler, element){
				toggler.getElement('h2').setStyles({
					background:'url(images/picto/bulle-carre2.gif) no-repeat 0 4px',
					color:'#B00931'					
				});
			},
			onBackground: function(toggler, element){
				toggler.getElement('h2').setStyles({
					background:'url(images/picto/bulle-carre.gif) no-repeat 0 4px',
					color:'#828282'	
				 });
			}
		});
	}
});

/////////////////////////////////////////////////////////////////////////////////////
// Notre offre 
/////////////////////////////////////////////////////////////////////////////////////
function afficheTexte(i){
	masqueTexte(i);
	$('texte'+i).setStyle('display','block');
	$('mapTableau').setStyle('background','#9C9C9C url(../images/background/bg-interieur-voiture.jpg) no-repeat -'+i*614+'px 7px');
}
function masqueTexte(i){
	$('texte'+i).setStyle('display','none');
	$('mapTableau').setStyle('background','#9C9C9C url(../images/background/bg-interieur-voiture.jpg) no-repeat 0 7px');
}

/////////////////////////////////////////////////////////////////////////////////////
// Circuit label qualité
/////////////////////////////////////////////////////////////////////////////////////
function afficheLabel(i){
	masqueLabel(i);
	$('texte'+i).setStyle('display','block');
	$('labelQualite').setStyle('background','url(images/background/sprite-bg-label-qualite.png) no-repeat -'+i*614+'px 56px');
}
function masqueLabel(i){
	$('texte'+i).setStyle('display','none');
	$('labelQualite').setStyle('background','url(images/background/sprite-bg-label-qualite.png) no-repeat 0 56px');
}

/////////////////////////////////////////////////////////////////////////////////////
// Nos implantations
/////////////////////////////////////////////////////////////////////////////////////
function afficheDiv(i){
	for(j=1;j<=5;j++){
		masqueDiv(j);	
	}
	$('div'+i).setStyle('display','block');
}
function masqueDiv(i){
	$('div'+i).setStyle('display','none');
}
/////////////////////////////////////////////////////////////////////////////////////
// Contact
/////////////////////////////////////////////////////////////////////////////////////
function fermerPopAppel(){
	$('etape2').setStyle('display','none');
}
// Pop up Rappeler
function popupRapeller(url){
	tel=$('inputTel').value;
  //SqueezeBox.assign($$('a[rel=boxed]'));
		SqueezeBox.initialize({
        size: {x: 320, y: 350}
    });
  	SqueezeBox.open(url+"?tel="+tel, {handler: 'iframe'},{size: {x: 240, y: 180}});
		
}
/////////////////////////////////////////////////////////////////////////////////////
// Notre offre
/////////////////////////////////////////////////////////////////////////////////////
function popupTexte(i){
  //SqueezeBox.assign($$('a[rel=boxed]'));
		SqueezeBox.initialize({
        size: {x: 320, y: 350}
    });
  	SqueezeBox.open("popup-offre.php?texte="+i, {handler: 'iframe'},{size: {x: 320, y: 350}});
		
}
/////////////////////////////////////////////////////////////////////////////////////
// Recherche
/////////////////////////////////////////////////////////////////////////////////////
/*function affichRecherche(){*/
window.addEvent('domready', function() {		
	el=$('divContenuRecherche');
	/*$('lienRecherche').addEvent('click', $('divContenuRecherche').fade.bind(el, [0]));*/

	$('lienRecherche').addEvent('click', function(e) {
		// You often will need to stop propagation of the event
		e.stop();
		el.fade(1);
	});
});
	/*$('divContenuRecherche').setStyle('display','block');
}*/

function affichRecherche(){
	$('divContenuRecherche').setStyle('display','block');
}
function masqueRecherche(){
	$('divContenuRecherche').setStyle('display','none');
}

