// ************************************* Fonctions pour le rollover des images du menu *************************************************************
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// *****************************************************************************************************************************************


// *****************************************************      GOOGLE MAP      ******************************************************************


		//-- Ici les coordonnes sous forme de tableau
		var Param = [[47.858976,6.826723]];
		//-- Meme Zoom pour tous
		var Zoom = 10;
		//-- Variable globale pour l'objet GMAP2 sous forme de tableau
		var map=[];

		var marker=[];
		//-- Nbr de map a creer
		var Nbr_Map = Param.length;
		//-- Variable globale pour les marqueurs sous forme de tableau
		var marker = new Array(); 

		//-------------------
		function initialize(tabadresse){
		  //-- Teste si le navigateur est compatible avec l'API Gmaps
		
			if (GBrowserIsCompatible() && document.getElementById('map')) {
					//-- Creation des objets princiapux
					map = new GMap2( document.getElementById('map'));
					//-- personnalisation	
					map.addControl(new GSmallMapControl());
					map.addControl(new GMapTypeControl());
					map.setCenter(new GLatLng(Param[0][0],Param[0][1]), Zoom);
				
				for(var i = 0; i <Nbr_Map; i++)
				{	
					//-- Position du point
					var Pos = new GLatLng( Param[i][0], Param[i][1]); 
					
					
					tinyIcon = new GIcon();
					tinyIcon.image = "images/test.png";
					tinyIcon.shadow = "images/ombretest.png";
					tinyIcon.iconSize = new GSize(12, 20);
					tinyIcon.shadowSize = new GSize(22, 20);
					tinyIcon.iconAnchor = new GPoint(6, 20);
					tinyIcon.infoWindowAnchor = new GPoint(5, 1);
					 
					// Set up our GMarkerOptions object literal
					markerOptions = { icon:tinyIcon };
					
					marker[i] = new GMarker( Pos, markerOptions);
					//-- Ajout du marqueur
					map.addOverlay(marker[i]); 
				}
				
				GEvent.addListener(marker[0], "click", function() {
						marker[0].openInfoWindowHtml(
						"<table><tr><td align=\"center\" width=\"150\" style=\"color:#000\"><b>"+tabadresse[0][0]+"<\/b><br \/>"+tabadresse[0][1]+"<br \/>"+tabadresse[0][2]+" "+tabadresse[0][3]+"<br \/><br \/>Tél. <b>"+tabadresse[0][4]+"</b>"/*<br \/>Fax. "+tabadresse[0][5]*/+"<\/td><\/tr><\/table>");
						
					});
				
				/*GEvent.addListener(marker[1], "click", function() {
							marker[1].openInfoWindowHtml(
						"<table><tr><td align=\"center\" width=\"150\" style=\"color:#000\"><b>"+tabadresse[1][0]+"<\/b><br \/>"+tabadresse[1][1]+"<br \/>"+tabadresse[1][2]+" "+tabadresse[1][3]+"<br \/><br \/>Tél. <b>"+tabadresse[1][4]+"</b>"+"<\/td><\/tr><\/table>");
						
					});
*/
					map.openInfoWindowHtml(map.getCenter(),
				"<table><tr><td align=\"center\" width=\"150\" style=\"color:#000\"><b>"+tabadresse[0][0]+"<\/b><br \/>"+tabadresse[0][1]+"<br \/>"+tabadresse[0][2]+" "+tabadresse[0][3]+"<br \/><br \/>Tél. <b>"+tabadresse[0][4]+"</b>"/*<br \/>Fax. "+tabadresse[0][5]*/+"<\/td><\/tr><\/table>");

			}
		} 

	function mounvementMap(tabadresse,pos,i)
	{
		if (GBrowserIsCompatible() && document.getElementById('map')) {
			map = new GMap2( document.getElementById('map'));
			//-- personnalisation	
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(pos[0],pos[1]), 16);
			
			var Pos = new GLatLng( pos[0], pos[1]); 
			marker[i] = new GMarker( Pos, markerOptions);
			//-- Ajout du marqueur
			map.addOverlay(marker[i]); 
			
			GEvent.addListener(marker[i], "click", function() {
							marker[i].openInfoWindowHtml(
						"<table><tr><td align=\"center\" width=\"150\" style=\"color:#000\"><b>"+tabadresse[i][0]+"<\/b><br \/>"+tabadresse[i][1]+"<br \/>"+tabadresse[i][2]+" "+tabadresse[i][3]+"<br \/><br \/>Tél. <b>"+tabadresse[i][4]+"</b>"/*<br \/>Fax. "+tabadresse[i][5]*/+"<\/td><\/tr><\/table>");
						
					});
			map.openInfoWindowHtml(map.getCenter(),
			"<table><tr><td align=\"center\" width=\"150\" style=\"color:#000\"><b>"+tabadresse[i][0]+"<\/b><br \/>"+tabadresse[i][1]+"<br \/>"+tabadresse[i][2]+" "+tabadresse[i][3]+"<br \/><br \/>Tél. <b>"+tabadresse[i][4]+"</b>"/*<br \/>Fax. "+tabadresse[i][5]*/+"<\/td><\/tr><\/table>");

		}
	}	
