// JavaScript Document

function popupreceive()	{
		var win2 = window.open("https://secure.fia-net.com/wallet/paiement/commentpayer.php",'popup','height=480,width=750,status=yes,scrollbars=yes,menubar=no,resizable=yes');
}http://www.receiveandpay.com/wallet/customer/popup3x.php?logo=2967

function popupreceive2()	{
		var win2 = window.open("http://www.receiveandpay.com/wallet/customer/popup3x.php?logo=10774",'popup','height=750,width=480,status=yes,scrollbars=yes,menubar=no,resizable=yes');
}

function toogleEcolo(){
	var bool = true;
	$('#overEcolo')[0].onclick = function(){
		$("#ecolo_wrapper").slideToggle("normal");
		if(bool == true){
			$('#h3_ecolo')[0].style.backgroundPosition = 'left -83px';
			this.style.height =83+'px';
			$("#bird_mc")[0].echo();
			bool = false;
		}else{
			$('#h3_ecolo')[0].style.backgroundPosition = 'left top';
			this.style.height =135+'px';
			bool = true;
		}
	}
}

function addCart(id, bool){
	var link_id = $('#'+id)[0];
	var w = link_id.offsetWidth;
	var parent = link_id.parentNode;
	parent.style.position = "relative";
	var added = document.createElement('div');
	if(!bool){
		added.className = "elementAd";
	}else{
		added.className = "elementAd elementAdBig";
	}
	added.id="addpanierMove";
	added.style.position = "absolute";
	added.style.left = 0;
	parent.appendChild(added);
	if (!jQuery.browser.msie){
		function removeId(){
			$('#'+added.id).fadeOut(1000 ,function() { parent.removeChild(added); });
		}
		setTimeout(removeId,1000)
	}else{
		function removeId(){
			$('#'+added.id).remove();
		}
		setTimeout(removeId,1000)
	}
}


function swapOnglet(id){
	var onglet = $('#'+id)[0];
	if(onglet.className == ""){
		onglet.className = "actif";
		if(onglet.id == "onglet1"){
			$('#onglets')[0].style.backgroundPosition = "left top";	
			$('#onglet2')[0].className = "";
		}else{
			$('#onglets')[0].style.backgroundPosition = "left -26px";
			$('#onglet1')[0].className = "";
		}
	}else{
		onglet.className = "";	
	}
}



function onFocusVide(obj, chaine) {
	if (obj.value==chaine) {
		obj.value="";
	}
}

function hoverIe6(myClasses){
	if (!window.XMLHttpRequest){
		var tabAllClass = myClasses.split(',');
		var nbrAll = tabAllClass.length;
		for(i=0; i<nbrAll; i++){
			var tabClass = $('.'+tabAllClass[i]);
			var nbr = tabClass.length;
			for(j=0; j<nbr; j++){
				tabClass[j].num = i;
				tabClass[j].onmouseover = function(){
					this.className = tabAllClass[this.num] + " over";
				}
				tabClass[j].onmouseout = function(){
					this.className = tabAllClass[this.num];
				}
			}
		}
	}
}


$(document).ready(
	function(){
		toogleEcolo();	
		//showMenu();
		hoverIe6('add,bt_connect,btnAcces,search_btn,btnPanier,smallImg,vider,valider,modif,annuler,poursuivre,envoi_ami,btSelect,back_home')
		
			
		$('.perso a').each(function(e){	
			$(this).hover(function(){
				$('#perso'+(e+1)+'_id').addClass('actif');
			},function(){
				$('#perso'+(e+1)+'_id').removeClass('actif');
			});	
		});	
		
		/*$('#slide_holder div').cycle({ 
			fx:      'scrollLeft', 
			speed:    600, 
			timeout:  5000
			
		});*/
	}
);


function setOpacityetOnclick(div, opa) {
	if (document.getElementById(div)) {
		document.getElementById(div).style.opacity = opa;
		document.getElementById(div).style.filter = 'alpha(opacity='+opa*100+')';
		if (opa==0.1) {
			document.getElementById(div).style.cursor="default";
		}else{
			document.getElementById(div).style.cursor="pointer";
		}
	}
}

function mouvementVignette(direction) {
	if (direction=="flecheDroite" && nbrvignetteplusEncour<nbrvignetteplus) {
		varLeft=varLeft-40;
		nbrvignetteplusEncour++;
		setOpacityetOnclick('flecheGauche', 1);
	}
	if (direction=="flecheGauche" && nbrvignetteplusEncour!=0) {
		varLeft=varLeft+40;
		nbrvignetteplusEncour--;
		setOpacityetOnclick('flecheDroite', 1);
	}
	if (nbrvignetteplusEncour==nbrvignetteplus) {
		setOpacityetOnclick('flecheDroite', 0.1);
	}
	if (nbrvignetteplusEncour==0) {
		setOpacityetOnclick('flecheGauche', 0.1);
	}
	if (nbrvignetteplusEncour<=nbrvignetteplus) {
		$('#ulVignette').animate( {left : varLeft+'px'},100);
		
	}
}



