﻿function checkPanier(){
	if(confirm('Attention, êtes-vous sûr de vouloir supprimer votre commande ?')){
		panier_valide = true;
		document.location.href='commerce-equitable-commande.php?del_panier=1';
	}	
}
function validEmail(){	
	var regex = /^([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+$/;
	var str = new String(document.getElementById('newsletter').value);	
	if(!regex.exec(str)){
		return false;	
	}
}
function mentions(url){
	window.open(url,"mentions","height=535, width=600");
}

function tb_prod(){
	window.open("infos-producteurs.php","infos_producteurs","height=535, width=800, scrollbars=1");
}

function aide()
{
	url="aide.htm";
	window.open(url,"Aide","height=480, width=600");
}
function aide2()
{
	url="aide2.htm";
	window.open(url,"Aide","height=620, width=600");
}


function popup()
{
	url="popup_carte.htm";
	window.open(url,"Carte","height=535, width=600");
}

var id_producteur

function over_producteur(id){
	if(document.getElementById(id).style.display != 'block'){
		document.getElementById(id).style.display = 'block';
		id_producteur = id;
		document.onmousemove = position;
	}
}

function out_producteur(id){
	if(document.getElementById(id).style.display != 'none'){
		document.getElementById(id).style.display = 'none';
		id_producteur = id;
	}
}

function position(evt)
{
  var tabEvent=renvoiTabEvent(evt);
  var x=tabEvent[0];//position X du curseur de la souris.
  var y=tabEvent[1];//postion Y du curseur de la souris
  var objCadrePostit=document.getElementById(id_producteur);
  //Calcule le retrait gauche/haut du curseur de la souris à l'intérieur du cadre.
  var posXcadre=tabEvent[0]+20;
  var posYcadre=tabEvent[1]-50;
  if(ib.ie){	
  var posXcadre=posXcadre+document.body.scrollLeft;
  var posYcadre=posYcadre+document.body.scrollTop;
  }
  //Positionne le "cadre post-it".
  objCadrePostit.style.left=posXcadre;	
  objCadrePostit.style.top=posYcadre; 
}
/*
* Renvoie un tableau contenant les positions X et Y du curseur de la souris.
* 1 paramètre :
* - e : évenement mousedown ou mouseup.(toujours mousedown);
*/
function renvoiTabEvent(e){
 var tabEvcXY=new Array();
 if(ib.ie){
  tabEvcXY=[event.clientX,event.clientY];
 }else{
  tabEvcXY=[e.pageX,e.pageY];
 }
  return tabEvcXY;
}

/**
* Récupère les informations sur le navigateur.
*/
function infoBrowser(){	
	//Infos version.
	this.ver=navigator.appVersion;
	//Infos moteur.
	this.agent=navigator.userAgent;	
	//Infos dom.
	this.dom=document.getElementById?1:0;
	//Numéro de version.
	this.nver=this.agent.substring(this.agent.length-5,this.agent.length);
	/*Détection.*/
	//Opéra.
	this.opera5=this.agent.indexOf("Opera")>-1;
	//Explorer.
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
	this.ie8=(this.ver.indexOf("MSIE 8")>-1 && this.dom && !this.opera5)?1:0
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6||this.ie7;
	//Netscape.
	this.ns6=(this.dom && this.nver.indexOf("6")>-1 && this.agent.indexOf("Firefox")<0) ?1:0; 
	this.ns4=(document.layers && !this.dom && this.nver.indexOf("6")<0 && this.nver.indexOf("8")<0) ?1:0;
	this.ns8=(this.dom && this.nver.indexOf("8")>-1) ?1:0;	
	//Mac.
	this.mac=this.agent.indexOf("Mac")>-1;
	//Sont exclus les navigateurs explorer 4, netscape 4 et 6, opéra 5 et mac.
	this.serv="http://www.basilique-guingamp.fr/";
	this.bw=(this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.mac);
	return this;
}
var ib=new infoBrowser();


