
function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}

function DescargarDisco(cual) {

	nombre = document.getElementById("data_nombres").value;
	apellido = document.getElementById("data_apellidos").value;
	email = document.getElementById("data_email").value;
	fecha = document.getElementById("data_ano").value+"-"+document.getElementById("data_mes").value+"-"+document.getElementById("data_dia").value;
	ciudad = document.getElementById("data_ciudad").value;
	pais = document.getElementById("data_pais").value;
	telefonocodigo = document.getElementById("data_telefonocodigo").value;
	telefononumero = document.getElementById("data_telefononumero").value;
	celularcodigo = document.getElementById("data_celularcodigo").value;
	celularnumero = document.getElementById("data_celularnumero").value;	
	buscar = nombre+"|"+apellido+"|"+email+"|"+fecha+"|"+ciudad+"|"+pais+"|"+telefonocodigo+"|"+telefononumero+"|"+celularcodigo+"|"+celularnumero+"|"+cual;
	var ajax=nuevoAjax(); 
	ajax.open("POST", "/v3/ajax/DescargarDisco.php?",true); 
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	ajax.send("buscar="+buscar);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			document.getElementById("CampoRegistro").innerHTML = "<p align='center' style='color: #CC0000; font-weight: bold'>Gracias! El disco comenzara a bajarse automaticamente en unos segundos. Si esto no sucede, puedes descargarlo manualmente <a href='/records/downloads.php?email="+email+"&cual="+cual+"'>haciendo click aca</a>.</p>";
			window.location="http://www.descargas-os.com/NadaQueEsperarTurboEstereo.zip";
		}
	}
	

}

function PaginaOn() {
  document.getElementById("body").className='blanco';
  document.getElementById("logo").src='/img/logorojo.png';
}

function PaginaOff() {
  document.getElementById("body").className='rojo';
  document.getElementById("logo").src='/img/logo.png';
}


function Enviar(form) {

	pasa = true;
	var mensaje;
	
	mensaje = "";
	
	if(form.nombres.value=="") {
		mensaje = mensaje + "Debes ingresar tu nombre<br />";
		pasa = false;
	}

	if(form.apellidos.value=="") {
		mensaje = mensaje + "Debes ingresar tu apellido<br />";
		pasa = false;
	}		

	if(form.ciudad.value=="") {
		mensaje = mensaje + "Debes ingresar tu ciudad<br />";
		pasa = false;
	}		

	var	validRegExp	= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var strEmail	= form.email.value;
	
	if (strEmail.length > 0) {
	
		if(strEmail.search(validRegExp)==-1) {
		
			mensaje = mensaje + "Debes escribir un email valido<br />";
			pasa = false;	

		}
		
	}
	else
	{

			mensaje = mensaje + "Debes escribir un email valido<br />";
			pasa = false;	
			
	}

	if(pasa) {

		form.submit();
		document.getElementById("mensaje").innerHTML = mensaje;	

	}
	else
	{

		document.getElementById("mensaje").innerHTML = mensaje;
		form.nombres.focus();
	}


}

function cNumeros(e) {
    k = (document.all) ? e.keyCode : e.which;
    if (k==8 || k==0) return true;
    patron = /\d/;
    n = String.fromCharCode(k);
    return patron.test(n);
}

function cNick(e) {
    k = (document.all) ? e.keyCode : e.which;
    if (k==8 || k==0) return true;
    patron = /\w/;
    n = String.fromCharCode(k);
    return patron.test(n);
}

function cEmail(e) {
    k = (document.all) ? e.keyCode : e.which;
    if (k==8 || k==0) return true;
    patron = /[a-zA-Z0-9_.@-]/;
    n = String.fromCharCode(k);
    return patron.test(n);
}
