// JavaScript Document

// constants to define the title of the alert and button text.
var ALERT_TITLE = "Naranjas El Abuelo";
var ALERT_BUTTON_TEXT = "Ok";

// over-ride the alert method only if this a newer browser.
// Older browser will see standard alerts
if(document.getElementById) {
	window.alert = function(txt) {
		createCustomAlert(txt);
	}
}

function createCustomAlert(txt) {
	// shortcut reference to the document object
	d = document;

	// if the modalContainer object already exists in the DOM, bail out.
	if(d.getElementById("modalContainer")) return;

	// create the modalContainer div as a child of the BODY element
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	 // make sure its as tall as it needs to be to overlay all the content on the page
	mObj.style.height = document.documentElement.scrollHeight + "px";

	// create the DIV that will be the alert 
	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBox";
	// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
	if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
	// center the alert box
	alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";

	// create an H1 element as the title bar
	h1 = alertObj.appendChild(d.createElement("h1"));
	h1.appendChild(d.createTextNode(ALERT_TITLE));

	// create a paragraph element to contain the txt argument
	msg = alertObj.appendChild(d.createElement("p"));
	msg.appendChild(d.createTextNode(txt));

	// create an anchor element to use as the confirmation button.
	btn = alertObj.appendChild(d.createElement("a"));
	btn.id = "closeBtn";
	btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
	btn.href = "#";
	// set up the onclick event to remove the alert when the anchor is clicked
	btn.onclick = function() { removeCustomAlert(); return false; }

	
}

// removes the custom alert from the DOM
function removeCustomAlert() {
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
	 
}

function Validar_form1(in_form1)
{
	
if ((in_form1.cant1.value == 0)&&(in_form1.cant2.value == 0)&&(in_form1.cant3.value == 0)&&(in_form1.cant4.value == 0))
        {
         alert("Haz tu pedido.");
         in_form1.cant1.focus();
         return (false);
        }
if (!V00_validar_tipodato(in_form1.cant1.value,"es_numero"))
        {
        alert('Escriba solo números');
        in_form1.cant1.focus();
         return (false);
        }
if (!V00_validar_tipodato(in_form1.cant2.value,"es_numero"))
        {
        alert('Escriba solo números');
        in_form1.cant2.focus();
         return (false);
        }

return (true);
}

function Validar_form2(in_form1)
{
if (in_form1.fr_nom.value == "")
        {
         alert("Introduce el Nombre.");
        in_form1.fr_nom.focus();
         return (false);
        }
if (!V00_validar_tipodato(in_form1.fr_nom.value,"caracter_control"))
        {
        alert('Caracter erroneo en Nombre');
        in_form1.fr_nom.focus();
         return (false);
        }
if (in_form1.fr_apellidos.value == "")
        {
         alert("Introduce los Apellidos.");
        in_form1.fr_apellidos.focus();
         return (false);
        }
if (!V00_validar_tipodato(in_form1.fr_apellidos.value,"caracter_control"))
        {
        alert('Caracter erroneo en Apellidos');
        in_form1.fr_apellidos.focus();
         return (false);
        }
if (in_form1.fr_direccion.value == "")
        {
         alert("Introduce la Dirección.");
        in_form1.fr_direccion.focus();
         return (false);
        }
if (!V00_validar_tipodato(in_form1.fr_direccion.value,"caracter_control"))
        {
        alert('Caracter erroneo en Direccion');
        in_form1.fr_direccion.focus();
         return (false);
        }
if (in_form1.fr_poblacion.value == "")
        {
         alert("Introduce la Población.");
        in_form1.fr_poblacion.focus();
         return (false);
        }
if (!V00_validar_tipodato(in_form1.fr_poblacion.value,"caracter_control"))
        {
        alert('Caracter erroneo en Poblacion');
        in_form1.fr_poblacion.focus();
         return (false);
        }
if (in_form1.fr_provincia.value == "")
        {
         alert("Introduce la Provincia.");
        in_form1.fr_provincia.focus();
         return (false);
        }   
if (!V00_validar_tipodato(in_form1.fr_provincia.value,"caracter_control"))
        {
        alert('Caracter erroneo en Provincia');
        in_form1.fr_provincia.focus();
         return (false);
        }

if (in_form1.fr_cp.value == "")
        {
         alert("Introduce el Código Postal.");
        in_form1.fr_cp.focus();
         return (false);
        }    
if (!V00_validar_tipodato(in_form1.fr_cp.value,"es_numero"))
        {
        alert('C.P: Escriba solo números');
        in_form1.fr_cp.focus();
         return (false);
        }
if (in_form1.fr_tel.value == "")
        {
         alert("Introduce el Teléfono.");
        in_form1.fr_tel.focus();
         return (false);
        }      
if (!V00_validar_tipodato(in_form1.fr_tel.value,"es_numero"))
        {
        alert('Teléfono: Escriba solo números');
        in_form1.fr_tel.focus();
         return (false);
        }     
    
 
if (in_form1.fr_email.value == "")
        {
         alert("Introduce el correo electrónico.");
        in_form1.fr_email.focus();
         return (false);
        }
if (!V00_validar_tipodato(in_form1.fr_email.value,"es_email"))
        {
        alert('El Email no es correcto');
        in_form1.fr_email.focus();
         return (false);
        }
if (!V00_validar_tipodato(in_form1.fr_desc.value,"caracter_control"))
        {
        alert('Caracter erroneo en Comentario');
        in_form1.fr_desc.focus();
         return (false);
        }
return (true);
}

function Validar_form5(in_form1)
{
	
		
if (in_form1.realname.value == "")
        {
         alert("Introduce el Nombre.");
        in_form1.realname.focus();
         return (false);
        }
		
if (in_form1.email.value == "")
        {
         alert("Introduce el correo electrónico.");
        in_form1.email.focus();
         return (false);
        }
if (!V00_validar_tipodato(in_form1.email.value,"es_email"))
        {
        alert('El formato del correo electronico no es correcto');
        in_form1.email.focus();
         return (false);
        }

return (true);
}
