function datosServidor() {
};
datosServidor.prototype.iniciar = function() {
	try {
		// Mozilla / Safari
		this._xh = new XMLHttpRequest();
	} catch (e) {

		var success = false;
		try {
			this._xh = new ActiveXObject("MSXML2.XMLHTTP");
			success = true;
		} catch (e) {
			try {
				this._xh = new ActiveXObject("Microsoft.XMLHTTP");
				success = true;
			} catch (e) {}
		}

/*		
		// Explorer
		var _ieModelos = new Array(
		'MSXML2.XMLHTTP.5.0',
		'MSXML2.XMLHTTP.4.0',
		'MSXML2.XMLHTTP.3.0',
		'MSXML2.XMLHTTP',
		'Microsoft.XMLHTTP'
		);
		var success = false;
		for (var i=0;i < _ieModelos.length && !success; i++) {
			try {
				this._xh = new ActiveXObject(_ieModelos[i]);
				success = true;
			} catch (e) {
				// Implementar manejo de excepciones
			}
		}*/
		if ( !success ) {
			// Implementar manejo de excepciones, mientras alerta.
			return false;
		}
		return true;
	}
}

datosServidor.prototype.ocupado = function() {
	estadoActual = this._xh.readyState;
	return (estadoActual && (estadoActual < 4));
}

datosServidor.prototype.procesa = function() {
	if (this._xh.readyState == 4 && this._xh.status == 200) {
		this.procesado = true;
	}
}

datosServidor.prototype.enviar = function(urlget,datos) {
	if (!this._xh) {
		this.iniciar();
	}
	if (!this.ocupado()) {
		this._xh.open("GET",urlget,false);
		this._xh.send(datos);
		if (this._xh.readyState == 4 && this._xh.status == 200) {
			return this._xh.responseText;
		}
		
	}
	return false;
}



function rate(rating,id )  {
	document.body.style.cursor = "wait";
	remotos = new datosServidor;
	nt = remotos.enviar('puntuar.php?rating='+rating+'&id='+id );
	rating = (rating * 25 );
	document.getElementById('current-rating').style.width = rating+'px';
	document.getElementById('ratelinks').style.display = 'none';
	document.body.style.cursor = "default"; 
	if(!nt)
		document.getElementById('ratingtext').innerHTML = 'No se ha podido procesar';
	else
		document.getElementById('ratingtext').innerHTML = '¡Gracias por votar!';
}

function reportarVideo(id)  {
	document.body.style.cursor = "wait";
	remotos = new datosServidor;
	nt = remotos.enviar('aviso.php?id='+id);
	obj = document.getElementById('botonReportar');
	obj.className = 'respuesta';
	document.body.style.cursor = "default";
	if(!nt)
		obj.innerHTML = 'No se ha podido procesar';
	else
		obj.innerHTML = '¡Gracias por avisarnos!'; 
}
