

function PopulateDropDown(json, element){
	$(element).append("<option value=0>Choisir</option>");
    $.each(json['data'], function(){
        $(element).append($('<option></option').val(this.id).html(this.nom));
    });
}

function clearDropDown(element){
    $(element).empty("option");
}

function initRecherche(){
    listMarquesModeles();
}

function initBoutiquePanier(){
    if (jQuery('#blocEVO').length > 0) {
        jQuery("#ca").focus(function(){
            jQuery("#ca").val('');
            jQuery('#ca').effect('highlight', {}, 3000);
        })
        jQuery("#co").focus(function(){
            jQuery("#co").val('');
            jQuery('#co').effect('highlight', {}, 3000);
        })
        jQuery("#btnSetEVO").click(function(){
            boutiqueUpd('setevo', 'ca=' + jQuery('#ca').val() + '&co=' + jQuery('#co').val());
        })
    }
    if (jQuery('#tt').length > 0) {
        updST();
        jQuery('#tt').show("blind", {
            direction: "vertical"
        }, 1000);
    }
    if(window.boutique_panier_observeBoutons){boutique_panier_observeBoutons();}
    if (jQuery('#cp').length > 0) {
        jQuery("#cp").focus(function(e){
            $('cp').val('');
            jQuery('#cp').effect('highlight', {}, 3000);
        });
        jQuery("#btnSetCP").click(function(){
            boutiqueUpd('setcp', 'cp=' + jQuery('#cp').val());
        });
    }
    if (jQuery('#envoi').length > 0) {
        //alert('MDERRLNG46');
        jQuery("#envoi").change(boutique_choix_envoi);
    }
}

function initBoutiqueVitrine(){
    //prototype
    //if($('tt')){
    //jquery
    if (jQuery('#tt').length == 1) {
        updST();
        // prototype
        //new Effect.Highlight($('tt'));
    }
    
    //if($('blocEVO'))
    if (jQuery('#blocEVO').length > 0) {
        // cool
        //jQuery("#statut").dialog();
        //jQuery("<div>I'm in a dialog</div>").dialog()
        // jquery
        jQuery("#ca").focus(function(){
            jQuery("#ca").val('');
            jQuery('#ca').effect('highlight', {}, 3000);
        })
        jQuery("#co").focus(function(){
            jQuery("#co").val('');
            jQuery('#co').effect('highlight', {}, 3000);
        })
        jQuery("#btnSetEVO").click(function(){
            boutiqueUpd('setevo', 'ca=' + jQuery('#ca').val() + '&co=' + jQuery('#co').val());
        })
        // prototype
        //Event.observe('ca', 'focus', function(e){ $('ca').value = '';new Effect.Highlight($('ca'));});
        //Event.observe('co', 'focus', function(e){ $('co').value = '';new Effect.Highlight($('co'));});
        //Event.observe('btnSetEVO', 'click', function(e){boutiqueUpd('setevo','ca='+$('ca').value+'&co='+$('co').value);});
    }
}

function initBoutiqueDetailsItem(){
    if (itemOptions) {
		jQuery('#tableauOptions').effect('highlight', {}, 3000);
    }
    jQuery("#ajout_item").click(boutique_ajout_item)
    updST();
    //jQuery("#ajout_item").attr("disabled", "disabled");
    jQuery("#ajout_item").removeAttr("disabled");
    jQuery('#ajout_item').effect('highlight', {}, 3000);
}

function boutique_choix_envoi(){
    jQuery("#btnCheckOut").attr("disabled", "disabled");
    
    if (jQuery('#envoi').val() == 'null') {
        alert('Vous devez selectionner une m\351thode d\'envoi');
        return false;
    }
    else {
        boutiqueUpd('setenvoi', 'envoi=' + jQuery('#envoi').val());
        return true;
    }
}

function boutique_choix_option(){
    boutique_choix('change_options');
}

function boutique_ajout(){
    boutique_choix('ajout');
}

