var zAct=50;var trad={CCT:"Cristian"};var idDivNotSel='-1';var nCargant=0;var actAnch='-1';var llistaIncludes=new Array(0);var carregant=false;function _$(x){return document.getElementById(x);}function prnt(text){document.write(text);}function trd(x){document.write(trad[x]);}function trdDocument(){trdListElem(document.getElementsByTagName('span'));}function initChekAnchor(){setInterval("checkAnchor()",400);}function checkAnchorDiferent(){var anchor=actAnch;var listDef=defAnch.split('/');var listDif=new Array('');if(anchor.length>0){var listAct=anchor.split('/');for(k=0;k<listAct.length;k++){var matched=false;var paramA=listAct[k].split(';');for(j=0;j<listDef.length&&!matched;j++){var paramB=listDef[j].split(';');if(paramA[0]==paramB[0]){listDif.unshift(listDef[j]);listDef[j]=listAct[k];matched=true;}}}}actAnch='';evalAnchor(listDif);}function genURLElem(id,typ){var url=document.location.href.split('#')[0];url=url.split('?')[0];url=url.split('!=')[0];url=url.substring(url.lastIndexOf('/')+1);if(id!=''){url+='?!=1;'+typ+';'+id;}return url;}function chgLangParamUrl(url,lang){var indxA=url.indexOf('?');var linkLang=url;if(indxA<0){indxA=url.indexOf('#');if(indxA<0){linkLang=linkLang+"?lang="+lang;}else{linkLang=url.substr(0,indxA)+"?lang="+lang+url.substr(indxA,url.length);}}else{indxA=url.indexOf('lang=');var indxB=url.indexOf('&',indxA);if(indxB<0){indxB=url.indexOf('#',indxA);}linkLang=url.substr(0,indxA)+"lang="+lang;if(indxB>0){linkLang+=url.substr(indxB,url.length);}}return linkLang;}function checkAnchor(){var anchor=document.location.hash.substring(1);if(actAnch!=anchor){if(anchor==''){checkAnchorDiferent();}else{actAnch=anchor;var listAnch=actAnch.split('/');evalAnchor(listAnch);}}}function evalAnchor(listDef){for(var k=0;k<listDef.length;k++){var def=listDef[k].split(';');var titl=def[0].split(':');if(titl.length>1){def[0]=titl[1];titl=titl[0];document.title=trad['nomPagina']+' : '+titl;genTitolRuta(titl,listDef[k],def[1]);}var fun='showGet'+def[1]+'("contenidor'+def[0]+'"';for(var i=2;i<def.length;i++){fun+=',"'+def[i]+'"';}fun+=');';try{eval(fun);}catch(e){}}}function trdContenidor(idCont){trdListElem(document.getElementById(idCont).getElementsByTagName('span'));}function trdListElem(list){for(k=0;k<list.length;k++){var tmp=list[k].getAttribute('trd');if(tmp){list[k].removeAttribute(tmp);list[k].innerHTML=trad[tmp];list[k].removeAttribute('trd');}}}function addEvent(obj,evType,fn,useCapture){useCapture=useCapture||false;if(obj.addEventListener){obj.addEventListener(evType,fn,useCapture);return true;}else if(obj.attachEvent){var r=obj.attachEvent("on"+evType,fn);return r;}else{alert("Handler could not be attached");}}function removeEvent(obj,evType,fn,useCapture){useCapture=useCapture||false;if(obj.removeEventListener){obj.removeEventListener(evType,fn,false);}else if(obj.detachEvent){obj.detachEvent('on'+evType,obj[fn.toString()+evType]);obj[fn.toString()+evType]=null;}else{obj['on'+evType]=function(){}}}function cancelEv(e){e=e||window.event;if(e.preventDefault)e.preventDefault();else e.returnValue=false;}function stopEv(e){e=e||window.event;if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true;}function getAbsoluteElementPosition(element){if(typeof element=="string")element=document.getElementById(element);if(!element)return{top:0,left:0};var y=0;var x=0;while(element.offsetParent){x+=element.offsetLeft;y+=element.offsetTop;element=element.offsetParent;}return{top:y,left:x};}function showHide(id){if(_$(id).style.visibility!='hidden'){_$(id).style.visibility='hidden';return'hidden';}else{_$(id).style.visibility='visible';return'visible';}}function show(id){var elm=_$(id);if(elm){elm.style.visibility='visible';}}function hide(id){var elm=_$(id);if(elm){elm.style.visibility='hidden';}}function switchDisplay(id,typ){if(!typ){typ='block';}if(_$(id).style.display!='none'){return notDisplay(id);}else{_$(id).style.display=typ;return typ;}}function notDisplay(id){try{_$(id).style.display='none';}catch(e){}return'none';}function display(id){try{_$(id).style.display='block';}catch(e){}return'block';}function extractDiaData(idDia){var sepD=idDia.indexOf('-',0);var dia=idDia.substring(0,sepD);return dia;}function extractMesData(idDia){var sepD=idDia.indexOf('-',0);var sepM=idDia.indexOf('-',sepD+1);var mes=idDia.substring(sepD+1,sepM);return mes;}function extractAnyData(idDia){var sepD=idDia.indexOf('-',0);var sepM=idDia.indexOf('-',sepD+1);var any=idDia.substring(sepM+1,idDia.length);return any;}function getMesAnterior(data){var mes=extractMesData(data)-1;var any=extractAnyData(data);if(mes<=0){mes=12;any=any-1;}return extractDiaData(data)+"-"+mes+"-"+any;}function getMesPosterior(data){var mes=extractMesData(data)-1+2;var any=extractAnyData(data);if(mes>12){mes=1;any=any-1+2;}return extractDiaData(data)+"-"+mes+"-"+any;}function dateSqlToJava(timestamp){var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;var parts=timestamp.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');var r=new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);return r;}function dateJavaToSql(time){return''+time.getFullYear()+'-'+(time.getMonth()+1)+'-'+time.getDay()+' '+time.getHours()+':'+time.getMinutes()+':'+time.getSeconds();}function htmlToTextArea(text){text=text.split('<br/>').join('\n');text=text.split('<br>').join('\n');text=text.split('&nbsp;').join(' ');text=text.split(/&lt;/).join('<');text=text.split(/&gt;/).join('>');text=text.split(/&amp;/).join('&');return text;}function textAreaToHtml(text){text=text.split('&').join('&amp;');text=text.split(/</).join('&lt;');text=text.split(/>/).join('&gt;');text=text.split(/\n/).join('<br/>');text=text.split(/\s/).join('&nbsp;');return text;}function clearSelection(){if(window.getSelection){window.getSelection().removeAllRanges();}else if(document.selection&&document.selection.empty){try{document.selection.empty();}catch(e3){}}}function escapeReally(text){text=escape(text);text=text.replace(new RegExp("\\+","g"),"%2B");return text;}function unescapeReally(text){text=unescape(text);return text;}function chkMinDigits(text,numDig,errCont){var textResp='';var resp=0;if(text.length<numDig){textResp=trad.errNumDigits+numDig;resp=-1;}if(_$(errCont)){_$(errCont).innerHTML=textResp;return resp;}else{if(textResp!=''){window.alert(textResp);}}}function parseXMLAppendCode(xmlHttp){if(xmlHttp.readyState==4&&xmlHttp.status==200){var resposta=xmlHttp.responseXML;var listResp=resposta.getElementsByTagName("info");var add=0;for(var k=0;k<listResp.length;k++){try{add=listResp[k].getElementsByTagName("add")[0].childNodes[0].nodeValue;}catch(e){}}listResp=resposta.getElementsByTagName("code");for(var k=0;k<listResp.length;k++){var id=listResp[k].getElementsByTagName("id")[0].childNodes[0].nodeValue;var divTmp=_$(id);if(divTmp){divTmp.parentNode.removeChild(divTmp);}var idCont=listResp[k].getElementsByTagName("idCont")[0].childNodes[0].nodeValue;if(!_$(idCont)){var div=document.createElement('div');div.id=idCont;try{document.body.appendChild(div);}catch(e){}}else{var div=_$(idCont);}var codi=listResp[k].getElementsByTagName("html")[0].childNodes[0].nodeValue;if(add==1){div.innerHTML+=codi;}else{div.innerHTML=codi;}}listResp=resposta.getElementsByTagName("include");for(var k=0;k<listResp.length;k++){var path=listResp[k].getElementsByTagName("path")[0].childNodes[0].nodeValue;llistaIncludes.push(path);}iniciaCarregaIncludes();}}function include(path){llistaIncludes.push(path);iniciaCarregaIncludes();}function iniciaCarregaIncludes(){if(!carregant){carregant=true;carregaNextInclude();}}function carregaNextInclude(){if(llistaIncludes.length>0){addInclude(llistaIncludes.shift());}else{carregant=false;}}function addInclude(path){var fr=Array(0);var tmpF=path.indexOf('#',0);var tmpI=0;if(tmpF==-1){fr[0]=path;}else{for(k=0;k<3&&tmpF!=-1;k++){fr[k]=path.substring(tmpI,tmpF);tmpI=tmpF+1;tmpF=path.indexOf('#',tmpI);}fr[k]=path.substring(tmpI,path.length);}if(document.getElementById(fr[0])==null){if(fr[0].match(/\.(css)$/)){loadCss(fr[0]);}else{if(fr[0].match(/\.(js)$/)){if(fr[1]){loadScript(fr[0],fr[1]);}else{loadScript(fr[0],'');}}else{}}}else{if(fr[1]){eval(fr[1]);}carregaNextInclude();}}function loadScript(url,nextFun){var script=document.createElement("script");script.type="text/javascript";if(script.readyState){script.onreadystatechange=function(){if(script.readyState=="loaded"||script.readyState=="complete"){script.onreadystatechange=null;if(nextFun!=''){eval(nextFun);}carregaNextInclude();}};}else{script.addEventListener('load',function(){if(nextFun!=''){eval(nextFun);}carregaNextInclude();},false);}script.id=url;script.src=url;document.getElementsByTagName("head")[0].appendChild(script);}function loadCss(url){var css=document.createElement("link");css.type="text/css";css.rel="stylesheet";css.id=url;css.href=url;document.getElementsByTagName("head")[0].appendChild(css);if(css.readyState){css.onreadystatechange=function(){if(css.readyState=='complete'){carregaNextInclude();}};}else{carregaNextInclude();}}function showGetMenuPopUp(top,left,html){var div=_$('menuPopUp');if(!div){div=document.createElement('div');div.id="menuPopUp";document.body.appendChild(div);}div.style.zIndex=zAct+3;div.style.top=top;div.style.left=left;div.innerHTML='';try{div.appendChild(html);}catch(e){div.innerHTML=html;}div.style.visibility='visible';}function addOpcMenuPopUp(table,funcio,param,titol){var opc=document.createElement('div');opc.className="opcMenPop";opc.innerHTML=titol;table.appendChild(opc);if(funcio!=-1){addEvent(opc,'click',function(e){funcio(param);},true);}return opc;}function clkLogoutCommon(){include(PATH_WEB+'/codi/js/login/login.js#logoutUser();');}function clkLoginCommon(){showGetLoginUsu('loginOkCommon();');}function loginOkCommon(){document.location.reload();}function showGetEditUsu(idU){if(_$('editUsuWin')){showEditUsu(idU);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getCodiEditUsu&idUsu='+idU,parseXMLAppendCode);}}function showGetEditGrup(idG){if(_$('editGrupWin')){showEditGrup(idG);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getCodiEditGrup&idGrup='+idG,parseXMLAppendCode);}}function showGetGestorAdmin(){if(_$('gestorAdminWin')){showGestorAdmin();}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php',parseXMLAppendCode,'action=getGestorAdmin');}}function showGetGestorUsus(){if(_$('gestorUsusWin')){showGestorUsus();}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getCodiGestorUsus',parseXMLAppendCode);}}function showGetGestorGrups(){if(_$('gestorGrupsWin')){showGestorGrups();}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getCodiGestorGrups',parseXMLAppendCode);}}function showGetLoginUsu(fun){if(_$('loginWin')){showLogin(fun);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getCodiLogin&fun='+fun,parseXMLAppendCode);}}function showGetOpcLogin(){var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getCodiLogin&fun='+fun,parseXMLAppendCode);}function showGetGestorCarp(idC){if(_$('gestorCarpWin')){showGestorCarp(idC);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getCodiGestorCarp&idC='+idC,parseXMLAppendCode);}}function showGetGestorFitx(idCont,idC,vA,vC,vN,vLN){if(_$('gestorFitxWin')){showGestorFitx(idC);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php',parseXMLAppendCode,'action=getGestorFitxers&idC='+idC+'&idCont='+idCont+'&vA='+vA+'&vC='+vC+'&vN='+vN+'&vLN='+vLN);}}function showGetEditCont(idCont,idDadIni){if(_$('editContWin')){showEditCont(idDadIni);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getEditorContingut&idCont='+idCont+'&idDadIni='+idDadIni,parseXMLAppendCode);}}function showGetNot(idCont,idN,idL,shTit,shDes,shRes,shIni,shFi,shLloc,shForm,shLink,lang){var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php',parseXMLAppendCode,'action=getShowNoticia&idN='+idN+'&idCont='+idCont+'&idL='+idL+'&tit='+shTit+'&des='+shDes+'&res='+shRes+'&ini='+shIni+'&fi='+shFi+'&lloc='+shLloc+'&form='+shForm+'&idioma='+lang+'&link='+shLink);}function showGetLliNot(idCont,idL,nIni){var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php',parseXMLAppendCode,'action=getShowLliNot&idL='+idL+'&idCont='+idCont+'&nIni='+nIni);}function showGetEditLliNot(idCont,idLN,idCarp,dIni){if(_$('editLliNotWin')){showEditLliNot(idLN,idCarp,dIni);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getEditLliNot&idLN='+idLN+'&idCarp='+idCarp+'&idCont'+idCont+'&dIni'+dIni,parseXMLAppendCode);}}function showGetImg(idCont,idA){if(idCont){_$(idCont).innerHTML='<img src="codi/gf.php?id='+idA+'"/>';}}function showElemNewWin(type,id,tit,idCon,width,height){if(!idCon){idCon=1;}if(!width){width=850;}if(!height){height=700;}if(!tit){tit="ShowWindow"+type+id}tit=escape(tit);switch(type){case'Arx':myRef=window.open(PATH_WEB+'/codi/gf.php?id='+id+'&tit='+tit,tit="ShowWindow"+type+id,'width='+width+',height='+height+',toolbar=yes,resizable=yes,location=yes,scrollbars=yes,directories=no,copyhistory=no');break;case'FlashUpload':myRef=window.open(PATH_WEB+'/blank.php#'+tit+':'+idCon+';'+type+';'+id,"ShowWindow"+type+id,'width='+width+',height='+height+',toolbar=yes,resizable=yes,location=yes,scrollbars=yes,directories=no,copyhistory=no');break;case'EditNot':myRef=window.open(PATH_WEB+'/blank.php#'+tit+':'+idCon+';'+type+';'+id,"Edit Not id:"+id,'width='+width+',height='+height+',toolbar=yes,resizable=yes,location=yes,scrollbars=yes,directories=no,copyhistory=no');break;default:myRef=window.open(PATH_WEB+'/blank.php?!='+idCon+';'+type+';'+id+'&tit='+tit+'',"ShowWindow"+type+id,'width='+width+',height='+height+',toolbar=yes,resizable=yes,location=yes,scrollbars=yes,directories=no,copyhistory=no');break;}}function showGetEditNot(idCont,idN,idCarp,idDivNot,shRes){if(_$(idDivNotSel)){display(idDivNotSel);}idDivNotSel=idDivNot||-1;if(_$('editNotWin')){showEditNot(idN,idCarp,'',idCont,shRes);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php',parseXMLAppendCode,'action=getEditorNoticia&idN='+idN+'&idC='+idCarp+'&idCont='+idCont+'&shRes='+shRes);}}function showGetEditCss(idE,idCont,tab){if(_$('editCssWin')){showEditCss(idE,tab);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getEditCss&idE='+idE+'&idCont='+idCont+'&tab='+tab,parseXMLAppendCode);}}function showGetEditImage(idA,idCont){if(_$('editImageWin')){showEditImage(idA);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getEditImage&idA='+idA+'&idCont='+idCont,parseXMLAppendCode);}}function showGetFlashUpload(idCont,idC){if(_$('flashUploadWin')){showFlashUpload(idC);}else{var sendReq=new sendRequestAjax();sendReq.connect(PATH_WEB+'/codi/php/passarela.php?action=getFlashUpload&idC='+idC+'&idCont='+idCont,parseXMLAppendCode);}}function addCarga(){if(nCargant==0){display('ajaxLoader');document.body.style.cursor="progress";}nCargant++;}function remCarga(){nCargant--;setTimeout(function(){if(nCargant<=0){nCargant=0;notDisplay('ajaxLoader');document.body.style.cursor="";}},500);}function genUrlRec(idR,tip,nom,target){var url=new Array();nom=escape(nom);url[0]='';target=target||'_self';url[1]=target;if(tip.match(/^(image)/)){if(target=="_blank"){url[0]='blank.php?!='+nom+':1;Img;'+idR;}else{url[0]='?!='+nom+':1;Img;'+idR;}}else{if(tip=='not'){url[0]='?!='+nom+':1;Not;'+idR;}else{if(tip=='lliNot'){url[0]='?!='+nom+':1;LliNot;'+idR;}else{url[0]='codi/gf.php?id='+idR+' &tit='+nom;}}}return url;}function genTitolRuta(titol,ruta,type,rec){ruta=escape(ruta);try{var parent=_$('titolRutaNot').parentNode;if(type=='LliNot'){_$('titolRutaNot').innerHTML='';_$('titolRutaArx').innerHTML='';}else{if(type=='Not'){_$('titolRutaArx').innerHTML='';}else{type='Arx';}}}catch(e){}try{_$('titolRuta'+type).innerHTML='<span style="font-size:10px;"> &#222; </span><a href="?!='+ruta+'">'+titol+'</a>';}catch(e){if(rec!=1){try{parent.innerHTML+='<span id="titolRutaArx"></span>';genTitolRuta(titol,ruta,type,1);}catch(e1){}}}}addEvent(window.document,'click',function(e){var ie='0';var evt=window.event||e;if(!evt.target){ie=1;evt.target=evt.srcElement}else{var tmpList=evt.currentTarget.childNodes;for(k=0;k<tmpList.length;k++){}}var elem=evt.target;try{for(var k=0;k<5&&!elem.href;k++){elem=elem.parentNode;}}catch(e){return;}var anch=unescape(elem.href).split('!=');if(anch){if(elem.target=='_blank'){return;}urlPag=nomPagAct.split('?')[0];urlPag=urlPag+'?';if(urlPag.split('!=')[0].indexOf(anch[0],0)>-1){if(anch[1]){var linkTitol='';var titl=anch[1].split(':');if(titl.length>1){}else{linkTitol=evt.target.innerHTML||'';titl.unshift(linkTitol);}if(ie==1){event.returnValue=false;}else{evt.preventDefault();}anch[1]=titl.join(':');window.location=nomPagAct.split('#')[0]+"#"+anch[1];return(false);}}}else{}},false);