// JavaScript Document// shopping_cart.js//// DAMART - 09/02/2007// variable et fonction sp?cifique a la page des coordonneesvar popUpMDP, popUpAdresse, popUpFond, prefixe;window.onload = function(){	popUpFond = new fx.Opacity('popUpFond');}function checkoutShipping(pForm, lien, lienErreur){	if(document.frm_commander.chk_conditions_sell.checked){		destination = lien; //"./checkout_shipping.php";		document.location.href = destination;	}else{		destination = lienErreur + "?error=o"; //"./shopping_cart.php?error=o";		document.location.href = destination;		//window.alert("Veuillez cocher la case a cocher d'acceptation des Conditions Generales de Vente pour pouvoir passer a l'etape suivante")	}}function afficheModMDP(text){  popUpFond = new fx.Opacity('popUpFond');  popUpMDP= new fx.Opacity('modifPass');  //switchListeCombo(0);  afficheFauxPopup('modifPass','popUpFond', 200, popUpMDP, popUpFond, text);  document.getElementById('popUpFond').style.width = "100%";  //document.getElementById('popUpFond').style.height = document.getElementById('body').offsetHeight+"px";}function fermerModMDP(){  fermerFauxPopUp(popUpMDP, popUpFond);  //switchListeCombo(1);}function afficheFauxPopup(elt, eltprin, valtop, fader1, fader2, text){	scrolling=Position.realOffset($(elt))[1];	$(elt).style.top=(scrolling)+valtop;	fader1.now=0;	fader1.toggle();	fader2.now=0;	fader2.custom(0, 0.35);	$(eltprin).style.left=0;	$(eltprin).style.top=0;	//$(eltprin).style.height=document.body.scrollHeight;	//document.getElementById('text').innerHTML = text;}function fermerFauxPopUp(fader1, fader2){	if(fader1.now>0 && fader2.now>0){		fader1.custom(fader1.now, 0);		fader2.custom(fader2.now, 0);	}}//Ajout de fonctions pour calque de modification de lignefunction display(action, idPopUp){	//if(action == "update_line"){		popUpFond = new fx.Opacity('popUpFond');		document.getElementById('popUpFond').style.height = document.getElementById('header').offsetHeight+document.getElementById('contenu').offsetHeight+document.getElementById('footer').offsetHeight+"px";		document.getElementById('popUpFond').style.width = "120%";		var popUpMDP = idPopUp;		afficheModModifLigne(idPopUp);		document.getElementById(idPopUp).style.display="block";	//}}//Ajout de fonctions pour calque de suppression de lignefunction display2(action, idPopUp, product){	if(action == "delete_lines_confirmation"){		popUpFond = new fx.Opacity('popUpFond');		afficheModModifLigne(idPopUp);	}}function afficheModModifLigne(text){  popUpMDP= new fx.Opacity(text);  //switchListeCombo(0);  afficheFauxPopup(text,'popUpFond', 200, popUpMDP, popUpFond, text);}/* * DEBUT PRISE EN COMPTE DE LA COMMANDE DIRECTE MULTIPLE */// Fonction permettant d'incr?menter la quantit? pour la commande directefunction incremanteQuantity(indice){if(!checkQuantity(indice)){}else{	if(document.getElementById('quantity[' + indice + ']').value*1<99)	document.getElementById('quantity[' + indice + ']').value=document.getElementById('quantity[' + indice + ']').value*1+1;	}}// Fonction permettant de d?cr?menter la quantit? pour la commmande directefunction decremanteQuantity(indice){if(!checkQuantity(indice)){}else{	if(document.getElementById('quantity[' + indice + ']').value*1>1)	document.getElementById('quantity[' + indice + ']').value=document.getElementById('quantity[' + indice + ']').value*1-1;	}}// Pour le lien "Voir nos autres marques"function show_commande_directe(divTarget, divLien){	// Rend visible l'ensemble de la commande directe	document.getElementById(divTarget).style.display = 'block';	// Rend invisible le lien pour ?tendre la commande directe	document.getElementById(divLien).style.display = 'none';}/* * FIN PRISE EN COMPTE DE LA COMMANDE DIRECTE MULTIPLE */// Fonction permettant d'incr?menter la quantit? pour la modification de lignefunction incremanteQuantity2(product_id){//modif 03-07-08if(!checkQuantity2(product_id)){}else {//fin modif	if(document.getElementById(product_id).value*1<99)	document.getElementById(product_id).value=document.getElementById(product_id).value*1+1;}}// Fonction permettant de d?cr?menter la quantit? pour la modification de lignefunction decremanteQuantity2(product_id){	if(document.getElementById(product_id).value*1>1)	document.getElementById(product_id).value=document.getElementById(product_id).value*1-1;}//met a jour la liste des couleurs correspondantes au mod?le choisifunction changeColorList(pref) {	if(pref == null){		pref='';		type = '&type=0';	}	else		type = '&type=0';	prefixe = pref;	// R?cup?ration infos produit	modele_id = $F(pref+"Modele");	//products_id = $F('proto_products_id');	// Appel AJAX	var url = 'ajax_tepspec_get_color_by_model_code_cart.php';	var pars = 'modele_id=' + modele_id + '&products_id=' + pref + type;	var myAjax = new Ajax.Request(		url,		{			method: 'get',			parameters: pars,			onComplete: change_color_list		});}function change_color_list(originalRequest){    $(prefixe + 'col').innerHTML = originalRequest.responseText;	/*changeDisponibility(prefixe);    changeProductsRef(prefixe);*/}function changeSizeList(pref) {	if(pref == null){	pref='';	type = '&type=0';	}	else		type = '&type=0';	prefixe = pref;	// Changement sizeList	// R?cup?ration infos produit	//Attention on recupere la valeur du premier select, donc si l'ordre change il faudra modier getElementsByTagName("select")[0].value;	//modele_id = document.getElementById( ).getElementsByTagName("select")[0].value;	modele_id = $F(pref + 'Modele');	//products_id = $F('proto_products_id');	// Appel AJAX	var url = 'ajax_tepspec_get_size_by_model_code_cart.php';	var pars = 'modele_id=' + modele_id + '&products_id=' + pref + type;	var myAjax = new Ajax.Request(		url,		{			method: 'get',			parameters: pars,			onComplete: change_size_list		});}//met a jour la liste des tailles correspondantes au modele choisifunction change_size_list(originalRequest){//    document.getElementById().getElementsByTagName("select")[2].innerHTML = originalRequest.responseText;	$(prefixe + 'tail').innerHTML = originalRequest.responseText;	changePrice(prefixe);	changeDisponibility(prefixe);}function changePrice(pref) {	//si pref==null on est dans une fiche produit normal	if(pref == null)pref='';	prefixe=pref;	// Changement du prix	// R?cup?ration infos produit	products_id = $F(pref+'product_id_ajax');	color_id = $F(pref+'Couleur');	size_id = $F(pref+'Taille');	support_id = $F(pref+'support_id_update');	// Appel AJAX	var url = 'ajax_tepspec_get_product_price_shopping_cart.php';	var pars = 'products_id=' + products_id + '&color_id=' + color_id + '&size_id=' + size_id + '&support_id=' + support_id;	var myAjax = new Ajax.Request(		url,		{			method: 'get',			parameters: pars,			onComplete: showResponse_products_price		});}function showResponse_products_price(originalRequest){	//put returned XML in the textareaif(originalRequest.responseText=="-"){//	alert('test');}	if(originalRequest.responseText == -1){		$('products_price' + prefixe).innerHTML = '&nbsp;';	}	else	{     	$('products_price' + prefixe).innerHTML = originalRequest.responseText;	}}function changeProductsRef(pref) {	//si pref==null on est dans une fiche produit normal	if(pref == null)pref='';	prefixe=pref;	// Changement ref	// R?cup?ration infos produit	products_id = $F(pref+'proto_products_id');	color_id = $F(pref+'Couleur');	// Appel AJAX	var url = 'ajax_tepspec_get_products_ref.php';	var pars = 'products_id=' + products_id + '&color_id=' + color_id;	var myAjax = new Ajax.Request(		url,		{			method: 'get',			parameters: pars,			onComplete: showResponse_products_ref		});}function showResponse_products_ref(originalRequest){	//put returned XML in the textarea	$(prefixe+'products_ref').innerHTML = originalRequest.responseText;}function changeDisponibility(pref) {	//si pref==null on est dans une fiche produit normal	if(pref == null)pref='';	prefixe=pref;	// Changement ref	// R?cup?ration infos produit	products_id = $F(pref+'proto_products_id');	color_id = $F(pref+'Couleur');	size_id = $F(pref+'Taille');	// Appel AJAX	var url = 'ajax_tepspec_get_products_disponibility.php';	var pars = 'products_id=' + products_id + '&color_id=' + color_id + '&size_id=' + size_id;	var myAjax = new Ajax.Request(		url,		{			method: 'get',			parameters: pars,			onComplete: showResponse_products_disponibility		});}function showResponse_products_disponibility(originalRequest){	//put returned XML in the textarea	$(prefixe+'products_disponibility').innerHTML = originalRequest.responseText;}function checkDisponibility(pref) {	//si pref==null on est dans une fiche produit normal	if(pref == null)pref='';	prefixe=pref;	// R?cup?ration infos produit	products_id = $F(pref+'proto_products_id');	color_id = $F(pref+'Couleur');	size_id = $F(pref+'Taille');	// Appel AJAX	var url_dispo_product = 'ajax_tepspec_get_products_disponibility_code.php';	var pars_dispo_product = 'products_id=' + products_id + '&color_id=' + color_id + '&size_id=' + size_id;	var myAjax = new Ajax.Request(    	url_dispo_product,		{			method: 'get',			parameters: pars_dispo_product,			onComplete: show_button_add_cart		});}// Fonction permettant de valider la popup de modification de ligne produit (dans le panier)function validateFormUpdateLine(idForm, priceOrNot, fieldQty, popupErrorQty){	// On test si la quantit? saisie est bien num?rique	qtyElement = parseInt(document.getElementById(fieldQty).value);	popupElement = document.getElementById(popupErrorQty);	if(parseInt(document.getElementById(fieldQty).value) < 0){		popupElement.style.display = "block";	}else{		if(!qtyElement){			popupElement.style.display = "block";		}else{			popupElement.style.display = "none";			// On test si les choix effectu?s dans les listes d?roulantes retourne un prix			targetElement = document.getElementById(priceOrNot);			if(targetElement == null)				document.getElementById(idForm).submit();			if(document.getElementById(priceOrNot).value == "noPrice"){				// On ne retrouve pas de prix. On ne valide pas le formulaire			}else{				// On r?cup?re un prix, on  valide donc le formulaire (price)				document.getElementById(idForm).submit();			}		}	}}//fonction qui bloque la validation d'un formulaire par la//saisie de la touche entree sur un champs de saisiefunction blockEntrer(e) {	var touche = window.event ? e.keyCode : e.which;	if(touche==13) {		return false;	}}//03-07-08 Ajout des fct checkQuantity pour empecher les commandes de fractions d'articlesfunction checkQuantity2(product_id){	if(isNaN(document.getElementById(product_id).value) || document.getElementById(product_id).value*1 < 1){		document.getElementById(product_id).value=1;	return false;	}return true;}function checkQuantity(indice){	if(isNaN(document.getElementById('quantity[' + indice + ']').value) || document.getElementById('quantity[' + indice + ']').value*1 < 1){		document.getElementById('quantity[' + indice + ']').value=1;	return false;	}return true;}
