
/**
 * @copyright META-GEN.COM
 * @lastModification 1305639604 
 * @author Cataland Dougwald 
 * @Author Tomasina Pierre 
 * @email dev@meta-gen.com
 */
 var MG=(function(){var imgPath="ressources/lib/mg/imgs/";var setImgPath=function(string){imgPath=string;};var getImgPath=function(){return imgPath;};var $=function(id){return(MG.Typing.isString(id)&&id !=='')?document.getElementById(id):null};$$=function(name,origine){return(origine?(typeof origine=='object'?origine:this.$(origine)):document).getElementsByTagName(name);};var trim=function(str){return str.replace(/\s+/,"");};var sleep=function(s){var start=new Date().getTime();while(new Date()<start+s*1000){}return 0;};var count=function(v){var r=0;switch(typeof v){case 'object':for(p in v)if(v.hasOwnProperty(p))++r;break;case 'string':r=v.length;break;case 'Array':r=v.length;break;}return r;};var delay=function(time,callback,scope,args){var interval,a=MG.Typing.isArray(args)?args:[],s=scope||window;var fn_wait=function(){callback.apply(s,a);clearInterval(interval);};interval=setInterval(fn_wait,time);};var cloneObject=function(obj){if(obj==null||typeof(obj)!="object")return obj;var tmp=new obj.constructor();for(var key in obj)tmp[key]=this.cloneObject.call(this,obj[key]);return tmp;};return{$:$,$$:$$,trim:trim,sleep:sleep,count:count,delay:delay,setImgPath:setImgPath,getImgPath:getImgPath,cloneObject:cloneObject};})(); MG.Window=(function(){var convertFormat=function(format){};var pageXOffset=function(){return window.pageXOffset||(document.body.scrollLeft>0?document.body.scrollLeft:document.documentElement.scrollLeft);};var pageYOffset=function(){return window.pageYOffset||(document.body.scrollTop>0?document.body.scrollTop:document.documentElement.scrollTop);};var innerHeight=function(){return MG.Browser.isIe()?document.documentElement.offsetHeight:window.innerHeight;};var innerWidth=function(){return MG.Browser.isIe()?document.documentElement.offsetWidth:window.innerWidth;};var outerHeight=function(){return document.documentElement.clientHeight;};var outerWidth=function(){return document.documentElement.clientWidth;};var scrollHeight=function(el){return(el||document.documentElement).scrollHeight;};var scrollWidth=function(el){return(el||document.documentElement).scrollWidth;};return{pageXOffset:pageXOffset,pageYOffset:pageYOffset,innerHeight:innerHeight,innerWidth:innerWidth,outerHeight:outerHeight,outerWidth:outerWidth,scrollHeight:scrollHeight,scrollWidth:scrollWidth};})(); MG.Console=(function(){var write_log=function(msg){if(typeof console !="undefined")console.log(msg);};var notice=function(msg){write_log("NOTICE:"+msg);};var warning=function(msg){write_log("WARNING:"+msg);};var error=function(msg){write_log("ERROR:"+msg);};return{notice:notice,warning:warning,error:error};})(); MG.Typing={typeOf:function(value){var type=typeof value;if(type=='object'&&!value)return 'null';return type;},isArray:function(value){var r=false;if(value)if(value.constructor.prototype==Array.prototype)r=true;return r;},isObject:function(value){return(this.typeOf(value)=='object');},isFunction:function(value){return(this.typeOf(value)=='function');},isString:function(value){return(this.typeOf(value)=='string');},isNumber:function(value){return(this.typeOf(value)=='number');},isUndefined:function(value){return(this.typeOf(value)=='undefined');},isBoolean:function(value){return(this.typeOf(value)=='boolean');},isNull:function(value){return(this.typeOf(value)=='null');},isNode:function(value){return(this.isNumber(value.nodeType));},nodeType:function(value){var r=false;var t={1:'element',2:'attribute',3:'text',4:'cdata',5:'entityRef',6:'entity',7:'instruction',8:'comment',9:'document',10:'documentType',11:'documentFrag',12:'notation'};if(this.isNode(value))r=t[value.nodeType];return r;},isEmail:function(value){exp=new RegExp('^[a-z]+[a-z0-9_\\-\\.]+@[a-z0-9\\.\\-]+\\.[a-z]{2,16}$','i');return v.match(exp)===null?false:true;}}; MG.Browser=(function(){var isIe=function(){var r=false;if(navigator.appName=="Microsoft Internet Explorer"){r=true;if(navigator.appVersion.search(/MSIE 6.0/)!="-1")r=6;else if(navigator.appVersion.search(/MSIE 7.0/)!="-1")r=7;else if(navigator.appVersion.search(/MSIE 8.0/)!="-1")r=8;else if(navigator.appVersion.search(/MSIE 9.0/)!="-1")r=9;}return r;};var isSafari=function(){var r=false;if(navigator.appVersion.search(/Gecko\)Version\/([0-9]+\.?)*Safari/i)!="-1")r=true;return r;};var isFF=function(){var r=false;if(navigator.userAgent.search(/Firefox/i)!="-1")r=true;return r;};return{isIe:isIe,isSafari:isSafari,isFF:isFF}})(); MG.Style=(function(){var usingClass=function(el,className){el=typeof el=='object'?el:MG.$(el);return el.className.match(new RegExp('(\\s|^)'+className+'(\\s|$)'));};var addClass=function(el,className){el=typeof el=='object'?el:MG.$(el);if(!this.usingClass(el,className))el.className+=' '+className;};var removeClass=function(el,className){el=typeof el=='object'?el:MG.$(el);el.className=el.className.replace(new RegExp('(\\s|^)'+className+'(\\s|$)'),' ');};var replaceClass=function(el,classNameOld,classNameNew){el=typeof el=='object'?el:MG.$(el);this.removeClass(el,classNameOld);this.addClass(el,classNameNew);};var getStyle=function(el,styleName){el=typeof el=='object'?el:MG.$(el);cssStyle=cssConvers(styleName,"");return el.style[cssStyle.key]||'';};var removeStyle=function(el,styleName){el=typeof el=='object'?el:MG.$(el);cssStyle=cssConvers(styleName,"");el.style[cssStyle.key]="";};var setStyle=function(el,styleName,styleValue){el=typeof el=='object'?el:MG.$(el);cssStyle=cssConvers(styleName,styleValue);el.style[cssStyle.key]=cssStyle.value;};var cssConvers=function(k,v){var r={};switch(k){case "float":if(MG.Browser.isIe()!==false)r.key="styleFloat";else r.key="cssFloat";r.value=v;break;case "opacity":if(MG.Browser.isIe()!==false){v=v.toString();if(v.slice(0,1)=="1")v="100";else{v=v.split(".");v=v.length==2?(v[1].length==1?v[1]+"0":v[1]):v[0];}r.key="filter";r.value="alpha(opacity="+v+")";}else{r.key="opacity";r.value=v;}break;default:var kpart=k.split("-");if(kpart.length===1)r.key=kpart[0];else if(kpart.length===2)r.key=kpart[0]+kpart[1].slice(0,1).toUpperCase()+kpart[1].slice(1,kpart[1].length);r.value=v;break;}return r;};var addCssFile=function(url){var head=MG.$$("head")[0];MG.Dom.addElement("link",{parent:head,attrs:{type:"text/css",rel:"stylesheet",href:url}});};var show=function(el){var el=MG.Typing.isString(el)?MG.$(el):el;el.style["display"]="block";};var hide=function(el){var el=MG.Typing.isString(el)?MG.$(el):el;el.style["display"]="none";};return{usingClass:usingClass,addClass:addClass,removeClass:removeClass,replaceClass:replaceClass,removeStyle:removeStyle,getStyle:getStyle,setStyle:setStyle,cssConvers:cssConvers,addCssFile:addCssFile,show:show,hide:hide};})(); MG.Dom=(function(){var idAlreadyGenerate={};var addElement=function(name,conf){var el=document.createElement(name);var attrs=conf.attrs||false,cls=conf.cls||false,style=conf.style||false,value=conf.value||false,parent=conf.parent||false,id=conf.id||false;if(attrs){for(var attrKey in attrs){switch(attrKey){case "name":el.name=attrs[attrKey];break;case "type":el.type=attrs[attrKey];break;default:el.setAttribute(attrKey,attrs[attrKey]);}}}if(cls)MG.Style.addClass(el,cls);if(style){for(var styleKey in style){var css=MG.Style.cssConvers(styleKey,style[styleKey]);if(el.style)el.style[css.key]=css.value;}}if(id===true)genId(el);else if(MG.Typing.isString(id)&&id !=='')el.id=id;if(value)el.appendChild(document.createTextNode(value));if(MG.Typing.typeOf(parent)=="string")parent=MG.$(parent);if(MG.Typing.typeOf(parent)=="object"){if(parent.nodeName=="BODY")parent.insertBefore(el,parent.firstChild);else parent.appendChild(el);}return el;};var delNode=function(el,lvl){var node=MG.Typing.isString(el)?MG.$(el):el,lvl=lvl||0;if(MG.Typing.isObject(node)){if(node.parentNode !=undefined){if(lvl<0){for(var i=0;i>lvl;i--)node=node.parentNode;}else if(lvl>0){for(var i=0;i<lvl;i++)node=node.firstChild;}node.parentNode.removeChild(node);}}else{if(MG.Typing.isNode(node)&&node.parentNode !=undefined)if(node.nodeName.toLowerCase()=="embed")node.parentNode.removeChild(node);}};var dropNode=function(el){var node=MG.Typing.isString(el)?MG.$(el):el;if(node.hasChildNodes)while(node.childNodes.length>0)node.removeChild(node.childNodes[(node.childNodes.length)-1]);};var genId=function(el){var el=el||false,idStr=Math.ceil(Math.random()*9999999).toString();while(idAlreadyGenerate.hasOwnProperty(idStr))idStr=Math.ceil(Math.random()*9999999).toString();idAlreadyGenerate[idStr]=true;if(el&&MG.Typing.isNode(el))el.id=idStr;return idStr;};var makeSelect=function(conf){var data=conf.data||false,reqAjaj=conf.reqAjaj||false,OC=conf.onchange||false,style=conf.style||{},selected=conf.selected||false,cls=conf.cls||"",S=addElement("select",{style:style,cls:cls});var makeOption=function(data){for(var i=0,ilen=data.length;i<ilen;i++){addElement("option",{parent:S,value:data[i]['label'],attrs:{value:data[i]['ref']}});if(data[i].hasOwnProperty("selected"))if(data[i]['selected']==true)S.value=data[i]['ref'];}if(OC.hasOwnProperty("f")){if(MG.Typing.isFunction(OC.f)){var scope=OC.hasOwnProperty("s")?OC.s:window,args=OC.hasOwnProperty("a")?(MG.Typing.isArray(OC.a)?OC.a:[]):[];MG.Events.on(S,"change",OC.f,OC.s,OC.a);}}if(selected !==false)S.value=selected;};if(data){makeOption(data);}else if(reqAjaj){MG.Request.ajaj({data:reqAjaj,callback:function(r){if(r.success==true)if(r.hasOwnProperty("data"))makeOption(r.data);}});}return S;};return{addElement:addElement,delNode:delNode,dropNode:dropNode,genId:genId,makeSelect:makeSelect};})(); MG.Request=(function(){var url=undefined;var types=[];var setUrl=function(newUrl){url=newUrl;};var getUrl=function(){return url;};var urlIsDefine=function(){if(url==undefined){MG.Console.warning("URL not define for Request,try «MG.Request.setUrl('your_local_file')»");return false;}else return true;};var regType=function(t,callback,scope,method){types[t]={callback:callback,scope:scope,method:method};};var Xhr=(function(){var XHR=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP");var stacks=[];var requestRuning=false;var callback=function(){if(XHR.readyState==4){requestRuning=false;var ss=stacks,s=ss[0],t=types[s.type],x=XHR;ss.splice(0,1);var r=t.method=='xml'?x.responseXML:x.responseText;var st=x.status;send();if(st&&typeof(s.callback)=='function'){s.args.unshift(t.callback.call(t.scope,r));s.callback.apply(s.scope,s.args);}}};var bindMethod=function(method,scope){return function(){method.apply(scope,arguments);}};var send=function(){if(!requestRuning&&stacks.length){requestRuning=true;var s=stacks[0],x=XHR;x.open('POST',s.url||url,true);x.setRequestHeader('Content-Type','application/x-www-form-urlencoded');x.onreadystatechange=bindMethod(callback,this);x.send(s.data);}};var request=function(type,dataObj,callbackFn,scope,args){var data='';for(key in dataObj)data+=(data.length?'&':'')+key+'='+encodeURIComponent(dataObj[key]);stacks[stacks.length]={type:type,data:data,callback:callbackFn,scope:scope,args:args,url:url};send();};return{request:request};})();var Ihr=(function(){var stacks=[];var requestRuning=false;var callback=function(e,iframeId){if(requestRuning==true){requestRuning=false;var ss=stacks,s=ss[0],t=types[s.type],r=MG.$(iframeId).contentWindow.document.body.innerHTML;MG.Events.removeAll(iframeId,"load");MG.Dom.delNode(iframeId);ss.splice(0,1);send();if(typeof(s.callback)=='function'){s.args.unshift(t.callback.call(t.scope,r));s.callback.apply(s.scope,s.args);}}};var makeIfram=function(){var r="IFRAME99",body=MG.$$("body")[0];if(MG.Browser.isIe()){var iF_Container=MG.Dom.addElement("div",{parent:body,style:{display:"none"}});iF_Container.innerHTML='<iframe id="'+r+'" name="'+r+'" />';iF=MG.$(r);}else{var iF=document.createElement("iframe");MG.Dom.genId(iF);r=iF.id;iF.setAttribute("name",r);iF.setAttribute("style","display:none;");body.appendChild(iF);}MG.Events.on(iF,"load",callback,this,[r]);return r;};var send=function(){if(!requestRuning&&stacks.length){requestRuning=true;var s=stacks[0];var iFid=makeIfram();s.form.setAttribute("target",iFid);for(pro in s.data){var currInput=MG.Dom.addElement("input",{attrs:{type:"hidden"},parent:s.form});currInput.name=pro;currInput.value=s.data[pro];}s.form.submit();}};var request=function(type,dataObj,callbackFn,scope,args){var F=dataObj.form?(MG.Typing.isString(dataObj.form)?MG.$(dataObj.form):dataObj.form):false;if(F.nodeName=="FORM"){delete dataObj.form;stacks[stacks.length]={type:type,form:F,data:dataObj,callback:callbackFn,scope:scope,args:args,url:url};}send();};return{request:request};})();var lunch=function(conf){var conf=conf||{},type=conf.type=="IHR"?"IHR":"XHR",data=MG.Typing.isObject(conf.data)?conf.data:false,callback=MG.Typing.isFunction(conf.callback)?conf.callback:function(){},scope=conf.scope||window,args=conf.args||[];if(data){if(urlIsDefine()||type=="IHR"){if(type=="XHR")Xhr.request('ajaj',data,callback,scope,args);else Ihr.request('ajaj',data,callback,scope,args);}}};var ajaj=function(conf){var conf=conf||{},type=conf.type=="IHR"?"IHR":"XHR",data=MG.Typing.isObject(conf.data)?conf.data:false,callback=MG.Typing.isFunction(conf.callback)?conf.callback:function(){},scope=conf.scope||window,args=conf.args||[];if(data){if(urlIsDefine()||type=="IHR"){var fn_callback=function(responseText){var ret='';try{ret=eval('('+(responseText)+')');}catch(e){ret=false;MG.Console.error("Le retour ci dessou n'est pas une chaîne JSON valide");MG.Console.notice(responseText);};return ret;};regType('ajaj',fn_callback,this,'text');if(type=="XHR")Xhr.request('ajaj',data,callback,scope,args);else Ihr.request('ajaj',data,callback,scope,args);}}};var ajax=function(){};var ajat=function(conf){var conf=conf||{};var fn_callback=function(responseText){return responseText;};regType('ajaj',fn_callback,this,'text');lunch(conf);};return{setUrl:setUrl,getUrl:getUrl,ajaj:ajaj,ajax:ajax,ajat:ajat};})(); MG.Form=(function(){var imgPath=MG.getImgPath;var fnElRm={};var inputAutoComp=function(conf){var styleContainer=conf.styleContainer||{},clsContainer=conf.clsContainer||"mg_iac_c",clsInput=conf.clsInput||"mg_iac_i",clsContainerData=conf.clsContainerData||"mg_iac_cd",clsItemData=conf.clsItemData||"mg_iac_id",styleItemHover=conf.styleItemHover||false,parent=conf.elParent||false,data=conf.data||false,reqAjaj=conf.reqAjaj||false,hiddenKsearch=conf.hiddenKsearch||false,cacheData=conf.cacheData !=undefined?conf.cacheData:true;styleContainer["display"]='none';var Items=[];var C=MG.Dom.addElement("div",{cls:clsContainer,parent:parent,id:true});var input=MG.Dom.addElement("input",{cls:clsInput,attrs:{"type":'text'},parent:C});var divData=MG.Dom.addElement("div",{cls:(MG.Browser.isIe()==6?'mg_iac_cd_IE_6 ':(MG.Browser.isIe()==7?'mg_iac_cd_IE_7 ':''))+clsContainerData,style:styleContainer,parent:C});var fn_importData=function(r){if(r.success==true&&Items.length==0){var data=r.data;if(MG.Typing.typeOf(data)=="object"){for(var i in data){var item=MG.Dom.addElement("div",{cls:clsItemData,attrs:{"ki":Items.length},parent:divData});Items[Items.length]={"ref":data[i]['ref'],"v":data[i]['label'],"ks":data[i]['ksearch'],"el_i":item};var itemV=MG.Dom.addElement("p",{cls:clsItemData,parent:item,value:data[i]['label']});var itemKsearch=MG.Dom.addElement("span",{cls:clsItemData,parent:item,value:data[i]['ksearch']});if(styleItemHover){MG.Effect.rollhover(item,styleItemHover);injectFnEvRm(C.id,function(el){MG.Effect.removeEvEffect(el.id);},[item]);}if(hiddenKsearch)itemKsearch.display="none";MG.Dom.addElement("div",{style:{"clear":'both'},parent:item});MG.Events.on(item,"click",fn_clickItem);injectFnEvRm(C.id,function(el){MG.Events.remove(el,"click",fn_clickItem);},[item]);}}}};var fn_loadData=function(){if(Items.length==0){if(MG.Typing.typeOf(data)==="object")fn_importData({success:true,data:data});else{if(MG.Typing.typeOf(reqAjaj)==="object")MG.Request.ajaj({data:reqAjaj,callback:fn_importData,scope:this});else if(MG.Typing.isFunction(reqAjaj))MG.Request.ajaj({data:reqAjaj.call(),callback:fn_importData,scope:this});}}};var fn_clickItem=function(e){input.value=Items[e.el.getAttribute("ki")]["v"];input.setAttribute("value:id",Items[e.el.getAttribute("ki")]["ref"]);};var divDataIsOpen=false;var fn_listenClose=function(){if(itemSelect.index>-1){MG.Events.fire(itemSelect.list[itemSelect.index]["el_i"],"rollunhover");itemSelect.index=-1;}divData.style.display="none";MG.Events.remove(document,"click",fn_listenClose);divDataIsOpen=false;};var fn_click_loaded=false;var fn_click=function(e){fn_loadData();if(!divDataIsOpen){divData.style.display="block";divDataIsOpen=true;if(MG.Browser.isIe()===false){e.stopPropagation();MG.Events.removeAll(document,"click");MG.Events.on(document,"click",fn_listenClose);}else if(!fn_click_loaded){var fn_mouseover=function(){divDataIsOpen=true;MG.Events.removeAll(document,"click");MG.Events.on(document,"click",fn_listenClose);};MG.Events.on(divData,"mouseover",fn_mouseover);injectFnEvRm(C.id,function(){MG.Events.remove(divData,"mouseover",fn_mouseover);});fn_click_loaded=true;}}};var itemSelect={list:Items,index:-1};var fn_keyup=function(e){fn_loadData();if(!divDataIsOpen){divData.style.display="block";divDataIsOpen=true;MG.Events.removeAll(document,"click");MG.Events.on(document,"click",fn_listenClose);}if(e.keyCode==13){if(itemSelect.index>-1){MG.Events.fire(itemSelect.list[itemSelect.index]["el_i"],"click");fn_listenClose();}}};var fn_keydown=function(e){fn_loadData();if(e.keyCode !==40&&e.keyCode !==38&&e.keyCode !==9&&e.keyCode !==13){var lastItem=undefined,exp=new RegExp(e.el.value+'.*','i');if(itemSelect.index>-1)MG.Events.fire(itemSelect.list[itemSelect.index]["el_i"],"rollunhover");itemSelect.list=[];itemSelect.index=-1;for(var i=0,ilen=Items.length;i<ilen;i++){var lastItem=false;if(Items[i]["v"].search(exp)!=-1||Items[i]["ks"].search(exp)!=-1){itemSelect.list[itemSelect.list.length]=Items[i];lastItem=Items[i]["el_i"];lastItem.style["borderWidth"]="1px";lastItem.style.display="block";}else Items[i]["el_i"].style.display="none";}if(lastItem)lastItem.style["borderWidth"]="0px";if(!divDataIsOpen){divData.style.display="block";divDataIsOpen=true;MG.Events.removeAll(document,"click");MG.Events.on(document,"click",fn_listenClose);}}else if(itemSelect.list.length>0){switch(e.keyCode){case 40:if(itemSelect.index<(itemSelect.list.length-1)){if(itemSelect.index>-1)MG.Events.fire(itemSelect.list[itemSelect.index]["el_i"],"rollunhover");++itemSelect.index;MG.Events.fire(itemSelect.list[itemSelect.index]["el_i"],"rollhover");}break;case 38:if(itemSelect.index>0){MG.Events.fire(itemSelect.list[itemSelect.index]["el_i"],"rollunhover");--itemSelect.index;MG.Events.fire(itemSelect.list[itemSelect.index]["el_i"],"rollhover");}break;case 9:fn_listenClose();break;}}};var fn_focus=function(){if(cacheData==false){if(!MG.Typing.isObject(data)){if(MG.Typing.isFunction(reqAjaj)){Items=[];MG.Dom.dropNode(divData);MG.Request.ajaj({data:reqAjaj.call(),callback:fn_importData,scope:this});}}}};MG.Events.on(input,"keyup",fn_keyup,this);MG.Events.on(input,"keydown",fn_keydown,this);MG.Events.on(input,"click",fn_click,this);MG.Events.on(input,"focus",fn_focus,this);injectFnEvRm(C.id,function(){MG.Events.remove(input,"keyup",fn_keyup,this);MG.Events.remove(input,"keydown",fn_keydown,this);MG.Events.remove(input,"click",fn_click,this);MG.Events.remove(input,"focus",fn_focus,this);MG.Events.remove(document,"click",fn_listenClose);});return C;};var upBox=function(conf){var conf=conf||{},parent=conf.parent||false,action=conf.action||{file:"request.php",send:{key:"action",value:"upFileAdd"},edit:{key:"action",value:"upFileEdit"}},actionCheck=false,data=conf.data||false,isOpen=false,body=MG.$$("body")[0],btnText=MG.Typing.isString(conf.btnText)?MG.Lang.word(conf.btnText):MG.Lang.word("addfile");if(action.hasOwnProperty("file")&&action.hasOwnProperty("send")&&action.hasOwnProperty("edit")&&action.hasOwnProperty("rem")&&action.hasOwnProperty("dl")){if(MG.Typing.isString(action.file)&&MG.Typing.isObject(action.send)&&MG.Typing.isObject(action.edit)&&MG.Typing.isObject(action.rem)&&MG.Typing.isObject(action.dl)){if(action.send.hasOwnProperty("key")&&action.send.hasOwnProperty("value")&&action.edit.hasOwnProperty("key")&&action.edit.hasOwnProperty("value")&&action.rem.hasOwnProperty("key")&&action.rem.hasOwnProperty("value")&&action.dl.hasOwnProperty("key")&&action.dl.hasOwnProperty("value")){actionCheck=true;}}}if(!actionCheck){action={file:"request.php",send:{key:"action",value:"upfile_add"},edit:{key:"action",value:"upfile_edit"},rem:{key:"action",value:"upfile_remove"},dl:{key:"action",value:"upfile_dl"}};}var C=MG.Dom.addElement("div",{parent:body,cls:"mg_up_c"}),H=MG.Dom.addElement("div",{parent:C,cls:"mg_up_h"}),B=MG.Dom.addElement("div",{parent:C,cls:"mg_up_b"}),V=MG.Dom.addElement("div",{parent:C,cls:"mg_up_v"}),HT=MG.Dom.addElement("div",{parent:H,cls:"mg_up_ht",value:"Upload Box"}),HC=MG.Dom.addElement("div",{parent:H,cls:"mg_up_hc"});if(MG.Browser.isIe()==6)MG.Style.addClass(C,"mg_up_c_IE6");MG.Dom.addElement("img",{parent:HC,attrs:{src:imgPath.call()+"/minus-button.png",alt:"Close"}});MG.Dom.addElement("div",{parent:H,style:{clear:"both"}});var CF=MG.Dom.addElement("div",{parent:B}),F_ID=MG.Dom.genId();CF.innerHTML='<form id="'+F_ID+'" class="mg_up_b_f" action="'+action.file+"?"+action.send.key+"="+action.send.value+'" method="post" enctype="multipart/form-data"></form>';var F=MG.$(F_ID),FF=MG.Dom.addElement("div",{parent:F,cls:"mg_up_b_ff"}),FN=MG.Dom.addElement("div",{parent:F,cls:"mg_up_b_fn"}),FD=MG.Dom.addElement("div",{parent:F,cls:"mg_up_b_fd"});var FFlabelC=MG.Dom.addElement("div",{parent:FF}),FFinputC=MG.Dom.addElement("div",{parent:FF}),IF=MG.Dom.addElement("input",{parent:FFinputC,attrs:{type:"file",name:"file"},style:{width:"378px"}});MG.Dom.addElement("label",{parent:FFlabelC,value:MG.Lang.word("File:")});var FNlabelC=MG.Dom.addElement("div",{parent:FN}),FNinputC=MG.Dom.addElement("div",{parent:FN}),IN=MG.Dom.addElement("input",{parent:FNinputC,attrs:{type:"text",name:"nom"}});MG.Dom.addElement("label",{parent:FNlabelC,value:MG.Lang.word("Nom:")});var FDlabelC=MG.Dom.addElement("div",{parent:FD}),FDtareaC=MG.Dom.addElement("div",{parent:FD}),TD=MG.Dom.addElement("textarea",{parent:FDtareaC,attrs:{name:"desc"}});MG.Dom.addElement("label",{parent:FDlabelC,value:MG.Lang.word("Description:")});var CBtn=MG.Dom.addElement("div",{parent:B,style:{"marginTop":"10px","textAlign":"center"}}),btnAdd=MG.Dom.addElement("span",{parent:CBtn,cls:"mg_btn",value:MG.Lang.word("Ajouter")}),btnEdit=MG.Dom.addElement("span",{parent:CBtn,cls:"mg_btn",value:MG.Lang.word("Modifier"),style:{display:"none"}}),btnCancel=MG.Dom.addElement("span",{parent:CBtn,cls:"mg_btn",value:MG.Lang.word("Annuler"),style:{display:"none","marginLeft":"75px"}});MG.Dom.addElement("div",{parent:CBtn,style:{clear:"both"}});var cmpBtnOpenBox=MG.Dom.addElement("div",{id:true,parent:parent,attrs:{"value:id":""}}),btnOpenBox=MG.Dom.addElement("div",{id:true,parent:cmpBtnOpenBox,value:btnText,cls:"mg_btn",style:{float:"left"}}),cmpNotif=MG.Dom.addElement("div",{parent:cmpBtnOpenBox,value:"0",style:{float:"left",padding:"4px 4px 0px 16px",background:"url('"+imgPath.call()+"/attach.png')no-repeat scroll 0px 5px #77B5FF"}});MG.Dom.addElement("div",{parent:cmpBtnOpenBox,style:{clear:"both"}});var IN_nbLoop=0;var IN=setInterval(function(){IN_nbLoop+=1;var H=parseInt(btnOpenBox.offsetHeight);if(H !=0){MG.Style.setStyle(cmpNotif,"height",H-4+"px");clearInterval(IN);}if(IN_nbLoop>=5)clearInterval(IN);},10);var inject_callback_item_delete=function(id,scope,fn,args){callbacks_item_delete[id]={s:scope,callback:fn,args:args};};var callbacks_item_delete={};var itemData={};var fn_callback_viewer=function(r){if(r.success==true&&MG.Typing.isObject(r.data)){var Item=r.data;itemData[Item['id']]=Item;if(Item.hasOwnProperty("path")&&Item.hasOwnProperty("file")&&Item.hasOwnProperty("img_seen")&&Item.hasOwnProperty("name")&&Item.hasOwnProperty("desc")){cmpNotif.innerHTML=parseInt(cmpNotif.innerHTML)+1;var CI=MG.Dom.addElement("div",{id:true,parent:V,cls:"mg_up_vf"}),CI_t=MG.Dom.addElement("div",{parent:CI,cls:"mg_up_vft"}),CI_tc=MG.Dom.addElement("div",{parent:CI_t,cls:"mg_up_vftc"}),CI_b=MG.Dom.addElement("div",{parent:CI,cls:"mg_up_vfb"}),iEdit=MG.Dom.addElement("img",{parent:CI_tc,style:{float:"left",cursor:"pointer"},attrs:{src:imgPath.call()+"/edit.png",alt:"Éditer"}}),iRem=MG.Dom.addElement("img",{parent:CI_tc,style:{float:"right",cursor:"pointer"},attrs:{src:imgPath.call()+"/x.png",alt:"Fermer"}}),iDl=MG.Dom.addElement("img",{parent:CI_tc,attrs:{src:imgPath.call()+"/floppy.png",alt:"Télécharger"},style:{cursor:"pointer"}});MG.Dom.addElement("span",{parent:CI_t,style:{float:"left"}});MG.Dom.addElement("div",{parent:CI_t,style:{clear:"both"}});MG.Dom.addElement("img",{parent:CI_b,attrs:{src:Item["img_seen"],alt:""}});MG.Events.on(iDl,"click",fn_dlFile,this,[Item['id']]);MG.Events.on(iRem,"click",fn_remFile,this,[CI.id,Item['id']]);MG.Events.on(iEdit,"click",fn_editFile,this,[Item['id']]);inject_callback_item_delete(CI.id,this,function(conf){MG.Events.remove(conf.dl.el,"click",conf.dl.fn,conf.dl.scope,conf.dl.args);MG.Events.remove(conf.rem.el,"click",conf.rem.fn,conf.rem.scope,conf.rem.args);MG.Events.remove(conf.edit.el,"click",conf.edit.fn,conf.edit.scope,conf.edit.args);},[{dl:{el:iDl,fn:fn_dlFile,scope:this,args:[Item['id']]},rem:{el:iRem,fn:fn_remFile,scope:this,args:[CI.id,Item['id']]},edit:{el:iEdit,fn:fn_editFile,scope:this,args:[Item['id']]}}]);var value_id=cmpBtnOpenBox.getAttribute("value:id")==""?[]:(cmpBtnOpenBox.getAttribute("value:id")).split(";");value_id[value_id.length]=Item['id'];cmpBtnOpenBox.setAttribute("value:id",value_id.join(";"));}}else if(r.hasOwnProperty('msg'))MG.Msg.warning(r.msg);IF.value="";IN.value="";TD.value="";};var fn_addFile=function(e){if(IF.value){MG.Request.ajaj({type:"IHR",data:{form:F},callback:fn_callback_viewer,scope:this});}};var idFile_current_edit=0;var fn_valideEditFile=function(e){if(idFile_current_edit !==0){var data={id:idFile_current_edit,nom:IN.value,desc:TD.value};data[action.edit.key]=action.edit.value;MG.Request.ajaj({data:data,callback:function(r){if(r.success===true){if(itemData.hasOwnProperty(idFile_current_edit)){itemData[idFile_current_edit]['name']=IN.value;itemData[idFile_current_edit]['desc']=TD.value;}IF.value="";IN.value="";TD.value="";idFile_current_edit=0;btnAdd.style.display="";btnEdit.style.display="none";btnCancel.style.display="none";IF.disabled=false;}else if(r.hasOwnProperty('msg'))MG.Msg.warning(r.msg);}});}};var fn_cancelEditFile=function(e){btnAdd.style.display="";btnEdit.style.display="none";btnCancel.style.display="none";IF.disabled=false;IN.value="";TD.value="";idFile_current_edit=0;};var fn_remFile=function(e,divID,fileID){var data={id:fileID};data[action.rem.key]=action.rem.value;MG.Request.ajaj({data:data,callback:function(r){if(r.success===true){cmpNotif.innerHTML=parseInt(cmpNotif.innerHTML)-1;var value_id=cmpBtnOpenBox.getAttribute("value:id")==""?[]:(cmpBtnOpenBox.getAttribute("value:id")).split(";");for(var i=0,ilen=value_id.length;i<ilen;i++)if(value_id[i]==fileID)value_id.splice(i,1);cmpBtnOpenBox.setAttribute("value:id",value_id.join(";"));if(callbacks_item_delete.hasOwnProperty(divID))callbacks_item_delete[divID].callback.apply(callbacks_item_delete[divID].scope,callbacks_item_delete[divID].args);MG.Dom.delNode(divID);}else if(r.hasOwnProperty('msg'))MG.Msg.warning(r.msg);}});};var fn_editFile=function(e,id){btnAdd.style.display="none";btnEdit.style.display="";btnCancel.style.display="";idFile_current_edit=id;IF.disabled=true;IN.value=itemData[id]['name'];TD.value=itemData[id]['desc'];};var fn_dlFile=function(e,id){window.open(action.file+"?"+action.dl.key+"="+action.dl.value+"&id="+id);return false;};var fn_openBox=function(e){MG.Effect.blurContainer.on(body);C.style.display="block";};var fn_closeBox=function(e){MG.Effect.blurContainer.off(body);C.style.display="none";};var fn__keyField=function(e){if(e.keyCode==13)MG.Events.fire(btnAdd,"click");};MG.Events.on(btnOpenBox,"click",fn_openBox);MG.Events.on(HC,"click",fn_closeBox);MG.Events.on(btnAdd,"click",fn_addFile);MG.Events.on(btnEdit,"click",fn_valideEditFile);MG.Events.on(btnCancel,"click",fn_cancelEditFile);MG.Events.on(IF,"keydown",fn__keyField);MG.Events.on(FNinputC,"keydown",fn__keyField);injectFnEvRm(cmpBtnOpenBox.id,function(){for(itemID in callbacks_item_delete)callbacks_item_delete[itemID].callback.apply(callbacks_item_delete[itemID].scope,callbacks_item_delete[itemID].args);MG.Events.remove(btnOpenBox,"click",fn_openBox);MG.Events.remove(HC,"click",fn_closeBox);MG.Events.remove(btnAdd,"click",fn_addFile);MG.Events.remove(IF,"keydown",fn__keyField);MG.Events.remove(FNinputC,"keydown",fn__keyField);MG.Dom.delNode(C);});if(data)fn_callback_viewer({success:true,data:data});return cmpBtnOpenBox;};var multiSelBox=function(conf){var conf=conf||{},id=conf.id||true,activeHover=conf.activeHover||false,parent=conf.parent||false,data=conf.data||false,reqAjaj=conf.reqAjaj||false,BoxStyle=conf.style||{},BoxViewStyle=conf.styleView||{},height=conf.height||false,width=conf.width||170,isOpen=false;BoxStyle["width"]=width+"px";var Box=MG.Dom.addElement("div",{parent:parent,id:id,style:BoxStyle,cls:"mg__multisel_b",attrs:{"value:ref":""}}),BoxView=MG.Dom.addElement("div",{parent:Box,style:BoxViewStyle,cls:"mg__multisel_bv"}),BoxData=MG.Dom.addElement("div",{parent:Box,cls:"mg__multisel_bd",style:{width:(width-2)+"px"}});var ViewItemsCheck=MG.Dom.addElement("input",{parent:BoxView,style:{width:(width-30)+"px"}});ViewItemsCheck.readOnly=true;MG.Dom.addElement("img",{parent:BoxView,attrs:{src:imgPath.call()+"/arrow_down.png",alt:""}});MG.Dom.addElement("div",{parent:BoxView,cls:"mg__both"});var searchBox=MG.Dom.addElement("div",{parent:BoxData,cls:"mg__multisel_bd_sb"}),inputSB=MG.Dom.addElement("input",{parent:searchBox,style:{width:(width-25)+"px"}});MG.Dom.addElement("img",{parent:searchBox,attrs:{src:imgPath.call()+"/loupe.png",alt:""}});MG.Dom.addElement("div",{parent:searchBox,cls:"mg__both"});var itemsBox=MG.Dom.addElement("div",{parent:BoxData,cls:"mg__multisel_bd_il"}),itemList=[],itemsChecked={};var fn__searching=function(e){exp=new RegExp(e.el.value+'.*','i');for(var i=0,ilen=itemList.length;i<ilen;i++){var item=itemList[i];if(item["label"].search(exp)!=-1||item["ks"].search(exp)!=-1)item["cmp"].style.display="block";else item["cmp"].style.display="none";}};var fn__check=function(e,index){var item=itemList[index];if(item["check"]==true){item["checkBox"].src=imgPath.call()+"/uncheckbox.png";delete itemsChecked[item["ref"]];item["check"]=false;}else{item["checkBox"].src=imgPath.call()+"/checkbox.png";itemsChecked[item["ref"]]=item["label"];item["check"]=true;}var valueRef="",valueLabel="";for(ref in itemsChecked){valueRef+=valueRef==""?ref:","+ref;valueLabel+=valueLabel==""?itemsChecked[ref]:","+itemsChecked[ref];}Box.setAttribute("value:ref",valueRef);ViewItemsCheck.value=valueLabel;};var fn__buildItemList=function(r){if(r.success==true&&r.hasOwnProperty("data")){for(var i=0,ilen=r.data.length;i<ilen;i++){var item=r.data[i],I_container=MG.Dom.addElement("div",{parent:itemsBox,cls:"mg__multisel_bd_il_i"}),I_checkBox=MG.Dom.addElement("img",{parent:I_container,attrs:{src:imgPath.call()+"/uncheckbox.png",alt:""}});MG.Dom.addElement("span",{parent:I_container,value:item["label"]});MG.Dom.addElement("div",{parent:I_container,cls:"mg__both"});if(activeHover)MG.Effect.rollhover(I_container,{hover:{"background-color":"#0069AA"}});itemList[i]={"ref":item["ref"],"label":item["label"],"ks":item.hasOwnProperty("ksearch")?item["ksearch"]:"","check":false,"cmp":I_container,"checkBox":I_checkBox};MG.Events.on(I_container,"click",fn__check,this,[i]);injectFnEvRm(Box.id,function(el,fn,scope){MG.Events.remove(el,"click",fn,scope);MG.Effect.removeEvEffect(el.id);},[I_container,fn__check,this]);if(item["check"]==true)MG.Events.fire(I_container,"click");}if(r.data.length>=10)MG.Style.setStyle(itemsBox,"height","240px");MG.Style.setStyle(itemsBox,"overflow","auto");if(height)MG.Style.setStyle(itemsBox,"height",height+"px");}else if(r.hasOwnProperty("msg"))MG.Msg.warning(r.msg);};var clean__options=function(){for(k in itemList){var I_container=itemList[k]["cmp"];MG.Events.remove(I_container,"click",fn__check,this);MG.Dom.delNode(I_container);delete itemList[k];};};Box.replaceOptions=function(data){clean__options();fn__buildItemList.call(this,{success:true,data:data});};Box.checkOptions=function(data){for(k in itemList)if(data.hasOwnProperty(itemList[k]["ref"]))MG.Events.fire(itemList[k]["cmp"],"click");};var cursorInBoxData=false;var fn__overBox=function(e){if(!cursorInBoxData){cursorInBoxData=true;MG.Events.remove(document,"click",fn__close);}};var fn__outBox=function(e){cursorInBoxData=false;MG.Events.on(document,"click",fn__close);};var fn__open=function(e){if(!isOpen){BoxData.style.display="block";isOpen=true;cursorInBoxData=true;MG.Events.on(Box,"mouseout",fn__outBox);MG.Events.on(Box,"mouseover",fn__overBox);}};var fn__close=function(e){BoxData.style.display="none";isOpen=false;MG.Events.remove(Box,"mouseout",fn__outBox);MG.Events.remove(Box,"mouseover",fn__overBox);MG.Events.remove(document,"click",fn__close);};if(reqAjaj){MG.Request.ajaj({data:reqAjaj,callback:fn__buildItemList,scope:this});}else if(data){fn__buildItemList.call(this,{success:true,data:data});}MG.Events.on(inputSB,"keyup",fn__searching,this);MG.Events.on(BoxView,"click",fn__open,this);injectFnEvRm(Box.id,function(){MG.Events.remove(inputSB,"keyup",fn__searching,this);MG.Events.remove(BoxView,"click",fn__open,this);});return Box;};var remove=function(id){var r=false,el=MG.$(id);if(MG.Typing.isNode(el)){if(fnElRm.hasOwnProperty(id)){var D=fnElRm[id];for(var i=0,ilen=D.length;i<ilen;i++)D[i].callback.apply(this,D[i].args);}MG.Dom.delNode(el);delete fnElRm[id];r=true;}return r;};var injectFnEvRm=function(id,fn,args){if(!fnElRm.hasOwnProperty(id))fnElRm[id]=[];var D=fnElRm[id],args=args||[];if(MG.Typing.isFunction(fn))D[D.length]={callback:fn,args:args};};return{inputAutoComp:inputAutoComp,upBox:upBox,multiSelBox:multiSelBox,remove:remove};})(); MG.Effect=(function(){var imgPath=MG.getImgPath;var fnEvEffectRm={};var rollhover=function(el,styles){var el=MG.Typing.isString(el)?MG.$(el):el;if(MG.Typing.isNode(el)){var id=el.id?el.id:MG.Dom.genId(el),s_hover=styles.hover||{},s_unhover=styles.unhover||{};var fn_hover=function(){for(var styleKey in s_hover){var css=MG.Style.cssConvers(styleKey,s_hover[styleKey]);el.style[css.key]=css.value;}};var fn_unHover=function(){for(var styleKey in s_hover){var css=MG.Style.cssConvers(styleKey,s_hover[styleKey]);MG.Style.removeStyle(el,css.key);}for(var styleKey in s_unhover){var css=MG.Style.cssConvers(styleKey,s_unhover[styleKey]);el.style[css.key]=css.value;}};if(MG.Typing.typeOf(s_hover)=="object"&&MG.Typing.typeOf(s_unhover)=="object"){MG.Events.on(el,"mouseover",fn_hover);MG.Events.on(el,"mouseout",fn_unHover);MG.Events.on(el,"rollhover",fn_hover);MG.Events.on(el,"rollunhover",fn_unHover);injectFnEvEffectRm(id,function(){MG.Events.remove(el,"mouseover",fn_hover);MG.Events.remove(el,"mouseout",fn_unHover);MG.Events.remove(el,"rollhover",fn_hover);MG.Events.remove(el,"rollunhover",fn_unHover);});}}};var blurContainer=(function(){var list={};var on=function(el,conf){var conf=conf||{},opacity=conf.opacity||'0.80',color=conf.color||"#000",zIndex=conf.zIndex||7,position=conf.position||"fixed",el=MG.Typing.isString(el)?MG.$(el):el;if(MG.Typing.isObject(el)){var id=el.id?el.id:MG.Dom.genId(el);if(!list.hasOwnProperty(id)){if(conf.height)var H=conf.height;else var H=el.nodeName=="BODY"?MG.Window.innerHeight()+"px":(el.offsetHeight !=0?el.offsetHeight+"px":"100%");if(MG.Browser.isIe()==6){position="absolute";H="2000px";}if(position=="absolute"){window.scrollTo(0,0);MG.Style.setStyle(el,"overflow","hidden");}var W=conf.width||(el.offsetWidth !=0?el.offsetWidth+"px":"100%"),node=MG.Dom.addElement("div",{id:true,style:{opacity:opacity,"backgroundColor":color,"zIndex":zIndex,width:W,height:H,position:position}});el.insertBefore(node,el.firstChild);list[id]=node.id;}}};var off=function(el){var el=MG.Typing.isString(el)?MG.$(el):el;if(MG.Typing.isObject(el)){MG.Style.removeStyle(el,"overflow");var id=el.id?el.id:MG.Dom.genId(el);if(list.hasOwnProperty(id)){MG.Dom.delNode(list[id]);delete list[id];}}};return{on:on,off:off};})();var tips=function(el,conf){var fn__close=function(e){MG.Events.remove(Cx,"click",fn__close);MG.Dom.delNode(Ctips);};var fn__out=function(e){MG.Style.hide(Ctips);isVisible=false;};var fn__move=function(e){if(isVisible==false){MG.Style.show(Ctips);isVisible=true;}var pageY=MG.Window.pageYOffset(),pageX=MG.Window.pageXOffset(),innerH=MG.Window.innerHeight(),innerW=MG.Window.innerWidth(),pageH=innerHeight+pageYOffset,pageW=innerWidth+pageXOffset,scrollH=MG.Window.scrollHeight(),scrollW=MG.Window.scrollWidth(),tipsH=Ctips.offsetHeight,tipsW=Ctips.offsetWidth;clientY=e.clientY,clientX=e.clientX;var T=clientY,Tout=pageY+T,B=innerH-T,Bout=scrollH-T;var top_T=(T+pageY)-15-tipsH,top_B=T+pageY+15;if(T>=tipsH||B>=tipsH)Ctips.style["top"]=""+(T>B?top_T:top_B)+"px";else Ctips.style["top"]=""+(Tout>Bout?top_T:top_B)+"px";var L=clientX,Lout=pageX+L,R=innerW-L,Rout=scrollW-L,alignLeft=L<(scrollW/2)?true:false;var left_L=(L+pageX)-15-tipsW,left_R=L+pageX+15;if(L>=tipsW&&R>=tipsW)Ctips.style["left"]=""+(alignLeft?left_L:left_R)+"px";else{if(L>=tipsW||R>=tipsW)Ctips.style["left"]=""+(L>R?left_L:left_R)+"px";else Ctips.style["left"]=""+(Lout>Rout?left_L:left_R)+"px";}};var el=MG.Typing.isString(el)?MG.$(el):el,conf=conf||{},opacity=conf.opacity||"0.80",top=conf.top||false,left=conf.left||false,width=conf.width||false,data=conf.data||false,reqAjaj=conf.reqAjaj||false,closable=conf.closable||false,isVisible=false,parent=conf.parent||MG.$$("body")[0];var pageYOffset=window.pageYOffset||document.documentElement.scrollTop,pageXOffset=window.pageXOffset||document.documentElement.scrollLeft;var innerHeight=MG.Browser.isIe()?document.body.offsetHeight:window.innerHeight,innerWidth=MG.Browser.isIe()?document.body.offsetWidth:window.innerWidth;if(el&&(data||reqAjaj)){var Ctips=MG.Dom.addElement("div",{parent:parent,style:{display:"none","z-index":"10",opacity:opacity,position:"absolute"}});if(width)MG.Style.setStyle(Ctips,"width",width);if(closable){Cx=MG.Dom.addElement("img",{parent:Ctips,style:{cursor:"pointer",float:"right",padding:"5px 5px 0px 5px"},attrs:{src:imgPath.call()+"/x.png",alt:"Close"}});MG.Events.on(Cx,"click",fn__close);}CT=MG.Dom.addElement("div",{parent:Ctips,cls:"mg__tips"});if(MG.Typing.isString(data))CT.innerHTML=data;else CT.appendChild(data);if(closable){top=top?top:(pageYOffset+el.offsetTop-15-Ctips.offsetHeight)+"px";left=left?left:(pageXOffset+el.offsetLeft+15)+"px";MG.Style.setStyle(Ctips,"top",top);MG.Style.setStyle(Ctips,"left",left);MG.Style.show(Ctips);}else{MG.Events.on(el,"mouseout",fn__out);MG.Events.on(el,"mousemove",fn__move);}}};var moveEffect=function(el,cnf){var type=cnf.type||"line";var deplacement=cnf.deplacement||"margin-left";var delay=cnf.delay||200;var length=cnf.length||100;var negatif=length<0?true:false;length=Math.abs(length);var intervalTime=cnf.intervalTime !==undefined?cnf.intervalTime:(delay>200?100:10);var timer=intervalTime;var p=0;var pos;var fn_getnewpos=function(){switch(type){case "line":var px=((timer/delay)*length);break;case "^":var px=725*timer /(104+timer);break;}px=px>length?length:px;return px;};var fn_loop=function(){if(timer>=delay){clearInterval(interval);if(cnf.callback !==undefined)cnf.callback();}fn_move();timer+=intervalTime;};var fn_move=function(){pos=pos==undefined?(parseInt(MG.Style.getStyle(el,deplacement))?parseInt(MG.Style.getStyle(el,deplacement)):0):pos;p=pos+((negatif===true?-1:1)*fn_getnewpos());MG.Style.setStyle(el,deplacement,p+"px");};if(typeof el=="object")var interval=setInterval(fn_loop,timer);};var removeEvEffect=function(id){if(fnEvEffectRm.hasOwnProperty(id)){var D=fnEvEffectRm[id];for(var i=0,ilen=D.length;i<ilen;i++)D[i].callback.apply(this,D[i].args);delete fnEvEffectRm[id];}};var injectFnEvEffectRm=function(id,fn,args){if(!fnEvEffectRm.hasOwnProperty(id))fnEvEffectRm[id]=[];var D=fnEvEffectRm[id],args=args||[];if(MG.Typing.isFunction(fn))D[D.length]={callback:fn,args:args};};return{rollhover:rollhover,blurContainer:blurContainer,tips:tips,moveEffect:moveEffect,removeEvEffect:removeEvEffect};})(); MG.Events=(function(){var register={};var evtMoz={click:'click',contextmenu:'contextmenu',dblclick:'dblclick',mouseover:'mouseover',mouseout:'mouseout',mousedown:'mousedown',mouseup:'mouseup',mousemove:'mousemove',mousewheel:'DOMMouseScroll',select:'select',change:'change',submit:'submit',reset:'reset',focus:'focus',blur:'blur',activate:'DOMActivate',attrchange:'DOMAttrModified',contentloaded:'DOMContentLoaded',load:'load',unload:'unload',resize:'resize',scroll:'scroll',keydown:'keydown',keypress:'keypress',keyup:'keyup'};var evtIe={click:'onclick',contextmenu:'oncontextmenu',dblclick:'ondblclick',mouseover:'onmouseover',mouseout:'onmouseout',mousedown:'onmousedown',mouseup:'onmouseup',mousemove:'onmousemove',mousewheel:'onmousewheel',select:'onselect',change:'onchange',submit:'onsubmit',reset:'onreset',focus:'onfocus',blur:'onblur',activate:'ondomactivate',attrchange:'onpropertychange',load:'onload',unload:'onunload',resize:'onresize',scroll:'onscroll',keydown:'onkeydown',keypress:'onkeypress',keyup:'onkeyup'};var evtOther={click:'click',contextmenu:'contextmenu',dblclick:'dblclick',mouseover:'mouseover',mouseout:'mouseout',mousedown:'mousedown',mouseup:'mouseup',mousemove:'mousemove',mousewheel:'mousewheel',select:'select',change:'change',submit:'submit',reset:'reset',focus:'focus',blur:'blur',activate:'DOMActivate',attrchange:'DOMAttrModified',contentloaded:'DOMContentLoaded',load:'load',unload:'unload',resize:'resize',scroll:'scroll',keydown:'keydown',keypress:'keypress',keyup:'keyup'};var domEvents=(MG.Typing.isNumber(MG.Browser.isIe())&&MG.Browser.isIe()<9)?evtIe:(MG.Browser.isFF()?evtMoz:evtOther);var on=function(arg1,arg2,arg3,arg4,arg5,arg6){var T=MG.Typing,R=register,cible=false,id,handle,scope,args,arg5=arg5||[],arg6=arg6||false,virtual=false;if((T.isObject.call(T,arg1)||T.isString.call(T,arg1))&&T.isString.call(T,arg2)&&T.isFunction.call(T,arg3)){var cible=T.isString.call(T,arg1)?MG.$(arg1):arg1,id=cible.id?cible.id:MG.Dom.genId(cible),event=arg2,handle=arg3,scope=arg4||window,args=T.isArray.call(T,arg5)?arg5:[];if(!domEvents[arg2])virtual=true;if(!R[id])R[id]={};if(!R[id][event]){R[id][event]={element:cible,virtual:virtual,event:event,callbacks:[]};var RE=R[id][event];if(!virtual){RE.handle=function(e){bindCallback.call(MG.Events,e,RE);};domRegister(cible,RE.event,RE.handle);}}else{var RE=R[id][event];}var C=RE.callbacks;C[C.length]={scope:scope,callback:handle,args:args};}};var remove=function(el,e,fn,s,a){var T=MG.Typing,R=register;if((T.isObject.call(T,el)||T.isString.call(T,el))&&T.isString.call(T,e)&&T.isFunction.call(T,fn)){var cible=T.isString.call(T,el)?MG.$(el):el,id=cible.id?cible.id:false,scope=s||window,event=e,args=T.isArray.call(T,a)?a:[];if(R[id]&&id !==false){if(R[id][event]){var RE=R[id][event];var C=RE['callbacks'];for(var i=0,ilen=C.length;i<ilen;i++){if(C[i]!=undefined){if(C[i]['scope'].toString()==scope.toString()&&C[i]['callback'].toString()==fn.toString()){C.splice(i,1);break;}}}if(C.length===0)cleanRegister(id,e);}}}};var removeAll=function(el,e){var T=MG.Typing,R=register;if((T.isObject.call(T,el)||T.isString.call(T,el))&&T.isString.call(T,e)){var cible=T.isString.call(T,el)?MG.$(el):el,id=cible.id?cible.id:MG.Dom.genId(cible);if(R[id]){if(R[id][e]){var RE=R[id][e];var C=RE['callbacks']=[];if(C.length===0)cleanRegister(id,e);}}}};var purge=function(el){var T=MG.Typing,R=register;if(T.isObject.call(T,el)||T.isString.call(T,el)){var cible=T.isString.call(T,el)?MG.$(el):el,id=cible.id?cible.id:MG.Dom.genId(cible);if(R[id])for(E in R[id])removeAll(el,E);}};var fire=function(el,e){var T=MG.Typing,R=register;if((T.isObject.call(T,el)||T.isString.call(T,el))&&T.isString.call(T,e)){var cible=T.isString.call(T,el)?MG.$(el):el,id=cible.id?cible.id:MG.Dom.genId(cible);if(R[id])if(R[id][e])bindCallback({},R[id][e]);}};var bindCallback=function(e,RE){var T=MG.Typing;if(T.isObject.call(T,RE)){var C=RE.callbacks;e.el=RE.element;e.stopEvent=stopEvent;for(var i=0,ilen=C.length;i<ilen;i++){var ae=[e],args=ae.concat(C[i]["args"]);C[i]["callback"].apply(C[i]["scope"],args);}}};var cleanRegister=function(id,e){var R=register;RE=R[id][e];if(!RE.virtual)domUnRegister(RE.element,RE.event,RE.handle);delete R[id][e];if(MG.count(R[id])===0)delete R[id];};var domRegister=function(el,e,fn){if(el.addEventListener)el.addEventListener(domEvents[e],fn,false);else if(el.attachEvent)el.attachEvent(domEvents[e],fn);};var domUnRegister=function(el,e,fn){if(el.removeEventListener)el.removeEventListener(domEvents[e],fn,false);else if(el.detachEvent)el.detachEvent(domEvents[e],fn);};var stopEvent=function(e){if(!e){if(window.event)e=window.event;else return;}if(e.cancelBubble !=null)e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation();if(e.preventDefault)e.preventDefault();if(window.event)e.returnValue=false;if(e.cancel !=null)e.cancel=true;};return{on:on,remove:remove,removeAll:removeAll,purge:purge,fire:fire,nbRE:function(){console.log(MG.count(register));},displayRE:function(){for(pro in register)console.log(pro);},RE:function(){console.log(register.toSource());}};})(); MG.Lang=(function(){var lang="FR";var dico={"Oui":{FR:"Oui",EN:"Yes"},"Non":{FR:"Non",EN:"No"},"Nom":{FR:"Nom",EN:"Last name"},"Prénom":{FR:"Prénom",EN:"Name"},"addpic":{FR:"Gestion des images",EN:"Pictures management"},"addfile":{FR:"Ajouter des fichiers",EN:"Add files"},"Ajouter":{FR:"Ajouter",EN:"Add"},"Modifier":{FR:"Modifier",EN:"Edit"},"Annuler":{FR:"Annuler",EN:"Cancel"}};var fn__setLang=function(str){if(str.match(/^(FR|EN)$/)!=-1)lang=str;};var fn__getlang=function(){return lang;};var fn__word=function(str){var r=str;if(dico.hasOwnProperty(str))r=dico[str][lang];return r};var fn__importWord=function(words){for(kw in words)if(!dico.hasOwnProperty(kw))dico[kw]=words[kw];};return{setLang:fn__setLang,getLang:fn__getlang,word:fn__word,importWord:fn__importWord};})(); MG.ParamCheck=(function(){var login=function(v,regexp){var regexp=regexp||{},exp=regexp.hasOwnProperty('multiline')&&regexp.hasOwnProperty('ignoreCase')?regexp:new RegExp("([0-9a-z_-]){1,32}",'i');return(v.search(exp)!=-1)?true:false;};var passwd=function(v,regexp){var regexp=regexp||{},exp=regexp.hasOwnProperty('multiline')&&regexp.hasOwnProperty('ignoreCase')?regexp:new RegExp("^[a-z0-9\-%_#~;\?\.\:\$]{6,64}$",'i');return(v.search(exp)!=-1)?true:false;};return{login:login,passwd:passwd};})(); MG.Msg=(function(){var imgPath=MG.getImgPath;var warning=function(msg){var msg=msg||"Aucun message définit",body=MG.$$("body")[0];var fn_closeBox=function(e){MG.Effect.blurContainer.off(body);MG.Events.remove(HC_IMG,"click",fn_closeBox);MG.Events.remove(HC_IMG,"click",fn_closeBox);MG.Events.remove(document,"keypress",keySubmit,MG.Msg);MG.Dom.delNode(BOX);};var keySubmit=function(e,callback,scope){if(document.event&&document.event.keyCode==13)callback.call(scope,e);else if(e&&e.keyCode==13)callback.call(scope,e);};MG.Effect.blurContainer.on(body,{position:"absolute"});var BOX=MG.Dom.addElement("div",{parent:body,cls:"mg__box",style:{"z-index":"10",width:"400px",border:"1px solid #888",'margin-left':"-200px",'margin-top':"-80px"}});if(MG.Browser.isIe()==6)MG.Style.addClass(BOX,"mg__box_IE6");var H=MG.Dom.addElement("div",{parent:BOX,cls:"mg__box_h"}),HC=MG.Dom.addElement("div",{parent:H,cls:"mg__box_hc"}),HC_IMG=MG.Dom.addElement("img",{parent:HC,attrs:{src:imgPath.call()+"/x.png",alt:"Close"}});MG.Dom.addElement("div",{parent:H,cls:"mg__box_ht",value:"Message"});MG.Dom.addElement("div",{parent:H,style:{clear:"both"}});var C=MG.Dom.addElement("div",{parent:BOX,cls:"mg__box_c",style:{height:""}}),B=MG.Dom.addElement("div",{parent:BOX,cls:"mg__box_b"}),OK=MG.Dom.addElement("div",{parent:B,value:MG.Lang.word("Ok"),cls:"mg_btn",style:{margin:"0 95px"}});C.innerHTML='<table style="height:100%;width:100%"><tr><td style="text-align:center;vertical-align:middle;">'+msg+'</td></tr></table>';MG.Events.on(HC_IMG,"click",fn_closeBox);MG.Events.on(OK,"click",fn_closeBox);MG.Events.on(document,"keypress",keySubmit,MG.Msg,[fn_closeBox,MG.Msg]);};var prompt=function(o){var msg=o.msg||"Confirmer vous l'action?",callYes=o.callYes||false,callNo=o.callNo||false,noblur=o.noblur||false,zIndex=o.zIndex||10,body=MG.$$("body")[0];var fn_closeBox=function(e){if(!noblur)MG.Effect.blurContainer.off(body);MG.Events.remove(HC_IMG,"click",fn_closeBox);MG.Events.remove(YES,"click",fn_yes);MG.Events.remove(NO,"click",fn_no);MG.Dom.delNode(BOX);};var fn_no=function(e){if(callNo)callNo.call();MG.Events.fire(HC_IMG,"click");};var fn_yes=function(e){callYes.call();MG.Events.fire(HC_IMG,"click");};if(callYes){if(!noblur)MG.Effect.blurContainer.on(body,{position:"absolute"});var BOX=MG.Dom.addElement("div",{parent:body,cls:"mg__box",style:{width:"400px",border:"1px solid #888",'margin-left':"-200px",'margin-top':"-80px","z-index":zIndex}});if(MG.Browser.isIe()==6)MG.Style.addClass(BOX,"mg__box_IE6");var H=MG.Dom.addElement("div",{parent:BOX,cls:"mg__box_h"}),HC=MG.Dom.addElement("div",{parent:H,cls:"mg__box_hc"}),HC_IMG=MG.Dom.addElement("img",{parent:HC,attrs:{src:imgPath.call()+"/x.png",alt:"Close"}});MG.Dom.addElement("div",{parent:H,cls:"mg__box_ht",value:"Confirmation"});MG.Dom.addElement("div",{parent:H,style:{clear:"both"}});var C=MG.Dom.addElement("div",{parent:BOX,cls:"mg__box_c"}),B=MG.Dom.addElement("div",{parent:BOX,cls:"mg__box_b"}),YES=MG.Dom.addElement("div",{parent:B,value:MG.Lang.word("Oui"),cls:"mg_btn",style:{float:"left"}}),NO=MG.Dom.addElement("div",{parent:B,value:MG.Lang.word("Non"),cls:"mg_btn",style:{float:"right"}});MG.Dom.addElement("div",{parent:B,style:{clear:"both"}});C.innerHTML='<table style="height:100%;width:100%"><tr><td style="text-align:center;vertical-align:middle;">'+msg+'</td></tr></table>';MG.Events.on(HC_IMG,"click",fn_closeBox);MG.Events.on(YES,"click",fn_yes);MG.Events.on(NO,"click",fn_no);}else{MG.Console.warning("Vous devez spécifiez une fonction de validation propriété 'callYes'");}};return{warning:warning,prompt:prompt};})();
