// Esta es para llamado de datos remotos via xmlHttpRequest

function datosServidor() {};
datosServidor.prototype.iniciar = function() {
	try {
		// Mozilla / Safari
		this._xh = new XMLHttpRequest();
	} 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. 
alert("error");
			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;
}


// Este es un acceso rapido, le paso la url y el div a cambiar
function _gr(reqseccion,divcont) {
	remotos = new datosServidor;
	nt = remotos.enviar(reqseccion,"");
	document.getElementById(divcont).innerHTML = nt;
}



//Estas dos son para guardar


function rate(rating,id,script)  {
var script_cgi;

if(script == 1){script_cgi="fororevista.cgi";}
if(script == 2){script_cgi="articulos.cgi"}
if(script == 3){script_cgi="islam.cgi"}

		remotos = new datosServidor;
		nt = remotos.enviar('/bin/'+script_cgi+'?rating='+rating+'&id='+id);
		stars = rating;
		rating = rating * 30;
		document.getElementById('current-rating_'+id).style.width = rating+'px';
		document.getElementById('ratingtext_'+id).innerHTML='<img src="/images/working.gif">...Procesando. Por favor espere.';
		setTimeout(function(){ document.getElementById('ratingtext_'+id).innerHTML='Tu voto de '+stars+ ' estrellas ha sido agregado. Gracias por tu voto.';}, 500);

//alert(rating);
}