function mouvementMaSelectionVignette(direction) {
	if (direction=="flecheBasMaSelection" && nbrvignetteMaSelectionplusEncour<nbrvignetteMaSelectionplus) {
		varMaSelectionHaut=varMaSelectionHaut-60;
		nbrvignetteMaSelectionplusEncour++;
		setOpacityetOnclick('flecheHautMaSelection', 1);
	}
	if (direction=="flecheHautMaSelection" && nbrvignetteMaSelectionplusEncour!=0) {
		varMaSelectionHaut=varMaSelectionHaut+60;
		nbrvignetteMaSelectionplusEncour--;
		setOpacityetOnclick('flecheBasMaSelection', 1);
	}
	if (nbrvignetteMaSelectionplusEncour==nbrvignetteMaSelectionplus) {
		setOpacityetOnclick('flecheBasMaSelection', 0.1);
	}
	if (nbrvignetteMaSelectionplusEncour==0) {
		setOpacityetOnclick('flecheHautMaSelection', 0.1);
	}
	if (nbrvignetteMaSelectionplusEncour<=nbrvignetteMaSelectionplus) {
		$('#ulMaSelection').animate( {top : varMaSelectionHaut+'px'},100);
		
	}
	
}


function mouvementPanierVignette (direction) {
	if (direction=="flecheBasPanier" && nbrvignettePanierplusEncour<nbrvignettePanierplus) {
		varPanierHaut=varPanierHaut-60;
		nbrvignettePanierplusEncour++;
		setOpacityetOnclick('flecheHautPanier', 1);
	}
	if (direction=="flecheHautPanier" && nbrvignettePanierplusEncour!=0) {
		varPanierHaut=varPanierHaut+60;
		nbrvignettePanierplusEncour--;
		setOpacityetOnclick('flecheBasPanier', 1);
	}
	if (nbrvignettePanierplusEncour==nbrvignettePanierplus) {
		setOpacityetOnclick('flecheBasPanier', 0.1);
	}
	if (nbrvignettePanierplusEncour==0) {
		setOpacityetOnclick('flecheHautPanier', 0.1);
	}
	if (nbrvignettePanierplusEncour<=nbrvignettePanierplus) {
		$('#ulPanier').animate( {top : varPanierHaut+'px'},100);
		
	}
	
}

function evalPerso(div, html) {
	if (div!="") {
		$("#"+div).innerHTML = html;
		scripts = document.getElementById(div).getElementsByTagName("script");
		for(var i=0;i<scripts.length;i++){
		   eval(scripts[i].innerHTML);
		}
	}
}


function verifMail(z) {
	var reg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/
	if (reg.exec(z)==null){
		return false;
	}else{
		return true;
	}
}


function displayOnOff(id) {
	if (document.getElementById(id).style.display=='none') {
		document.getElementById(id).style.display='block';
	}else{
		document.getElementById(id).style.display='none';
	} 
}

function displayOn(id) {
	document.getElementById(id).style.display='block';
}

function displayOff(id) {
	document.getElementById(id).style.display='none';
}

function displayOnOffTab(id) {
	if (document.getElementById(id).style.display=='none') {
		if (jQuery.browser.msie) {
			document.getElementById(id).style.display='block';
		}else{
			document.getElementById(id).style.display='table-row';
		}
	}else{
		document.getElementById(id).style.display='none';
	} 
}

function showMenu(){
	var tabMenu = $('.menu_item');
	var nbrMenu = tabMenu.length
	for(i=0;i<nbrMenu;i++){
		$(tabMenu[i])[0].num = i;
		$(tabMenu[i])[0].onmouseover = function(){
			var id = this.num;
			$('#sousm'+id).slideDown('normal');
		}
		$(tabMenu[i])[0].onmouseout = function(){
			var id = this.num;
			$('#sousm'+id).slideUp('normal');
		}
	}
//onmouseover="$('#sousm0').slideDown('normal');" onmouseout="$('#sousm0').slideUp('normal');"
}


//////////////////////////////////////// panier ////////////////////////////////////////
function recharge (validCommande) {
	$.get('includes/inc_tableau_panier.php', {validCommande : validCommande, livNom : document.formadresse.livNom.value, livPrenom : document.formadresse.livPrenom.value, livAdresse : document.formadresse.livAdresse.value, livCP : document.formadresse.livCP.value, livVille : document.formadresse.livVille.value, livIdPays : document.formadresse.livIdPays.value, facNom : document.formadresse.facNom.value, facPrenom : document.formadresse.facPrenom.value, facAdresse : document.formadresse.facAdresse.value, facCP : document.formadresse.facCP.value, facVille : document.formadresse.facVille.value, facIdPays : document.formadresse.facIdPays.value, facTel : document.formadresse.facTel.value, livraison : document.formadresse.livraison.value}, function(html){document.getElementById('tableauPanier').innerHTML=html;} );
}
//////////////////////////////////////// panier ////////////////////////////////////////





/// bloc droite //////////////////////////////

function changeBlocDroite () {
	
	var tableau=choixJsDroite.split(",");
	longTab=tableau.length;

	if (nbrTab>=longTab) { nbrTab=0; }
	for (var i=0; i<tableau.length; i++) {
	 	if (nbrTab==i) {
			resultchoixBlocSelection=tableau[i];
		}
	}
	nbrTab++;
	
	$.get(CHEMIN_SITEWEB+'includes/inc_bloc_selection.php', {choixBlocSelection : ''+resultchoixBlocSelection+''}, function(html){document.getElementById('ajax_bloc_selection').innerHTML=html;} );
	setTimeout(changeBlocDroite,10000)
}
setTimeout(changeBlocDroite,10000)
var nbrTab=0;
//;
//////////////////////////////////////