function boutique_subpanier(){
    if (jQuery('#envoi').length > 0) {
        if (boutique_choix_envoi()) {
            parent.location = '/boutique/co/';
        }
    }
    else {
        parent.location = '/boutique/co/';
    }
}


function boutique_choix(methode){
    tabData = new Array;
	var requete = false;
    for (var i = 0; i < tableauOptions.length; i++) {
		sel = jQuery('#'+tableauOptions[i]).val();
        if (sel == 0) {
            // Une valeur est a 0, on fait pas de requete
        }else{
			requete = true;
			tabData.push(sel);
		}
    }
    
    if (requete) {
        boutiqueUpd(methode, 'code=' + jQuery('#i').val() + '&options=' + tabData);
    }
    else {
        boutique_statut('Vous devez s&eacute;lectionner une option');
    }
}


function boutiqueUpd(fn, param){
    jQuery.ajax({
        type: "POST",
		async: false,
        url: "/boutique/ajax/" + fn,
        data: param,
        dataType: "script",
        beforeSend: function(){
            jQuery('#dataLoad').show();
        },
        complete: function(){
            jQuery('#dataLoad').hide();
        }
    });
    
}

function evalReponse(remote){
    jQuery('statut').innerHTML = '&nbsp;';
    eval(remote.responseText);
}

function boutique_changeImage(holder, photoId, lienId, photo){
    jQuery(photoId).src = "/images/boutique/petit/" + photo;
    jQuery(lienId).href = "javascript:PopupImage('/images/boutique/" + photo + "',320,240,'')";
    boutique_highlight('#tablePhoto');
}

function boutique_update_en_stock(texte){
    if ((texte != ' ') && (texte.length) && (texte != '&nbsp;')) {
        jQuery("#en_stock").html(texte);
    }
}


function boutique_ajout_item(){
    if (itemOptions) {
        tabData = new Array;
        optionOk = true;
        for (var i = 0; i < tableauOptions.length; i++) {      
			val = jQuery('#'+tableauOptions[i]).val();
            if (val == 0) {
                optionOk = false;
            }
            tabData.push(val);
        }
        
        if (optionOk) {
            boutiqueUpd('ajout', 'code=' + jQuery('#i').val() + '&options=' + tabData);
        }
        else {
            boutique_requis('#tableauOptions','Veuillez choisir un option');
        }
        
    }
    else {
        boutiqueUpd('ajout', 'code=' + jQuery('#i').val());
    }
}

function MDrequest(url, param, fn){ // url requeste, parametres, function si succes	
    jQuery.ajax({
        type: "POST",
        url: url,
		cache: false,
        data: param,
        dataType: "script",
        success: fn,
        beforeSend: function(){
            jQuery('#dataLoad').show();
        },
        complete: function(){
            jQuery('#dataLoad').hide();
        }
    });
}

function la(){
    MDrequest('/mdlive.php', 'f=la', receivedHandler)
}

function listMarquesModeles(){
    jQuery('#dataLoad').hide();
    jQuery('#frm_marque').attr("disabled", "disabled"); 
    jQuery('#frm_modele').attr("disabled", "disabled"); 

    if (jQuery('#marque_selected').val() == ""){
	    jQuery.getJSON("/mdlive.php?f=mm", function(json){
		 clearDropDown("#frm_marque");
		 PopulateDropDown(json, "#frm_marque");
		 jQuery('#frm_marque').removeAttr("disabled"); 
	    });
    }else{
	    jQuery.getJSON("/mdlive.php?f=mm", function(json){
		 clearDropDown("#frm_marque");
		 PopulateDropDown(json, "#frm_marque");
		 jQuery("#frm_marque").val(jQuery('#marque_selected').val());
		 jQuery('#frm_marque').removeAttr("disabled"); 
		 jQuery.getJSON("/mdlive.php?f=mm&id=" + jQuery('#frm_marque').val(), function(json){
		  PopulateDropDown(json, "#frm_modele");
		  jQuery("#frm_modele").val(jQuery('#modele_selected').val());
		  jQuery('#frm_modele').removeAttr("disabled"); 
		 });
	    });
    }
    
    jQuery('#frm_marque').change(function(){
		jQuery('#frm_modele').attr("disabled", "disabled"); 
        clearDropDown("#frm_modele");
        jQuery.getJSON("/mdlive.php?f=mm&id=" + jQuery('#frm_marque').val(), function(json){
            PopulateDropDown(json, "#frm_modele");
			jQuery('#frm_modele').removeAttr("disabled"); 
        });
    });
}

