// popup messages erreurs
/*function showerrorbox(){
	var elname = 'errorbox';
	var erreurText = 'error_wrapper';	
	
	var actualposition = document.documentElement.scrollTop ;
	var modbox = document.getElementById(elname);
	var boxText = document.getElementById(erreurText);

	boxText.style.display="block"; 
	modbox.style.display="block"; 
	
	window.scrollTo(0,actualposition);
}

function close_errorbox() {
	var elname = 'errorbox';
	var erreurText = 'error_wrapper';	
	
	var modbox = document.getElementById(elname);
	var boxText = document.getElementById(erreurText);
	
	modbox.style.display="none"; waitingAddToBasket
	boxText.style.display="none"; 
	
	closemodal();
}*/
var save_id = 0;
var cpt_save = 0;

function addEvent(elem,event,name_function) {

	if(document.all) elem.attachEvent("on"+event,name_function);
	else elem.addEventListener(event,name_function,false);

}

function delEvent(elem,event,name_function) {

	if(document.all) elem.detachEvent("on"+event,name_function);
	else elem.removeEventListener(event,name_function,false);

}

// empeche les evenements de remonter dans l'arbre

function doNothing(e) {

if (document.all) {
  if (!e) var e = window.event;
  e.cancelBubble = true;
 }
 else {
	e.stopPropagation();
 } 
 return false;
}
// popup guide des tailles
function showsizeguide(){
	var elname = 'sizeguidebox';
	
	var actualposition = document.documentElement.scrollTop;
	var modbox = document.getElementById(elname);
	var shad = document.getElementById('shad');
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	
	/*var option=['btn_femmes','btn_hommes','btn_filles','btn_garcons','btn_bebes'];
	for(var i=0; i<option.length; i++){
			obj=document.getElementById(option[i]);
			obj.style.display="none"; 
	}*/
	
	
	
	modbox.style.position = "absolute";
	shad.style.display="block";
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('7.') != -1 ) {
		topconnexion.style.zIndex = -1;
	}
	
	addEvent(shad,'click',closesizeguide);
	/*addEvent(modbox,'click',closesizeguide);*/
	
	addEvent(document.getElementById('menu_sizeguide'), 'click', doNothing);

	modbox.style.display="block";
	
	window.scrollTo(0,actualposition);
}

function closesizeguide() {
	var elname = 'sizeguidebox';
	var shad = document.getElementById('shad');
	var modbox = document.getElementById(elname);
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	modbox.style.display=""; 
	topconnexion.style.zIndex = 1501;
	
	/*var option=['btn_femmes','btn_hommes','btn_filles','btn_garcons','btn_bebes'];
	for(var i=0; i<option.length; i++){
			obj=document.getElementById(option[i]);
			obj.style.display="inline"; 
	}*/

	delEvent(shad,'click',closesizeguide);
	delEvent(modbox,'click',closesizeguide);
	delEvent(document.getElementById('menu_sizeguide'), 'click', doNothing);
	
	/*if(save_id!=0) {
		var option=['sizeguide_femme','sizeguide_homme','sizeguide_lingerie','sizeguide_fille','sizeguide_garcon','sizeguide_bebe'];
		for(var i=0; i<option.length; i++){
			obj = document.getElementById(option[i]);
			obj.style.display = (i==(save_id-1))? 'block':'none';
			if(document.getElementById('btn_'+(i+1)+'select')) document.getElementById('btn_'+(i+1)+'select').id = 'btn_'+(i+1);
		}
		
		if(document.getElementById('btn_'+(save_id))) document.getElementById('btn_'+(save_id)).id = 'btn_'+(save_id)+'select';
	}*/
	
	closemodal();
}

// switch guide des tailles
function switch1(div) {
	
	if (document.getElementById('sizeguide_femme')) {
		var option=['sizeguide_femme','sizeguide_homme','sizeguide_lingerie','sizeguide_fille','sizeguide_garcon','sizeguide_bebe'];	
		for(var i=0; i<option.length; i++){
			obj=document.getElementById(option[i]);			
			obj.style.display=(option[i]==div)? "block" : "none";
			/*if(document.getElementById('btn_'+(i+1)+'select')){
				document.getElementById('btn_'+(i+1)+'select').id = 'btn_'+(i+1);
				if(cpt_save==0) save_id = (i+1);
			}
			
			if(option[i]==div) {
				document.getElementById('btn_'+(i+1)).id = 'btn_'+(i+1)+'select';
			}*/
		}
	}
	
	cpt_save++;

}

