﻿jQuery(document).ready(function(){jQuery(':submit').dblclick(function(){return false});jQuery('a[rel*=external]').click(function(){window.open(jQuery(this).attr('href'));return false})});function muestraSubcategoriaFormacion(val){if(val<=0){jQuery('#divSubcategoria').hide()}else{jQuery('#divSubcategoria').slideDown('slow');jQuery('#subcategoria').empty();$A(arr_categorias[val]).each(function(el){var opcion=document.createElement("option");jQuery('#subcategoria').append(opcion);opcion.value=el[0];opcion.text=el[1]})}}function ir(n){history.go(n);return false}function deshabilitarBoton(obj){var el=document.getElementById(obj);if(el){el.value='Enviando...';el.style.cursor='wait';document.body.style.cursor='wait'}}function valida_tarifas(f){var el=eval('document.'+f.name+'.elements');for(var i=0;i<el.length;++i){if(el[i].type=="radio"){var radiogroup=el[el[i].name];var itemchecked=false;for(var j=0;j<radiogroup.length;++j){if(radiogroup[j].checked){itemchecked=true;return true}}}}if(itemchecked==false)return false}function uncheck(f){var el=eval('document.'+f.name+'.elements');for(var i=0;i<el.length;++i){if(el[i].type=="radio"){var radiogroup=el[el[i].name];var itemchecked=false;for(var j=0;j<radiogroup.length;++j){if(radiogroup[j].checked){radiogroup[j].checked=false}}}}if(itemchecked==false)return false}function valida(arr_campos){msg='Debes rellenar los campos:\n\n\t';var correcto=1;for(var i=0;i<arr_campos.length;i++){if(document.getElementById(arr_campos[i]).value==''){msg+='- '+arr_campos[i]+'\n\t';errorInsercion(arr_campos[i]);correcto=0}else{correctoInsercion(arr_campos[i])}}if(correcto==0){alert(msg);return false}else{deshabilitarBoton("Submit");return true}}function errorInsercion(obj){document.getElementById(obj).style.borderColor='#CC0000';var arr_label=document.getElementsByTagName('label');for(var i=0;i<arr_label.length;i++){if(arr_label[i].getAttribute("for")==obj||arr_label[i].getAttribute("htmlfor")==obj){arr_label[i].style.color='#CC0000'}}}function correctoInsercion(obj){document.getElementById(obj).style.borderColor='';var arr_label=document.getElementsByTagName('label');for(var i=0;i<arr_label.length;i++){if(arr_label[i].getAttribute("for")==obj||arr_label[i].getAttribute("htmlfor")==obj){arr_label[i].style.color=''}}}function habilitar(obj,id){if(obj.value==1||obj.value=='Otros'){document.getElementById(id).disabled=false}else{document.getElementById(id).disabled=true}}function gestion_ofertas(formulario,boton,disponibles){var el=eval('document.'+formulario.name+'.elements');var ofertas=0;for(var i=0;i<el.length;++i){if(el[i].type=="checkbox"&&el[i].name!="allbox"){var checkgroup=el[el[i].name];i=el.length;if(checkgroup.type=="checkbox")ofertas=1}}for(var j=0;j<checkgroup.length;++j){if(checkgroup[j].checked){ofertas+=1}}var pregunta;var accion;accion=boton.value.toLowerCase();if((ofertas>disponibles)&&(accion=='archivar')){alert("No dispone de ofertas archivadas suficientes.");return false}else if(ofertas>1){pregunta="¿Seguro que desea "+accion+" las "+ofertas+" ofertas?"}else if(ofertas==1){pregunta="¿Seguro que desea "+accion+" la oferta?"}else if(ofertas==0){return false}if(!confirm(pregunta)){return false}else{return true}}function cuenta_Longitud(obj,ncaracter){if(obj){var caracteres;caracteres=obj.value.length;if(caracteres>ncaracter){obj.value=obj.value.substring(0,ncaracter)}}}function CA(f,isO){var trk=0;for(var i=0;i<f.elements.length;i++){var e=f.elements[i];if((e.name!='allbox')&&(e.type=='checkbox')){if(isO!=1){trk++;e.checked=f.allbox.checked}else{}}}}function CCA(f,CB){var TB=TO=0;for(var i=0;i<f.elements.length;i++){var e=f.elements[i];if((e.name!='allbox')&&(e.type=='checkbox')){TB++;if(e.checked)TO++}}f.allbox.checked=(TO==TB)?true:false}function confirma_borrado(nombre){if(!confirm("¿Esta seguro que desea eliminar "+nombre+"?")){return false}else{return true}}function seleccionaValor(campo,valor){var elnum=parseInt(-1);var k=parseInt(-1);for(var j=0;j<document.form1.elements.length;j++){if(document.form1.elements[j].name==campo){elnum=j;break}}var myvar="";var srch="";var menuLength="";menuLength=eval("document.form1."+campo+".length");srch=valor;if(srch){srch=srch.toUpperCase();for(var i=0;i<menuLength;i++){myvar=eval("document.form1."+campo+".options["+i+"].text.toUpperCase()");if(myvar.indexOf(srch)>=0){document.form1.elements[elnum].options[i].selected=true;break}}}return false}function MM_jumpMenu(targ,selObj,restore){eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");if(restore)selObj.selectedIndex=0}function AbrirCentrada(theURL,winName,width,height){var posx=(screen.Width-width)/2;var posy=(screen.Height-height)/2;parametros='width='+width+',left='+posx+',height='+height+',top='+posy+',toolbar=no,location=no,status=no,directories=no,menubar=no,scrollbars=no,resizable=no,titlebar=no';window.open(theURL,winName,parametros);return false}function AbrirCentrada2(theURL,winName,width,height){var posx=(screen.Width-width)/2;var posy=(screen.Height-height)/2;parametros='width='+width+',left='+posx+',height='+height+',top='+posy+',toolbar=no,location=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=no,titlebar=no';window.open(theURL,winName,parametros)}function gestion_alertas(f,boton){var el=eval('document.'+f.name+'.elements');var registros=0;for(var i=0;i<el.length;++i){if(el[i].type=="checkbox"&&el[i].name!="allbox"){var checkgroup=el[el[i].name];i=el.length;if(checkgroup.type=="checkbox")registros=1}}for(var j=0;j<checkgroup.length;++j){if(checkgroup[j].checked){registros+=1}}var pregunta;var accion;accion=boton.value.toLowerCase();if(registros>1){pregunta="¿Seguro que deseas "+accion+" las "+registros+" alertas?"}else if(registros==1){pregunta="¿Seguro que deseas "+accion+" la alerta?"}else if(registros==0){return false}if(!confirm(pregunta)){return false}else{return true}}