var url_val = "/index.php?op=module&path_module=modules/Valuations/required.php&"; // The server-side script

function handleHttpResponsed() {
	if (http.readyState == 4) {
		if (http.responseText.indexOf('invalid') == -1) {
			// Use the XML DOM to unpack the city and state data 
			var xmlDocument = http.responseXML; 
				var valor = xmlDocument.getElementsByTagName('valor').item(0).firstChild.data;
				var mensaje = xmlDocument.getElementsByTagName('message').item(0).firstChild.data;
				if (valor == 0){
						var direccion = document.getElementById('path').value;
						window.location.href=direccion + "ok";
				}
				else
				{
				 	document.getElementById('error').style["visibility"]="visible";
				 	document.getElementById('error').style["position"]="";
					document.getElementById('error').innerHTML = mensaje;
					new_captcha();
					document.getElementById('textcaptcha').value = '';
				}
			isWorking = false;
		}
	}
}

var isWorking = false;
function validatecomment() {
	if (!isWorking && http) {
			var radioactivo = '';
			var form = document.getElementById('formcomment');
		  	var radios = form.getElementsByTagName ('input');
		  	if (radios) {
			for (var i = 0; i < radios.length; ++i) {
					if(radios[i].id == 'valuation'){
					if (radios[i].checked)
						{
						radioactivo = radios[i].value;
						}
					}
			}
		  }
			http.open("GET", url_val + "id=" + document.getElementById('id').value + "&name=" + document.getElementById('name').value + 		"&title=" + document.getElementById('title').value + "&comment=" + document.getElementById('comment').value + "&valuation=" + radioactivo + "&captcha=" + document.getElementById('textcaptcha').value, true);
			http.onreadystatechange = handleHttpResponsed;
			isWorking = true;
			http.send(null);
		}
}
function new_captcha(){
				if(document.getElementById){
					// extract image name from image source (i.e. cut off ?randomness)
					thesrc = document.getElementById("captcha").src;
       
					// add ?(random) to prevent browser/isp caching
					document.getElementById("captcha").src = thesrc+"&"+Math.round(Math.random()*100000);
				}//fin if
			}//fin function