function showmodal(produit_id){
	var actualposition = document.documentElement.scrollTop;
	var modbox = document.getElementById('modbox');
	var cmodbox = document.getElementById('cmodbox');
	var panmodbox = document.getElementById('panmodbox');
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	var shad = document.getElementById('shad');
	document.body.style.overflow='hidden';
	
	cmodbox.innerHTML='';
	panmodbox.innerHTML = '';
	
	modbox.style.marginTop = (actualposition-260)+"px";
	shad.style.display="block"; 
	modbox.style.display="block"; 
	document.getElementsByTagName("html")[0].style.overflow = "hidden"; 
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('7.') != -1 ) {
		topconnexion.style.zIndex = -1;
	}
	
	window.scrollTo(0,actualposition);		
}
function newshowmodal(produit_designation, nb_panier, type, path_web, is_not_produit, id_produit,type_gamme){
	var elname = 'modbox';
	
	if (type == 'err') {
		
		elname = 'errbox';
		
	}
	
	var actualposition = document.documentElement.scrollTop ;
	var modbox = document.getElementById(elname);
	var cmodbox = document.getElementById('cmodbox');
	var panmodbox = document.getElementById('panmodbox');
	var topconnexion = document.getElementById('connexion_top');
	var shad = document.getElementById('shad');
	//document.body.style.overflow='hidden';
	
	if (type != 'err') {
		
		var title = document.getElementById('ajax_product_name').innerHTML;
		var subtitle = document.getElementById('ajax_product_description').innerHTML;
		if( is_not_produit ) {
			title = document.getElementById('ajax_product_name_'+id_produit).innerHTML;
			subtitle = document.getElementById('ajax_product_description_'+id_produit).innerHTML;
		}
		var str_taille = '';
		var str_couleur = '';
		var str_qte = '';
		
		if ( is_not_produit ) {
			if( document.getElementById('ligne_taille') ) {
				if( document.getElementById('tailleUnique_' + id_produit) &&  document.getElementById('tailleUnique_' + id_produit)) 
					str_taille = document.getElementById('tailleUnique_' + id_produit).innerHTML;
				else if(document.getElementById('tailleProd_' + id_produit)) 
					str_taille = document.getElementById('tailleProd_' + id_produit).options[document.getElementById('tailleProd_' + id_produit).selectedIndex].text;
			}
			if( document.getElementById('ligne_couleur') ) {
				if( document.getElementById('couleurUnique_' + id_produit) ) 
					str_couleur = document.getElementById('couleurUnique_' + id_produit).innerHTML;
				else if(document.getElementById('couleurProd_' + id_produit)) 
					str_couleur = document.getElementById('couleurProd_' + id_produit).options[document.getElementById('couleurProd_' + id_produit).selectedIndex].text;
			}
			if( document.getElementById('ligne_qte') && document.getElementById('qteProd_' + type_gamme + '_' + id_produit) ) 
				str_qte = document.getElementById('qteProd_' + type_gamme + '_' + id_produit).options[document.getElementById('qteProd_' + type_gamme + '_' + id_produit).selectedIndex].text;
				
			document.getElementById('modbox_visu').src = document.getElementById('ajax_main_visu_prod_' + id_produit).src;
		} else {
			if( document.getElementById('ligne_taille') ) {
				if( document.getElementById('tailleUnique') ) 
					str_taille = document.getElementById('tailleUnique').innerHTML;
				else if(document.getElementById('tailleProd'))
					str_taille = document.getElementById('tailleProd').options[document.getElementById('tailleProd').selectedIndex].text;
			}
			if( document.getElementById('ligne_couleur') ) {
				if( document.getElementById('couleurUnique') ) 
					str_couleur = document.getElementById('couleurUnique').innerHTML;
				else if(document.getElementById('couleurProd'))
					str_couleur = document.getElementById('couleurProd').options[document.getElementById('couleurProd').selectedIndex].text;
			}
			if( document.getElementById('ligne_qte') ) 
				str_qte = document.getElementById('qteProd').options[document.getElementById('qteProd').selectedIndex].text;
			
			document.getElementById('modbox_visu').src = visu_modbox;
		}
		
		var taille_label = ajax_file(path_web+'ajax_sprintf.php?arg1=product_size');
		var couleur_label = ajax_file(path_web+'ajax_sprintf.php?arg1=coloris');
		var qte_label = ajax_file(path_web+'ajax_sprintf.php?arg1=quantite');
		
		var str_response = '<p class="title_product_ajout_panier"><strong>' +title + '</strong></p>';
		str_response += '<p class="subtitle_product_ajout_panier">' + subtitle + '</p>';
		
		str_response += '<p class="infos_product_ajout_panier">';
		if( str_taille != '' ) str_response += '<strong>' + taille_label + ' :</strong> ' + str_taille + '<br />';
		if( str_couleur != '' ) str_response += '<strong>' + couleur_label + ' :</strong> ' + str_couleur + '<br />';
		if( str_qte != '' ) str_response += '<strong>' + qte_label + ' :</strong> ' + str_qte + '<br />';
		str_response += '</p>';
		
		cmodbox.innerHTML = str_response;
		
		if (nb_panier == '1') {
			
			panmodbox.innerHTML = '<strong>' + nb_panier + '</strong> ' + ajax_file(path_web+'ajax_sprintf.php?arg1=article') + '.';
			
		} else {
			
			panmodbox.innerHTML = '<strong>' + nb_panier + '</strong> ' + ajax_file(path_web+'ajax_sprintf.php?arg1=articles') + '.';
			
		}
	}
	
	show_lightbox('modbox');
	/*shad.style.display="block"; 
	modbox.style.display="block"; */
		/*topconnexion.style.zIndex = 0;*/

	
	window.scrollTo(0,actualposition);		
}

