/*$(document).ready(function() { 
	
	/*$(function() {
		function sendDatos (datos, resultado, total, borrar){     
			divTotal = $('#'+total);
			elemento = divTotal.parent().parent().find('.current-rating');
		}

	});*/


	//function sendDatos(datos, resultado, total, borrar){

		//divTotal = $('#'+total);
		//elemento = divTotal.parent().parent().find('.current-rating');
		/*$.ajax({
			type: 'get', //Forma en que lo va a mandar 
			url: datos,
							
				beforeSend: function(objeto){
					//var precarga = new Element('img', { src: '../../multimedia/images/loader.gif', alt: 'Cargando datos...' });
					//$("#dialog-modal").append('<img src="'+RAIZ_IMG+'multimedia/images/loading.gif" alt="Cargando datos..." title="Cargando datos..." /> Cargando datos...');
				},
				dataType: 'data', //Formato en que lo va a devolver 
				
				success: function(data) {
					//$("#dialog-modal").html(data);
				}
		});	*/
	//}
//});

function objetoAjax(){
	var xmlhttp=false;
	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 sendDatos(datos, resultado, total, current_rating, borrar){	
	
	divTotal = document.getElementById(total);
	divcurrent_rating = document.getElementById(current_rating);
	
	//capa_contenedora = document.getElementById(total); divTotal.parentNode.parentNode.childNodes[0].childNodes[0];
	//alert(capa_contenedora.className);
	//capa_contenedora = divTotal.parentNode.parentNode;
	
	
	//alert(capa_contenedora.childNodes[1].childNodes[1].className);

	//current_rating = capa_contenedora.childNodes[1].childNodes[1];

	divResultado = document.getElementById(resultado);		
	divTotal = document.getElementById(total);
	if(divResultado.innerHTML=='' || borrar){
		ajax = objetoAjax();
		if(datos!=""){
			divResultado.innerHTML = "<span style='color:#ff0000;'>Votando...</span>";		
			ajax.open("GET", datos);
			ajax.onreadystatechange=function() {
				if (ajax.readyState==4) {
					if(ajax.responseText != 'NOTOK'){
						result = ajax.responseText.split("|");
						divResultado.innerHTML = 'Voto realizado';
						
						divTotal.innerHTML = 'Media Votos: <strong>'+result[1]+'</strong>/5<br />Total votos emitidos: ('+result[0]+' votos)';
						divcurrent_rating.style.width = (result[1] * 25)+'px;';
					
					}else{
						divResultado.innerHTML = 'Usted ya ha votado a este Cartel';
					}
					
				}
			}
			ajax.send(null);
		}else divResultado.innerHTML ="";
	}
}