function listMarquesModelesOLD(){
    // MDrequest('/mdlive.php', 'f=mm', receivedHandler)
    jQuery('#dataLoad').hide();
    
	jQuery('#frm_marque').attr("disabled", "disabled"); 
    jQuery('#frm_modele').attr("disabled", "disabled"); 
	
    jQuery.getJSON("/mdlive.php?f=mm", function(json){
         clearDropDown("#frm_marque");
		 PopulateDropDown(json, "#frm_marque");
		jQuery('#frm_marque').removeAttr("disabled"); 
    });
    
    jQuery('#frm_marque').change(function(){
		jQuery('#frm_modele').attr("disabled", "disabled"); 
        clearDropDown("#frm_modele");
        jQuery.getJSON("/mdlive.php?f=mm&id=" + jQuery('#frm_marque').val(), function(json){
            PopulateDropDown(json, "#frm_modele");
			jQuery('#frm_modele').removeAttr("disabled"); 
        });
    });
}

function listProduits(){
    MDrequest('/mdlive.php', '', receivedHandler)
}

function listProduits2(){
    MDrequest('/mdlive.php', 'f=affiche_child&parent=0&type=C', receivedHandlerNew)
}

function verifinfos(place){
    if (place == "adhesion1") {
        //$('verifInfosEtape1').disabled = true;
        var check_ok = 1;
        
        if (check_ok != '0') {
            var str = 'section=adhesion&u=' + jQuery('#surnom').val() + '&e=' + jQuery('#courriel').val() + '&p=' + jQuery('#mpasse').val() + '&c=' + jQuery('#chkSurnom').val();
			jQuery.ajax({ type: 'POST', url: "/mdl/ajax/vn", dataType: 'script', data: str});
        }
    }
	else 
        if (place == "inscription") {
			var check_ok = 1;
        
	        if (check_ok != '0') {
	            var str = 'section=inscription&u=' + jQuery('#surnom').val() + '&e=' + jQuery('#courriel').val() + '&p=' + jQuery('#mpasse').val() + '&c=' + jQuery('#chkSurnom').val();
				jQuery.ajax({ type: 'POST', url: "/mdl/ajax/vn", dataType: 'script', data: str});
	        }
		}
    else 
        if (place == "adhesion2") {
            var check_ok = 1;
            
			// enleve les marqueurs
			jQuery(":input").removeClass("encercle_erreur");
			
            var typePaiement = jQuery('input[name=typePaiement]:checked').val();
            
            if (jQuery('#achat').length > 0) {
                if (!jQuery('#courriel').val()) {
                    boutique_requis('#courriel','Vous devez entrer une adresse courriel');
                    check_ok = 0;
                    return false;
                }
                if (jQuery('#courriel').val() != jQuery('#courriel2').val()) {
                    boutique_requis('#courriel2','Les adresses courriel sont diff&eacute;rentes');
                    check_ok = 0;
                    return false;
                }
            }
            
            if (!jQuery('#nom').val()) {
                boutique_requis('#nom','Vous devez entrer votre nom');
                check_ok = 0;
            }
            else 
                if (!jQuery('#prenom').val()) {
                    boutique_requis('#prenom','Vous devez entrer votre pr&eacute;nom');
                    check_ok = 0;
                }
                else 
                    if (!jQuery('#tel1a').val()) {
						boutique_requis('#tel1a','Vous devez entrer votre num&eacute;ro de t&eacute;l&eacute;phone');
                        check_ok = 0;
                    }
                    else 
                        if (!jQuery('#tel1b').val()) {
                            boutique_requis('#tel1b','Vous devez entrer votre num&eacute;ro de t&eacute;l&eacute;phone');
                            check_ok = 0;
                        }
                        else 
                            if (!jQuery('#tel1c').val()) {
                                boutique_requis('#tel1c','Vous devez entrer votre num&eacute;ro de t&eacute;l&eacute;phone');
                                check_ok = 0;
                            }
                            else 
                                if (!jQuery('#adresse').val()) {
                                    boutique_requis('#adresse','Vous devez entrer votre adresse postale');
                                    check_ok = 0;
                                }
                                else 
                                    if (!jQuery('#ville').val()) {
										boutique_requis('#ville','Vous devez entrer votre ville');
                                        check_ok = 0;
                                    }
                                    else 
                                        if (!jQuery('#codePostal').val()) {
											boutique_requis('#codePostal','Vous devez entrer votre code postal sous la forme (A2B 3C4)');
                                            check_ok = 0;
                                        }
                                        else 
                                            if (jQuery('#in_idRegion').val() == 0) {
												boutique_requis('#in_idRegion','Vous devez choisir une r&eacute;gion');
                                                check_ok = 0;
                                            }
                                            else 
                                                if (typePaiement == 'interac') {
                                                // rien de specifique
                                                }
                                                else 
                                                    if (typePaiement == 'credit') {
                                                        if (!jQuery('#cc_nom').val()) {
															boutique_requis('#cc_nom','Vous devez entrer le nom du d&eacute;tenteur de la carte');
                                                            check_ok = 0;
                                                        }
                                                        else 
                                                            if (!jQuery('#cc_num').val()) {
																boutique_requis('#cc_num','Vous devez entrer le num&eacute;ro de la carte de cr&eacute;dit');
                                                                check_ok = 0;
                                                            }
															else
																if(!valide_cc(jQuery('#cc_num').val())){
																	boutique_requis('#cc_num','Le num&eacute;ro de la carte de cr&eacute;dit est invalide');
                                                                	check_ok = 0;
																}
																else
																	if(jQuery('#cc_expMonth').val() == 0 || jQuery('#cc_expMonth').val() == ''){
																		boutique_requis('#cc_expMonth','La date d\'expirarion de la carte de cr&eacute;dit est invalide');
                                                                		check_ok = 0;
																	}
																	else
																		if(jQuery('#cc_expYear').val() == 0 || jQuery('#cc_expYear').val() == ''){
																			boutique_requis('#cc_expYear','La date d\'expirarion de la carte de cr&eacute;dit est invalide');
	                                                                		check_ok = 0;
																		}
			                                                            else 
			                                                                if (!jQuery('#cc_verif').val()) {
																				boutique_requis('#cc_verif','Vous devez entrer le num&eacute;ro de v&eacute;rification de la carte de cr&eacute;dit (cryptogramme)');
			                                                                    check_ok = 0;
			                                                                }
                                                    }
			if((jQuery('#politiques:checked').val() != 'OK') && (check_ok)){
					boutique_requis('#politiques','Vous devez accepter les mentions l&eacute;gales');
					check_ok = 0;
			}
			if (check_ok) {
                boutique_statut(' ');
                boutique_t('#etape2');
                boutique_t('#etape3');
                return true;
            }
            else {
                return false;
            }
        }
        else {
            boutique_statut('Erreur MD034');
            return false;
        }
}

