// JAVASCRIPT Fade function from nofunc.com

function $(v) { return(document.getElementById(v)); }
function $S(v) { return($(v).style); }
function uni(v,id,s,top) { var ob=$S(id),b=v/100; ob.opacity=b; ob.top=top+'px'; ob.MozOpacity=b; ob.KhtmlOpacity=b; ob.filter="alpha(opacity="+v+")"; }
function zero(v) { v=parseInt(v); return(!isNaN(v)?v:0); }

function fade(id,ln,s) { var top=zero(parseInt($S(id).top));

  function opacity(oStart,oEnd,ln) { var speed=Math.round(ln/100),timer=0;
    
    if(oStart>oEnd) { for(i=oStart; i>=oEnd; i--) { setTimeout("uni("+i+",'"+id+"','','"+(top--)+"')",timer*speed); timer++; } setTimeout("$S('"+id+"').display='none';",timer*speed); }
    else if(oStart<oEnd) { $S(id).display='inline'; for(i=oStart; i<=oEnd; i++) { setTimeout("uni("+i+",'"+id+"','"+1+"','"+(top++)+"')",timer*speed); timer++; } }
  
  }

  if(s==1 || (!s && $S(id).opacity==0)) opacity(0,100,ln); else opacity(100,0,ln);

}


// 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.
			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

var urlBase = "update.php?";


function rateImg(rating,spil)  {
		fade('takStemme',2000,1)
		remotos = new datosServidor;
		nt = remotos.enviar('update.php?rating='+rating+'&spil='+spil);
		rating = rating * 25;
		document.getElementById('current-rating').style.width = rating+'px';
}
