var pos_actual=0;
var max_pos=0;
function dreta(){
	document.getElementById("besq").style.display="block";
	pos_actual++;
	//document.getElementById("llista_llibres").style.top=(-180*pos_actual)+"px";
	var tmp=document.getElementById("llista_llibres").style.left;
	if(tmp.substr(tmp.length-2,2)=="px"){
		tmp=tmp.substr(0,tmp.length-2);
	}
	posicio("llista_llibres",tmp,-75*pos_actual,1000);
	if(pos_actual==max_pos-9){
		document.getElementById("bdre").style.display="none";
	}
}
function esquerra(){
	document.getElementById("bdre").style.display="block";
	pos_actual--;
	//document.getElementById("llista_llibres").style.top=(-180*pos_actual)+"px";
	var tmp=document.getElementById("llista_llibres").style.left;
	if(tmp.substr(tmp.length-2,2)=="px"){
		tmp=tmp.substr(0,tmp.length-2);
	}
	posicio("llista_llibres",tmp,-75*pos_actual,1000);
	if(pos_actual==0){
		document.getElementById("besq").style.display="none";
	}
}

var timeoutId=new Array();
function posicio(id, posStart, posEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(posStart > posEnd) { 
		i = posStart;
		while(i > posEnd){
			tmp=Math.floor(parseInt(i)+(posEnd-i)/10);
			if(i!=tmp){
				i=tmp;
			}else{
				i=posEnd;
			}
            timeoutId.push(setTimeout("changepos(" + i + ")",(timer * speed))); 
            timer++; 
        } 
    } else if(posStart < posEnd) { 
		i = posStart;
		while(i < posEnd){
			tmp=Math.ceil(parseInt(i)+(posEnd-i)/10);
			if(i!=tmp){
				i=tmp;
			}else{
				i=posEnd;
			}
            timeoutId.push(setTimeout("changepos(" + i + ")",(timer * speed))); 
            timer++; 
        } 
    } 
} 
function changepos(pos) { 
	document.getElementById("llista_llibres").style.left=pos+"px";
}

quina="onsom_mapa";
function canviar_onsom(){
	if(quina=="onsom_mapa"){
		quina="onsom2";	
	}else{
		quina="onsom_mapa";	
	}
	document.getElementById("foto_onsom").src="images/"+quina+".jpg";
}


function changeOpac(opacity, id) { 
   /* var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; */
	
      var objToFade = document.getElementById(id);
      if(typeof objToFade.style.opacity == "string") {
			objToFade.style.opacity = opacity/100;
      } else { 
			document.getElementById(id).style.filter="alpha(opacity="+opacity+")";
      }
}
