 

function Validar_bus_reportes(theForm)
<!-- Validacion de Formulario BUSQUEDA DE NOTICIAS	-->
{
var checkStr1 = theForm.tituloreporte.value;
var checkStr2 = theForm.descripcionreporte.value;
var checkStr3 = theForm.codpais; 
var checkStr4 = theForm.codproducto;
 

 
 
  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.tituloreporte.focus();
    return (false);
	}	
 
		if (checkStr1.length!=0) {
	if (checkStr1.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.tituloreporte.focus();
		theForm.tituloreporte.select();
		return (false);
		}
	}
	
		if (checkStr2.length!=0) {
	if (checkStr2.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.descripcionreporte.focus();
		theForm.descripcionreporte.select();
		return (false);
		}
	}
 return (true);
}

 
function Validar_reportes(theForm)
<!-- Validacion de Formulario INGRESO NOTICIAS -->
{var checkStr = theForm.tituloreporte.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su Titulo, por favor.");
    theForm.tituloreporte.focus();
    return (false);
	}	
	
 
	//*****************  validacion de textarea
theForm.descripcionreporte.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.descripcionreporte.value)=='<P>&nbsp;</P>')
	{
    alert("No dejar en blanco la descripcion, por favor.");
 
    return (false);
	}
//************************************ 
//************************************ 

var checkStr2 = theForm.codpais;
var checkStr3 = theForm.codproducto;
 
 
 
  if (checkStr2[0].selected == true && checkStr3[0].selected == true )
	{
    alert("Selecciones un pais o producto, por favor.");
    theForm.codpais.focus();
    return (false);
	}	
 	
 
	
	/* 
	if (checkStr3[0].selected == true )
	{
    alert("Selecciones un producto, por favor.");
    theForm.codproducto.focus();
    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 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;
	}
	}
 /*
var oas = new ActiveXObject("Scripting.FileSystemObject");
var d = window.document.formulario.file.value;
var e = oas.getFile(d);
var f = e.size;
alert(f + " bytes");
 */
  
 return (true);
}

/*************************/

//******************

function Validar_reportes_modi(theForm)
<!-- Validacion de Formulario INGRESO NOTICIAS -->
{var checkStr = theForm.tituloreporte.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su Titulo, por favor.");
    theForm.tituloreporte.focus();
    return (false);
	}	
	
 
	//*****************  validacion de textarea
theForm.descripcionreporte.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.descripcionreporte.value)=='<P>&nbsp;</P>')
	{
    alert("No dejar en blanco la descripcion, por favor.");
 
    return (false);
	}
//************************************ 
	
	var checkStr2 = theForm.codpais;
var checkStr3 = theForm.codproducto;
 
 
 
  if (checkStr2[0].selected == true && checkStr3[0].selected == true )
	{
    alert("Selecciones un pais o producto, por favor.");
    theForm.codpais.focus();
    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 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)
	{	alert("Ingrese un documento Válido, por favor");
		theForm.file.focus();
		return false;
	}
	}

  
 return (true);
}
 
/*************************/
/************************  OPCIONES DE USUARIO **************/ 
/*************************/

function EDITAR_REPORTES(VER,CODIGO,ENVIAR)
{
//if (Validar_noticia(window.document.formulario))
//{

 window.document.formulario.enviar.value=ENVIAR;
	window.document.formulario.ver_opt.value=VER;
 	window.document.formulario.id_pre.value=CODIGO;
 	/// alert(VER);
 //alert(CODIGO);
 window.document.formulario.submit();
//}
} 
 /*************************/
function pregunta_elimina_reportes(CODIGO,ENVIAR,VER){ 
   if (confirm('¿Estas seguro de ELIMINAR este REPORTES DE MERCADO?')){ 
 
	 document.formulario.enviar.value=ENVIAR;   
 document.formulario.id_pre.value=CODIGO;
  window.document.formulario.ver_opt.value=VER;
// alert(ENVIAR);
 //alert(CODIGO);
 document.formulario.submit();
    } 
} 
/*************************/
function GUARDAR_MODI_REPORTES(VER,CODIGO,ENVIAR)
{
if (Validar_reportes_modi(window.document.formulario))
{
	window.document.formulario.enviar.value=ENVIAR;
	window.document.formulario.ver_opt.value=VER;
 	window.document.formulario.id_pre.value=CODIGO;
 //	 alert(ENVIAR);
 //alert(VER);
 //alert(CODIGO);
 window.document.formulario.submit();

}

}

 /*************************/
function DETALLE_REPORTES(VER,CODIGO,ENVIAR)
{

 window.document.formulario.enviar.value=ENVIAR;
	window.document.formulario.ver_opt.value=VER;
 	window.document.formulario.id_pre.value=CODIGO;
 //	 alert(VER);
 //alert(CODIGO);
 window.document.formulario.submit();

}

 /*************************/
function DETALLE_REPORTES_HOME(VER,CODIGO,ENVIAR)
{

 window.document.frm_home_noticia.enviar.value=ENVIAR;
	window.document.frm_home_noticia.ver_opt.value=VER;
 	window.document.frm_home_noticia.id_pre.value=CODIGO;
 
 //  alert(ENVIAR);
 //alert(VER);
 //alert(CODIGO);
 window.document.frm_home_noticia.submit();

}
 
 
/*************************/
/*************************/
function GUARDAR_REPORTES(VER,ENVIAR)
{
if (Validar_reportes(window.document.formulario))
{

	//window.document.formulario.enviar.value=AREGLO;
	window.document.formulario.enviar.value=ENVIAR;
//	window.document.formulario.nom_seccion.value=SECCION;
	window.document.formulario.ver_opt.value=VER;
// 	window.document.formulario.id_pre.value=CODIGO;
 //	 alert(ENVIAR);
 //alert(VER);
 //alert(CODIGO);
 window.document.formulario.submit();

}
}

function BUSCAR_REPORTES(VER,ENVIAR)
{
 if (Validar_bus_reportes(window.document.formulario))
 {
  window.document.formulario.enviar.value=ENVIAR;
	window.document.formulario.ver_opt.value=VER;
	//alert(ENVIAR);
// alert(VER);
	window.document.formulario.submit();

 }
}
/************************   **************/ 
/*************************/
 
 
function focus(){
	window.document.formulario.login.focus();
}
 /************************   **************/ 
/*************************/
 function Ir_tipo_producto_preporte(VER,DERECHO,TIPO_EMP,VER_TIPO_EMP)
{
 //alert(VER);
    window.document.formulario.ver_opt.value="";
    window.document.formulario.ver_opt.value=VER;
 	window.document.formulario.t_producto.value=TIPO_EMP;
	window.document.formulario.tip_empresa2.value=VER_TIPO_EMP;
	window.document.formulario.t_pais.value='';
	window.document.formulario.derecho.value=DERECHO;
	//alert(VER);
	//alert(NOM_SECCION);
	//alert(DERECHO);
	window.document.formulario.submit();

} 
 /************************   **************/ 
/*************************/
 function Ir_tipo_pais_reporte(VER,DERECHO,TIPO_EMP,VER_TIPO_EMP)
{
 //alert(VER);
    window.document.formulario.ver_opt.value="";
    window.document.formulario.ver_opt.value=VER;
 	window.document.formulario.t_pais.value=TIPO_EMP;
	window.document.formulario.tip_empresa2.value=VER_TIPO_EMP;
	window.document.formulario.t_producto.value='';
	window.document.formulario.derecho.value=DERECHO;
	//alert(VER);
	//alert(NOM_SECCION);
	//alert(DERECHO);
	window.document.formulario.submit();

} 

