// JavaScript Document

// load2 --> despres del loadi, per mostrar fotos en ordre
function load2(){
	var vindex=1;
    eld=document.getElementById("fotovariable");
	//alert('c'+eld.innerHTML);
	vindex = parseInt(eld.innerHTML.substr(18, 1))+parseInt(1);
	if (vindex==7) {vindex=1;}
	eld.innerHTML='<img src="img/home'+String(vindex)+
	              '.jpg" width="640" height="280" align="left">';

	setTimeout("load2()", 8000);
}

// loadi --> inicial, un sol cop
function loadi(){
	var rango_inferior = 1;
	var rango_superior = 6;
	var aleatorio = Math.floor(Math.random()*(rango_superior-(rango_inferior-1))) + rango_inferior;  
    eld=document.getElementById("fotovariable");
	eld.innerHTML='<img src="img/home'+aleatorio+
	              '.jpg" width="640" height="280" align="left">';

	setTimeout("load2()", 8000);
}

function img_change(dir, numero, maxnum) {
	var nexnum;
	if ((numero>1 && dir==0) || (numero<maxnum && dir==1)) {
		if (dir==0) {nexnum=(numero-1);}
		else        {nexnum=(numero+1);}
		eld=document.getElementById("fotoslide");
		eld.innerHTML='<img src="img/restaurant'+(nexnum)+
		              '.jpg" width="640" height="280" align="left">';
		elc=document.getElementById("fotoslidectl");
		elc.innerHTML='<a href="#" onclick="javascript:img_change(0, '+(nexnum)+', '+(maxnum)+')">'+
		               '<img height="8" width="15" src="img/dir_esq.gif" border="0" /></a>'+
					   nexnum + ' / ' + maxnum +
		               '<a href="#" onclick="javascript:img_change(1, '+(nexnum)+', '+(maxnum)+')">'+
					   '<img height="8" width="15" src="img/dir_dta.gif" border="0" /></a>';
	}
}

