// JavaScript Document
// Animation functions By AMD
// Version 2.0 - Nov 2008
// For showing more information on the item data
var actualTimer = 0;
var fullstop = false;

function abrir(id){
	if (!fullstop){ 
		clearTimeout(actualTimer);
		var divPath = document.getElementById(id); 
		var tempWidth = divPath.style.left.split('p');
		var currPos = parseInt(tempWidth[0]);
		var sliderw = 110; //divPath.offsetWidth;
		
		if (currPos > sliderw) {
			currPos -= 10; 
			divPath.style.left = currPos + "px"; 
			actualTimer = setTimeout("abrir('" + id + "')",12.5); 
		}else{
			detener();
		}
	}
}
function cerrar(id){
	if (!fullstop){ 
		clearTimeout(actualTimer);
		var divPath = document.getElementById(id); 
		var tempWidth = divPath.style.left.split('p');
		var currPos = parseInt(tempWidth[0]);
		var sliderw = 210;
		
		if (currPos < sliderw) {
			currPos += 10; 
			divPath.style.left = currPos + "px"; 
			actualTimer = setTimeout("cerrar('" + id + "')",12.5); 
		}else{
			detener();
		}
	}
}
function detener(){
	clearTimeout(actualTimer);
}
function detenerTotal(){
	detener();
	fullstop = true;
}

/* Javascript scroller by AMD for SurePointSystems */
/* Scrolls 'scrollid' in the direction 'direction' (>0: scroll down, <0: scroll up, =0: dont scroll just update. */
function myScroller(scrollid, direction){
	mydir = (direction==0)?0:direction;
	if(mydir!=0){
		mydir = (direction<0)?-1:1;
	}
	scrollup = document.getElementById("scrollup"+scrollid);
	scrolldown = document.getElementById("scrolldown"+scrollid);
	mydiv = document.getElementById("scroller"+scrollid);
	
	tempWidth = mydiv.style.top.split('p');
	currPos = parseInt(tempWidth[0]);

	containerh = 160;
	sliderh = mydiv.offsetHeight+15;
	
	maxscroll = containerh - sliderh;
	mystep = 50;
	
	currPos += mystep*mydir;
	
	if(sliderh>containerh){
		if(currPos>maxscroll && currPos<0){ //el slider sobrepaso
			mydiv.style.top = currPos + "px"; 
			scrollup.style.visibility = "visible";
			scrolldown.style.visibility = "visible";
		}else{ //llego al tope o al fondo
			mydiv.style.top = ((mydir<1)?maxscroll:0) + "px"; 
			
			scrollup.style.visibility = (mydir<1)?"visible":"hidden";
			scrolldown.style.visibility = (mydir<1)?"hidden":"visible";
		}
	}else{
			scrolldown.style.visibility = "hidden";
	}
	//alert('Past end! '+maxscroll+" np: "+currPos);

}