function showsendfriendmodal(product_id, path_web){
	
	var elname = 'sendfriendbox';
	
	var actualposition = document.documentElement.scrollTop ;
	var modbox = document.getElementById(elname);
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	var shad = document.getElementById('shad');
	//document.body.style.overflow='hidden';
	
	document.getElementById('product_sendfriend_nok').innerHTML='';
	document.getElementById('product_sendfriend_ok').innerHTML='';
	document.getElementById('product_sendfriend_nok').style.display='none';
	document.getElementById('product_sendfriend_ok').style.display='none';
	
	prodGetProductDisplay( product_id, path_web );
	
		$('#shad').fadeTo("slow", 0.8).queue(function () {
			$('#sendfriendbox').slideDown("slow");
			$(this).dequeue();
		});

	addEvent(shad,'click',closesendfriendmodal);	
	
	window.scrollTo(0,actualposition);		
}

function closesendfriendmodal() {
	var modbox = document.getElementById('sendfriendbox');
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	var shad = document.getElementById('shad');
	/*
	modbox.style.marginLeft='';
	shad.style.display="none"; 
	modbox.style.display="none"; 
	*/
	$('#sendfriendbox').slideUp("slow").queue(function () {
		$('#shad').fadeTo("slow", 0);
		$(this).dequeue();
		shad.style.display = 'none';
		modbox.style.display = 'none';
	});
	document.getElementById('sendfriend_alert_mail').style.display="none";
	document.getElementById('sendfriend_prodinfos').style.display="block";
	document.getElementById('sendfriend_form_to').style.display="block";
	document.getElementById('sendfriend_form_froms').style.display="block";
	document.getElementById('sendfriend_form_buttons').style.display="block";
	document.getElementById('sendfriend_form_needed').style.display="block";
	//topconnexion.style.zIndex = 1501;
	document.body.style.overflow='';
	document.getElementsByTagName("html")[0].style.overflow = ""; 
	
	delEvent(shad,'click',closesendfriendmodal);
	
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('6.') != -1 ) {
		
		var svn=document.getElementsByTagName("SELECT");
		for (a=0;a<svn.length;a++){
			svn[a].style.visibility="visible";
		}
		
	}
}

function closesendfriendmodalfromconfirm() {
	var modbox = document.getElementById('sendfriendbox');
	var shad = document.getElementById('shad');
	modbox.style.marginLeft='';
	shad.style.display="none"; 
	modbox.style.display="none"; 
	document.body.style.overflow='';
	document.getElementsByTagName("html")[0].style.overflow = ""; 
	document.getElementById('sendfriend_prodinfos').style.display="block";
	document.getElementById('sendfriend_form_to').style.display="block";
	document.getElementById('sendfriend_form_froms').style.display="block";
	document.getElementById('sendfriend_form_buttons').style.display="block";
	document.getElementById('sendfriend_form_needed').style.display="block";
	document.getElementById('sendfriend_alert_mail').innerHTML="";
	document.getElementById('sendfriend_alert_mail').style.display="none";
	
	delEvent(shad,'click',closesendfriendmodal);
	
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('6.') != -1 ) {
		
		var svn=document.getElementsByTagName("SELECT");
		for (a=0;a<svn.length;a++){
			svn[a].style.visibility="visible";
		}
		
	}
		
}

function closemodal() {
	
	var modbox = document.getElementById('modbox');
	var errbox = document.getElementById('errbox');
	var cmodbox = document.getElementById('cmodbox');
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	var shad = document.getElementById('shad');
	
	cmodbox.innerHTML='';
	modbox.style.marginLeft='';
	shad.style.display="none"; 
	modbox.style.display="none"; 
	errbox.style.display="none"; 
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('7.') != -1 ) {
		topconnexion.style.zIndex = 1501;
	}
	
	document.body.style.overflow='';
	document.getElementsByTagName("html")[0].style.overflow = ""; 
	
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('6.') != -1 ) {
		
		var svn=document.getElementsByTagName("SELECT");
		for (a=0;a<svn.length;a++){
			svn[a].style.visibility="visible";
		}
		
	}
}
/*
function addToBasket(produit_id, suff, isAssoc, basket_id, page_name, path_web, enable_omniture) {
	var panier_id = basket_id;
	
	var array_panier = newUpdatePanier(produit_id, suff, panier_id, document.getElementById('prixU').value, isAssoc, path_web);
	
	if (array_panier != false) {
		var type = '';
		
		
		if (array_panier[1] == 'false' || array_panier.length == 0) {
			
			type = 'err';
			
		}
		
		omnitureEvent = '';
		
		if (array_panier[1] == 0) {
			
			document.getElementById('panier_prix').innerHTML = 'Votre Panier est vide';
			document.getElementById('panier_prix').style.textAlign = 'center';
			omnitureEvent = '';
			
		} else if (array_panier[1] == 1) {
			
			document.getElementById('panier_prix').innerHTML = '<nobr><a href="' + path_web + 'panier.php">' + array_panier[1] + ' Article</a></nobr>';
			document.getElementById('panier_prix').style.textAlign = 'left';
			omnitureEvent = 'scOpen,scAdd'; // le premier produit ajouté au panier 
			
		} else {
			
			document.getElementById('panier_prix').innerHTML = '<nobr><a href="' + path_web + 'panier.php">' + array_panier[1] + ' Articles</a></nobr>';
			document.getElementById('panier_prix').style.textAlign = 'left';
			omnitureEvent = 'scAdd'; // il y a déjà un produit au panier
			
		}
		
		if (array_panier[1] > 0 && enable_omniture == true) {
			
			void(s.t());
			s.pageName	= "'" + page_name + "'";
            s.products	= ";" + produit_id;
            s.events	= omnitureEvent;				
			void(s.t());				
			
		}
		
		
		document.getElementById('total_euros_panier').innerHTML = array_panier[2];

		newshowmodal(array_panier[0], array_panier[1], type);
	}
	
	return false;
	
}*/

