			var adNodoAdd = 0
			var adNodoEdit = 1
			var adNodoDelete = 2
			var adNodoActualizaTitulares = 3
			var adNodoUpdate = 4
			var adNodoInsert = 5
			var adNodoSacarDatos = 6
			var adNodoServicios = 7
			var adNodoStateChange = 8

			 

//	--------------------------------------------------------------------------------------------------------------
//
//		Controlamos los campos obligatorios en función de los nombres de los campos
//		que contiene la variable strcampoobligado (varible que declaramos publica en cada página)
//		Devolvemos true o false en funcion de si todo esta correcto o falta algun campo por rellenar.
//
//	--------------------------------------------------------------------------------------------------------------

		function camposobligatorios()
			{
				try{
					var strcampoaux,x,blnok;

					if (strcampoobligado=="")
					{
						blnok=true;
					}else{
						strcampoaux=strcampoobligado.split(",");
						blnok=true;
				
						for (x=0;x<=parseInt(strcampoaux.length-1);x++)
						{
							switch(document.getElementsByName(strcampoaux[x])[0].tagName.substring(0,3).toLowerCase())
							{
								case 'inp':
									switch (document.getElementsByName(strcampoaux[x])[0].type.substring(0,4).toLowerCase())
									{
										case 'text':
											if (strcampoaux[x].substring(3,strcampoaux[x].length)=="Precio"){
												if((document.getElementsByName(strcampoaux[x])[0].value=="")||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<")!=-1)||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<script")!=-1)||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<script scr=")!=-1))
												{
													alert("Debe introducir datos en el campo obligatorio." );
													document.getElementsByName(strcampoaux[x])[0].focus();
													document.getElementsByName(strcampoaux[x])[0].scroll;
													blnok=false;
												}

											}else{
												if((document.getElementsByName(strcampoaux[x])[0].value=="")||(document.getElementsByName(strcampoaux[x])[0].value=="0")||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<")!=-1)||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<script")!=-1)||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<script scr=")!=-1))
												{
													alert("Debe introducir datos en el campo obligatorio.");
													document.getElementsByName(strcampoaux[x])[0].focus();
													document.getElementsByName(strcampoaux[x])[0].scroll;
													blnok=false;
												}
											}
											if (blnok==false) return(blnok);
											break;										
										case 'pass':
											if((document.getElementsByName(strcampoaux[x])[0].value=="")||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<")!=-1)||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<script")!=-1)||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<script scr=")!=-1))
											{
												alert("Debe introducir datos en el campo obligatorio.");
												document.getElementsByName(strcampoaux[x])[0].focus();
												document.getElementsByName(strcampoaux[x])[0].scroll;
												blnok=false;
											}
											if (blnok==false) return(blnok);
											break;
										case 'radi':
											var todos = 0;
											for(i=0;i<=document.getElementsByName(strcampoaux[x]).length-1;i++)
											{
												if(document.getElementsByName(strcampoaux[x])[i].checked == true)
												{
													todos++;
												}
											}
											if(todos==0)
											{
												alert("Debe seleccionar los campos obligatorios.");
												document.getElementsByName(strcampoaux[x])[0].focus();
												document.getElementsByName(strcampoaux[x])[0].scroll;
												blnok=false;
											}
											return(blnok);
											break;
										case 'chec':
												todos = 0;
												for(i=0;i<=document.getElementsByName(strcampoaux[x]).length-1;i++)
												{
													if(document.getElementsByName(strcampoaux[x])[i].checked == true)
													{
														todos++;
													}
												}
												if(todos==0)
												{
													alert("Debe seleccionar los campos obligatorios.");
													document.getElementsByName(strcampoaux[x])[0].focus();
													document.getElementsByName(strcampoaux[x])[0].scroll;
													blnok=false;
												}
												return(blnok);
												break;											
									}
									break;
									
								case 'sel':
									todos=0;
									for(var i=0;i<=document.getElementsByName(strcampoaux[x]).length-1;i++)
									{
											if(parseInt(document.getElementsByName(strcampoaux[x])[i].value)!=0)
											{
												todos=1;
												break;
											}
									}

									if(todos==0)
									{
										alert("Debe seleccionar un registro ");
										document.getElementsByName(strcampoaux[x])[0].focus();
										document.getElementsByName(strcampoaux[x])[0].scroll;
										blnok=false;
										break;
									}
									break;
											
								case 'tex':
									if((document.getElementsByName(strcampoaux[x])[0].value=="")||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<")!=-1)||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<script")!=-1)||(document.getElementsByName(strcampoaux[x])[0].value.indexOf("<script scr=")!=-1))
									{
										alert("Debe rellenar los campos obligatorios.");
										document.getElementsByName(strcampoaux[x])[0].focus();
										document.getElementsByName(strcampoaux[x])[0].scroll;
										blnok=false;
									}
									break;
							}
							if (blnok==false) break;
						}
					}
					return(blnok);
				}catch(e){
					//alert("Nº: "+e.number+ String.fromCharCode(10)+ " Descripccion: "+e.description);
				}
			}
	
			function mostrardatos(id)
			{
				var objid;
				objid = document.getElementsByName(id);
				if(objid[1].style.display=="block")
				{
					objid[1].style.display="none";
					objid[0].style.display="block";
				}else{
					objid[1].style.display="block";
					objid[0].style.display="none";
				}
			}
 			
			function ControlNumerico(evento){
				if (window.navigator.appVersion.indexOf("MSIE") != -1)
				{
				   if (isNaN(parseInt(String.fromCharCode(evento.keyCode)))){
						//MsgBox "Este campo solo admite caracteres numéricos",48,"Esglesia"
						evento.keyCode=0;
					}
				}else{
					if (isNaN(parseInt(String.fromCharCode(evento.keyCode)))){
						//MsgBox "Este campo solo admite caracteres numéricos",48,"Esglesia"
						window.event.keyCode=0;
					}
				}
			}
			
			function ControlObligadoFrame(frname,campos)
			{
				// CONTROLA LOS CAMPOS OBLIGATORIOS DENTRO DE UN IFRAME
				var objfrm = document.frames(frname);
				var strcampoaux = campos.split(",");
				var blnok = true;
				for(x=0;x<=parseInt(strcampoaux.length-1);x++)
				{
					switch(strcampoaux[x].substring(0,3).toLowerCase())
					{
						case 'sel':
							if(objfrm.document.getElementById(strcampoaux[x]).value==0)
							{
								alert("Debe seleccionar un registro.");
								objfrm.document.getElementById(strcampoaux[x]).focus();
								objfrm.document.getElementById(strcampoaux[x]).scroll;
								//window.scroll(0,0);
								blnok=false;
								break;
							}
							break;
						case 'txt':
							break;
					}
				}
				return blnok;
			}			

			

			function Restablecer()
			{
				try{
					var strcampoaux,x,blnok;

					if (strcampofiltro=="")
					{
						blnok=true;
					}else{
						strcampoaux=strcampofiltro.split(",");
						blnok=true;
				
						for (x=0;x<=parseInt(strcampoaux.length-1);x++)
						{
							switch(document.getElementsByName(strcampoaux[x])[0].tagName.substring(0,3).toLowerCase())
							{
								case 'inp':
									switch (document.getElementsByName(strcampoaux[x])[0].type.substring(0,4).toLowerCase())
									{
										case 'text':
											document.getElementsByName(strcampoaux[x])[0].value="";
											break;
										case 'pass':
											document.getElementsByName(strcampoaux[x])[0].value="";
											break;
										case 'radi':
											document.getElementsByName(strcampoaux[x])[0].checked="true";										
											break;
										case 'chec':
											document.getElementsByName(strcampoaux[x])[0].checked="true";
											break;
									}
									break;
								case 'sel':
									document.getElementsByName(strcampoaux[x])[0].options(0).selected="true";
									break;
								case 'tex':
									break;
								case 'ifr':
									break;
							}
							 if (blnok==false) break;		
						 }
					}
					document.getElementById("txtNumReg").value ="10";
					filtrar.submit();
				}catch(e){
					//alert("Nº: "+e.number+ String.fromCharCode(10)+ " Descripccion: "+e.description)
				}
			}
			
			function cargarmenu(obj,cual)
				{
					switch(parseInt(cual))
					{
						case 0:
							obj.className = "";
							break;
						case 1:
							obj.className = "filaClara";
							break;
					}
				}
			
			function MM_reloadPage(init) {  //reloads the window if Nav4 resized
              if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
                document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
              else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
              
            }

            function CompruebaPaginas(intPageCount){
					//Comprobamos que el número de página que ha introducido para ir directamente no supere el total
					//de páginas y que sea mayor que cero.
					intPageCount = parseInt("0" + intPageCount);
					if ((parseInt("0"+document.getElementById("txtIrA").value)>intPageCount) && (parseInt("0"+document.getElementById("txtIrA").value)== 0)) {
						//Es mayor o es igual a cero y no puede ser. Mostramos mensaje y borramos el valor.
						alert("El número de página introducido no existe. Por favor introduzca un número correcto.");
						document.getElementById("txtIrA").value = "";
					}
				}
				
//-------------------------------------------------------------------------------------------------------------------
//
//    Compureba el contenido introducido
//
//-------------------------------------------------------------------------------------------------------------------
function valortexto(obj)
{
    if((obj.value.indexOf("<")!=-1)||(obj.value.indexOf("<script")!=-1)||(obj.value.indexOf("<script scr=")!=-1)){
        obj.bgcolor="red";
        obj.value="";
        obj.focus();
    }
}


function isEMailAddr(elem) {
    var str = elem.value;
	if(str!=""){
		var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
		if (!str.match(re)) {
			document.getElementById("rotulo").innerText="El formato de email no es válido.";
			return false;
		} else {
			document.getElementById("rotulo").innerText="";
			return true;
		}
	}else{
		document.getElementById("rotulo").innerText="";
			return true;
	}
}

function isNumero(elem){
	var str=elem.value;
	if (str!=""){
		var re = /^[\0-9]+[\0-9]+[\0-9]+[\0-9]+[\0-9]+[\0-9]+[\0-9]+[\0-9]+[\0-9]+[\0-9]$/;
		if (!str.match(re)) {
			elem.value="";
			return false;
		} else {
			elem.value="";
			return true;
		}
	}else{
		elem.value="";
			return true;
	}
}

