var flg_affWait=0;
var chrSep="||";
var chrEgal="%|%";
var flg_insImgCart='';
var flg_insImgGal='';
var flg_insImg1='';
var flg_insImg2='';
var flg_insImgLib='';
var flg_insImgProm='';
var txt_insImgGal=new Array();
var tx_insImgGal="";
var tx_insImgCart="";
var tx_insImgMod="";
var flg_insImgMod='';
var regImaFrm1=0;
var regImaFrm2=0;
var retAjIdFiche='';
var flg_ajSaveOnglRefOptBis='';
var flg_ajsupMediaLst=0;
var moduleChoixIdFic;
var flg_fiCibl;
var flg_nmCibl;
function setGetPlanBo() {
	var val = this.req.responseText;	

	var node = new Element('div', {id:'choixFiche'}).update(val);
	
	Modalbox.show(node, {title: "Veuiller choisir une fiche", width: 600, afterHide:afterHideChoixFic});
	
}

function afterHideChoixFic() {
	if(moduleChoixIdFic != null) {
		sendAjax('GetPromoModule', moduleChoixIdFic);
		moduleChoixIdFic = null;
	}
	
}

function setChoixFiche(id_, type, typeRub, url, isPromo, libelReg, libelRub, libelCat, libelFiche) {
	if(type == 'fic' & isPromo == 1) {
		moduleChoixIdFic = id_;
	}
	Modalbox.hide();
	if(type=="rub" || type=="ass" || type=="dep"){
		if(type!="rub"){
			var cib=type;
		}else{
			var cib='';
		}
		$('idCibl'+cib).value=id_;
		$('tyCibl'+cib).value=typeRub;
		$('rgCibl'+cib).value=libelReg;
		$('ruCibl'+cib).value=libelRub;
		$('caCibl'+cib).value=libelCat;
	}else if(!isPromo){
		$('idCibl').value=id_;
		$('tyCibl').value=type;
		$('fiCibl').value=url;
		$('nmCibl').value=libelFiche;
	}else{
		flg_tyCibl=type;
		flg_fiCibl=url;
		flg_nmCibl=libelFiche;
	}
	
	//alert(id_ + ' / ' + type + ' / ' + typeRub + ' / ' + url + ' / ' + isPromo + ' / ' + libelReg + ' / ' + libelRub + ' / ' + libelCat + ' / ' + libelFiche);
}

function setGetPromoModule() {
	Modalbox.afterHide = null;

	var val = this.req.responseText;	

	var node = new Element('div', {id:'choixPromo'}).update(val);
	
	Modalbox.show(node, {title: "Veuiller choisir une promotion", width: 300});
}

function setChoixPromo(id_fiche, id_promo, libel_promo) {
	Modalbox.hide();
	$('idCibl').value=id_fiche;
	$('fiCibl').value=flg_fiCibl;
	$('tyCibl').value=flg_tyCibl;
	$('nmCibl').value=flg_nmCibl;
	$('idprCibl').value=id_promo;
	$('prCibl').value=libel_promo;
	//alert(id_fiche + ' / ' + id_promo);
}

