function number_format( number, decimals, dec_point, thousands_sep ) {
	var n = number, prec = decimals;
	n = !isFinite(+n) ? 0 : +n;
	prec = !isFinite(+prec) ? 0 : Math.abs(prec);
	var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep;
	var dec = (typeof dec_point == "undefined") ? '.' : dec_point;
	var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
	var abs = Math.abs(n).toFixed(prec);
	var _, i;
	if (abs >= 1000) {
		_ = abs.split(/\D/);
		i = _[0].length % 3 || 3;
		 _[0] = s.slice(0,i + (n < 0)) +
		_[0].slice(i).replace(/(\d{3})/g, sep+'$1');
		s = _.join(dec);
		} else {
		s = s.replace('.', dec);
		}
	return s;
	}

function datosServidor() {
};
datosServidor.prototype.iniciar = function() {
	try {
		this._xh = new XMLHttpRequest();
		} catch (e) {
		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) {
					}
			}
		if ( !success ) {
			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) {
			var data=this._xh.responseText.split("|");
			document.getElementById('totalrating').innerHTML = "Overall Rating: <b>"+number_format(data[0],1,'.','')+"</b> / 5 stars - "+data[1]+" votes";
			if(data[2] >0) {
				document.getElementById('totalsrating').innerHTML = "Sweepstakes: <b>"+number_format(data[2],1,'.','')+"</b> / 5 stars - "+data[3]+" votes";
				}
			return this._xh.responseText;
			}
		}
	return false;
	}

function _gr(reqseccion,divcont) {
	remotos = new datosServidor;
	nt = remotos.enviar(reqseccion,"");
	document.getElementById(divcont).innerHTML = nt;
	}

function rateImg(rating, cid, sid)  {
	remotos = new datosServidor;
	nt = remotos.enviar('ajax/ax_rating.php?rating='+rating+'&cid='+cid+'&sid='+sid);
	rating = rating * 25;
	document.getElementById('current-rating').style.width = rating+'px';
	}