 


function Validar_bus_consorcios(theForm)
<!-- Validacion de Formulario BUSQUEDA DE NOTICIAS	-->
{
var checkStr1 = theForm.tituloconsorcio.value;
var checkStr2 = theForm.descripcionconsorcio.value;
  var checkStr4 = theForm.codsector;
 	var checkStr5 = theForm.codregion;
  if (checkStr1.length==0 && checkStr2.length==0 && checkStr4[0].selected == true && checkStr5[0].selected == true ) 
	{
    alert("Ingrese al menos una opcion de Búsqueda, por favor.");
    theForm.codsector.focus();
    return (false);
	}	
	  
	if (checkStr1.length!=0) {
	if (checkStr1.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.tituloconsorcio.focus();
		theForm.tituloconsorcio.select();
		return (false);
		}
	}
	
		if (checkStr2.length!=0) {
	if (checkStr2.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.descripcionconsorcio.focus();
		theForm.descripcionconsorcio.select();
		return (false);
		}
	}
 return (true);
}

//******************  check_date


function check_date(day,month,year){
var leap = 0;
var err = 0;
  /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) { leap = 1;  }
   if ((month == 2) && (leap == 1) && (day > 29)) {  err = 23;  }
   if ((month == 2) && (leap != 1) && (day > 28)) {  err = 24;  }
   /* Validation of other months */
   if ((day > 31) && ((month == 1) || (month == 3) || (month == 5) || (month == 7) || (month == 8) || (month == 10) || (month == 12))) {
      err = 25;
   }
   if ((day > 30) && ((month == 4) || (month == 6) || (month == 9) || (month == 11))) {
      err = 26;
   }
   if (err == 0) {	return true;  }
   else {		return false;  }
}

function MayorFecha(di,mi,ai,df,mf,af){
di=di*1;
mi=mi*1;
ai=ai*1;
df=df*1;
mf=mf*1;
af=af*1;
if (ai>af) return false;
else {
  if(ai<af) return true;
  else{
   if (mi>mf) return false;
   else{
     if(mi<mf) return true;
     else{
      if(di>df) return false;
      else{
        return true;
      }
     }
   }
  }
}
}

//******************

function Validar_consorcios(theForm)
<!-- Validacion de Formulario INGRESO NOTICIAS -->
{var checkStr = theForm.tituloconsorcio.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su Titulo, por favor.");
    theForm.tituloconsorcio.focus();
    return (false);
	}	
	
 
 
	
	//*****************  validacion de textarea
theForm.descripcionconsorcio.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.descripcionconsorcio.value)=='<P>&nbsp;</P>')
	{
    alert("No dejar en blanco la descripcion, por favor.");
 
    return (false);
	}
//************************************ 

var checkStr2 = theForm.codsector;
 
 
  if (checkStr2[0].selected == true )
	{
    alert("Selecciones un sector, por favor.");
    theForm.codsector.focus();
    return (false);
	}	
	
	var checkStr3 = theForm.codregion;
 
 
  if (checkStr3[0].selected == true )
	{
    alert("Selecciones una región, por favor.");
    theForm.codregion.focus();
    return (false);
	}	
	
 
	var checkStr = theForm.contactoconsorcio.value.length;
	if (checkStr==0) 
	{
    alert("Ingrese el nombre del contacto, por favor.");
    theForm.contactoconsorcio.focus();
    return (false);
	}
		var checkStr = theForm.telefonoconsorcio.value.length;
	if (checkStr==0) 
	{
    alert("Ingrese un numero telefónico, por favor.");
    theForm.telefonoconsorcio.focus();
    return (false);
	}
 
 
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.emailconsorcio.value)){
   //alert("La dirección de email " + theForm.emailusuario.value    + " es correcta.") 
   //return (true)
   }
   else {
   alert("La dirección email" + theForm.emailconsorcio.value    + " es incorrecta.");
   	theForm.emailconsorcio.focus();
	theForm.emailconsorcio.select();
   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_consorcios_modi(theForm)
<!-- Validacion de Formulario INGRESO NOTICIAS -->
{var checkStr = theForm.tituloconsorcio.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su Titulo, por favor.");
    theForm.tituloconsorcio.focus();
    return (false);
	}	
	
 
	
	//*****************  validacion de textarea
theForm.descripcionconsorcio.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.descripcionconsorcio.value)=='<P>&nbsp;</P>')
	{
    alert("No dejar en blanco la descripcion, por favor.");
 
    return (false);
	}
