function imagen_azar(imagen,tipo)
{
	var url = "imagen_azar.php"; 
	var pars;
	if(document.getElementById(imagen))
	{
		if (tipo=='src')
		{
			if (document.getElementById(imagen).src!='')
				pars = "actual="+document.getElementById(imagen).src.substring(document.getElementById(imagen).src.lastIndexOf('/')+1); 
			else
				pars = "actual=dummy.jpg";
		}
		if (tipo=='style')
		{
			if(document.getElementById(imagen).style.backgroundImage!='')
				pars = "actual="+document.getElementById(imagen).style.backgroundImage.split("url(")[1].split(")")[0].substring(document.getElementById(imagen).style.backgroundImage.split("url(")[1].split(")")[0].lastIndexOf('/')+1); 
			else
				pars = "actual=dummy.jpg";			
		}
		pars=pars+"&t="+Math.random();

//		prompt("",url+"?"+pars);
//		return false;
		var opciones = {
		// función a llamar cuando reciba la respuesta
		parameters: pars,
		method:"get",
		onSuccess: function(t) {
		resul = eval(t.responseText);
		resultado(resul,document.getElementById(imagen),tipo);
		}
		}

		var ajax = new Ajax.Request( url, opciones); 
	}
}

function resultado(imagen,obj_destino,tipo)
{
//alert(imagen);

if(tipo=="img")
	obj_destino.src=imagen;

if(tipo=="style")
	obj_destino.style.backgroundImage="url('"+imagen+"')";;

}