function verifnickmembre(){

    var str = 'u=' + jQuery('#pa_surnom').val() + '&c=true&section=membres&e=' + jQuery('#pa_email').val() + '&p=' + jQuery('#pa_mpasse').val();
	jQuery.ajax({ type: 'POST', url: "/mdl/ajax/vn", dataType: 'script', data: str});
}

function valide_carte(no){
    var str = 'f=validation&noCarte=' + no;
	jQuery.ajax({ type: 'POST', url: "/boutique/ajax/vn", dataType: 'script', data: str});
}

function genFonction(listeXML){
    var fn = getNodeValue(listeXML, 'fn');
    var fnParam = getNodeValue(listeXML, 'fnParam');
    
    eval(fn)(listeXML, fnParam);
}

function listeModeles(listeXML, fnParam){
    var nomDropdown = getNodeValue(listeXML, 'options');
    var ddm = $(nomDropdown);
    var sel = ddm.val();
    
    if (sel != '0') {
        MDrequest('/mdlive.php', 'f=mm&id=' + sel, receivedHandler)
    }
}

function selModeles(listeXML, fnParam){
    var ddm = $(getNodeValue(listeXML, 'options'));
    var sel = ddm.val();
    
    if (sel != '0') {
        //$('modeletext').innerHTML	= 'Vous avez choisi le mod�le '+ddm[ddm.selectedIndex].text;
    }
}

