
function Validar_bus_vitrinas(theForm)
<!-- Validacion de Formulario BUSQUEDA DE NOTICIAS	-->
{
var checkStr1 = theForm.nombrevitrina.value;
var checkStr2 = theForm.resumenvitrina.value;
var checkStr3 = theForm.codsector;
var checkStr4 = theForm.codregion;
 
 
  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.codregion.focus();
    return (false);
	}	
	   	if (checkStr1.length!=0) {
	if (checkStr1.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.nombrevitrina.focus();
		theForm.nombrevitrina.select();
		return (false);
		}
	}
	
	 	if (checkStr2.length!=0) {
	if (checkStr2.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.resumenvitrina.focus();
		theForm.resumenvitrina.select();
		return (false);
		}
	}
 
 return (true);
}

//*******************

 function Validar_vitrinas(theForm)
<!-- Validacion de Formulario INGRESO NOTICIAS -->
{var checkStr = theForm.nombrevitrina.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su Titulo, por favor.");
    theForm.nombrevitrina.focus();
    return (false);
	}	
	
 	 	if (checkStr.length!=0) {
	if (checkStr.replace(/ /g, '') == '')
	{
		alert("No se aceptan espacios en blanco.");
		theForm.nombrevitrina.focus();
		theForm.nombrevitrina.select();
		return (false);
		}
	}
//*****************  validacion de textarea
theForm.resumenvitrina.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.resumenvitrina.value)=='<P>&nbsp;</P>')
	{
    alert("No dejar en blanco la descripcion, por favor.");
    return (false);
	}
 // Validamos el email.

   if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(theForm.emailvitrina.value)){
   //alert("La dirección de email " + theForm.emailusuario.value    + " es correcta.") 
   //return (true)
   }
   else {
   alert("La dirección " + theForm.emailvitrina.value    + " de email es incorrecta.");
   theForm.emailvitrina.focus();
	theForm.emailvitrina.select();
   return (false);
  }
	
	
	 var checkStr = theForm.telefonovitrina.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su teléfono, por favor.");
    theForm.telefonovitrina.focus();
    return (false);
	}	
	
				if (checkStr.length!=0) {
				if (checkStr.replace(/ /g, '') == '')
				{
				alert("No se aceptan espacios en blanco.");
				theForm.telefonovitrina.focus();
				theForm.telefonovitrina.select();
				return (false);
				}
				}
				
	 var checkStr = theForm.direccionvitrina.value;
  if (checkStr.length==0)
	{
    alert("Ingrese su dirección, por favor.");
    theForm.direccionvitrina.focus();
    return (false);
	}	
	
				if (checkStr.length!=0) {
				if (checkStr.replace(/ /g, '') == '')
				{
				alert("No se aceptan espacios en blanco.");
				theForm.direccionvitrina.focus();
				theForm.direccionvitrina.select();
				return (false);
				}
				}
				
 var checkStr = theForm.contactovitrina.value;
  if (checkStr.length==0)
	{
    alert("Ingrese un contacto, por favor.");
    theForm.contactovitrina.focus();
    return (false);
	}	
	
				if (checkStr.length!=0) {
				if (checkStr.replace(/ /g, '') == '')
				{
				alert("No se aceptan espacios en blanco.");
				theForm.contactovitrina.focus();
				theForm.contactovitrina.select();
				return (false);
				}
				}
//************************************ 
 
 	 var checkStr2 = theForm.codregion;

  if (checkStr2[0].selected == true )
	{
    alert("Selecciones una region, 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);
	}	
	

	var imagen = theForm.file.value;
	if(imagen !=""){
	if (imagen.lastIndexOf(".jpg")== -1 && imagen.lastIndexOf(".JPG")== -1 && imagen.lastIndexOf(".jpeg")== -1 && imagen.lastIndexOf(".JPEG")== -1  && imagen.lastIndexOf(".BMP")== -1 && imagen.lastIndexOf(".bmp")== -1)
	{	alert("Ingrese un documento Válido (imagen), por favor");
		theForm.file.focus();
		return false;
	}
	}
  
 return (true);
}

/*************************/
 
/*************************/

function EDITAR_VITRINAS(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_vitrinas(CODIGO,ENVIAR,VER,VER2){ 
   if (confirm('¿Estas seguro de ELIMINAR esta VITRINA MYPE?')){ 
 
	 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_VITRINAS(VER,VER2,CODIGO,ENVIAR)
{
if (Validar_vitrinas(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_VITRINAS(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_VITRINAS(VER,VER2,ENVIAR)
{
if (Validar_vitrinas(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_VITRINAS_RES(VER,VER2,ENVIAR)
{
 if (Validar_bus_vitrinas(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_VITRINAS(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_VITRINAS(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_VITRINAS(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();

} 

function LISTAR_VITRINA_TIPO(VER,VER2,CODIGO,TIPO)
{
     
window.document.formulario.ver_opt.value=VER;
window.document.formulario.ver_opt2.value=VER2;
window.document.formulario.nom_seccion.value=VER;
window.document.formulario.id_pre_bus.value=CODIGO;
if (TIPO=='SECTOR')
{
	window.document.formulario.tipo.value='SECTOR';
}
else
{
	window.document.formulario.tipo.value='REGION';
	}


window.document.formulario.submit();

}