// *****************************************************************************************************************************************


function verifidentiquelivraison(){
	if (document.getElementById('identiqueLivraison').checked)
	{
		document.getElementById('noml').value = document.getElementById('nomf').value;
		document.getElementById('prenoml').value = document.getElementById('prenomf').value;
		document.getElementById('adressel').value = document.getElementById('adressef').value;
		document.getElementById('cpl').value = document.getElementById('cpf').value;
		document.getElementById('villel').value = document.getElementById('villef').value;
		document.getElementById('paysl').value = document.getElementById('paysf').value;
	}

}
function insertLivraison(nom,valeur){

	if (document.getElementById('identiqueLivraison').checked)
	{
		switch (nom){
			case 'nom' :
				document.getElementById('noml').value = valeur;
			break;
			case 'prenom' :
				document.getElementById('prenoml').value = valeur;
			break;
			case 'adresse' :
				document.getElementById('adressel').value = valeur;
			break;
			case 'cp' :
				document.getElementById('cpl').value = valeur;
			break;
			case 'ville' :
				document.getElementById('villel').value = valeur;
			break;
			case 'pays' :
				document.getElementById('paysl').value = valeur;
			break;
		}
	}


}

function valideformcommande()
{
	if (	document.getElementById('nomf').value != "" &&
			document.getElementById('prenomf').value != "" &&
			document.getElementById('adressef').value != "" &&
			document.getElementById('cpf').value != "" &&
			document.getElementById('villef').value != "" &&
			document.getElementById('paysf').value != "" &&
			
			document.getElementById('noml').value != "" &&
			document.getElementById('prenoml').value != "" &&
			document.getElementById('adressel').value != "" &&
			document.getElementById('cpl').value != "" &&
			document.getElementById('villel').value != "" &&
			document.getElementById('paysl').value != "" )
	{
			/*document.getElementById('noml').value = document.getElementById('nomf').value;
			document.getElementById('prenoml').value = document.getElementById('prenomf').value;
			document.getElementById('adressel').value = document.getElementById('adressef').value;
			document.getElementById('cpl').value = document.getElementById('cpf').value;
			document.getElementById('villel').value = document.getElementById('villef').value;
			document.getElementById('paysl').value = document.getElementById('paysf').value;*/
	
		document.form_valide_commande.submit();
	}
	else
	{
		alert ('Tous les champs de l\'adresse de facturation et de livraison sont obligatoires.');
	}
}
		
function showLocation(adresse){
	if (GBrowserIsCompatible()) {
		var geocoder = new google.maps.ClientGeocoder();
		geocoder.getLatLng(adresse, function (coord) {
			if(document.getElementById("map")) {
				var map = new GMap2(document.getElementById("map"));
				map.clearOverlays();
				map.setCenter(coord, 15);
				var marker = new GMarker(coord);
				map.addOverlay(marker);
			}
		});
	}
}
// *****************************************************************************************************************************************

// *****************************************************    POUR FAVORIS    ******************************************************************

$(document).ready(function(){

			//Page Flip on hover

				$("#pageflip").hover(function() {
					$("#pageflip img , .msg_block").stop()
						.animate({
							width: '140px', 
							height: '135px'
						}, 500); 
					} , function() {
					$("#pageflip img").stop() 
						.animate({
							width: '50px', 
							height: '52px'
						}, 220);
					$(".msg_block").stop() 
						.animate({
							width: '50px', 
							height: '50px'
						}, 200);
				});

				
			});
	
	//configurer les deux variables ci-dessous en fonction du site
	function favoris(url,signature) {
		if (navigator.appVersion.indexOf("Mac",0)>0) {
			alert("Cette fonction n\'est pas réalisable sur Macintosh.\n\nUtilisez plutôt la combinaison de touches \"Pomme-D\"");
		}
		else {
			var bookmarkurl=url;
			var bookmarktitle=signature;
			if ((navigator.appName.indexOf("Microsoft",0)>=0) && (parseInt(navigator.appVersion)>=4)) {
				//window.external.AddFavorite(location.href, document.title);
				window.external.AddFavorite(bookmarkurl,bookmarktitle);
			}
			else {
				//alert("Cette fonction n'est possible que par Internet Explorer 4 et +\n\nPour Netscape utilisez plutôt la combinaison de touches \"Control-D\"");
				window.sidebar.addPanel(bookmarktitle,bookmarkurl,"");
			}
		}
	}
// *****************************************************************************************************************************************



function changeOver(obj,color){
	obj.style.backgroundColor=color;
}


