
function validar(formulario)
{
  if (formulario.nombre.value.length < 1)
  {
    alert("Este campo es obligatorio \"Nombre\".");
    formulario.nombre.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚabcdefghijklmnñopqrstuvwxyzáéíóú ";
  var checkStr = formulario.nombre.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
    if (!allValid)
  {
    alert("Escriba sólo letra caracteres en el campo \"Nombre\".");
    formulario.nombre.focus();
    return (false);
  }
  
  if (formulario.apellidos.value.length < 4)
  {
    alert("Este campo es obligatorio \"Apellidos\".");
    formulario.apellidos.focus();
    return (false);
  }
  
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚabcdefghijklmnñopqrstuvwxyzáéíóú ";
  var checkStr = formulario.apellidos.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Escriba sólo letra caracteres en el campo \"Apellidos\".");
    formulario.apellidos.focus();
    return (false);
  }

  if ((formulario.email.value.indexOf ('@', 0) == -1)||(formulario.email.value.length < 5)) { 
    alert("Escriba una dirección de correo válida en el campo \"Email\"."); 
    formulario.email.focus();
    return (false); 
  }
  
  if (formulario.telefono.value.length != 9)
  {
    alert("Escriba un valor válido para este campo \"Teléfono de Contacto\".");
    formulario.telefono.focus();
    return (false);
  }

  var checkOK = "0123456789-";
  var checkStr = formulario.telefono.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Escriba sólo dígito caracteres en el campo \"Teléfono de Contacto\".");
    formulario.telefono.focus();
    return (false);
  }
  
	if (formulario.urlproducto.value.length < 1)
  {
    alert("Este campo es obligatorio \"URL del Producto\".");
    formulario.urlproducto.focus();
    return (false);
  }
 
 if ((formulario.precioproducto.value.length < 1)||(formulario.precioproducto.value==0))
  {
    alert("Este campo es obligatorio \"Precio del Producto\". 0 es un valor no válido");
    formulario.precioproducto.focus();
    return (false);
  }
  var checkOK = "0123456789-";
  var checkStr = formulario.precioproducto.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Escriba sólo dígito caracteres en el campo \"Precio del Producto\".");
    formulario.precioproducto.focus();
    return (false);
  }
  
  if (formulario.gastosenvio.value.length < 1)
  {
    alert("Este campo es obligatorio \"Gastos de Envío\".");
    formulario.gastosenvio.focus();
    return (false);
  }
  var checkOK = "0123456789-";
  var checkStr = formulario.gastosenvio.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Escriba sólo dígitos en el campo \"Gastos de Envío\".");
    formulario.gastosenvio.focus();
    return (false);
  }
  
  return (true);
}


function cambia_destino(){
	var cosa;
	
	cosa = "http://www.ilev";
	cosa2 = "ante.com/shoppi";
	cosa3 = "ng_cart.php?coun";
	cosa4 = "try="+ document.getElementById("country").value;
	location.href=cosa + cosa2 + cosa3 + cosa4;
}
function http_request() {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp
}

var http_request2 = false;
   function makePOSTRequest(url, parameters) {
      http_request2 = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request2 = new XMLHttpRequest();
         if (http_request2.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request2.overrideMimeType('text/xml');
            http_request2.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request2 = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request2 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request2) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request2.onreadystatechange = alertContents;
      http_request2.open('POST', url, true);
      http_request2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request2.setRequestHeader("Content-length", parameters.length);
      http_request2.setRequestHeader("Connection", "close");
      http_request2.send(parameters);
   }
   
   
   function makeRequest(url, parameters) {
      http_request2 = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request2 = new XMLHttpRequest();
         if (http_request2.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request2.overrideMimeType('text/xml');
            http_request2.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request2 = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request2 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request2) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request2.onreadystatechange = alertContents2;
      http_request2.open('POST', url, true);
      http_request2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request2.setRequestHeader("Content-length", parameters.length);
      http_request2.setRequestHeader("Connection", "close");
      http_request2.send(parameters);
   }
   
   function alertContents() {

        if (http_request2.readyState == 4) {
            if (http_request2.status == 200) {
               result = http_request2.responseText; 
                 document.getElementById("resultadook").innerHTML = result;  
            } else {
                alert('Hubo problemas con la petición.');
            }
        }

    }
    
    
   function alertContents2() {

        if (http_request2.readyState == 4) {
            if (http_request2.status == 200) {
               result = http_request2.responseText; 
                 document.getElementById("resultado_oferta").innerHTML = result;  
            } else {
                alert('Hubo problemas con la petición.');
            }
        }

    }
     
   
   
     
function setVisible2(booleanValue)
{
if( booleanValue==true )
//elemento visible
document.getElementById('textoform').style.display = '';
else
//elemento oculto
document.getElementById('textoform').style.display = 'none';
}

		function hacer_cosas(){
			get(document.getElementById('myform'));
			setVisible2(false);
			return false;
		}
		
		
		function http_request() {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp
}

	function CargarAjax(fragment_url, element_id) { 
		
	    var element = document.getElementById(element_id); 
	    element.innerHTML = '<p><em>Cargando ...</em></p>'; 
	    xmlhttp=http_request();
	    xmlhttp.open("GET", fragment_url); 
	    xmlhttp.onreadystatechange = function() { 
	        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
	                        
	            element.innerHTML = xmlhttp.responseText; 
	            
	        } 
	    } 
	    xmlhttp.send(null); 
	} 
		
		
		
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
d.style.left = (cX-210) + "px";
d.style.top = (cY-10) + "px";
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}