function ajMajActivLg(id_) {
	sendAjax('MajActivLg', id_, $(id_).checked);
}
function setMajActivLg() {
	var val = this.req.responseText;
	if(val != '1') {
		alert("Un problème est survenu sur la base de donnée. Merci de contacter un administrateur");
	}
	else {
		alert("Modification effectuée");
	}
}
function ajRefrOngl(){
	affWait();
	document.frm.submit();
}
function extractValue(df){
	var el,tt,vl,rr;
	var i=0;
	var txt="";var tmp="";
	while(df[i]){
		el=df[i];
		rr=1;
		if(el.name!=""){
			switch(el.type){
				case "radio":
					tt=el.name;
					vl="";
					if(tt!=tmp){
						for(a=0;a<df[tt].length;a++){if(df[tt][a].checked){vl=df[tt][a].value;}}
						tmp=tt;
					}else{rr=0;}
					break;
				case "checkbox":
					vl="";
					if(el.checked){vl=el.value;}
					break;
				default:
					vl=el.value;
			}
			if(rr){
				txt+=chrSep+el.name + chrEgal +vl;
			}
		}
		i++;
	}
	return txt;
}
function ajSaveOnglSel1(n){
	var txt=flg_insImg1;
	var df=document.forms["intFrm1"].elements;
	txt+=chrSep+"ongl"+chrEgal+"presentation"+chrSep+"sOngl"+chrEgal+"1"+chrSep+"idImLg"+chrEgal + n + extractValue(df);
	sendAjax('save_onglet',chrSep, chrEgal, txt);
}
function ajSaveOnglSel2(n){
	var txt=flg_insImg2;
	var df=document.forms["intFrm2"].elements;
	txt+=chrSep+"ongl"+chrEgal+"presentation"+chrSep+"sOngl"+chrEgal+"2"+chrSep+"typArt"+chrEgal+"pres"+chrSep+"idImLg"+chrEgal + n + extractValue(df);
	sendAjax('save_onglet',chrSep, chrEgal, txt);
}
function ajSaveOnglSelLib(n){
	var txt="idImLg"+chrEgal + n + chrSep + flg_insImgLib;
	sendAjax('save_onglet',chrSep, chrEgal, txt);
}
function ajSaveOnglSelCart(n){
	var txt="idImLg" + chrEgal + n + chrSep + flg_insImgCart;
	sendAjax('save_onglet',chrSep, chrEgal, txt);
}
function ajSaveOnglSelFlCart(n){
	var txt="idFlash" + chrEgal + n + chrSep + flg_insImgCart;
	if(insImg0.$('imart').value!=''){
		flg_insImgCart=txt;
		eval(tx_insImgCart);
		return false;
	}else{
		sendAjax('save_onglet',chrSep, chrEgal, txt);
	}
}
function ajSaveOnglSelProm(n){
	var txt="idImLg" + chrEgal + n + chrSep + flg_insImgProm;
	sendAjax('save_onglet',chrSep, chrEgal, txt);
}
function ajSaveOnglSelGal(n){
	var txt="idImLg" + chrEgal + n + chrSep + flg_insImgGal;
	sendAjax('save_onglet',chrSep, chrEgal, txt);
}
function ajSaveOnglSelFlGal(n){
	var txt="idFlash" + chrEgal + n + chrSep + flg_insImgGal;
	if(insImgg.$('imart').value!=''){
		flg_insImgGal=txt;
		eval(tx_insImgGal);
		return false;
	}else{
		sendAjax('save_onglet',chrSep, chrEgal, txt);
	}
}
function ajSaveOnglSel(idOng, idFiche, idRegion, idRubMod, idRubCat) {
	affWait();
	if(idFiche==''){idFiche=retAjIdFiche;}
	var txt='idOng'+ chrEgal + idOng + chrSep + 'idFiche'+ chrEgal + idFiche + chrSep + 'idRegion'+ chrEgal + idRegion + chrSep + 'idRubMod'+ chrEgal + idRubMod + chrSep + 'idRubCat'+ chrEgal + idRubCat;
	if(idOng=="4"){
		var df=document.forms["frmTag"+flg_selectOngletFic].elements;
		txt+=chrSep + "ongl"+chrEgal+"tag"+chrSep+"sOngl"+chrEgal + flg_selectOngletFic + extractValue(df);
	}else if(idOng=="5"){
		var df=document.forms["frmMeta"+flg_selectOngletFic].elements;
		txt+=chrSep + "ongl"+chrEgal+"meta"+chrSep+"sOngl"+chrEgal + flg_selectOngletFic + extractValue(df);
	}else if(idOng=="6"){
		if(flg_selectOngletFic==2){
			if($('rgCibldep').value!=""){
				if(!confirm("Vous êtes sur le point de déplacer cette fiche vers une autre rubrique.\nEtes vous sûr de vouloir continuer ?")){
					hideWait();return false;
				}
				var selAssDep="dep";
			}else{
				alert("Vous devez selectionner une rubrique !");
				hideWait();return false;
			}
		}else{
			if($('rgCiblass').value!=""){
				if(!confirm("Vous êtes sur le point de dupliquer cette fiche à une autre rubrique.\nEtes vous sûr de vouloir continuer ?")){
					hideWait();return false;
				}
				var selAssDep="ass";
			}else{
				alert("Vous devez selectionner une rubrique !");
				hideWait();return false;
			}
		}
		var df=document.forms["mod"+selAssDep].elements;
		txt+=chrSep + "ongl"+chrEgal+"assoc"+chrSep+"sOngl"+chrEgal + flg_selectOngletFic + extractValue(df);
	}else{
		switch(flg_selectOngletFic){
			case "1":
			case 1:
				if(idOng=="0"){
					switch(flg_selectSsOngletFic){
						case "1":
						case 1:
							if($('txtLstCli').value.substr(0,5)=="Id: -"){
								alert('Vous devez selectionner un compte client !');hideWait();return false;
							}
							if($('gpsGG').value!=""){
								var ttp=$('gpsGG').value.split(",");
								if(ttp.length!=2){alert('Le format "Coord. Google" n\'est pas valide !');hideWait();return false;}
							}
							if(insInf.$('imart').value!=""){
								flg_insImg1=txt;
								insInf.saveImg(idFiche,'',1,idRegion);
								return false;
							}
							break;
						case "2":
						case 2:
							var e = xGetElementsByClassName('dvVersBlock', '', 'div'); 
							for (var i = 0; i < e.length; i++) {
								if($(e[i]).id.substr(9,1)=="1"){txt+=chrSep+"cont[" + $(e[i]).id.substr(10) + "]"+chrEgal + $(e[i]).innerHTML;}
							}
							if(insImg1.$('imart').value!=''){
								flg_insImg2=txt+chrSep+"typArt"+chrEgal+"pres";
								insImg1.saveImg(idFiche,'article/',2,idRegion);
								return false;
							}
							break;
					}
					var df=document.forms["intFrm"+flg_selectSsOngletFic].elements;
					txt+=chrSep + "ongl"+chrEgal+"presentation"+chrSep+"sOngl"+chrEgal + flg_selectSsOngletFic+chrSep+"typArt"+chrEgal+"pres" + extractValue(df);
					if($('preact2')){if($('preact2').checked){txt+=chrSep + "preact"+chrEgal+"1";}else{txt+=chrSep + "preact"+chrEgal+"0";}}
				}else{
					hideWait();
					return;
				}
				break;
			case 2:
			case "2":
			case "2e":
				if($('idmedia')){
					var df=document.forms["libGal"].elements;
					var ty,tmty,flgty;
					txt+=chrSep + 'typmed'+chrEgal;
					if($('chxMed1').checked){
						txt+=1;ty=1;tmty="f";
					}else if($('chxMed2').checked){
						txt+=2;ty=2;tmty="v";
					}else{
						txt+=3;ty=3;tmty="i";
					}
					flgty=1;
					if($('idmedia').value.substr(0,1)!=tmty && $('idmedia').value!="A"){
						if(!confirm("Vous êtes sur le point de modifier le type de media,\nl'ancien media sera supprimé.\nEtes vous sûr de vouloir continuer ?")){
							flgty=0;
						}
					}
					if(!flgty){hideWait();return;}
					txt+=chrSep + "ongl"+chrEgal+"galerie" + extractValue(df);
					if(insFlash.$('flhart').value!=''){
						flg_insImgGal=txt;
						tx_insImgGal="insImgg.saveImg("+idFiche+",'Gal',"+ty+","+idRegion+",'"+$('idmedia').value+"');";
						insFlash.saveFlash(idFiche,'FlGal',ty,idRegion,$('idmedia').value);
						return false;
					}
					if(insImgg.$('imart').value!=''){
						flg_insImgGal=txt;
						insImgg.saveImg(idFiche,'Gal',ty,idRegion,$('idmedia').value);
						return false;
					}
				}else{
					if(document.forms["libFrm"]){
						var df=document.forms["libFrm"].elements;
						txt+=chrSep + "ongl"+chrEgal+"presentation"+chrSep+"sOngl"+chrEgal+"2"+chrSep+"typArt"+chrEgal+"libre" + extractValue(df);
						var e = xGetElementsByClassName('dvVersBlock', '', 'div'); 
						for (var i = 0; i < e.length; i++) {
							if($(e[i]).id.substr(9,1)=="3"){txt+=chrSep + "cont[" + $(e[i]).id.substr(10) + "]"+chrEgal + $(e[i]).innerHTML;}
						}
						if(insImg3.$('imart').value!=''){
							flg_insImgLib=txt;
							insImg3.saveImg(idFiche,'article/','Lib',idRegion);
							return false;
						}
					}else{
						var df=document.forms["libCart"].elements;
						txt+=chrSep + "ongl"+chrEgal+"presentation"+chrSep+"sOngl"+chrEgal+"2"+chrSep+"typArt"+chrEgal+"cart" + extractValue(df);
						var e = xGetElementsByClassName('dvVersBlock', '', 'div'); 
						for (var i = 0; i < e.length; i++) {
							if($(e[i]).id.substr(9,1)=="0"){txt+=chrSep + "cont[" + $(e[i]).id.substr(10) + "]"+chrEgal + $(e[i]).innerHTML;}
						}
						if(insFlash.$('flhart').value!=''){
							if(insImg0.$('imart').value!=''){
								flg_insImgGal=txt;
								insImg0.$('idit').value='f';
								tx_insImgCart="insImg0.saveImg("+idFiche+",'article/','Cart',"+idRegion+");";
								insFlash.saveFlash(idFiche,'FlCart',ty,idRegion,$('idmedia').value);
								return false;
							}else if($('ediArtIma01').style.display=='none'){
								hideWait();
								alert("L'image de la vignette est manquante !");
								return false;
							}
						}else if($('chpVideo').value!=''){
							if(insImg0.$('imart').value=='' && $('ediArtIma01').style.display=='none'){
								hideWait();
								alert("L'image de la vignette est manquante !");
								return false;
							}else{
								insImg0.$('idit').value='v';
							}
						}
						if(insImg0.$('imart').value!=''){
							flg_insImgCart=txt;
							insImg0.saveImg(idFiche,'article/','Cart',idRegion);
							return false;
						}
						
					}
				}
				break;
			case "3":
			case 3:
				var df=document.forms["promFrm"].elements;
				txt+=chrSep + "ongl"+chrEgal+"promotion"+chrSep+"sOngl"+chrEgal + flg_selectSsOngletFic +chrSep +"isActif_pro"+chrEgal;
				if($('isActif_pro').checked){txt+="1";}else{txt+="0";}
				txt+=extractValue(df);
				if($('onglS11')){
					var e = xGetElementsByClassName('dvVersBlock', '', 'div'); 
					for (var i = 0; i < e.length; i++) {
						if($(e[i]).id.substr(9,1)=="4"){txt+=chrSep + "cont[" + $(e[i]).id.substr(10) + "]"+chrEgal + $(e[i]).innerHTML;}
					}
					if(insImg4.$('imart').value!=''){
						flg_insImgProm=txt;
						insImg4.saveImg(idFiche,'article/','Prom',idRegion);
						return false;
					}
				}
				break;
			case "3e":
				var df=document.forms["libCartMeta"].elements;
				txt+=chrSep + "ongl"+chrEgal+"meta_cartouche"+chrSep+"sOngl"+chrEgal+"2"+chrSep+"typArt"+chrEgal+"cart" + extractValue(df);
				break;
			default:
			return false;
		}
	}	
	sendAjax('save_onglet',chrSep, chrEgal, txt);
}
function setsave_onglet(){
	getAjaxReponse(this);
	hideWait();
}
function ajSaveOnglSelReg(idOng, idFiche, idRegion){
	affWait();
	if(idFiche==''){idFiche=retAjIdFiche;}
	var txt='idOng'+chrEgal + idOng + chrSep + 'idFiche'+chrEgal + idFiche + chrSep + 'idRegion'+chrEgal + idRegion+ chrSep + 'idRubMod'+chrEgal+'13';
	if(idOng==1){
		txt+=chrSep + "ongl"+chrEgal+"rubrique" + chrSep + "chkReg"+chrEgal;
		if($('isRegAct').checked){txt+="1";}else{txt+="0";}
		var e = xGetElementsByClassName('ddIntOff', '', 'div'); 
		for (var i = 0; i < e.length; i++) {
			txt+=chrSep + "idm[" + $(e[i]).id.substr(5) + "]"+chrEgal + reg_chxRubInt[$(e[i]).id.substr(5)];
		}
	}else if(idOng=="4"){
		var df=document.forms["frmTag"+flg_selectOngletFic].elements;
		txt+=chrSep + "ongl"+chrEgal+"tag"+chrSep+"sOngl"+chrEgal + flg_selectOngletFic + extractValue(df);
	}else if(idOng=="5"){
		var df=document.forms["frmMeta"+flg_selectOngletFic].elements;
		txt+=chrSep + "ongl"+chrEgal+"meta"+chrSep+"sOngl"+chrEgal + flg_selectOngletFic + extractValue(df);
	}else{
		switch(flg_selectOngletFic){
			case "1":
			case 1:
				switch(flg_selectSsOngletFic){
					case 1:
					case "1":
						if($('gpsGG').value!=""){
							var ttp=$('gpsGG').value.split(",");
							if(ttp.length!=2){alert('Le format "Coord. Google" n\'est pas valide !');hideWait();return false;}
						}
						break;
					case "2":
					case 2:
						var e = xGetElementsByClassName('dvVersBlock', '', 'div'); 
						for (var i = 0; i < e.length; i++) {
							if($(e[i]).id.substr(9,1)=="1"){txt+=chrSep+"cont[" + $(e[i]).id.substr(10) + "]"+chrEgal + $(e[i]).innerHTML;}
						}
						if(insImg1.$('imart').value!=''){
							flg_insImg2=txt+chrSep+"typArt"+chrEgal+"pres";;
							insImg1.saveImg(idFiche,'article/',2,idRegion);
							return false;
						}
						break;
				}
				var df=document.forms["intFrm"+flg_selectSsOngletFic].elements;
				txt+=chrSep + "ongl"+chrEgal+"presentation" + chrSep + "sOngl"+chrEgal + flg_selectSsOngletFic + chrSep+"typArt"+chrEgal+"pres" + extractValue(df);
				break;
			case 2:
			case "2":
			case "2e":
				if($('idmedia')){
					var df=document.forms["libGal"].elements;
					var ty,tmty,flgty;
					txt+=chrSep + 'typmed'+chrEgal;
					if($('chxMed1').checked){
						txt+=1;ty=1;tmty="f";
					}else if($('chxMed2').checked){
						txt+=2;ty=2;tmty="v";
					}else{
						txt+=3;ty=3;tmty="i";
					}
					flgty=1;
					if($('idmedia').value.substr(0,1)!=tmty && $('idmedia').value!="A"){
						if(!confirm("Vous êtes sur le point de modifier le type de media,\nl'ancien media sera supprimé.\nEtes vous sûr de vouloir continuer ?")){
							flgty=0;
						}
					}
					if(!flgty){hideWait();return;}
					txt+=chrSep + "ongl"+chrEgal+"galerie" + extractValue(df);
					if(insFlash.$('flhart').value!=''){
						flg_insImgGal=txt;
						tx_insImgGal="insImgg.saveImg("+idFiche+",'Gal',"+ty+","+idRegion+",'"+$('idmedia').value+"');";
						insFlash.saveFlash(idFiche,'FlGal',ty,idRegion,$('idmedia').value);
						return false;
					}
					if(insImgg.$('imart').value!=''){
						flg_insImgGal=txt;
						insImgg.saveImg(idFiche,'Gal',ty,idRegion,$('idmedia').value);
						return false;
					}
				}else{
					if(document.forms["libFrm"]){
						var df=document.forms["libFrm"].elements;
						txt+=chrSep + "ongl"+chrEgal+"presentation"+chrSep+"sOngl"+chrEgal+"2"+chrSep+"typArt"+chrEgal+"libre" + extractValue(df);
						var e = xGetElementsByClassName('dvVersBlock', '', 'div'); 
						for (var i = 0; i < e.length; i++) {
							if($(e[i]).id.substr(9,1)=="3"){txt+=chrSep + "cont[" + $(e[i]).id.substr(10) + "]"+chrEgal + $(e[i]).innerHTML;}
						}
						if(insImg3.$('imart').value!=''){
							flg_insImgLib=txt;
							insImg3.saveImg(idFiche,'article/','Lib',idRegion);
							return false;
						}
					}else{
						var df=document.forms["libCart"].elements;
						txt+=chrSep + "ongl"+chrEgal+"presentation"+chrSep+"sOngl"+chrEgal+"2"+chrSep+"typArt"+chrEgal+"cart" + extractValue(df);
						var e = xGetElementsByClassName('dvVersBlock', '', 'div'); 
						for (var i = 0; i < e.length; i++) {
							if($(e[i]).id.substr(9,1)=="0"){txt+=chrSep + "cont[" + $(e[i]).id.substr(10) + "]"+chrEgal + $(e[i]).innerHTML;}
						}
						if(insFlash.$('flhart').value!=''){
							if(insImg0.$('imart').value!='' || $('ediArtIma01').style.display!='none'){
								flg_insImgGal=txt;
								insImg0.$('idit').value='f';
								tx_insImgCart="insImg0.saveImg("+idFiche+",'article/','Cart',"+idRegion+");";
								insFlash.saveFlash(idFiche,'FlCart',ty,idRegion,$('idmedia').value);
								return false;
							}else{
								hideWait();
								alert("L'image de la vignette est manquante !");
								return false;
							}
						}else if($('chpVideo').value!=''){
							if(insImg0.$('imart').value=='' && $('ediArtIma01').style.display=='none'){
								hideWait();
								alert("L'image de la vignette est manquante !");
								return false;
							}else{
								insImg0.$('idit').value='v';
							}
						}
						if(insImg0.$('imart').value!=''){
							flg_insImgCart=txt;
							insImg0.saveImg(idFiche,'article/','Cart',idRegion);
							return false;
						}
					}
				}
				break;
			case "3e":
				var df=document.forms["libCartMeta"].elements;
				txt+=chrSep + "ongl"+chrEgal+"meta_cartouche"+chrSep+"sOngl"+chrEgal+"2"+chrSep+"typArt"+chrEgal+"cart" + extractValue(df);
				break;
			default:
			return false;
		}
	}
	sendAjax('save_onglet',chrSep, chrEgal, txt);
}
function ajSupEdiArtImaSo(idArt,so){
	if(confirm("Vous êtes sur le point de supprimer cette image.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		sendAjax('sup_ima_article',idArt,so);
	}
}
function setsup_ima_article() {
	getAjaxReponse(this);
	hideWait();
}
function ajSupEdiImgImaSo(idIma){
	if(confirm("Vous êtes sur le point de supprimer cette image.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		sendAjax('sup_image',idIma);
	}
}
function setsup_image() {
	getAjaxReponse(this);
	hideWait();
}
function ajSupCatImaSo(idRubCat){
	if(confirm("Vous êtes sur le point de supprimer cette image.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		sendAjax('sup_ima_cat',idRubCat);
	}
}
function setsup_ima_cat(){
	getAjaxReponse(this);
	hideWait();
}
function ajSupRubImaSo(idRub, $col){
	if(confirm("Vous êtes sur le point de supprimer cette image.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		sendAjax('sup_ima_rub',idRub, $col);
	}
}
function setsup_ima_rub(){
	getAjaxReponse(this);
	hideWait();
}
function ajSupEdiFicImaSo(idIma){
	if(confirm("Vous êtes sur le point de supprimer cette image.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		sendAjax('sup_image_fiche',idIma);
	}
}
function setsup_image_fiche() {
	var txt = this.req.responseText;
	alert("L'image à été supprimée !");
	document.frm.submit();
}
function ajSaveOnglRefOpt(n){
	affWait();
	var tt=$('btAjOpt' + flg_selectOngletFic).name.substring(5);
	var txt='idOng'+chrEgal + flg_selectOngletFic + chrSep + 'idMod'+chrEgal + tt + chrSep + 'idOpt'+chrEgal + flg_opInsImgOpt + chrSep + 'idReg'+chrEgal + n;
	i=1;
	while($('txt'+tt+'_'+i)){
		txt+=chrSep +$('txt'+tt+'_'+i).name+chrEgal+$('txt'+tt+'_'+i).value;
		i++;
	}
	var df=document.forms["intFrm"].elements;
	txt+=extractValue(df);
	if(insOpt.$('imart').value!=''){
		flg_ajSaveOnglRefOptBis=txt;
		insOpt.saveImg(flg_opInsImgOpt,tt,flg_selectOngletFic,n);
		return false;
	}else{
		sendAjax('save_option',chrSep, chrEgal, txt);
	}
}
function ajSaveOnglRefOptBis(n){
	var txt=flg_ajSaveOnglRefOptBis+chrSep+"idImLg"+chrEgal + n;
	sendAjax('save_option',chrSep, chrEgal, txt);
}
function ajSupOnglRefOpt(n){
	if(confirm("Vous êtes sur le point de supprimer cette option.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		var tt=$('btAjOpt' + flg_selectOngletFic).name.substring(5);
		var txt='idOng'+chrEgal + flg_selectOngletFic + chrSep + 'idMod'+chrEgal + tt + chrSep + 'idOpt'+chrEgal + n + chrSep + 'supOpt'+chrEgal+'1';
		sendAjax('save_option',chrSep, chrEgal, txt);
	}
}
function setsave_option(){
	getAjaxReponse(this);
	hideWait();
}
function ajEdiLien(id){
	affWait();
	var txt=chrSep+"sOngl"+chrEgal + flg_selectOngletFic + chrSep + "idLien"+chrEgal + id;
	sendAjax('edit_obj_lien',chrSep, chrEgal, txt);
}
function setedit_obj_lien(){
	getAjaxReponse(this);
	hideWait();
}
function ajNewLien(){
	switch(flg_selectOngletFic){
		case "1":var nmTg="actu";break;
		case "2":var nmTg="bdp";break;
	}
	var e = xGetElementsByClassName('tagInp'+nmTg, '', 'input'); 
	for (var i = 0; i < e.length; i++) {
		$(e[i]).value="";
	}
	$('btNewLien'+nmTg).style.display='none';
	reg_ccLienRo[nmTg]=0;
	$('ccLienRo'+nmTg).style.visibility='hidden';
	$('ccLienRo'+nmTg).style.visibility='hidden';
	var df=document.forms["frmLien"+flg_selectOngletFic].elements;
	df["idLien"].value="";
	df["liact"].checked=false;
	df["tar"].value="blank";
	$('affModLien'+nmTg).innerHTML="Mode: Création";
}
function ajSaveLien(){
	affWait();
	var df=document.forms["frmLien"+flg_selectOngletFic].elements;
	var txt=chrSep+"sOngl"+chrEgal + flg_selectOngletFic + extractValue(df);
	sendAjax('save_obj_lien',chrSep, chrEgal, txt);
}
function ajSupLien(n){
	if(confirm("Vous êtes sur le point de supprimer ce lien.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		var txt='sOngl'+chrEgal + flg_selectOngletFic + chrSep + 'idLien'+chrEgal + n + chrSep + 'supLien'+chrEgal+'1';
		sendAjax('save_obj_lien',chrSep, chrEgal, txt);
	}
}
function setsave_obj_lien(){
	getAjaxReponse(this);
	hideWait();
}
function ajActLien(id){
	if($('lienIsAct'+id).checked){var txt="d'activer";var acc=false;}else{var txt="de désactiver";var acc=true;}
	if(confirm("Vous êtes sur le point "+ txt +" ce lien.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		sendAjax('act_lien', id, $('lienIsAct'+id).checked);
	}else{
		$('lienIsAct'+id).checked=acc;
	}
}
function setact_lien(){
	getAjaxReponse(this);
	hideWait();
}
function ajNewOnglObjTag(){
	var e = xGetElementsByClassName('tagInp', '', 'input'); 
	for (var i = 0; i < e.length; i++) {
		$(e[i]).value="";
	}
	switch(flg_selectOngletFic){
		case "1":var nmTg="fic";break;
		case "2":var nmTg="class1";break;
		case "3":var nmTg="class2";break;
	}
	$('btNewTag'+nmTg).style.display='none';
	var df=document.forms["frmTag"+flg_selectOngletFic].elements;
	df["idTag"].value="";
	
	$('affModTag'+nmTg).innerHTML="Mode: Création";
}
function ajEdiTag(id){
	affWait();
	var txt=chrSep+"sOngl"+chrEgal + flg_selectOngletFic + chrSep + "idTag"+chrEgal + id;
	sendAjax('edit_obj_tag',chrSep, chrEgal, txt);
}
function setedit_obj_tag(){
	getAjaxReponse(this);
	hideWait();
}
function ajSaveOnglObjTag(){
	affWait();
	var df=document.forms["frmTag"+flg_selectOngletFic].elements;
	var txt=chrSep+"sOngl"+chrEgal + flg_selectOngletFic + extractValue(df);
	sendAjax('save_obj_tag',chrSep, chrEgal, txt);
}
function ajSupOnglObjTag(n){
	if(confirm("Vous êtes sur le point de supprimer ce tag.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		var txt='sOngl'+chrEgal + flg_selectOngletFic + chrSep + 'idTag'+chrEgal + n + chrSep + 'supTag'+chrEgal+'1';
		sendAjax('save_obj_tag',chrSep, chrEgal, txt);
	}
}
function setsave_obj_tag(){
	getAjaxReponse(this);
	hideWait();
}
function ajSelArtIma(n){
	if(!n){
		$('onglS4').style.display="block";
		$('onglS5').style.display="none";
		selectSsOngletFic(4);
	}else{
		$('onglS4').style.display="none";
		$('onglS5').style.display="block";
		selectSsOngletFic(5);
	}
}
function ajCart(){
	uploadOngLg('p', '1', false);
	uploadOngLg('idcar', 'A', true);
}
function ajchxCartLst(id){
	uploadOngLg('p', '1', false);
	uploadOngLg('idcar', id, true);
}
function ajsupCartLst(id){
	if(confirm("Vous êtes sur le point de supprimer ce cartouche.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		var txt='idCart'+chrEgal + id + chrSep + 'supCart'+chrEgal+'1';
		sendAjax('sup_cartouche',chrSep, chrEgal, txt);
	}
}
function setsup_cartouche(){
	getAjaxReponse(this);
	hideWait();
}
function ajProm(){
	uploadOngLg('p', '1', false);
	uploadOngLg('idprom', 'A', true);
}
function ajchxPromLst(id){
	uploadOngLg('p', '1', false);
	uploadOngLg('idprom', id, true);
}
function ajsupPromLst(id){
	if(confirm("Vous êtes sur le point de supprimer cette promotion.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		var txt='idProm'+chrEgal + id + chrSep + 'supProm'+chrEgal+'1';
		sendAjax('sup_promotion',chrSep, chrEgal, txt);
	}
}
function setsup_promotion(){
	getAjaxReponse(this);
	hideWait();
}
function ajMedia(){
	uploadOngLg('p', '1', false);
	uploadOngLg('idmedia', 'A', true);
}
function ajchxMedia(cx){
	if(!flg_ajsupMediaLst){
		uploadOngLg('p', '1', false);
		uploadOngLg('idmedia', cx, true);
	}else{flg_ajsupMediaLst=0;}
}
function ajsupMediaLst(id,n){
	flg_ajsupMediaLst=1;
	if(confirm("Vous êtes sur le point de supprimer ce media.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		var txt='idMedia'+chrEgal + id + chrSep + 'supGal'+chrEgal+'1' + chrSep + 'idFiche' + chrEgal + n;
		sendAjax('sup_galerie',chrSep, chrEgal, txt);
	}
}
function setsup_galerie(){
	getAjaxReponse(this);
	flg_ajsupMediaLst=0;
	hideWait();
}
function ajActFicLst(id){
	if($('fcIsAct'+id).checked){var txt="d'activer";var acc=false;}else{var txt="de désactiver";var acc=true;}
	if(confirm("Vous êtes sur le point "+ txt +" cette fiche.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		sendAjax('act_fiche', id, $('fcIsAct'+id).checked);
	}else{
		$('fcIsAct'+id).checked=acc;
	}
}
function setact_fiche(){
	getAjaxReponse(this);
	hideWait();
}
function ajActCartLst(id){
	if($('crIsAct'+id).checked){var txt="d'activer";var acc=false;}else{var txt="de désactiver";var acc=true;}
	if(confirm("Vous êtes sur le point "+ txt +" cette cartouche.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		sendAjax('act_cartouche', id, $('crIsAct'+id).checked);
	}else{
		$('crIsAct'+id).checked=acc;
	}
}
function setact_cartouche(){
	getAjaxReponse(this);
	hideWait();
}
function ajRegionActif(id){
	affWait();
	sendAjax('act_region', id, $('isRegAct').checked);
}
function setact_region(){
	hideWait();
}
function ajActModLst(id){
	if($('chkAcDe'+id).checked){var txt="d'activer";var acc=false;}else{var txt="de désactiver";var acc=true;}
	if(confirm("Vous êtes sur le point "+ txt +" ce module.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		var e=searchVarUrl('id');
		sendAjax('act_module', id, e, $('chkAcDe'+id).checked);
	}else{
		$('chkAcDe'+id).checked=acc;
	}
}
function setact_module(){
	getAjaxReponse(this);
	hideWait();
}
function ajSupModLst(id){
	if(confirm("Vous êtes sur le point de supprimer ce module.\nEtes vous sûr de vouloir continuer ?")){
		affWait();
		var e=searchVarUrl('id');
		var txt="supMod" + chrEgal + "1" + chrSep + "idMod" + chrEgal + id + chrSep + "idReg" + chrEgal + e;
		sendAjax('save_module',chrSep, chrEgal, txt);
	}
}
function ajSaveOnglSelFlMod(n){
	var txt="idFlash" + chrEgal + n + chrSep + flg_insImgMod;
	sendAjax('save_module',chrSep, chrEgal, txt);
}
function ajSaveOnglSelMod(n){
	var txt=flg_insImgMod;
	txt+=chrSep + "idImLg" + chrEgal + n;
	sendAjax('save_module',chrSep, chrEgal, txt);
}
function ajSaveModuleReg(idMod,typMod,idReg,col){
	affWait();
	var errRens="";
	switch(typMod){
		case "Promo":
		case "Fiche":
			if($('fiCibl').value=="" || $('fiCibl').value=="///"){errRens="fiche cible manquante !";}
			break;
		case "Rubrique":
			if($('ruCibl').value==""){errRens="rubrique cible manquante !";}
			break;
	}
	if(errRens==""){
		var df=document.forms["mod"].elements;
		var txt="col" + chrEgal + col + chrSep + "idReg" + chrEgal + idReg + chrSep + "typMod" + chrEgal + typMod + chrSep + "idMod" + chrEgal + idMod + extractValue(df);
		var e = xGetElementsByClassName('dvVersBlock', '', 'div'); 
		for (var i = 0; i < e.length; i++) {
			txt+=chrSep + "cont[" + $(e[i]).id.substr(11) + "]"+chrEgal + $(e[i]).innerHTML;
		}
		if(typMod!="Rubrique"){
			if(typMod=="Article" || typMod=="Fiche" || typMod=="Promo"){
				if(insImg.$('imart').value!=''){
					flg_insImgMod=txt;
					insImg.saveImg(idMod,'article/',idReg, col);
					return false;
				}else if(insFlash.$('flhart').value!=''){
					flg_insImgMod=txt;
					insFlash.saveFlash(idMod,idReg, col);
					return false;
				}
			}else if(typMod=="Image" || typMod=="Marché"){
				if(insImg.$('imart').value!=''){
					flg_insImgMod=txt;
					insImg.saveImg(idMod,'article/',idReg, col);
					return false;
				}
			}
		}
		sendAjax('save_module',chrSep, chrEgal, txt);
	}else{
		alert(errRens);
		hideWait();
	}
}
function setsave_module(){
	getAjaxReponse(this);
	hideWait();
}
function ajChgMediaMod(n){
	if($('chpVideo')){
		if(n=="i"){
			$('chpVideo').value="";
			insFlash.$('flhart').value="";
		}else if(n=="v"){
			insImg.$('imart').value="";
			insFlash.$('flhart').value="";
		}else if(n=="f"){
			$('chpVideo').value="";
			insImg.$('imart').value="";
		}
	}
}
function ajOpLstAjMod(n){
	if($('lstAjMod'+n).style.visibility=="visible"){var tt="hidden";}else{var tt="visible";}
	$('lstAjMod'+n).style.visibility=tt;
}
function ajSelCartProd(){
	if($('isProduit').checked){
		$('tyProd').style.display="block";
	}else{
		$('tyProd').style.display="none";
		$('tyProdPrix').style.visibility="hidden";
		$('btProd').innerHTML="&nbsp;Voir&nbsp;le&nbsp;tableau&nbsp;Tarif&nbsp;";
	}
}
function ajAffTabTarif(){
	if($('tyProdPrix').style.visibility=="visible"){
		$('tyProdPrix').style.visibility="hidden";
		$('btProd').innerHTML="&nbsp;Voir&nbsp;le&nbsp;tableau&nbsp;Tarif&nbsp;";
	}else{
		$('tyProdPrix').style.visibility="visible";
		$('btProd').innerHTML="&nbsp;Fermer&nbsp;le&nbsp;tableau&nbsp;Tarif&nbsp;";
	}
}
function calculTarTva(){
	var prix,tva;
	if($('selCompo2').checked){
		prix=Math.abs($('prix1').value) + Math.abs($('prix2').value) + Math.abs($('prix3').value);
		tva=((Math.abs($('prix1').value)*Math.abs($('tva1').value))/100); 
		tva+=((Math.abs($('prix2').value)*Math.abs($('tva2').value))/100);
		tva+=((Math.abs($('prix3').value)*Math.abs($('tva3').value))/100);
	}else{
		prix=Math.abs($('prix1').value);
		tva=((Math.abs($('prix1').value)*Math.abs($('tva1').value))/100); 
	}
	tva=Math.round(tva*100)/100;
	$('totht').value=prix;
	$('tottva').value=tva;
	$('totttc').value=prix+tva;
}
function selProdUnique(n){
	if(n){
		var ro=false;
	}else{
		var ro=true;
		if(flg_opFicBlkPrx!=''){
			$('ficDivLg'+flg_opFicBlkPrx).style.visibility="hidden";
			flg_opFicBlkPrx='';
		}
	}
	for(i=1;i<=3;i++){
		$('libel'+i).readOnly=ro;
		if(i>1){
			$('tva'+i).readOnly=ro;
			$('prix'+i).readOnly=ro;
		}
	}
	calculTarTva();
}
function ajSupNewsIma(id,n){
	affWait();
	if(confirm("Vous êtes sur le point de supprimer cette image.\nEtes vous sûr de vouloir continuer ?")){	
		sendAjax('sup_ima_news',chrSep, chrEgal, "idIma" + chrEgal + id + chrSep + "pt" + chrEgal + n);
	}
}
function setsup_ima_news(){
	getAjaxReponse(this);
	hideWait();
}
function ajEnvNews(){
	affWait();
	if(confirm("Vous êtes sur le point d'envoyer cette Newsletter.\nEtes vous sûr de vouloir continuer ?")){
		sendAjax('env_news',chrSep, chrEgal, "idNews" + chrEgal + $('idNews').value);
	}
}
function setenv_news(){
	getAjaxReponse(this);
	hideWait();
}
var wNews;
function ajAppNews(){
	affWait();
	sendAjax('app_news',chrSep, chrEgal, "idNews" + chrEgal + $('idNews').value);
}
function setapp_news(){
	getAjaxReponse(this);
}
function clEdiApp(){
	$('editApp').style.display='none';
	hideWait();
}
var cnt_ajSaveNews=0;
var flg_ajSaveNews;
function ajSaveNews(sn){
	affWait();
	if(sn==null | sn=="0"){
		sn=0;
		if($('idNews').value!="0"){
			var alt="modifier";
		}else{
			var alt="créer";
		}
	}else{
		sn=1;
		var alt="Supprimer";
	}
	if(confirm("Vous êtes sur le point de " + alt + " cette newsletter!\nEtes vous sûr de vouloir continuer ?")){
		var df=document.forms["frm"].elements;
		var txt="supNews" + chrEgal + sn + extractValue(df);
		txt+=chrSep + "texteNews" + chrEgal + $('dvVersArt1').innerHTML;
		txt+=chrSep + "piedNews" + chrEgal + $('dvVersArt2').innerHTML;
		flg_ajSaveNews=txt;
		if(insImg1.$('imart').value!=''){
			insImg1.saveImg($('idNews').value,'','ajSaveImaNews2','1');
			return false;
		}else{
			ajSaveImaNews2('');
		}
	}else{
		hideWait();
	}
}
function setsave_news(){
	getAjaxReponse(this);
	hideWait();
}
function ajSaveImaNews2(n){
	if(n!='' && n!=null){
		flg_ajSaveNews+=chrSep + "idLogo" + chrEgal + n;
		cnt_ajSaveNews=1;
	}
	if(insImg2.$('imart').value!=''){
		insImg2.saveImg($('idNews').value,'','ajSaveImaNews3','2');
		return false;
	}else{
		ajSaveImaNews3('');
	}
}
function ajSaveImaNews3(n){
	if(n!='' && n!=null){
		flg_ajSaveNews+=chrSep + "idIma1" + chrEgal + n;
		cnt_ajSaveNews=2;
	}
	if(insImg3.$('imart').value!=''){
		insImg3.saveImg($('idNews').value,'','ajSaveImaNewsFinal','3');
		return false;
	}else{
		ajSaveImaNewsFinal('');
	}
}
function ajSaveImaNewsFinal(n){
	var txt=flg_ajSaveNews;
	if(n!=''){
		txt+=chrSep + "idIma2" + chrEgal + n;
	}
	sendAjax('save_news',chrSep, chrEgal, txt);
}
function ajSelNews(id){
	affWait();
	var txt="id" + chrEgal + id;
	sendAjax('edi_news',chrSep, chrEgal, txt);
}
function setedi_news(){
	getAjaxReponse(this);
	opDvSelNews('A');
	hideWait();
}
function ajChxUserClient(id){
	affWait();
	var txt="sel" + chrEgal + "client" + chrSep + "idClient" + chrEgal + id;
	sendAjax('edi_user_pass',chrSep, chrEgal, txt);
}
function ajChxPass(){
	affWait();
	var txt="sel" + chrEgal + "pass";
	sendAjax('edi_user_pass',chrSep, chrEgal, txt);
}
function setedi_user_pass(){
	getAjaxReponse(this);
	hideWait();
}
function ajSelUser(id){
	affWait();
	var txt="idUser" + chrEgal + id;
	sendAjax('edi_user',chrSep, chrEgal, txt);
}
function setedi_user(){
	getAjaxReponse(this);
	hideWait();
}
function ajSaveUser(){
	affWait();
	if($('idUser').value!="0"){
		var alt="modifier";
	}else{
		var alt="créer";
	}
	if(confirm("Vous êtes sur le point de " + alt + " cet utilisateur!\nEtes vous sûr de vouloir continuer ?")){
		var df=document.forms["frm"].elements;
		var txt="supUser"+ chrEgal + "0" + extractValue(df);
		sendAjax('save_user',chrSep, chrEgal, txt);
	}else{
		hideWait();
	}
}
function ajSupUser(){
	affWait();
	if(confirm("Vous êtes sur le point de supprimer cet utilisateur!\nEtes vous sûr de vouloir continuer ?")){
		var txt="supUser"+ chrEgal + "1" + chrSep +"idUser" + chrEgal + $('idUser').value;
		sendAjax('save_user',chrSep, chrEgal, txt);
	}else{
		hideWait();
	}
}
function setsave_user(){
	getAjaxReponse(this);
	hideWait();
}
function ajSaveLevel(){
	affWait();
	if($('idLevel').value!="0"){
		var alt="modifier";
	}else{
		var alt="créer";
	}
	if(confirm("Vous êtes sur le point de " + alt + " ce niveau!\nEtes vous sûr de vouloir continuer ?")){
		var df=document.forms["frm"].elements;
		var txt="supLevel"+ chrEgal + "0" + extractValue(df);
		sendAjax('save_level',chrSep, chrEgal, txt);
	}else{
		hideWait();
	}
}
function ajSupLevel(){
	affWait();
	if(confirm("Vous êtes sur le point de supprimer ce niveau!\nEtes vous sûr de vouloir continuer ?")){
		var txt="supLevel"+ chrEgal + "1" + chrSep +"idLevel" + chrEgal + $('idLevel').value;
		sendAjax('save_level',chrSep, chrEgal, txt);
	}else{
		hideWait();
	}
}
function setsave_level(){
	getAjaxReponse(this);
	hideWait();
}
function ajSelLevel(id){
	affWait();
	var txt="id" + chrEgal + id;
	sendAjax('edi_level',chrSep, chrEgal, txt);
}
function setedi_level(){
	getAjaxReponse(this);
	opDvSelLevel(0);
	hideWait();
}
function retAjPres(n){
	uploadOngLg('p', '1', false);
	uploadOngLg('idf', n, true);
}
function getAjaxReponse(th){
	var txt = th.req.responseText;
	if(txt.substr(0,1)=="*"){
		eval(txt.substr(1));
	}else{
		alert(txt);
	}
}
function affWait(){
	$('bgDisWarning').style.visibility="visible";
	flg_affWait=1;
}
function hideWait(){
	$('bgDisWarning').style.visibility="hidden";
	flg_affWait=0;
}