function waitingAddToBasket(produit_id, suff, isAssoc, panier_id, titreObjet, idTaille, lastTaille, idCouleur, lastCouleur, idQte, toEval, page_name, path_web, enable_omniture, is_not_produit,type) {
	
	var id = '';
	if( is_not_produit == true )
		id += '_' + type + '_' + produit_id;
	
	window.setTimeout('addToBasket("'+produit_id+'", "'+suff+'", '+isAssoc+', "'+panier_id+'", "'+titreObjet+'", "'+idTaille+'", "'+lastTaille+'", "'+idCouleur+'", "'+lastCouleur+'", "'+idQte+'","' + toEval + '", "'+page_name+'", "'+path_web+'", '+enable_omniture+', '+is_not_produit+', "'+type+'");',1000);
	//Chargement
	$("#bloc_btn_active"+id).attr('class','cache');
	$("#bloc_btn_loader"+id).attr('class','f_right');
}

function addToBasket(produit_id, suff, isAssoc, panier_id, titreObjet, idTaille, lastTaille, idCouleur, lastCouleur, idQte, toEval, page_name, path_web, enable_omniture, is_not_produit, type_gamme) {
	
	var id = '';
	if( is_not_produit == true )
		id += '_' + type_gamme + '_' + produit_id;
		
	var array_panier = newUpdatePanier(produit_id, suff, panier_id, document.getElementById('prixU').value, isAssoc, path_web, titreObjet, idTaille, lastTaille, idCouleur, lastCouleur, idQte, type_gamme);
	
	if (array_panier != false) {
		var type = '';
		
		if (array_panier[1] == 'false' || array_panier.length == 0) {
			
			type = 'err';
			
		}
		
		omnitureEvent = '';
		if (array_panier[1] == 0) {
			omnitureEvent = '';
			
			$("#nb_article").html('0');
			$("#txt_nb_article").html(ajax_file(path_web+'ajax_sprintf.php?arg1=article'));
			
			$("#panier").click();
			$("#panier").css('cursor','none');
			
		} else if (array_panier[1] == 1) {
			$("#nb_article").html('1');
			$("#txt_nb_article").html(ajax_file(path_web+'ajax_sprintf.php?arg1=article'));
			
			omnitureEvent = 'scOpen,scAdd'; // le premier produit ajouté au panier 
			
			$("#panier").click(function(){location.href=path_web+'panier.php';});
			$("#panier").css('cursor','pointer');
			
		} else {
			$("#nb_article").html(array_panier[1]);
			$("#txt_nb_article").html(ajax_file(path_web+'ajax_sprintf.php?arg1=articles'));
			
			omnitureEvent = 'scAdd'; // il y a déjà un produit au panier
			
			$("#panier").click(function(){location.href=path_web+'panier.php';});
			$("#panier").css('cursor','pointer');
			
		}
		
		if (array_panier[1] > 0 && enable_omniture == true) {
			void(s.t());
			s.pageName	= "'" + page_name + "'";
			s.products	= ";" + produit_id;
			s.events	= omnitureEvent;				
			void(s.t());				
			
		}
		
		newshowmodal(array_panier[0], array_panier[1], type, path_web, is_not_produit, produit_id, type_gamme);
		
		$("#bloc_btn_active"+id).attr('class','');
		$("#bloc_btn_loader"+id).attr('class','f_right cache');
		
	}
	else {
		
		$("#bloc_btn_active"+id).attr('class','');
		$("#bloc_btn_loader"+id).attr('class','f_right cache');
		
	}
	
	eval(toEval);
	
	/*
	if (array_panier != false) {
		if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('6.') != -1 ) {
		
			var svn=document.getElementsByTagName("SELECT");
			for (a=0;a<svn.length;a++){
				svn[a].style.visibility="hidden";
			}
			
		}
	
	}
	*/
	
	
	// zanox: a chaque ajout du panier, on ouvre une page contenant un tag zanox mediaslot(add to cart) plus le contenu du panier
	if (document.getElementById('zx_price') != undefined) {

		// product_id = produit_id;
		// product_prix = document.getElementById('zx_price').childNodes[0].nodeValue;
		// product_quantite = document.getElementById(idQte).value;
		
		ajax_file(path_web+'ajax_zanox_product.php');
	}
	
	return false;
	
}

 function displayOnglet( pDiv ){
	
	if ( pDiv == "ongletSavoirPlus" ) {
		if ( document.getElementById('ongletCaracteristiques') )
			document.getElementById('ongletCaracteristiques').style.display ='none';
		/*if ( document.getElementById('ongletGammes') )
			document.getElementById('ongletGammes').style.display ='none';
		if ( document.getElementById('ongletAssociations') )
			document.getElementById('ongletAssociations').style.display ='none';*/
	}
	
	if ( pDiv == "ongletCaracteristiques" ) {
		if ( document.getElementById('ongletSavoirPlus') )
			document.getElementById('ongletSavoirPlus').style.display ='none';
		/*if ( document.getElementById('ongletGammes') )
			document.getElementById('ongletGammes').style.display ='none';
		if ( document.getElementById('ongletAssociations') )
			document.getElementById('ongletAssociations').style.display ='none';*/
	}
	
	if ( pDiv == "ongletGammes" ) {
		if ( document.getElementById('ongletCaracteristiques') )
			document.getElementById('ongletCaracteristiques').style.display ='none';
		if ( document.getElementById('ongletSavoirPlus') )
			document.getElementById('ongletSavoirPlus').style.display ='none';
		if ( document.getElementById('ongletAssociations') )
			document.getElementById('ongletAssociations').style.display ='none';
	}
	
	if ( pDiv == "ongletAssociations" ) {
		if ( document.getElementById('ongletCaracteristiques') )
			document.getElementById('ongletCaracteristiques').style.display ='none';
		if ( document.getElementById('ongletSavoirPlus') )
			document.getElementById('ongletSavoirPlus').style.display ='none';
		if ( document.getElementById('ongletGammes') )
			document.getElementById('ongletGammes').style.display ='none';
	}
			
	if ( document.getElementById(pDiv) )	
		document.getElementById(pDiv).style.display ='block';
}

