/*
function slider(slide){
	if(typeof startPos == "undefined"){
		startPos = 0;
	}
	
	speed = 300;
	
	containerWidth = document.getElementById("slide_container").offsetWidth;
	subpageWidth = 630;
	
	// Animate slide	
	$("#slide_container").animate({ 
	        left: slide
	      }, 1500 );
	

}
*/
function slider(pos, abs){
	if(typeof startPos == "undefined"){
		startPos = 0;
	}
	if(typeof animationSpeed == "undefined"){
		animationSpeed = 500;
	}
	
	// Get container and subpage width
	containerWidth = document.getElementById("slide_container").offsetWidth;
	subpageWidth = document.getElementById("subpage1").offsetWidth;
	
	// Check old start position
	oldstartPos = startPos;
	

	startPos = startPos+pos;

	if(startPos < ((containerWidth-(containerWidth*2))+subpageWidth)){
		$("#slide_container").animate({ 
			left: 0
		}, 300 );
		startPos = 0;
	}
	else if(startPos==630){
		$("#slide_container").animate({ 
			left: ((containerWidth-(containerWidth*2))+subpageWidth)+4
		}, 300 );
		startPos = ((containerWidth-(containerWidth*2))+subpageWidth)+4;
	}
	
	
	
	// Set the animation speed
	if(startPos > oldstartPos){
		speed = (startPos-oldstartPos)/(subpageWidth*2);
	}
	else{
		speed = (oldstartPos-startPos)/(subpageWidth*2);	
	}
	if(speed < 1){speed = 1;}


	// Animate slide
	$("#slide_container").animate({ 
		left: startPos
	}, animationSpeed/speed );
	
	document.getElementById("curr_prod_nr_top").innerHTML = ((startPos/630)-((startPos/630)*2))+1;
	document.getElementById("curr_prod_nr_bottom").innerHTML = ((startPos/630)-((startPos/630)*2))+1;
	
}