function listeAttributs(listeXML, fnParam){
    var nomDropdown = getNodeValue(listeXML, 'options');
    var codeFinal = getNodeValue(listeXML, 'final');
    var parent = getNodeValue(listeXML, 'parent');
    var ddm = $(nomDropdown);
    var sel = ddm.val();
    
    
    if (sel != '0') {
        if (codeFinal != 1) {
            MDrequest('/mdlive.php', 'i=' + sel + '&p=' + parent + '&f=' + codeFinal, receivedHandler);
        }
    }
}

function errorHandler(remote){
    alert('Erreur survenue');
}

function validateurcarte(remote){
    jQuery('#statut').html('');
    jQuery('#statut').html(remote.responseText);
}

function updSTFE(r){
	 updST(); updFE();
}
function updST(){
    jQuery('#tp').text('');
	jQuery.ajax({ type: 'POST', url: "/boutique/tx/st", async: false, dataType: 'text', 
		success: function(data, textStatus) {
                      	jQuery('#tp').text(data);
        				jQuery('#tpt').effect('highlight', {}, 3000);
                  }
	});
}

function updFE(){
    jQuery('#fe').text('');
	jQuery.ajax({ type: 'POST', url: "/boutique/tx/fe", async: false, dataType: 'text', 
		success: function(data, textStatus) {
                      	jQuery('#fe').text(data);
        				jQuery('#few').effect('highlight', {}, 3000);
                  }
	});
}

function receivedHandlerNew(remote){
    var listeXML = remote.responseXML.documentElement;
    var tagId = getNodeValue(listeXML, 'tagId');
    var tagVal = getNodeValue(listeXML, 'tagVal');
    var tagFn = getNodeValue(listeXML, 'fn');
    var nomDropdown = getNodeValue(listeXML, 'options');
    var code_final = getNodeValue(listeXML, 'final');
    var parent = getNodeValue(listeXML, 'parent');
    var destination = getNodeValue(listeXML, 'destination');
    var niveau = getNodeValue(listeXML, 'niveau');
    var nbres = getNodeValue(listeXML, 'nbres');
    var suboptions = getNodeValue(listeXML, 'suboptions');
    
    
    if (nbres > 0) {
        if ($(nomDropdown)) {
            // si existe calcul position
            niveau++;
            PopulateXlist(listeXML, nomDropdown, tagId, tagVal, tagFn);
        }
        else {
            CreateAndPopulateXlist(listeXML, destination, nomDropdown, parent, tagId, tagVal, tagFn);
        }
    }
    else {
        $('debug').innerHTML = 'Aucunes donnees';
    }
    
}

function receivedAttribs(remote){
    var listeXML = remote.responseXML.documentElement;
    var tagId = getNodeValue(listeXML, 'tagId');
    var tagVal = getNodeValue(listeXML, 'tagVal');
    var tagFn = getNodeValue(listeXML, 'fn');
    var nomDropdown = getNodeValue(listeXML, 'options');
    var code_final = getNodeValue(listeXML, 'final');
    var parent = getNodeValue(listeXML, 'parent');
    var destination = getNodeValue(listeXML, 'destination');
    var niveau = getNodeValue(listeXML, 'niveau');
    var nbres = getNodeValue(listeXML, 'nbres');
    var suboptions = getNodeValue(listeXML, 'suboptions');
    
    
    
    if ($(nomDropdown)) {
        // si existe calcul position
        niveau++;
        PopulateXlist(listeXML, nomDropdown, tagId, tagVal, tagFn);
    }
    else {
        CreateAndPopulateXlist(listeXML, destination, nomDropdown, parent, tagId, tagVal, tagFn);
    }
    
    
}