function sendData(balise, param, page){
	//alert(balise+" "+param+" "+page);
	if(document.all) {
		//Internet Explorer
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
	}else{
		//Mozilla
		var XhrObj = new XMLHttpRequest();
	}


	//définition de l'endroit d'affichage
	var content = document.getElementById(balise);
	//var scripts = document.getElementById(balise).getElementsByTagName("script");
	XhrObj.open("POST", page);


	//Ok pour la page cible
	XhrObj.onreadystatechange = function() {
		if (XhrObj.readyState == 4 && XhrObj.status == 200){
			content.innerHTML = XhrObj.responseText ;
			/*if(scripts.length > 0) {
				for (var i=0; i<scripts.length; i++) {
					eval(scripts[i].innerHTML);
				}
			}*/
			//eval(content.innerHTML);
		}
	}


	if (XhrObj.readyState == 4 && XhrObj.status == 200){
		content._innerhtml = XhrObj.responseText ;
		alert(XhrObj.responseText);
	}


	XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	XhrObj.send(param);
}


function myGetElementById(elemID) {
	if (document.getElementById && document.getElementById(elemID)) {
		return document.getElementById( elemID );
	} else if (document.all && document.all[divID]) {
		return document.all[ divID ];
	} else if (document.layers && document.layers[divID]) {
		return document.layers[ divID ];
	} else {
		return false;
	}
}


function ShowHide(divID) {
	Pdiv = myGetElementById(divID);
	if (Pdiv) {
		Pdiv.className = (Pdiv.className=='cache')?'':'cache';
	}
}


function catchEnter(evenement,form){
	var touche = window.event ? evenement.keyCode : evenement.which;
	if(touche==13) {
		form.submit();
	}
}
function recupDataPays(id) {
	var indexsite = document.getElementById(id);
	var valeursite = indexsite.options[indexsite.selectedIndex].value;
	return valeursite;
}

function agrandirimage(imgAchanger)   
 {     
	
	var a=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height+2",100);
	var b=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height+2",200);
	var c=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height+2",300);
	var d=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height-2",400);
	var e=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height-2",500);
	var f=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height-2",600);
	
	
 }  
 function Show(divID) {
	Pdiv = myGetElementById(divID);
	if (Pdiv) {
		if(Pdiv.className=='cache') {
			Pdiv.className = '';
		}
	}
}

function Hide(divID) {
	Pdiv = myGetElementById(divID);
	if (Pdiv) {
		if(Pdiv.className=='') {
			Pdiv.className = 'cache';
		}
	}
}

 function clone2(input,val) {
	input.value = val
}

function codeTouche(evenement)
{
        for (prop in evenement)
        {
                if(prop == "which") return(evenement.which);
        }
        return(evenement.keyCode);
}

/* Controle des caractères de saisis pour des champs ne pouvant pas avoir d'espace ou de caractèrs spèciaux */
function scanToucheChiffre(evenement,id)
{

    var codeDecimal  = codeTouche(evenement);
    var car = String.fromCharCode(codeDecimal);
		
	//Les caractères acceptés.
	var accepter = "0123456789";


	if (accepter.indexOf(car) >= 0)
		autorisation =true;
	else
		autorisation =false;

	if (evenement.keyCode==8)
	{
		/*taille=document.getElementById(id).value.length;
			if (taille <=1)	
			{
				document.getElementById(id).value=1;
				
			}*/
		autorisation=true;
	}
	if (autorisation) 	
	{
		document.getElementById('majpanier').style.display='block';
		document.getElementById('valideFormulaire').style.display='none';
	}
        return autorisation;
}
/* Controle des caractères de saisis pour des champs ne pouvant pas avoir d'espace ou de caractèrs spèciaux */
function scanTouche(evenement)
{

    var codeDecimal  = codeTouche(evenement);
    var car = String.fromCharCode(codeDecimal);
		
	//Les caractères acceptés.
	var accepter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";


	if (accepter.indexOf(car) >= 0)
		autorisation =true;
	else
		autorisation =false;

	if (evenement.keyCode==8)
				autorisation=true;

				
		if (!(autorisation))
			document.getElementById('messagErreurcaractere').style.display = "block";
		else
			document.getElementById('messagErreurcaractere').style.display ="none";

			
        return autorisation;
}

//Permet d'enlever les images qui seraient toujours visible pendant l'affichage d'une thickbox
function verifimage()
{
	//if (!document.all) return;  Pour navigateur different de IE on ne fait rien.
	
	
	if (document.getElementById('imgprev') && document.getElementById('imgnext') && document.getElementById('information'))
	{
		var imgprev = document.getElementById('imgprev');
		var imgnext = document.getElementById('imgnext');
		var information = document.getElementById('information');
		if (imgprev.style.display == "none" || imgprev.style.display == "") 
		{
			imgprev.style.display = "block";
			imgnext.style.display = "block";
			information.style.display = "block";
		}
		/*else
		{
			imgprev.style.display = "none";
			imgnext.style.display = "none";
			information.style.display = "none";
		}*/
		
	}
	

}
function Cacherimage()
{
	if (document.getElementById('imgprev') && document.getElementById('imgnext') && document.getElementById('information'))
	{
		document.getElementById('imgprev').style.display = "none";
		document.getElementById('imgnext').style.display = "none";
		document.getElementById('information').style.display = "none";
	}
}




