/*------------------------------------------------------------------------*/
//Rolando Alonso Melchor Alcántar
//rolandhwx@gmail.com
/*----------------------------------------------------------------------*--*/
function abrirCategoria(cat)
{ 
	var w=800
	var h=720
	winX=(screen.width - w) / 2
	winY=(screen.height - h) / 2 	
	var url="libros.php?cat="+cat
	window.open(url, "",'width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY + ', resizable, scrollbars')
}
/*----------------------------------------------------------------------*--*/
function validaSimulador(f)
{
	if(f.medida[0].selected)
	{
		alert('Seleccione el tamaño')
		f.medida.focus()
		return false
	}
	if(f.paginas.value=="")
	{
		alert('Escriba el número de páginas')
		f.paginas.focus()
		return false
	}
	else
	{
		if(! validarNumero(f.paginas.value))
		{
			alert('Ingrese sólo números enteros')
			f.paginas.focus()
			return false
		}
		
	}
	if(f.ejemplares.value=="")
	{
		alert('Escriba el número de ejemplares')
		f.ejemplares.focus()
		return false
	}
	else
	{
		if(! validarNumero(f.ejemplares.value))
		{
			alert('Ingrese sólo números enteros')
			f.ejemplares.focus()
			return false
		}
	}
	return true
}
/*----------------------------------------------------------------------*--*/
function validarNumero(c_numero)
{
   
       for (i = 0; i < c_numero.length; i++)
       {
          if (!((c_numero.charAt(i) >= "0") && (c_numero.charAt(i) <= "9")))
          return false
       }
      return true
  
}
/*----------------------------------------------------------------------*--*/
function abrirSemestre(sem){ 
	var w=800
	var h=720
	winX=(screen.width - w) / 2
	winY=(screen.height - h) / 2 	
	var url="textoTarea.php?sem="+sem
	window.open(url, "",'width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY + ', resizable, scrollbars')
}
/*----------------------------------------------------------------------*--*/
function abreNovedad(id)
{
	var w=800
	var h=720
	winX=(screen.width - w) / 2
	winY=(screen.height - h) / 2 
	var url="novedad.php?id="+id
  window.open(url, "",'width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY + ', resizable, scrollbars')
}
/*---------------------------------------------------------------------------*/
function capaSistema(obj)
{
    capa=document.getElementById("paqueteria")
	if(obj[0].selected)
	 	capa.style.display ="none"
	if(obj[1].selected)
		capa.style.display ="block"	
}
/*---------------------------------------------------------------------------*/
function validaSolicitud(f)
{
	var ok=true
	var mensaje="Los siguientes campos son obligatorios:\n"
	if(f.nombre.value=="")
	{	mensaje+=" - Nombre\n"
		ok=false}
	if(f.telefono.value=="")
	{	mensaje+=" - Teléfono\n"
		ok=false}
	if(f.correo.value!="")
	{
		if(f.correo.value.indexOf('@')==-1 || f.correo.value.indexOf('.')==-1)	
		{
			mensaje+="- El correo proporcionado no es válido\n"
			ok=false
		}
	}
	if(f.sistema[1].selected)
	{
		if(f.direccion.value=="")
		{	mensaje+=" - Dirección\n"
			ok=false}
		if(f.ciudad.value=="")
		{	mensaje+=" - Ciudad\n"
			ok=false}
		if(f.estado.value=="")
		{	mensaje+="- Estado\n"
			ok=false}
		if(f.cp.value=="")
		{	mensaje+=" - Código Postal\n"
			ok=false}
	}
	if(ok==false)
	{
		alert(mensaje)
		return false
	}
	else
		return true
}
/*---------------------------------------------------------------------------*/
