
function Validar_bus_deman_doc(theForm)
<!-- Validacion de Formulario BUSQUEDA DE NOTICIAS	-->
{
var checkStr1 = theForm.nombredemanda_doc.value;
var checkStr2 = theForm.descripciondemanda_doc.value;
 
 
  if (checkStr1.length==0 && checkStr2.length==0)
	{
    alert("Ingrese al menos una opcion de Búsqueda, por favor.");
    theForm.nombredemanda_doc.focus();
    return (false);
	}	
	
 	if (checkStr1.length!=0) {
	if (checkStr1.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.nombredemanda_doc.focus();
		theForm.nombredemanda_doc.select();
		return (false);
		}
	}
	
	 	if (checkStr2.length!=0) {
	if (checkStr2.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.descripciondemanda_doc.focus();
		theForm.descripciondemanda_doc.select();
		return (false);
		}
	}
	
 
 return (true);
}

 
function Validar_deman_doc(theForm)
{
	var checkStr = theForm.nombredemanda_doc.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su Titulo, por favor.");
    theForm.nombredemanda_doc.focus();
    return (false);
	}	
	
 
//*****************  validacion de textarea
theForm.descripciondemanda_doc.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;
	}
}
 /*
 var expresion = /S/; //No acepta espacios, saltos de línea, tabulaciones y retornos carro... 
   if(expresion.test(theForm.descripciondemanda_doc.value)){ 
    
   }else{ 
      alert('Por favor, no deje el campo de descripcion en blanco');
	  	theForm.descripciondemanda_doc.focus();
		theForm.descripciondemanda_doc.select();
	  return (false);
   } 
 */
 
	
if (Trim(theForm.descripciondemanda_doc.value)=='<P>&nbsp;</P>')
	{
    alert("No dejar en blanco la descripcion, por favor.");
 
    return (false);
	}
	//alert(theForm.descripciondemanda_doc.value.length);
	//alert(theForm.descripciondemanda_doc.value);
//************************************ 
 
	
	 var checkStr = theForm.file.value.length;
	if (checkStr==0) 
	{
    alert("Ingrese una archivo, por favor.");
    theForm.file.focus();
    return (false);
	}
	 
	
	var imagen = theForm.file.value;
	if(imagen !=""){
	if (imagen.lastIndexOf(".doc")== -1 && imagen.lastIndexOf(".xls")== -1 && imagen.lastIndexOf(".pdf")== -1 && imagen.lastIndexOf(".txt")== -1  && imagen.lastIndexOf(".rtf")== -1 && imagen.lastIndexOf(".ppt")== -1 && imagen.lastIndexOf(".zip")== -1 && imagen.lastIndexOf(".rar")== -1)
	{	alert("Ingrese un documento Válido, por favor");
		theForm.file.focus();
		return false;
	}
	}
  
 return (true);
}

/*************************/

//******************

function Validar_deman_doc_modi(theForm)
<!-- Validacion de Formulario INGRESO NOTICIAS -->
{var checkStr = theForm.nombredemanda_doc.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su Titulo, por favor.");
    theForm.nombredemanda_doc.focus();
    return (false);
	}	
	
//*****************  validacion de textarea
theForm.descripciondemanda_doc.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_doc.value)=='<P>&nbsp;</P>')
	{
    alert("No dejar en blanco la descripcion, por favor.");
 
    return (false);
	}
//************************************ 
 
	
	var checkStr = theForm.nombre_archivo.value.length;
	if (checkStr==0) 
	{
    alert("Ingrese una nombre al archivo, por favor.");
    theForm.nombre_archivo.focus();
    return (false);
	}
	
	
	var imagen = theForm.file.value;
	if(imagen !=""){
	if (imagen.lastIndexOf(".doc")== -1 && imagen.lastIndexOf(".xls")== -1 && imagen.lastIndexOf(".pdf")== -1 && imagen.lastIndexOf(".txt")== -1  && imagen.lastIndexOf(".rtf")== -1 && imagen.lastIndexOf(".ppt")== -1 && imagen.lastIndexOf(".zip")== -1)
	{	alert("Ingrese un documento Válido, por favor");
		theForm.file.focus();
		return false;
	}
	}

  
 return (true);
}

 
/*************************/

function EDITAR_DEMAN_DOC(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_deman_doc(CODIGO,ENVIAR,VER,VER2){ 
   if (confirm('¿Estas seguro de ELIMINAR esta DOCUMENTO DE 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_DEMAN_DOC(VER,VER2,CODIGO,ENVIAR)
{
if (Validar_deman_doc_modi(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_DEMAN_DOC(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_DEMAN_DOC(VER,VER2,ENVIAR)
{
if (Validar_deman_doc(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_DEMAN_DOC_RES(VER,VER2,ENVIAR)
{
 if (Validar_bus_deman_doc(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 NUEVO_DEMAN_DOC(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_DEMAN_DOC(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_DEMAN_DOC(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();

} 