function displayZoom ( picture, product_ref, path_web, picture_medium, picture_mini, photo_path, photo_list ){
	
	var so = new SWFObject(path_web + "zoom.swf", "zoom", "405", "610", "8", "#FFFFFF");
	so.addParam("wmode", "transparent");
	so.addParam("allowScriptAccess", "always");
	so.addVariable("produit_id", product_ref);
	so.addVariable("url", path_web);

	so.addVariable("photo_path_medium", picture_medium);
	so.addVariable("photo_path_mini", picture_mini);

	so.addVariable("photo_path", photo_path);

	so.addVariable("photo_list", photo_list);
	so.addVariable("img_defaut", picture);
	so.write("flashVisuel");

}

function zoom( picture, product_ref, path_web, picture_medium, picture_mini, photo_path, photo_list ){
	
	displayZoom( picture, product_ref, path_web, picture_medium, picture_mini, photo_path, photo_list );
	
}

function zoomImg( photo, path_web ){

	var elname = 'zoomBox';
	
	var actualposition = document.documentElement.scrollTop ;
	var modbox = document.getElementById(elname);
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	var shad = document.getElementById('shad_zoom');
	
    modbox.style.position = "absolute";
	shad.style.display="block";
	modbox.style.display="block";
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('7.') != -1 ) {
		topconnexion.style.zIndex = -1;
	}
	var str_img = '';
	//modbox.innerHTML = '<img class="no_border" onClick="closeZoom()" style="cursor:pointer;border:7px solid #fff;" alt="" id="photo_zoom" />';
	//modbox.innerHTML = '<div id="wrapper_zoombox"><div class="f_left"><div id="wrapper_vgt_visus" class="f_left">Vues :<br /><img style="cursor:pointer;" class="no_border" width="60" onClick="" src="'+path_web+'img/visu_coup_de_coeur.jpg" /><br /><br /><img style="cursor:pointer;" class="no_border" width="60" onClick="" src="'+path_web+'img/visu_coup_de_coeur.jpg" /></div><div class="f_left">Couleurs :<br /><img style="cursor:pointer;" class="no_border" width="60" onClick="" src="'+path_web+'img/visu_coup_de_coeur.jpg" /><br /><br /><img style="cursor:pointer;" class="no_border" width="60" onClick="" src="'+path_web+'img/visu_coup_de_coeur.jpg" /></div></div><div class="f_left"><img class="no_border" style="border:1px solid #efefef;margin:0 0 0 10px" alt="" id="photo_zoom" /></div><div id="fermer_zoombox" class="f_left"><img class="no_border" onClick="closeZoom()" src="'+path_web+'img/fermer_photo.gif" /><br />FERMER</div></div>';
	
	str_img += '<div id="wrapper_zoombox">';
	str_img += '<div class="f_left"><div id="wrapper_vgt_visus" class="f_left">Vues :<br />';
	
	var cnt_tab_js = tab_js.length;
	var i = 0;
	var is_visu_detail = true;
	while( is_visu_detail && i<cnt_tab_js ) {
		is_visu_detail = ( tab_js[i][0].substr(tab_js[i][0].lastIndexOf('.')-1,1) == 'A' || tab_js[i][0].substr(tab_js[i][0].lastIndexOf('.')-1,1) == 'B' || tab_js[i][0].substr(tab_js[i][0].lastIndexOf('.')-1,1) == 'C' || tab_js[i][0].substr(tab_js[i][0].lastIndexOf('.')-1,1) == 'D' || tab_js[i][0].substr(tab_js[i][0].lastIndexOf('.')-1,1) == 'E' );
		if( is_visu_detail ) {
			
			var photo_large = tab_js[i][0].replace(/medium/,"large");
			
			str_img += '<img style="cursor:pointer;" class="no_border" width="60" onclick="changeVisuZoom(\'bloc_photo_zoom\',\''+photo_large+'\',\''+path_web+'\');" src="'+tab_js[i][0]+'" /><br /><br />';
			i++;
		}
	}
	
	str_img += '</div>';
	
	if( i < cnt_tab_js ) {
		
		var label_color = document.getElementById('ligne_couleur_label').innerHTML;
		label_color = label_color.replace(' :','s :');
		
		str_img += '<div id="wrapper_vgt_color" class="f_left">' + label_color + '<br />';
		var k = 0;
		for( j=i ; j<cnt_tab_js ; j++,k++ ) {
			var photo_large = tab_js[j][0].replace(/medium/,"large");
			str_img += '<div class="bloc_vgt_color"><img style="cursor:pointer;margin-bottom:-9px;" class="no_border" width="60" onclick="changeVisuZoom(\'bloc_photo_zoom\',\''+photo_large+'\',\''+path_web+'\');" src="'+tab_js[j][0]+'" />';
			if( typeof(tab_js_color[k]) != 'undefined' ) str_img += '<img onclick="changeVisuZoom(\'bloc_photo_zoom\',\''+photo_large+'\',\''+path_web+'\');" style="border:0;padding:0;width:70px;height:10px;cursor:pointer;" src="'+tab_js_color[k]+'" />';
			str_img += '</div>';
			
		}
		
		str_img += '</div>';
		
	}
	
	str_img += '</div>';
	str_img += '<div id="bloc_photo_zoom" class="f_left"><div style=\'z-index:1;position:relative;top:300px;\'><img src=\''+ path_web +'img/loader.gif\' /><p><strong>Chargement...</strong></p></div><div style="position:relative;z-index:2;top:0px;"><img class="no_border" style="margin:0 0 0 10px" alt="" id="photo_zoom" /></div></div><div onClick="closeZoom()" id="fermer_zoombox" class="f_left"><img class="no_border" src="'+path_web+'img/btn_retour_fiche_produit.png" /></div></div>';
	
	modbox.innerHTML = str_img;
	
	var el_zoom_pic = document.getElementById('photo_zoom');
	
	//el_zoom_pic.src = '/img/loader.gif';
	var myImage = new Image();
	myImage.src = photo;

	var el_zoom_pic_width = myImage.width;
	el_zoom_pic_width_demi = (el_zoom_pic_width)/ 2;
	/*modbox.style.top = "170px";
	modbox.style.left = "50%";*/
	/*modbox.style.marginLeft = "-" + el_zoom_pic_width_demi + "px";*/
	modbox.style.margin = "0 0 0 -45px";
	modbox.style.top = "186px";
	//modbox.style.width = "1090px";
	
	
	alert(jQuery("#zoomBox div").css('width'));
	
	el_zoom_pic.src = photo;
	el_zoom_pic.style.border = '1px solid #efefef'
	window.scrollTo(0,actualposition);
	
	/*addEvent(shad,'click',closeZoom);*/
	/*addEvent(modbox,'click',closeZoom);*/
	
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('6.') != -1 ) {		
		var svn=document.getElementsByTagName("SELECT");
		for (a=0;a<svn.length;a++){
			svn[a].style.visibility="hidden";
		}		
	}
}