//************************************ 
	 var checkStr2 = theForm.codsector;
 
 
  if (checkStr2[0].selected == true )
	{
    alert("Selecciones un sector, por favor.");
    theForm.codsector.focus();
    return (false);
	}	
	
	var checkStr3 = theForm.codregion;
 
 
  if (checkStr3[0].selected == true )
	{
    alert("Selecciones una región, por favor.");
    theForm.codregion.focus();
    return (false);
	}	
 
	var checkStr = theForm.contactoconsorcio.value.length;
	if (checkStr==0) 
	{
    alert("Ingrese el nombre del contacto, por favor.");
    theForm.contactoconsorcio.focus();
    return (false);
	}
		var checkStr = theForm.telefonoconsorcio.value.length;
	if (checkStr==0) 
	{
    alert("Ingrese un numero telefónico, por favor.");
    theForm.telefonoconsorcio.focus();
    return (false);
	}
 
 
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.emailconsorcio.value)){
   //alert("La dirección de email " + theForm.emailusuario.value    + " es correcta.") 
   //return (true)
   }
   else {
   alert("La dirección email" + theForm.emailconsorcio.value    + " es incorrecta.");
   	theForm.emailconsorcio.focus();
	theForm.emailconsorcio.select();
   return (false);
  }
  
 return (true);
}

/*************************/
/************************   OPCIONES VER GENERAL **************/ 
/*************************/
 
 
/*************************/
/*************************/
/************************  OPCIONES DE USUARIO **************/ 
/*************************/

function EDITAR_CONSORCIOS(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_consorcios(CODIGO,ENVIAR,VER,VER2){ 
   if (confirm('¿Estas seguro de ELIMINAR este CONSORCIO ?')){ 
 
	 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;
// alert(ENVIAR);
 //alert(CODIGO);
 document.formulario.submit();
    } 
} 
/*************************/

 /*************************/
function pregunta_aceptar_propuesta(CODIGO,ENVIAR,VER2,VER){ 
   if (confirm('¿Estas seguro que quiere publicar esta PROPUESTA ?')){ 
 
	 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;
// alert(ENVIAR);
 //alert(CODIGO);
  document.formulario.submit(); 
    } 
} 
/*************************/
 /*************************/
function pregunta_rechaza_propuesta(CODIGO,ENVIAR,VER){ 
   if (confirm('¿Estas seguro de Rechazar este CONSORCIO?')){ 
 
	 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_CONSORCIOS(VER,VER2,CODIGO,ENVIAR)
{
if (Validar_consorcios_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_CONSORCIOS(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;
 //	 alert(VER);
 //alert(CODIGO);
 window.document.formulario.submit();

}

 /*************************/
function DETALLE_CONSORCIOS_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;
 
 window.document.frm_home_noticia.submit();

}

 

 /*************************/
function ELI_ARCHIVO_CONSORCIOS(VER,CODIGO,NOMBRE)
{

 window.document.formulario.nombre_merca.value=NOMBRE;
	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 GUARDAR_CONSORCIOS(VER,VER2,ENVIAR)
{
if (Validar_consorcios(window.document.formulario))
{

 
	window.document.formulario.enviar.value=ENVIAR;
window.document.formulario.ver_opt2.value=VER2;
	window.document.formulario.ver_opt.value=VER;
 
 window.document.formulario.submit();

}
}

 

function BUSCAR_CONSOR(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_CONSORCIOS(VER,VER2,ENVIAR)
{
 if (Validar_bus_consorcios(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_CONSOR(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 focus(){
	window.document.formulario.login.focus();
}
 
 /*************************/
/*************************/
 

function IR_TIPO_CONSOR_OPOR(VER,VER2,DERECHO,TIPO_EMP)
{
 //alert(VER);
    window.document.formulario.ver_opt.value="";
    window.document.formulario.ver_opt.value=VER;
	    window.document.formulario.ver_opt2.value=VER2;
 	window.document.formulario.tip_empresa.value=TIPO_EMP;
	
	window.document.formulario.derecho.value=DERECHO;
	//alert(VER);
	//alert(NOM_SECCION);
	//alert(DERECHO);
	window.document.formulario.submit();

} 
 function LIS_PROPUESTA(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_CONSOR(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();

} 
 

