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

function stem_inzending(rating,imgId)
{
	if (rating.length==0)
{ 
	document.getElementById("rating").innerHTML="Er is iets niet goed gegaan!"
return
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
	alert ("Browser does not support HTTP Request")
	return
} 

document.getElementById("rating"+imgId).innerHTML='<img src="/templates/ontwerpen/images/loadersmall.gif">'  ;

var url="/modules/inzendingen/mod_site/ajax/stemmen.php"
url=url+'?rating='+rating+'&imgId='+imgId
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function()
      {
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		document.getElementById("rating"+imgId).innerHTML=xmlHttp.responseText  ;
		rating = (rating * 25) - 8;
		$('#current-rating'+imgId).css({width: rating});
		$('#ratelinks'+imgId).css({display: 'none'});
		} 
      }
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 



function stem_vid_inzending(rating,imgId)
{
	if (rating.length==0)
	{ 
		document.getElementById("rating").innerHTML="Er is iets niet goed gegaan!"
	return
	}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
	alert ("Browser does not support HTTP Request")
	return
} 

document.getElementById("rating"+imgId).innerHTML='<img src="/templates/ontwerpen/images/loadersmall.gif">'  ;

var url="/modules/inzendingen/mod_site/ajax/stemmen_vid.php"
url=url+'?rating='+rating+'&imgId='+imgId
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function()
      {
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("rating"+imgId).innerHTML=xmlHttp.responseText  ;
			var rating = (rating * 25) - 8;
			$('#current-rating-'+imgId).css({width: rating});
			$('#ratelinks'+imgId).css({display: 'none'});
		} 
      }
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

<!--------------------------------------------->

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 

<!--------------------------------------------->


var urlBase = "./ajax/stemmen.php?";