function makeRequest(url,param,dv) {
//alert("entra");
    //var http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
            // See note below about this line
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
	//http_request.onreadystatechange = function() { displayContents(http_request); };
    //http_request.open('GET', url + "?puntos=" + puntos, true);
    //http_request.send(null);

	http_request.onreadystatechange = function() { displayContents(http_request,dv); };
	http_request.open('POST', url, true);
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http_request.send(param);
}

function displayContents(http_request,dv) {
	document.getElementById(dv).innerHTML = "Sending...";
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
        	var result = http_request.responseText.split("|");
        	if (result[0] == "goto") { document.location.href = result[1]; }
			else if (result[0] == "alert") { 
				alert(result[1]);
				document.getElementById(dv).innerHTML = result[2]; 
			}
			else if (result[0] == "js") { 
				eval(result[1]);
				document.getElementById(dv).innerHTML = result[2]; 
			}
			else { document.getElementById(dv).innerHTML = http_request.responseText; }
        } else {
            alert('There was a problem with the request.');
        }
    }
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function unhideDiv(d) {
    document.getElementById(d).style.display = 'block';
}

function hideDiv(d) {
    document.getElementById(d).style.display = 'none';
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("E-mail Inv\u00e1lido")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("E-mail Inv\u00e1lido")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("E-mail Inv\u00e1lido")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("E-mail Inv\u00e1lido")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("E-mail Inv\u00e1lido")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("E-mail Inv\u00e1lido")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("E-mail Inv\u00e1lido")
		    return false
		 }

 		 return true					
	}

function ValidateEmail(emailTextbox){
	var emailID = document.getElementById(emailTextbox);
	
	if ((emailID.value == null)||(emailID.value == "")){
		//alert("Ingresa tu E-mail")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value) == false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