function changeVisuZoom( field, path ) {
	
	/*document.getElementById(field).style.width = document.getElementById(field).offsetWidth + 'px';
	document.getElementById(field).style.height = document.getElementById(field).offsetHeight + 'px';
	*/
	var elem = ( document.getElementById('nyroModalImg') )? 'nyroModalImg':'img_tmp';
	
	var w_tmp = $('#'+elem).width();
	var h_tmp = $('#'+elem).height();

	document.getElementById(field).innerHTML = "<div id='loader_tati' style='z-index:1;position:relative;top:400px;text-align:center;font-size:16px;color:#CBE423;'><img src='"+path_relative_root+"img/loader_zoom.gif' /><p><strong>Chargement...</strong></p></div>";
	document.getElementById(field).innerHTML += "<div style='position:relative;z-index:2;top:-41px;'><img id='img_tmp' src="+path+"></div>";
//	$("#"+field).attr('src',path)

	$('#img_tmp').load(function() { 
		$('#loader_tati').remove();
		$(this).parent().css('top','0');
		$(this).width(w_tmp);
		$(this).height(h_tmp);
	});
	
}

function closeZoom(){

	var elname = 'zoomBox';
	var modbox = document.getElementById(elname);
	var shad = document.getElementById('shad');
	var shad_zoom = document.getElementById('shad_zoom');
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	modbox.style.display="";
	shad_zoom.style.display="";
	
	delEvent(shad,'click',closeZoom);
	delEvent(shad_zoom,'click',closeZoom);
	delEvent(modbox,'click',closeZoom);
	topconnexion.style.zIndex = 1501;
	
	closemodal();
	
}

function updateSrc(path_web,dest) {

	var tmp_string = document.getElementById('img_large').src;
	tmp_string = tmp_string.replace(/medium/,"large");
	
	document.getElementById('loupe_plus').href = tmp_string;
	document.getElementById('img_large').setAttribute('jqimg',tmp_string);
	
	
	if(dest=='vue') {
		
		var i = 0;
		var trouve = false;
		while (i<tab_js.length && !trouve) {
			
			trouve = (tab_js[i][0].substring(tab_js[i][0].lastIndexOf('/')+1)==tmp_string.substring(tmp_string.lastIndexOf('/')+1));
			i++;
		
		}
		
		cpt_img = (i-1);
		
	}

}

function defilImg(sens,path_web) {
	
	if(sens == 'gauche') {
		if(cpt_img!=0) cpt_img--;
		else cpt_img = tab_js.length-1;
	}
	else {
		if(cpt_img<tab_js.length-1) cpt_img++;
		else cpt_img = 0;
	}
	
	changeVisu('img_large',tab_js[cpt_img][0],tab_js[cpt_img][1]);
	updateSrc(path_web);
	
}