function receivedHandler(remote){
    var listeXML = remote.responseXML.documentElement;
    var tagId = getNodeValue(listeXML, 'tagId');
    var tagVal = getNodeValue(listeXML, 'tagVal');
    var tagFn = getNodeValue(listeXML, 'fn');
    var nomDropdown = getNodeValue(listeXML, 'options');
    var code_final = getNodeValue(listeXML, 'final');
    var parent = getNodeValue(listeXML, 'parent');
    var destination = getNodeValue(listeXML, 'destination');
    var niveau = getNodeValue(listeXML, 'niveau');
    var nbres = getNodeValue(listeXML, 'nbres');
    var suboptions = getNodeValue(listeXML, 'suboptions');
    
    if (nbres > 0) {
        if ($(nomDropdown)) {
            // si existe calcul position
            niveau++;
            PopulateXlist(listeXML, nomDropdown, tagId, tagVal, tagFn);
        }
        else {
            CreateAndPopulateXlist(listeXML, destination, nomDropdown, parent, tagId, tagVal, tagFn);
        }
    }
    else {
        //$('debug').innerHTML	= 'Aucunes donnees';
    }
    
}

function getNodeValue(parent, tagName){
    var node = parent.getElementsByTagName(tagName)[0];
    return (node && node.firstChild) ? node.firstChild.nodeValue : '';
}

function GetInnerText(node){
    return (node.textContent || node.innerText || node.text);
}

function PopulateXlist(listeXML, nomDropdown, tagId, tagVal, tagFn){
    var xList = $(nomDropdown);
    
    xList.disabled = true;
    
    for (var count = xList.options.length - 1; count > -1; count--) {
        xList.options[count] = null;
    }
    
    listeXMLid = listeXML.getElementsByTagName(tagId);
    listeXMLval = listeXML.getElementsByTagName(tagVal);
    
    xList.options[xList.length] = new Option(' <------------------- Choisir ------------------->', '0', false, false);
    
    for (var count = 0; count < listeXMLid.length; count++) {
        texte = GetInnerText(listeXMLval[count]);
        valeur = GetInnerText(listeXMLid[count]);
        xList.options[xList.length] = new Option(texte, valeur, false, false);
    }
    
    // Si on a une valeur pour le tag option dans le XML, 
    // on observe les changements du select
    if (tagFn) {
        Event.observe(nomDropdown, 'change', function(){
            genFonction(listeXML)
        }, false);
    }
    
    xList.disabled = false;
    
}

function CreateAndPopulateXlist(listeXML, destination, nomDropdown, parent, tagId, tagVal, tagFn){

    var destLayer = $(destination);
    
    var nouveauSelect = document.createElement('select');
    
    nouveauSelect.setAttribute("id", nomDropdown);
    nouveauSelect.setAttribute("name", nomDropdown);
    
    listeXMLid = listeXML.getElementsByTagName(tagId);
    listeXMLval = listeXML.getElementsByTagName(tagVal);
    
    nouveauSelect.options[nouveauSelect.length] = new Option(' <------------------- Choisir ------------------->', '0', false, false);
    
    for (var count = 0; count < listeXMLid.length; count++) {
        texte = GetInnerText(listeXMLval[count]);
        valeur = GetInnerText(listeXMLid[count]);
        nouveauSelect.options[nouveauSelect.length] = new Option(texte, valeur, false, false);
    }
    
    destLayer.appendChild(nouveauSelect);
    
    // Si on a une valeur pour le tag option dans le XML, 
    // on observe les changements du select
    
    if (tagFn) {
        Event.observe(nouveauSelect, 'change', function(){
            genFonction(listeXML)
        }, false);
    }
    
}

