var message = "";
function clickIE() {
	if(document.all) {
		(message);return false;
	}
}
function clickNS(e) {
	if(document.layers || (document.getElementById && !document.all)) {
		if(e.which == 2 || e.which == 3) {
			(message);return false;
		}
	}
}
if(document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown = clickNS;
}else{
	document.onmouseup = clickNS;
	document.oncontextmenu = clickIE;
}
document.oncontextmenu = new Function("return false");

objetoAjax.prototype.enviar = peticionPost;
var peticionAjax = new objetoAjax();

function componerPost() {
   var cadena = '';
   var correo = document.getElementById('correo').value;
   cadena = 'correo=' + correo;
   return cadena;
}

function comprobarCorreo() {
	document.getElementById('comprobando').innerHTML = 'Comprobando datos ...';
	peticionAjax.cargando = function() {
		document.getElementById('comprobando').style.display = '';
		document.getElementById('botDescargar').style.display = 'none';
		document.getElementById('comprobarCorreo').innerHTML = '<img src="../comun/imagenes/cargando01.gif" />';
	}
	peticionAjax.completado = function(estado, estadoTexto, respuestaTexto, respuestaXML) {
		document.getElementById('comprobando').style.display = 'none';
		document.getElementById('botDescargar').style.display = '';
		if(respuestaTexto == 'Verdadero') {
			document.getElementById('comprobarCorreo').innerHTML = '<img src="../comun/imagenes/botok16.gif" alt="Correcto" id="respuesta"  />';
		}else{
			document.getElementById('comprobarCorreo').innerHTML = '<img src="../comun/imagenes/cerrarsesion.gif" alt="Incorrecto" id="respuesta" />';
		}
	}
	peticionAjax.enviar('../comun/funciones/correover.php');
}

function validar(frm) {
	var mensaje = "Debe introducir su:\n\n";
	if(frm.Nombre.value.length < 3) { mensaje += " Nombre\n"; }
	if(frm.Telefono.value.length < 6) { mensaje += " Telefono\n"; }
	if(frm.Ofertas.checked && document.getElementById('respuesta').alt != 'Correcto') {
		mensaje += " E-Mail\n";
	}else{
		if(frm.correo.value.length < 6) { mensaje += " E-Mail\n"; }
	}
	if(frm.Pais.value.length < 3) { mensaje += " Pais"; }
	if(mensaje.length > 23) {
		alert(mensaje);
		return false;
	}else{
		document.getElementById('comprobando').innerHTML = 'Descargando fichero ...';
		document.getElementById('comprobando').style.display = '';
		document.getElementById('botDescargar').style.display = 'none';
		if(document.getElementById('respuesta').alt != 'Correcto') {
			document.getElementById('correo').value = '';
		}
		return true;
	}
}
function ventanaSecundaria(URL) {
	window.open(URL, "AvisoLegal", "width=600, height=400, scrollbars=NO, resizable=NO, top=" + (screen.height / 2 - (400/2)) + ", left=" + (screen.width / 2 - (600/2)));
}