function productSendFriendForm( path_web, request_uri ) {
	
	document.getElementById("product_sendfriend_ok").style.display = 'block';
	document.getElementById("product_sendfriend_nok").style.display = 'block';
	
	//var content = "<p style=\"margin: 0px;padding: 0px;\">L'e-mail n'a pas pu être envoyé à votre ami.</p>";
	var content_id = "product_sendfriend_nok";
	
	if ( document.getElementById('sendFriendToMails') && document.getElementById('sendFriendToMessage') && document.getElementById('sendFriendYourName') && document.getElementById('sendFriendYourMail') && document.getElementById('sendFriendCopy') ) {
		document.getElementById('sendFriendToMails').style.border="";
		document.getElementById('sendFriendToMessage').style.border="";
		document.getElementById('sendFriendYourName').style.border="";
		document.getElementById('sendFriendYourMail').style.border="";
		var response = ajax_file( path_web + 'ajax_send_friend_form.php?url=' + request_uri + '&to_mails=' + document.getElementById('sendFriendToMails').value + '&to_message=' + document.getElementById('sendFriendToMessage').value.replace(/\n/g,'<br>') + '&your_name=' + document.getElementById('sendFriendYourName').value + '&your_mail=' + document.getElementById('sendFriendYourMail').value + '&copy=' + document.getElementById('sendFriendCopy').checked );
		
		if ( response.split(',')[0] == 'ok' ) {
			
			var s_adresse = response.substr(3);
			
			var sing = (response.split(',').length>2)? 'sendfriend_ok_plur' : 'sendfriend_ok_sing';
			
			var content = '<div style="font-size:14px;font-weight:bold;font-family:Arial; color:#00367B;text-align:center;margin-bottom:10px;margin-top:15px;font-family: EssaiRegular;">'+ajax_file(path_web+'ajax_sprintf.php?arg1='+sing)+'</div>';
			content += '<p style=\"margin-top: 0px;margin-bottom: 30px;padding:0;text-align:center;\">'+s_adresse+'</p>';
			
			var content_id = "sendfriend_alert_mail";
			document.getElementById('product_sendfriend_nok').innerHTML="";
			document.getElementById('sendfriend_prodinfos').style.display="none";
			document.getElementById('sendfriend_form_to').style.display="none";
			document.getElementById('sendfriend_form_froms').style.display="none";
			document.getElementById('sendfriend_form_buttons').style.display="none";
			document.getElementById('sendfriend_form_needed').style.display="none";
			document.forms["sendfriendform"].reset();		
			
		} else if (response == '1' ) {
			
			var content = "<p style=\"margin: 0px;padding: 0px;\">" + ajax_file(path_web+'ajax_sprintf.php?arg1=sendfriend_error_no_mail_friends') + "</p>";
			document.getElementById('sendFriendToMails').style.border="1px #AA0000 solid";
			document.getElementById('sendFriendToMessage').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourName').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourMail').style.border="1px #CCCCCC solid";
			
		} else if (response == '2' ) {
			
			var content = "<p style=\"margin: 0px;padding: 0px;\">" + ajax_file(path_web+'ajax_sprintf.php?arg1=sendfriend_error_mail_friends_invalid') + "</p>";
			document.getElementById('sendFriendToMails').style.border="1px #AA0000 solid";
			document.getElementById('sendFriendToMessage').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourName').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourMail').style.border="1px #CCCCCC solid";
			
		} else if (response == '3' ) {
			
			var content = "<p style=\"margin: 0px;padding: 0px;\">" + ajax_file(path_web+'ajax_sprintf.php?arg1=sendfriend_error_no_message') + "</p>";
			document.getElementById('sendFriendToMessage').style.border="1px #AA0000 solid";
			document.getElementById('sendFriendToMails').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourName').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourMail').style.border="1px #CCCCCC solid";
			
		} else if (response == '4' ) {
			
			var content = "<p style=\"margin: 0px;padding: 0px;\">" + ajax_file(path_web+'ajax_sprintf.php?arg1=sendfriend_error_no_name') + "</p>";
			document.getElementById('sendFriendYourName').style.border="1px #AA0000 solid";
			document.getElementById('sendFriendToMails').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendToMessage').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourMail').style.border="1px #CCCCCC solid";
			
		} else if (response == '5' ) {
			
			var content = "<p style=\"margin: 0px;padding: 0px;\">" + ajax_file(path_web+'ajax_sprintf.php?arg1=sendfriend_error_name_invalid') + "</p>";
			document.getElementById('sendFriendYourName').style.border="1px #AA0000 solid";
			document.getElementById('sendFriendToMails').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendToMessage').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourMail').style.border="1px #CCCCCC solid";
			
		}
		 else if (response == '6' ) {
			
			var content = "<p style=\"margin: 0px;padding: 0px;\">" + ajax_file(path_web+'ajax_sprintf.php?arg1=sendfriend_error_no_my_mail') + "</p>";
			document.getElementById('sendFriendYourMail').style.border="1px #AA0000 solid";
			document.getElementById('sendFriendToMails').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendToMessage').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourName').style.border="1px #CCCCCC solid";
			
		}
		 else if (response == '7' ) {
			
			var content = "<p style=\"margin: 0px;padding: 0px;\">" + ajax_file(path_web+'ajax_sprintf.php?arg1=sendfriend_error_my_mail_invalid') + "</p>";
			document.getElementById('sendFriendYourMail').style.border="1px #AA0000 solid";
			document.getElementById('sendFriendToMails').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendToMessage').style.border="1px #CCCCCC solid";
			document.getElementById('sendFriendYourName').style.border="1px #CCCCCC solid";
			
		}
		else{
			var s_adresse = response.substr(3);
			var sing = (response.split(',').length>2)? 'sendfriend_no_ok_plur' : 'sendfriend_no_ok_sing';
			var content = '<div style="font-size:14px;font-weight:bold;font-family:Arial; color:#00367B;text-align:center;margin-bottom:10px;margin-top:15px;font-family: EssaiRegular">'+ajax_file(path_web+'ajax_sprintf.php?arg1='+sing)+'</div>';
			var content_id = "sendfriend_alert_mail";
			content += '<p style="margin:0;padding-top:20px;text-align:center;"><a onclick="closesendfriendmodalfromconfirm()" href="#"><img class="no_border" src="'+path_web+'img/btn_retour_connexion_top.jpg" /></a><p>';
			
			document.getElementById('product_sendfriend_nok').innerHTML="";
			document.getElementById('sendfriend_prodinfos').style.display="none";
			document.getElementById('sendfriend_form_to').style.display="none";
			document.getElementById('sendfriend_form_froms').style.display="none";
			document.getElementById('sendfriend_form_buttons').style.display="none";
			document.getElementById('sendfriend_form_needed').style.display="none";
			
			document.getElementById('sendFriendToMails').value 		= "";
			document.getElementById('sendFriendToMessage').value 	= "";
			document.getElementById('sendFriendYourName').value 	= "";
			document.getElementById('sendFriendYourMail').value 	= "";
		}
		
	}
	document.getElementById(content_id).innerHTML = content;
	document.getElementById(content_id).style.display = 'block';
	
	return false;
}

