

function Validar_bus_demanda(theForm)
<!-- Validacion de Formulario BUSQUEDA DE NOTICIAS	-->
{
var checkStr1 = theForm.titulodemanda.value;
var checkStr2 = theForm.descripciondemanda.value;
var checkStr3 = theForm.codregion;
var checkStr4 = theForm.codsector;
 
 
 
  if (checkStr1.length==0 && checkStr2.length==0 && checkStr3[0].selected == true && checkStr4[0].selected == true)
	{
    alert("Ingrese al menos una opcion de Búsqueda, por favor.");
    theForm.titulodemanda.focus();
    return (false);
	
	}	
	if (checkStr1.length!=0) {
	if (checkStr1.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.titulodemanda.focus();
		theForm.titulodemanda.select();
		return (false);
		}
	}
		if (checkStr2.length!=0) {
	if (checkStr2.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.descripciondemanda.focus();
		theForm.descripciondemanda.select();
		return (false);
		}
	}
 return (true);
}

 

function Validar_demanda(theForm)
<!-- Validacion de Formulario INGRESO NOTICIAS -->
{var checkStr = theForm.titulodemanda.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su Titulo, por favor.");
    theForm.titulodemanda.focus();
    return (false);
	}	
	
 
//*****************  validacion de textarea
theForm.descripciondemanda.required = "true"; 
for (i = 0; i <theForm.elements.length; i++){
if ((theForm.elements[i].type == "textarea") &&  theForm.elements[i].required=="true" && theForm.elements[i].value=='')
{
  alert('Por favor, complete el campo de descripcion'); 
		 return (false);
		break;
	}
}

 
  if (Trim(theForm.descripciondemanda.value)=='<P>&nbsp;</P>')
	{
    alert("No dejar en blanco la descripcion, por favor.");
 
    return (false);
	}
//************************************ 
//************************************ 
 var checkStr2 = theForm.codregion;
 if (checkStr2[0].selected == true )
	{
    alert("Selecciones una región, por favor.");
    theForm.codregion.focus();
    return (false);
	}	
 
  var checkStr2 = theForm.codsector;
 if (checkStr2[0].selected == true )
	{
    alert("Selecciones un sector, por favor.");
    theForm.codsector.focus();
    return (false);
	}	
	 // Validamos el email.
		   oRegEmail = new RegExp ("^([A-Z]|[a-z]|[0-9]|[_]|[-]|[.])+[@]([A-Z]|[a-z]|[0-9]|[_]|[-]|[.]|[;]|[@])+$");
			if (!oRegEmail.test(theForm.emaildemanda .value)) 
			{
			  alert("Por favor, ingrese una dirección de e-mail válida");
			  theForm.emaildemanda.focus();
			  return(false);
			}
			
			
		var checkStr = theForm.telefonodemanda.value.length;
	if (checkStr==0) 
	{
    alert("Ingrese una telefono, por favor.");
    theForm.telefonodemanda.focus();
    return (false);
	}
 	var checkStr = theForm.telefonodemanda.value;
			if (checkStr.length!=0) {
	if (checkStr.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.telefonodemanda.focus();
		theForm.telefonodemanda.select();
		return (false);
		}
	}
 return (true);
}

/*************************/
 

/*************************/
/************************   OPCIONES VER GENERAL **************/ 
/*************************/
 

function Ir_derecho(VER,DERECHO)
{
 //alert(VER);
    window.document.formulario.ver_opt.value="";
    window.document.formulario.ver_opt.value=VER;
//	window.document.formulario.nom_seccion.value=NOM_SECCION;
	window.document.formulario.derecho.value=DERECHO;
	//alert(VER);
	//alert(NOM_SECCION);
	//alert(DERECHO);
	window.document.formulario.submit();

} 
/*************************/
/*************************/
/************************  OPCIONES DE USUARIO **************/ 
/*************************/

function EDITAR_DEMANDA(VER,VER2,CODIGO,ENVIAR)
{

window.document.formulario.enviar.value=ENVIAR;
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
window.document.formulario.id_pre.value=CODIGO;
window.document.formulario.submit();

} 
 /*************************/
function pregunta_elimina_demanda(CODIGO,ENVIAR,VER,VER2){ 
   if (confirm('¿Estas seguro de ELIMINAR esta DEMANDA COMERCIAL?')){ 
 
document.formulario.enviar.value=ENVIAR;   
document.formulario.id_pre.value=CODIGO;
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
document.formulario.submit();
    } 
} 


/*************************/
function GUARDAR_MODI_DEMANDA(VER,VER2,CODIGO,ENVIAR)
{
if (Validar_demanda(window.document.formulario))
{
window.document.formulario.enviar.value=ENVIAR;
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
window.document.formulario.id_pre.value=CODIGO;
window.document.formulario.submit();

}

}

 /*************************/
function DETALLE_DEMANDA(VER,VER2,CODIGO,ENVIAR)
{

 
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
window.document.formulario.id_pre.value=CODIGO;
window.document.formulario.enviar.value=ENVIAR;
window.document.formulario.submit();

}

/*************************/
/*************************/
function GUARDAR_DEMANDA(VER,VER2,ENVIAR)
{
if (Validar_demanda(window.document.formulario))
{

window.document.formulario.enviar.value=ENVIAR;
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
window.document.formulario.submit();

}
}

function BUSCAR_DEMANDA(VER,VER2,ENVIAR)
{
 if (Validar_bus_demanda(window.document.formulario))
 {
window.document.formulario.enviar.value=ENVIAR;
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
window.document.formulario.submit();

 }
}
/************************   **************/ 
/*************************/
 
 
function focus(){
	window.document.formulario.login.focus();
}
 
  
function NUEVO_DEMA(VER,VER2,DERECHO)
{
     
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
window.document.formulario.nom_seccion.value=VER;
window.document.formulario.derecho.value=DERECHO;
window.document.formulario.submit();

} 
 
function BUSCAR_DEMA(VER,VER2,DERECHO)
{
     
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
window.document.formulario.nom_seccion.value=VER;
window.document.formulario.derecho.value=DERECHO;
window.document.formulario.submit();

} 

function LISTAR_DEMA(VER,VER2)
{
     
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
window.document.formulario.nom_seccion.value=VER;
window.document.formulario.submit();

} 