function boutique_t(id){
    // prototype
    // new Effect.toggle($(id));	
    jQuery(id).toggle("slow");
}

function boutique_highlight(id){
    jQuery(id).effect('highlight', {}, 3000);
}

function boutique_mark(id){
	jQuery(id).effect('highlight', {}, 3000);
	jQuery(id).addClass("encercle_erreur");
}

function boutique_validated(id){
	if( jQuery(id).data('qtip') ) {
	 jQuery(id).qtip('destroy');
  }
	jQuery(id).removeClass("encercle_erreur");
	jQuery(id).addClass("encercle_validated");
	jQuery(id).attr("disabled","disabled");
}

function boutique_focus(id){
    jQuery(id).focus();
}

function boutique_requis(sel, msg){

	//jQuery(':input').qtip('destroy');

	//jQuery(sel).qtip("destroy");
	
	jQuery(":input").removeClass("encercle_erreur");
	if (sel.length) {
		jQuery(sel).qtip({
			content: { prerender: true, text: msg },
			show: {
				solo: true,
				ready: true
			},
			style: {
				padding: 2,
				textAlign: 'left',
				border: {
					width: 7,
					radius: 5
				},
				tip: 'topLeft',
				target: 'bottomLeft',
				name: 'cream'
			}
		});
		boutique_focus(sel);
		boutique_mark(sel);
	}
	//jQuery(sel).qtip('show');
}

function boutique_statut(texte){
    //if (jQuery('#statut').length > 0) {
        //jQuery("#statut").html(texte);
		if ((texte != ' ') && (texte != '') && (texte.length) && (texte != '&nbsp;')) {
			//jQuery("#statut").html(texte);
			//jQuery("#boite_info").show();
			//boutique_highlight("#boite_info");
			//jQuery("#statut").dialog('destroy');
			//jQuery("#statut").dialog({width: 500,height: 200});
			jQuery.fn.colorbox.init();
			jQuery.fn.colorbox({width: 400,height: 'auto', rel: 'info', overlayClose: true, modal: false, html: texte,opacity: 0.75,scrollbars: false});
			//jQuery.fn.colorbox.resize();
		}else{
			//jQuery("#boite_info").hide();
		}
    //}
}

function boutique_alerte(texte){
	jQuery("#statut").hide();
    jQuery("#statut").html(texte);
	alert(jQuery("#statut").html());
}

function autotab(current, to){
    if (current.getAttribute &&
    current.value.length == current.getAttribute("maxlength")) {
        to.focus()
    }
}

function boutique_ctp(){
    // prototype
    // var typePaiement = Form.getInputs('txinfos','radio','typePaiement').find(function(radio) { return radio.checked; }).value;
    
    var typePaiement = jQuery('input[name=typePaiement]:checked').val();
    
    if (typePaiement == 'interac') {
        // prototype
        //Effect.Appear($('div_interac')); new Effect.Fade($('div_credit'));
        jQuery("#div_interac").show("slow");
        jQuery("#div_credit").hide("slow");
    }
    else 
        if (typePaiement == 'credit') {
            // prototype
            //Effect.Appear($('div_credit')); new Effect.Fade($('div_interac'));
            jQuery("#div_credit").show("slow");
            jQuery("#div_interac").hide("slow");
        }
        else {
            // prototype
            //Effect.Fade($('div_credit')); new Effect.Fade($('div_interac'));
            jQuery("#div_credit").hide("slow");
            jQuery("#div_interac").hide("slow");
        }
}


function valide_cc(s) {
// remove non-numerics
var v = "0123456789";
var w = "";
for (i=0; i < s.length; i++) {
x = s.charAt(i);
if (v.indexOf(x,0) != -1)
w += x;
}
// validate number
j = w.length / 2;
if (j < 6.5 || j > 8 || j == 7) return false;
k = Math.floor(j);
m = Math.ceil(j) - k;
c = 0;
for (i=0; i<k; i++) {
a = w.charAt(i*2+m) * 2;
c += a > 9 ? Math.floor(a/10 + a%10) : a;
}
for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
return (c%10 == 0);
}


