function openPopUp(Url,Width,Height){win=window.open(Url,'_blank','menubar=no,toolbar=no,width='+Width+',height='+Height+',resizable=no,scrollbars=no,status=no,dialog');win.moveTo(screen.availWidth/2-(Width/2),screen.availHeight/2-(Height/2));if((Width==-1)&&(Height==-1)){win.moveTo(0,0);win.resizeTo(screen.width,screen.height);}}
function openPopUp2(Url,Width,Height){win=window.open(Url,'_blank','menubar=no,toolbar=no,width='+Width+',height='+Height+',resizable=no,scrollbars=yes,status=no,dialog');win.moveTo(screen.availWidth/2-(Width/2),screen.availHeight/2-(Height/2));if((Width==-1)&&(Height==-1)){win.moveTo(0,0);win.resizeTo(screen.width,screen.height);}}
function openPopUp3(Url,Width,Height){win=window.open(Url,'_blank','menubar=no,toolbar=no,width='+Width+',height='+Height+',resizable=yes,scrollbars=yes,status=no');win.moveTo(screen.availWidth/2-(Width/2),screen.availHeight/2-(Height/2));if((Width==-1)&&(Height==-1)){win.moveTo(0,0);win.resizeTo(screen.width,screen.height);}}
function openPhpAdsNew(Url){win=window.open(Url,'_blank','titlebar=no,menubar=no,toolbar=yes,width=10,height=10,resizable=no,scrollbars=yes,status=no');win.moveTo(0,0);maximizeWindow(win);}
function popup(nom,url){window.name=nom;var win=window.open(url,'_blank','menubar=no,toolbar=no,width=750,height=600,resizable=yes,scrollbars=yes,status=yes');win.moveTo(screen.availWidth/2-(750/2),screen.availHeight/2-(600/2));opener=self;}
function popup2(nom,url,Width,Height){window.name=nom;win=window.open(url,'_blank','menubar=no,toolbar=no,width=Width,height=Height,resizable=yes,scrollbars=yes,status=yes');win.moveTo(screen.availWidth/2-(Width/2),screen.availHeight/2-(Height/2));opener=self;if((Width==-1)&&(Height==-1)){win.moveTo(0,0);win.resizeTo(screen.width,screen.height);}
return win;}
function maximizeWindow(MyWindow){var offset=(navigator.userAgent.indexOf("Mac")!=-1||navigator.userAgent.indexOf("Gecko")!=-1||navigator.appName.indexOf("Netscape")!=-1)?0:4;MyWindow.moveTo(-offset,-offset);MyWindow.resizeTo(screen.availWidth+(2*offset),screen.availHeight+(2*offset));}
function search(){if(document.getElementById("txtSearch").value==""){alert("El campo de busqueda no puede ser vacio.");return false;}
else
return true;}
function checkDNI(num)
{let='TRWAGMYFPDXBNJZSQVHLCKE';if(num.length==9)
{numDNI=num.substr(0,8);letter=num.substr(8,1);let=let.charAt(parseInt(numDNI)%23);var cond=let.toString().toUpperCase().indexOf(letter.toString().toUpperCase(),0);if(cond!=-1)
return true;else
return false;}
else
return false;}
function checkSubscription(){var bOk=true;var sError="";if(document.getElementById("subs_nombre").value==""){bOk=false;sError+="El nombre no es válido.\n";}
if(document.getElementById("subs_mail").value==""){bOk=false;sError+="La dirección de correo electrónico no es válida.\n";}
else{var regExpMail=/^[\w-\.]+\@[\w\.-]+\.[a-z]{2,4}$/;bOk2=regExpMail.test(document.getElementById("subs_mail").value);if(bOk2==false){sError+='La dirección de correo electrónico no es válida.\n';bOk=false;}}
if(bOk==false)
alert(sError);return bOk;}
function checkFirma(){var bOk=true;var sError="";if(document.getElementById("nombre2").value==""){bOk=false;sError+="El nombre no es válido.\n";}
if(document.getElementById("apellidos").value==""){bOk=false;sError+="Los apellidos no son válidos.\n";}
if(document.getElementById("dni").value==""){bOk=false;sError+="El dni no es válido.\n";}
else{bOk2=checkDNI(document.getElementById("dni").value);if(bOk2==false){bOk=false;sError+="El dni no es válido.\n";}}
if(bOk==false)
alert(sError);else{document.getElementById("firma").submit();document.getElementById("nombre2").value="";document.getElementById("apellidos").value="";document.getElementById("dni").value="";}}
function hidediv(myDiv){if(document.getElementById){document.getElementById(myDiv).style.visibility='hidden';}
else{if(document.layers){document.hideShow.visibility='hidden';}
else{document.all.hideShow.style.visibility='hidden';}}}
function showdiv(myDiv){if(document.getElementById){document.getElementById(myDiv).style.visibility='visible';}
else{if(document.layers){document.hideShow.visibility='visible';}
else{document.all.hideShow.style.visibility='visible';}}}
function up(){iIndex=document.getElementById("listWordKeys").options.selectedIndex;if((iIndex!=0)&&(iIndex!=-1)){var swap=new Option();swap.text=document.getElementById("listWordKeys").options[iIndex-1].text;swap.value=document.getElementById("listWordKeys").options[iIndex-1].value;var swap1=new Option();swap1.text=document.getElementById("listWordKeys").options[iIndex].text;swap1.value=document.getElementById("listWordKeys").options[iIndex].value;swap1.selected=true;document.getElementById("listWordKeys").options[iIndex-1]=swap1;document.getElementById("listWordKeys").options[iIndex]=swap;}
else if(iIndex==-1){alert("Para subir la preferencia de una palabra clave, debe seleccionarla previamente.");}}
function down(){iIndex=document.getElementById("listWordKeys").options.selectedIndex;if((iIndex!=(document.getElementById("listWordKeys").options.length-1))&&(iIndex!=-1)){var swap=new Option();swap.text=document.getElementById("listWordKeys").options[iIndex+1].text;swap.value=document.getElementById("listWordKeys").options[iIndex+1].value;var swap1=new Option();swap1.text=document.getElementById("listWordKeys").options[iIndex].text;swap1.value=document.getElementById("listWordKeys").options[iIndex].value;swap1.selected=true;document.getElementById("listWordKeys").options[iIndex+1]=swap1;document.getElementById("listWordKeys").options[iIndex]=swap;}
else if(iIndex==-1){alert("Para bajar la preferencia de una palabra clave, debe seleccionarla previamente.");}}
function AddWordKey(Value)
{if(Value=="")
alert("Debe introducir una palabra clave");else
{for(i=0;i<document.getElementById("listWordKeys").options.length;i++)
{if(Value==document.getElementById("listWordKeys").options[i].value)
{if(!confirm("La palabra clave introducida ya existe en la posición "+(i+1)+". ¿Está seguro de repetir esta palabra clave?"))
return;}}
iCountItems=document.getElementById("listWordKeys").options.length;document.getElementById("listWordKeys").options[iCountItems]=new Option(Value,Value,false,false);document.getElementById("txtWordKey").value="";}}
function RemoveWordKey()
{bMultipleItemsSel=false;while(true)
{iIndex=document.getElementById("listWordKeys").options.selectedIndex;if(iIndex==-1)
{if(!bMultipleItemsSel)
alert("Para eliminar una palabra clave debe seleccionarla de la lista.");break;}
else
{document.getElementById("listWordKeys").options[iIndex]=null;bMultipleItemsSel=true;}}}
function getList(){var sWordsKeys="";for(i=0;i<document.getElementById("listWordKeys").options.length;i++)
sWordsKeys+=document.getElementById("listWordKeys").options[i].value+"|";sWordsKeys=sWordsKeys.substring(0,sWordsKeys.length-1);return sWordsKeys;}
function addCategoria(value,text,List2){if(value==-1)
{alert("Debe seleccionar una categoría.");}
else{Value=value;Text=text;finded=false;for(i=0;((i<document.getElementById(List2).options.length)&&(!finded));i++)
{if(Value==document.getElementById(List2).options[i].value)
{alert("La categoría ya existe en la posición "+(i+1));finded=true;}}
if(!finded){iCountItems=document.getElementById(List2).options.length;document.getElementById(List2).options[iCountItems]=new Option(Text,Value,false,false);}}}
function removeCategoria(List){bMultipleItemsSel=false;while(true)
{iIndex=document.getElementById(List).options.selectedIndex;if(iIndex==-1)
{if(!bMultipleItemsSel)
alert("Para eliminar una categoría debe seleccionarla de la lista.");break;}
else
{document.getElementById(List).options[iIndex]=null;bMultipleItemsSel=true;}}}
function getCategorias(List){var sWordsKeys="";for(i=0;i<document.getElementById(List).options.length;i++)
sWordsKeys+=document.getElementById(List).options[i].value+"|";sWordsKeys=sWordsKeys.substring(0,sWordsKeys.length-1);return sWordsKeys;}
function printNotice(){popup("print",domain+"/client/print/print_notice.php?IDH="+document.getElementById("IDH").value);}
