
function StringToFloat(stringNumber)
{var number;var i;i=0;if(stringNumber.length==0)return 0;while(i<stringNumber.length)
{if(stringNumber.charAt(i)!="0")break;i++;}
number=parseFloat(stringNumber.substring(i));return number;}
function redondear(num)
{var original=parseFloat(num);if((original*100%100)>=0.5)
{var result=Math.round(original*100)/100+0.01;}
else
{var result=Math.round(original*100)/100;}
return result;}
function CalculaCantidadPorHoras(idHoras,idPrecio1,idPrecio2)
{var horas=0;if(document.getElementById(idHoras).value.length>0)horas=StringToFloat(document.getElementById(idHoras).value);var precio1=0;if(document.getElementById(idPrecio1).value.length>0)precio1=StringToFloat(document.getElementById(idPrecio1).value);var precio2=0;if(document.getElementById(idPrecio2).value.length>0)precio2=StringToFloat(document.getElementById(idPrecio2).value);if(isNaN(horas))horas=0;if(isNaN(precio1))precio1=0;if(isNaN(precio2))precio2=0;document.getElementById(idHoras).value=horas;if(horas==0)return 0;return redondear((precio1+precio2*(horas-1)));}
function CalculaCantidad()
{var fecha=new Date();var value1=CalculaCantidadPorHoras("WTXANINHO","WTXANIVE1","WTXANIVE2");document.getElementById("WTXANINAP").value=value1;var value2=CalculaCantidadPorHoras("WTXASSOHO","WTXASOCI1","WTXASOCI2");document.getElementById("WTXANIMAP").value=value2;var value3=CalculaCantidadPorHoras("WTXALTRHO","WTXALTRE1","WTXALTRE2");document.getElementById("WTXALTRAP").value=value3;document.getElementById("WTXTOTALP").value=value1+value2+value3;}
function replaceAll(palabra,reemplazada,reemplazo)
{if(palabra.indexOf(reemplazada)>=0)
{palabra=palabra.replace(reemplazada,reemplazo);return replaceAll(palabra,reemplazada,reemplazo);}
else
{return palabra;}}
function TraduceFecha(fecha,stringFecha,idioma)
{idioma=idioma.toLowerCase();var catala=new Array();var diaSemana=stringFecha.split(",")[0];var mes=stringFecha.split(",")[1];mes=diaSemana.split("de ")[1];catala["mes"]=new Array("Gener","Febrer","Març","Abril","Maig","Juny","Juliol","Agost","Septembre","Octubre","Novembre","Desembre");catala["dia"]=new Array("Dilluns","Dimarts","Dimecres","Dijous","Divendres","Dissabte","Diumenge");var castellano=new Array();castellano["mes"]=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");castellano["dia"]=new Array("Lunes","Martes","Miercoles","Jueves","Viernes","Sabado","Domingo");switch(idioma)
{case"catala":stringFecha=replaceAll(stringFecha,mes,catala["mes"][fecha.getMonth()]);stringFecha=replaceAll(stringFecha,diaSemana,catala["dia"][fecha.getDay()-1]);break;default:}
stringFecha=stringFecha.substring(0,stringFecha.lastIndexOf(" ")+1);return stringFecha.split(",")[1];}
function GetIdioma()
{var aTmp=window.location.pathname.split('/');return aTmp[aTmp.length-3];}
function fechaFormatoLargo()
{var today=new Date();var resultado=today.toLocaleString();document.write(TraduceFecha(today,resultado,GetIdioma()));}
function CalculaNIF(opcionError,oEvent){var dni;var lletra;var lletra_correcta;var bOk;var ocampo;if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;if(ocampo)
{nif=ocampo.value;nif=nif.toUpperCase();bOk=true;if(nif!='')
{if(isNaN(nif))
{if((nif.length>2)&&(nif.length<10))
{dni=nif.substring(0,nif.length-1);if(!isNumber(dni))
{bOk=false;}
lletra=nif.substring(nif.length-1,nif.length);if(isNaN(dni))
{ocampo.style.color='Red';}
else
{lletra_correcta=quina_lletra(dni);if(lletra!=lletra_correcta)
{dni.concat(lletra_correcta);ocampo.value=dni;}}}
else
{bOk=false}}
else
{if((nif.length>2)&&(nif.length<10))
{if(nif.length<9)ocampo.value=nif.concat(quina_lletra(nif));else bOk=false;}
else
{bOk=false;}}}
devuelveResultado(ocampo,bOk,opcionError);}}
function ValidaNIF(opcionError,oEvent){var dni;var lletra;var lletra_correcta;var bOk;var ocampo;if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;if((ocampo.name=='WTXNUMDOC')||(ocampo.name=='WTXIPSTDO'))
{ocampoTipo=document.getElementById('WTXIPSTDO');ocampo=document.getElementById('WTXNUMDOC');}
else
{ocampoTipo=document.getElementById('WTXREPTDO');ocampo=document.getElementById('WTXREPNDO');}
if(ocampoTipo.value=='0-DNI / CIF')
{if(ocampo)
{nif=ocampo.value;nif=nif.toUpperCase();bOk=true;if(nif!='')
{if(isNaN(nif))
{if((nif.length>2)&&(nif.length<10))
{dni=nif.substring(0,nif.length-1);lletra=nif.substring(nif.length-1,nif.length);if(isNaN(dni))
{bOk=false;}
else
{lletra_correcta=quina_lletra(dni);if(lletra!=lletra_correcta)
{bOk=false;}}}
else
{bOk=false;}}
else
{bOk=false;}}}}
else
{bOk=true;}
devuelveResultado(ocampo,bOk,opcionError);}
function validaDecimal(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{decimal=ocampo.value;if(decimal.indexOf(',')>=0)bOk=false;if(bOk)
{separador=decimal.indexOf('.');if(separador==-1)
{if(!(validaNumeroInterno(decimal)))bOk=false;else ocampo.value=decimal+".0";}
else
{if(separador==0)
{partEntera="0";partDecimal=decimal.substring(separador+1);;}
else
{if(separador==decimal.length-1)
{partEntera=decimal.substring(0,separador);partDecimal="0";}
else
{partEntera=decimal.substring(0,separador);partDecimal=decimal.substring(separador+1);}}
if(!(validaNumeroInterno(partDecimal)))bOk=false;if(!(validaNumeroInterno(partEntera)))bOk=false;if(bOk)ocampo.value=partEntera+"."+partDecimal;}}
devuelveResultado(ocampo,bOk,opcionError);}}
function validaNumero(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{num=ocampo.value;bOk=validaNumeroInterno(num);devuelveResultado(ocampo,bOk,opcionError);}}
function validaLetras(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{cadena=ocampo.value;for(i=0;i<cadena.length;i++){if(((cadena.charAt(i)<'a')||(cadena.charAt(i)>'z'))&&((cadena.charAt(i)<'A')||(cadena.charAt(i)>'Z')))bOk=false;}
devuelveResultado(ocampo,bOk,opcionError);}}
function validaCaracters(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{cadena=ocampo.value;if(cadena!='')
{for(i=0;i<cadena.length;i++){if(((cadena.charAt(i)<'a')||(cadena.charAt(i)>'z'))&&((cadena.charAt(i)<'A')||(cadena.charAt(i)>'Z'))&&((cadena.charAt(i)<'0')||(cadena.charAt(i)>'9'))&&(cadena.charAt(i)!='.')&&(cadena.charAt(i)!='@'))bOk=false;}
devuelveResultado(ocampo,bOk,opcionError);}}}
function validaTelf(opcionError,oEvent){if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{num=ocampo.value;if(num!='')
{if(num.length!=9)
{if((num.charAt(0)!='0')||(num.charAt(1)!='0'))
{bOk=false;}
else
{bOk=validaNumeroInterno(num);}}
else
{bOk=validaNumeroInterno(num);}
devuelveResultado(ocampo,bOk,opcionError);}}}
function validaCP(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{num=ocampo.value;if(num!='')
{if(num.length==5)
{bOk=validaNumeroInterno(num);}
else
{bOk=false;}
devuelveResultado(ocampo,bOk,opcionError);}}}
function validaCorreu(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{adr=ocampo.value;if(adr!='')
{if((adr.indexOf('@')>0)&&(adr.indexOf('@')<adr.lastIndexOf('.'))&&(adr.indexOf('.')!=adr.length-1)&&(adr.indexOf('@')==adr.lastIndexOf('@'))&&validaCaractersIntern(adr))
{bOk=true;}else
{bOk=false;}
devuelveResultado(ocampo,bOk,opcionError);}}}
function ValidarData(opcionError,oEvent){var bTraspas;if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{sData=ocampo.value;sData=sData.split("/");if(sData.length!=3)
{bOk=false;}
else
{if((sData[0].length!=2)||(sData[1].length!=2)||(sData[2].length!=4))
{bOk=false;;}
else
{if((sData[2]<1900)||(sData[2]>2100))
{bOk=false;}
else
{if((sData[1]==1)||(sData[1]==3)||(sData[1]==5)||(sData[1]==7)||(sData[1]==8)||(sData[1]==10)||(sData[1]==12))
{if((sData[0]<1)||(sData[0]>31))
{bOk=false;}}
else
{if((sData[1]==4)||(sData[1]==6)||(sData[1]==9)||(sData[1]==11))
{if((sData[0]<1)||(sData[0]>30))bOk=false;}
else
{if(sData[1]==2)
{bTraspas=Traspas(sData[2]);if((bTraspas)&&((sData[0]<1)||(sData[0]>29)))
bOk=false;else if((!bTraspas)&&((sData[0]<1)||(sData[0]>28)))
bOk=false;}
else bOk=false;}}}}}
devuelveResultado(ocampo,bOk,opcionError);}}
function TransformarData(opcionError,oEvent){var iDia;var iMes;var iAny;if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{sData=ocampo.value;sData=sData.split("/");if(sData.length!=3)bOk=false;else{if(sData[0].length==1)iDia="0"+sData[0];else iDia=sData[0];if(sData[1].length==1)iMes="0"+sData[1];else iMes=sData[1];if(sData[2].length==2){if(sData[2][0]>=6)iAny="19"+sData[2];else iAny="20"+sData[2];}
else iAny=sData[2];}
if(!ValidarDataInterno(iDia+"/"+iMes+"/"+iAny))bOk=false;else
{ocampo.value=(iDia+"/"+iMes+"/"+iAny);}
devuelveResultado(ocampo,bOk,opcionError);}}
function ValidarObligatori(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=true;if(ocampo)
{s=ocampo.value;bOk=!((s==null)||(s.lenght==0)||s=='')
devuelveResultado(ocampo,bOk,opcionError);}}
function ValidaMes(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;bOk=false;if(ocampo)
{if(validaNumeroInterno(ocampo.value))
{s=parseInt(ocampo.value,10);if(!isNaN(s))
bOk=((s>0)&&(s<13))}
devuelveResultado(ocampo,bOk,opcionError);}}
function ValidarDocVisat(oEvent)
{var bOk,oCampoDoc,aCampos,sURL,sIdCol,sAssumeix;bOk=true;if(NavegadorIE())oCampoDoc=oEvent.srcElement;else oCampoDoc=oEvent.target;if(oCampoDoc.value.length>0)
{aCampos=document.getElementsByName('WTXCAMPRO');sIdCol=aCampos.item(0).value;if(oCampoDoc.name=='WTXREFASS')sAssumeix='S';else sAssumeix='N';sURL='/ABSIS/eAD/MTM/Acciones/SrvAcciones.asmx/ValidarDocVisat?idCol='+sIdCol+'&idDoc='+oCampoDoc.value+'&assumeix='+sAssumeix;if(NavegadorIE())xmlHttpReq=new ActiveXObject("MSXML2.XMLHTTP");else xmlHttpReq=new XMLHttpRequest();xmlHttpReq.open("GET",sURL,false);xmlHttpReq.send("");if(xmlHttpReq.responseXML!=null)
{if(NavegadorIE())bOk=(xmlHttpReq.responseXML.documentElement.nodeTypedValue=='S');else bOk=(xmlHttpReq.responseXML.documentElement.textContent=='S');}
else bOk=false;}
formateaCampoResult(oCampoDoc,bOk);if(!bOk)
{alert(strRefDocIncorrecta);oCampoDoc.focus();}}
function recalcularCampos()
{var result=0;var num1=0;var num2=0;if(document.getElementById('WTXNUMER1').value)
{num1=parseInt(document.getElementById('WTXNUMER1').value);}
if(document.getElementById('WTXNUMER2').value)
{num2=parseInt(document.getElementById('WTXNUMER2').value);}
result=num1+num2;document.getElementById('WTXRESULT').value=result;}
function CalculaImportNet()
{var importeBrut=0;var percIva=0;var percDte=0;var importNet=0;var result=0;if(document.getElementById('WTXIMPBRU').value)
{if(ValidaDecimalIntern(document.getElementById('WTXIMPBRU').value))
importeBrut=parseFloat(document.getElementById('WTXIMPBRU').value);}
if(document.getElementById('WTXPORDTO').value)
{if(ValidaPercentatgeIntern(document.getElementById('WTXPORDTO').value))
percDte=parseInt(document.getElementById('WTXPORDTO').value);}
if(document.getElementById('WTXPORIVA').value)
{if(ValidaPercentatgeIntern(document.getElementById('WTXPORIVA').value))
percIva=parseInt(document.getElementById('WTXPORIVA').value);}
result=importeBrut-(importeBrut*percDte/100);document.getElementById('WTXIMPNET').value=roundNumber(result+(result*percIva/100),2);}
function ValidaPercentatge(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;var bOk=true;var num;if(ocampo)
{num=ocampo.value;bOk=ValidaPercentatgeIntern(num);devuelveResultado(ocampo,bOk,opcionError);}}
function ValidaPercentatgeIntern(num)
{if(validaNumeroInterno(num))
{return((num>=0)&&(num<=100));}
else return false;}
function ValidaDecimalIntern(decimal){var bOk=true;var separador;var partEntera;var partDecimal;if(decimal.indexOf(',')>=0)bOk=false;if(bOk)
{separador=decimal.indexOf('.');if(separador==-1)
{if(!(validaNumeroInterno(decimal)))bOk=false;}
else
{if(separador==0)
{partEntera="0";partDecimal=decimal.substring(separador+1);}
else
{if(separador==decimal.length-1)
{partEntera=decimal.substring(0,separador);partDecimal="0";}
else
{partEntera=decimal.substring(0,separador);partDecimal=decimal.substring(separador+1);}}
if(!(validaNumeroInterno(partDecimal)))bOk=false;if(!(validaNumeroInterno(partEntera)))bOk=false;}}
return bOk;}
function textoEvento(oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;var sTexto;sTexto='Se ha provocado el evento '+oEvent.type+' sobre el campo '+ocampo.name
alert(sTexto);}
function mostrarPopupTextoClick()
{alert('Se ha provocado un click sobre un campo de texto');}
function mostrarPopupTexto()
{alert('Se ha provocado un evento sobre un evento texto');}
function Traspas(iAny){if((iAny%4)==0){if((iAny%100)==0){if((iAny%400)==0)return(true);else return(false);}
else return(true);}
else return(false);}
function quina_lletra(Dni){var lletra=new Array("T","R","W","A","G","M","Y","F","P","D","X","B","N","J","Z","S","Q","V","H","L","C","K","E");if(isNaN(Dni))return false;else return(lletra[Dni%23]);}
function validaCaractersIntern(cadena)
{bOk=true;if(cadena!='')
{for(i=0;i<cadena.length;i++){if(((cadena.charAt(i)<'a')||(cadena.charAt(i)>'z'))&&((cadena.charAt(i)<'A')||(cadena.charAt(i)>'Z'))&&((cadena.charAt(i)<'0')||(cadena.charAt(i)>'9'))&&(cadena.charAt(i)!='.')&&(cadena.charAt(i)!='@')&&(cadena.charAt(i)!='Ç')&&(cadena.charAt(i)!='Ñ')&&(cadena.charAt(i)!='ç')&&(cadena.charAt(i)!='ñ')&&(cadena.charAt(i)!='_')&&(cadena.charAt(i)!='-'))
bOk=false;}}
return bOk;}
function roundNumber(number,decimals){return Math.round(number*Math.pow(10,decimals))/Math.pow(10,decimals);}
function validaNumeroInterno(num)
{for(i=0;i<num.length;i++){if(num.charAt(i)<'0'||num.charAt(i)>'9')return false;}
return true;}
function ValidarDataInterno(sData){var bTraspas;sData=sData.split("/");if(sData.length!=3)
{return(false);}
else
{if((sData[0].length!=2)||(sData[1].length!=2)||(sData[2].length!=4))
{return(false);}
else
{if((sData[2]<1900)||(sData[2]>2100))
{return(false);}
else
{if((sData[1]==1)||(sData[1]==3)||(sData[1]==5)||(sData[1]==7)||(sData[1]==8)||(sData[1]==10)||(sData[1]==12))
{if((sData[0]<1)||(sData[0]>31))
{return false;}}
else
{if((sData[1]==4)||(sData[1]==6)||(sData[1]==9)||(sData[1]==11))
{if((sData[0]<1)||(sData[0]>30))return(false);}
else
{if(sData[1]==2)
{bTraspas=Traspas(sData[2]);if((bTraspas)&&((sData[0]<1)||(sData[0]>29)))
return(false);else if((!bTraspas)&&((sData[0]<1)||(sData[0]>28)))
return(false);}
else return false;}}}}}
return(true);}
function devuelveResultado(ocampo,resultado,opcionError,sMensaje)
{if(opcionError=='rojo')
{formateaCampoResult(ocampo,resultado);}
else if(opcionError=='mensaje'&&!resultado)
{if(!sMensaje)sMensaje="Campo no válido";alert(sMensaje);}}
function formateaCampoResult(ocampo,resultado)
{if(resultado)
{ocampo.style.color='Black';if(ocampo.style.backgroundColor=='Red'||ocampo.style.backgroundColor=='red')
{ocampo.style.backgroundColor="";}}
else
{if(ocampo.value.length==0)
{ocampo.style.color='White';ocampo.style.backgroundColor='Red';}
else
{ocampo.style.color='Red';ocampo.style.backgroundColor="";}}}
function CopiarEmail(opcionError,oEvent)
{if(NavegadorIE())ocampo=oEvent.srcElement;else ocampo=oEvent.target;document.getElementById('WTGMAINOT').value=ocampo.value;}
function CerrarVentana(){window.close();}
function insertAutoCompleteDestinatario(){if(document.getElementById("WTXNOMDES")){var sNomCampo='WTXNOMDES';}else{var sNomCampo='FIL_WUSNOMBRE';}
var urlASP='../../forms_base/lstusu.asp'
var idtargetDIV='targetLst_'+sNomCampo;var htmltargetDiv='<div id="'+idtargetDIV+'" class="auto_complete" ></div>';var getItemUpdate=function(resp){var oNode=document.getElementById(resp.id);var sNombre=oNode.getAttribute("WUSNOMBRE");var sApell1=oNode.getAttribute("WUSAPELL1");var sApell2=oNode.getAttribute("WUSAPELL2");if(oNode.getAttribute("WUSDIRMAI")){var sDirmail=oNode.getAttribute("WUSDIRMAI");}
var oNombre,oApell1,oApell2,oDirmail;if(document.getElementById("WTXNOMDES")){oNombre=document.getElementById("WTXNOMDES");oNombre.value=sNombre;oApell1=document.getElementById("WTXAP1DES");oApell1.value=sApell1;oApell2=document.getElementById("WTXAP2DES");oApell2.value=sApell2;if(document.getElementById("WTGMAINOT")){oDirmail=document.getElementById("WTGMAINOT");oDirmail.value=sDirmail;}}else{oNombre=document.getElementById("FIL_WUSNOMBRE");oNombre.value=sNombre;oApell1=document.getElementById("FIL_WUSAPELL1");oApell1.value=sApell1;oApell2=document.getElementById("FIL_WUSAPELL2");oApell2.value=sApell2;}}
new Insertion.After(sNomCampo,htmltargetDiv);new Ajax.Autocompleter(sNomCampo,idtargetDIV,urlASP,{updateElement:getItemUpdate});}
function hiHaArticleSeleccionat()
{var bSelec=false;if(document.getElementById('WTXLISTA1').checked)bSelec=true;else if(document.getElementById('WTXLISTA8').checked)bSelec=true;else if(document.getElementById('WTXLIST15').checked)bSelec=true;else if(document.getElementById('WTXLISTA2').checked)bSelec=true;else if(document.getElementById('WTXLISTA9').checked)bSelec=true;else if(document.getElementById('WTXLIST16').checked)bSelec=true;else if(document.getElementById('WTXLISTA3').checked)bSelec=true;else if(document.getElementById('WTXLIST10').checked)bSelec=true;else if(document.getElementById('WTXLIST17').checked)bSelec=true;else if(document.getElementById('WTXLISTA4').checked)bSelec=true;else if(document.getElementById('WTXLIST11').checked)bSelec=true;else if(document.getElementById('WTXLIST18').checked)bSelec=true;else if(document.getElementById('WTXLISTA5').checked)bSelec=true;else if(document.getElementById('WTXLIST12').checked)bSelec=true;else if(document.getElementById('WTXLIST19').checked)bSelec=true;else if(document.getElementById('WTXLISTA6').checked)bSelec=true;else if(document.getElementById('WTXLIST13').checked)bSelec=true;else if(document.getElementById('WTXLIST20').checked)bSelec=true;else if(document.getElementById('WTXLISTA7').checked)bSelec=true;else if(document.getElementById('WTXLIST14').checked)bSelec=true;return bSelec;}
function validarArticleSeleccionat(oCheck)
{if(!hiHaArticleSeleccionat())
{oCheck.checked=true;alert("Cal seleccionar al menys un article");return(false);}
else
return(true);}
function marcarArticleSeleccionatDefecte()
{if(!hiHaArticleSeleccionat())
document.getElementById('WTXLIST20').checked=true;}
function desmarcarArticle()
{document.getElementById('WTXLISTA1').checked=false;document.getElementById('WTXLISTA8').checked=false;document.getElementById('WTXLIST15').checked=false;document.getElementById('WTXLISTA2').checked=false;document.getElementById('WTXLISTA9').checked=false;document.getElementById('WTXLIST16').checked=false;document.getElementById('WTXLISTA3').checked=false;document.getElementById('WTXLIST10').checked=false;document.getElementById('WTXLIST17').checked=false;document.getElementById('WTXLISTA4').checked=false;document.getElementById('WTXLIST11').checked=false;document.getElementById('WTXLIST18').checked=false;document.getElementById('WTXLISTA5').checked=false;document.getElementById('WTXLIST12').checked=false;document.getElementById('WTXLIST19').checked=false;document.getElementById('WTXLISTA6').checked=false;document.getElementById('WTXLIST13').checked=false;document.getElementById('WTXLIST20').checked=false;document.getElementById('WTXLISTA7').checked=false;document.getElementById('WTXLIST14').checked=false;}
function hiHaTipusSeleccionat()
{var bSelec=false;if(document.getElementById('WTXLIST31').checked)bSelec=true;else if(document.getElementById('WTXLIST32').checked)bSelec=true;else if(document.getElementById('WTXLIST33').checked)bSelec=true;else if(document.getElementById('WTXLIST34').checked)bSelec=true;else if(document.getElementById('WTXLIST35').checked)bSelec=true;else if(document.getElementById('WTXLIST36').checked)bSelec=true;return bSelec;}
function validarTipusSeleccionat(oCheck)
{if(!hiHaTipusSeleccionat())
{oCheck.checked=true;alert("Cal seleccionar al menys un tipus d'activitat");return(false);}
else
return(true);}
function marcarTipusSeleccionatDefecte()
{if(!hiHaTipusSeleccionat())
document.getElementById('WTXLIST31').checked=true;}
function desmarcarTipus()
{document.getElementById('WTXLIST31').checked=false;document.getElementById('WTXLIST32').checked=false;document.getElementById('WTXLIST33').checked=false;document.getElementById('WTXLIST34').checked=false;document.getElementById('WTXLIST35').checked=false;document.getElementById('WTXLIST36').checked=false;}
function mostrarOcultarDadesFestaMajor()
{oElem=getElementsByClassName('dadesFestaMajor');oElemCheck=document.getElementById('WTXCHKMAJ');if(oElem.length>0)
{if(oElemCheck.checked==false)
{oElem[0].style.display="none";}
else
{if(document.getElementById('WTXCHKDIV').checked)
{document.getElementById('WTXCHKDIV').checked=false;getElementsByClassName('dadesDiverses')[0].style.display="none";desmarcarTipus();}
oElem[0].style.display="";marcarArticleSeleccionatDefecte();}}}
function mostrarOcultarDadesDiverses()
{oElem=getElementsByClassName('dadesDiverses');oElemCheck=document.getElementById('WTXCHKDIV');if(oElem.length>0)
{if(oElemCheck.checked==false)
{oElem[0].style.display="none";}
else
{if(document.getElementById('WTXCHKMAJ').checked)
{document.getElementById('WTXCHKMAJ').checked=false;getElementsByClassName('dadesFestaMajor')[0].style.display="none";desmarcarArticle();}
oElem[0].style.display="";marcarTipusSeleccionatDefecte();}}}
function getElementsByClassName(classname,node)
{if(!node)node=document.getElementsByTagName("body")[0];var a=[];var re=new RegExp('\\b'+classname+'\\b');var els=node.getElementsByTagName("*");for(var i=0,j=els.length;i<j;i++)
if(re.test(els[i].className))a.push(els[i]);return a;}
function getElementsByClass(type,clsName){var retVal=new Array();var elements=document.getElementsByTagName(type);for(var i=0;i<elements.length;i++){if(elements[i].className.indexOf(" ")>=0){var classes=elements[i].className.split(" ");for(var j=0;j<classes.length;j++){if(classes[j]==clsName)
retVal.push(elements[i]);}}
else if(elements[i].className==clsName)
retVal.push(elements[i]);}
return retVal;}
function sumaCampsTorn(torns,campResultat)
{var Tamanyo=torns.length;var suma=0;var i=0;while(i<Tamanyo)
{if(document.getElementById(torns[i]+"C").checked)
{suma=suma+Number(document.getElementById(torns[i]+"V").value);}
i++;}
document.getElementById(campResultat).value=suma;}
function sumaCamposInscripcion(){
  var resultado=0;
  var num1=0;
  var num2=0;
  var num3=0;
  var num4=0;
  var num5=0;
  var num6=0;
  var num7=0;
  var num8=0;
  var num9=0;
  var num10=0;
  var num11=0;
  var num12=0;
  var num13=0;
  var num14=0;
  var num15=0;
  
  if (document.getElementById('WTXTORN_70')!=undefined){
	if (document.getElementById('WTXTORN_70').checked){num1=parseFloat('95.90');}
  }
  if (document.getElementById('WTXTORN_71')!=undefined){
	if (document.getElementById('WTXTORN_71').checked){num2=parseFloat('54.00');}
  }
  if (document.getElementById('WTXTORN_72')!=undefined){
	if (document.getElementById('WTXTORN_72').checked){num3=parseFloat('54.00');}
  }
  if (document.getElementById('WTXTORN_73')!=undefined){
	if (document.getElementById('WTXTORN_73').checked){num4=parseFloat('00.00');}
  }
  if (document.getElementById('WTXMENJA1')!=undefined){
	if (document.getElementById('WTXMENJA1').checked){num5=parseFloat('48.00');}
  }
  if (document.getElementById('WTXMENJA2')!=undefined){
	if (document.getElementById('WTXMENJA2').checked){num6=parseFloat('48.00');}
  }
  if (document.getElementById('WTXTORN_80')!=undefined){
	if (document.getElementById('WTXTORN_80').checked){num7=parseFloat('00.00');}
  }
  if (document.getElementById('WTXTORN_81')!=undefined){
	if (document.getElementById('WTXTORN_81').checked){num8=parseFloat('95.90');}
  }
  if (document.getElementById('WTXTORN_82')!=undefined){
	if (document.getElementById('WTXTORN_82').checked){num9=parseFloat('54.00');}
  }
  if (document.getElementById('WTXTORN_83')!=undefined){
	if (document.getElementById('WTXTORN_83').checked){num10=parseFloat('54.00');}
  }
  if (document.getElementById('WTXMENJA3')!=undefined){
	if (document.getElementById('WTXMENJA3').checked){num11=parseFloat('48.00');}
  }
  if (document.getElementById('WTXMENJA4')!=undefined){
	if (document.getElementById('WTXMENJA4').checked){num12=parseFloat('48.00');}
  }
  if (document.getElementById('WTXTORN_90')!=undefined){
	if (document.getElementById('WTXTORN_90').checked){num13=parseFloat('00.00');}
  }
  if (document.getElementById('WTXTORN_91')!=undefined){
	if (document.getElementById('WTXTORN_91').checked){num14=parseFloat('18.00');}
  }
  if (document.getElementById('WTXMENJA5')!=undefined){
	if (document.getElementById('WTXMENJA5').checked){num15=parseFloat('14.40');}
  }
  
  resultado= (num1 + num2 + num3 + num4 + num5 + num6 + num7 + num8 + num9 + num10 + num11 + num12 + num13 + num14 + num15).toFixed(2);
  if (document.getElementById('WTXPREUTO')!=undefined){
	document.getElementById('WTXPREUTO').value=resultado;
  }
}
function gestionaDomicialiacion()
{var opcion=document.getElementById("WTXDARCOM0").checked;switch(opcion)
{case true:desactivarDomiciliacion();break;case false:activarDomiciliacion();break;}}
function desactivarDomiciliacion()
{document.getElementById("WTXTITURE").style["background"]="inactiveBorder";document.getElementById("WTXTITUCO").style["background"]="inactiveBorder";document.getElementById("WTXLOCALI").style["background"]="inactiveBorder";document.getElementById("WTXBANCAR").style["background"]="inactiveBorder";document.getElementById("WTXCOMPT0").style["background"]="inactiveBorder";document.getElementById("WTXCOMPT1").style["background"]="inactiveBorder";document.getElementById("WTXCOMPT2").style["background"]="inactiveBorder";document.getElementById("WTXCOMPT3").style["background"]="inactiveBorder";document.getElementById("WTXTITURE").readOnly="true";document.getElementById("WTXTITUCO").readOnly="true";document.getElementById("WTXLOCALI").readOnly="true";document.getElementById("WTXBANCAR").readOnly="true";document.getElementById("WTXCOMPT0").readOnly="true";document.getElementById("WTXCOMPT1").readOnly="true";document.getElementById("WTXCOMPT2").readOnly="true";document.getElementById("WTXCOMPT3").readOnly="true";}
function activarDomiciliacion()
{document.getElementById("WTXTITURE").style["background"]="white";document.getElementById("WTXTITUCO").style["background"]="white";document.getElementById("WTXLOCALI").style["background"]="white";document.getElementById("WTXBANCAR").style["background"]="white";document.getElementById("WTXCOMPT0").style["background"]="white";document.getElementById("WTXCOMPT1").style["background"]="white";document.getElementById("WTXCOMPT2").style["background"]="white";document.getElementById("WTXCOMPT3").style["background"]="white";document.getElementById("WTXTITURE").readOnly="";document.getElementById("WTXTITUCO").readOnly="";document.getElementById("WTXLOCALI").readOnly="";document.getElementById("WTXBANCAR").readOnly="";document.getElementById("WTXCOMPT0").readOnly="";document.getElementById("WTXCOMPT1").readOnly="";document.getElementById("WTXCOMPT2").readOnly="";document.getElementById("WTXCOMPT3").readOnly="";}
function compruebaDomiciliacion()
{var opcion=document.getElementById("WTXDARCOM0").checked;if(opcion==false)
{var campo="null";if(document.getElementById("WTXCOMPT3").value=="")campo="WTXCOMPT3";if(document.getElementById("WTXCOMPT2").value=="")campo="WTXCOMPT2";if(document.getElementById("WTXCOMPT1").value=="")campo="WTXCOMPT1";if(document.getElementById("WTXCOMPT0").value=="")campo="WTXCOMPT0";if(document.getElementById("WTXTITUCO").value=="")campo="WTXTITUCO";if(document.getElementById("WTXTITURE").value=="")campo="WTXTITURE";if(document.getElementById("WTXLOCALI").value=="")campo="WTXLOCALI";if(document.getElementById("WTXBANCAR").value=="")campo="WTXBANCAR";if(campo!="null")
{alert("El camp és obligatori i no està informat");document.getElementById(campo).focus();return false;}
var WTXCOMPT0=document.getElementById("WTXCOMPT0").value;var WTXCOMPT1=document.getElementById("WTXCOMPT1").value;var WTXCOMPT2=document.getElementById("WTXCOMPT2").value;var WTXCOMPT3=document.getElementById("WTXCOMPT3").value;ValidarDigitoControlCueBan(WTXCOMPT0,WTXCOMPT1,WTXCOMPT2,WTXCOMPT3);}
return true;}