function prodGetProductDisplay( id, path_web ) {

	var response = ajax_file( path_web + 'ajax_get_infos_send_friend.php?product_id=' +id );
	document.getElementById('sendfriend_prodinfos').innerHTML = response;
	
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('6.') != -1 ) {
		
		var svn=document.getElementsByTagName("SELECT");
		for (a=0;a<svn.length;a++){
			svn[a].style.visibility="hidden";
		}
		
	}
	
}

function showoscar(){
	var elname = 'oscarbox';
	
	var actualposition = document.documentElement.scrollTop;
	var modbox = document.getElementById(elname);
	var shad = document.getElementById('shad');
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	
	/*var option=['btn_femmes','btn_hommes','btn_filles','btn_garcons','btn_bebes'];
	for(var i=0; i<option.length; i++){
			obj=document.getElementById(option[i]);
			obj.style.display="none"; 
	}*/
	
	
	
	modbox.style.position = "absolute";
	shad.style.display = "block";
	if ( navigator.userAgent.indexOf('MSIE') != -1 && navigator.userAgent.indexOf('7.') != -1 ) {
		topconnexion.style.zIndex = -1;
	}
	
	addEvent(shad,'click',closesizeguide);
	/*addEvent(modbox,'click',closesizeguide);*/
	
	addEvent(document.getElementById('menu_sizeguide'), 'click', doNothing);

	modbox.style.display="block";
	
	window.scrollTo(0,actualposition);
}

function closeoscar() {
	var elname = 'oscarbox';
	var shad = document.getElementById('shad');
	var modbox = document.getElementById(elname);
	var topconnexion = document.getElementById('topMenuConnexionButtonInside');
	modbox.style.display=""; 
	topconnexion.style.zIndex = 1501;
	
	/*var option=['btn_femmes','btn_hommes','btn_filles','btn_garcons','btn_bebes'];
	for(var i=0; i<option.length; i++){
			obj=document.getElementById(option[i]);
			obj.style.display="inline"; 
	}*/

	delEvent(shad,'click',closeoscar);
	delEvent(modbox,'click',closesizeguide);
	delEvent(document.getElementById('menu_sizeguide'), 'click', doNothing);
	
	/*if(save_id!=0) {
		var option=['sizeguide_femme','sizeguide_homme','sizeguide_lingerie','sizeguide_fille','sizeguide_garcon','sizeguide_bebe'];
		for(var i=0; i<option.length; i++){
			obj = document.getElementById(option[i]);
			obj.style.display = (i==(save_id-1))? 'block':'none';
			if(document.getElementById('btn_'+(i+1)+'select')) document.getElementById('btn_'+(i+1)+'select').id = 'btn_'+(i+1);
		}
		
		if(document.getElementById('btn_'+(save_id))) document.getElementById('btn_'+(save_id)).id = 'btn_'+(save_id)+'select';
	}*/
	
	closemodal();
}

function show_lightbox(lightbox_contact) {	
	$('#shad').fadeTo("slow", 0.8).queue(function () {
		$('#'+lightbox_contact).slideDown("slow");
		$(this).dequeue();
	});	
}
function close_lightbox(lightbox_contact) {
	$('#'+lightbox_contact).slideUp("slow").queue(function () {
		$('#shad').fadeTo("slow", 0, function() {
			$(this).css('display','none');
		});
		$(this).dequeue();
	});
}
