var to;
var to2;
var stapjes=43;
var fotobreed=4; //aantal stappen per pagina
var found=0;
		function tosize(id) {
			tox=document.getElementById("slide_frame").offsetWidth;
			tox=parseInt(tox)-90;
			tds=document.getElementById(id).getElementsByTagName("td").length;
			tds=tds+(tds%2);
			//alert(tds);
			document.getElementById(id).style.width=(((tds/8)*tox)+0)+"px";
			//alert((((tds/8)*tox)+0)+"px");
			//alert((tds%8));
			//alert((tds%2));
			document.getElementById(id).style.display="block";
			
			
			//slide_left
			//slide_right
			document.getElementById("slide_left").style.visibility="hidden";
			if(tds<9) {
				document.getElementById("slide_right").style.visibility="hidden";
			}
		}
		
		function toprod(id,welke,aantal) {
			//alert(id+":"+welke+"/"+aantal);
			tds=document.getElementById(id).getElementsByTagName("td").length;
			if(tds>8) {
				document.getElementById("slide_left").style.visibility="visible";
				document.getElementById("slide_right").style.visibility="visible";
			}
			a=1;
			nu=0;
			nu=parseInt(nu);
			if(welke<((aantal)/2)) {
				//11=11/2=5.5		0-5
				//12=12/2=6			0-5
				//13=13/2=6.5		0-6
				a=welke-1;
			} else {
				r=Math.round((aantal)/2);
				//5/11	=	6		-1
				//6/11	=	6		0
				//7/11	=	6		1
				//5/12	=	6
				//6/12	=	6
				//7/12	=	6
				a=(welke-r)-1;
			}
			naar=nu-((tox/fotobreed)*a);
			naar=Math.round(naar/stapjes);
			if(naar>=0) {
				document.getElementById("slide_left").style.visibility="hidden";
			} else {
				document.getElementById("slide_left").style.visibility="visible";
			}
			naar=naar*stapjes;
			//alert(naar);
			oud=stapjes;
			stapjes=215000;
			to=setTimeout("scrol('"+id+"',"+naar+")",100);
			r=Math.round((aantal)/2);
			to2=setTimeout("stapset('"+oud+"')",(100*r));
		}
		function showload() {
			
		}
		
		function stapset(hoeveel) {
			stapjes=hoeveel*1;
			if(to2) {
				clearTimeout(to2);
			}
		}
		
		function scrol2(id,aantal) {
			if(to) {
				clearTimeout(to);
			}
			tox=document.getElementById("slide_frame").offsetWidth;
			toy=document.getElementById(id).offsetWidth;
			nu=document.getElementById(id).style.marginLeft;
			tox=parseInt(tox)-90;
			if(nu+""=="") {
				nu=0;
			}
			nu=parseInt(nu);
			//alert(nu+"-"+tox+"-"+toy);
			divs=document.getElementById(id).getElementsByTagName("div").length;
			tds=document.getElementById(id).getElementsByTagName("td").length;
			//document.getElementById(id).style.width=(((tds/8)*tox)+0)+"px";
			//alert((((divs-1)*tox)+0));
			breedte=((divs-1)*tox);
			aantalx=((breedte/tox)*8);
			//alert(aantal);
			t=document.getElementById(id).getElementsByTagName("td");
			f=0;
			for(a=0; a<tds; a++) {
				if(t[a].innerHTML=="") {
					//alert(a+"!");
				} else {
					f++;	
				}
			}
			found=f;
			//alert(f);
			//alert(tox);
			document.getElementById("slide_left").style.visibility="visible";
			document.getElementById("slide_right").style.visibility="visible";
			if(aantal>0) {
				naar=nu-(tox/fotobreed);
				naar=Math.round(naar/stapjes);
				//alert(naar);
				if(naar>=0) {
					document.getElementById("slide_left").style.visibility="hidden";
				} else {
					document.getElementById("slide_left").style.visibility="visible";
				}
				//alert(tds);
				naar=naar*stapjes;
				//alert(naar);
				//alert(tox);
				//n=Math.round(naar/tox);
				//alert(n);
				//alert(nu+"-"+naar);
				//naar=(n*tox);
				//alert(nu+"-"+naar2);
				scrol(id,naar);
			} else if(aantal<0) {
				naar=nu+(tox/fotobreed);
				naar=Math.round(naar/stapjes);
				//alert(naar);
				if(naar>=0) {
					document.getElementById("slide_left").style.visibility="hidden";
				} else {
					document.getElementById("slide_left").style.visibility="visible";
				}
				//alert(tds);
				naar=naar*stapjes;
					//n=Math.round(naar/tox);
				//alert(n);
				//alert(nu+"-"+naar);
					//naar=(n*tox);
				//alert(nu+"-"+naar2);
				scrol(id,naar);
			} else {
				document.getElementById("slide_left").style.visibility="hidden";
				scrol(id,0);	
			}
		}
		
		function scrol(id,naar) {
			//274-340 = 280-346
			tox=500;
			tox=document.getElementById("slide_frame").offsetWidth;
			tox=tox-90;
			//alert(tox);
			if(to) {
				//clearTimeout(to);
			}
			//nu=document.getElementById(id).offsetTop;
			nu=document.getElementById(id).style.marginLeft;
			if((nu+"")=="") {
				nu=0;
			} else {
				nu=parseInt(nu);
			}
			//naar=parseInt(nu*1)+parseInt(aantal);
			if(naar>0) {
				naar=0;
			}
			hoogte=document.getElementById(id).offsetWidth;
			nuhoog=parseInt(hoogte);
			
			
			hoogte=0-(parseInt(hoogte)-tox);
			if(naar<=hoogte) {
				naar=hoogte;
				document.getElementById("slide_right").style.visibility="hidden";
			}
			if(nuhoog<tox) {
				//te weinig om te scrollen
					document.getElementById("slide_left").style.visibility="hidden";
					document.getElementById("slide_right").style.visibility="hidden";
			} else {
				if(nu>(naar-(stapjes+1)) && nu<(naar+(stapjes-1))) {
					nu2=naar;	
				} else if(naar<nu) {
					nu2=nu-stapjes;
				} else if(naar>nu) {
					nu2=nu+stapjes;
				} else {
					nu2=nu;	
				}
				document.getElementById(id).style.marginLeft=nu2+"px";
				if(naar==nu) {
					if(to) {
						clearTimeout(to);
					}
				} else if(naar+""!="") {
					to=setTimeout("scrol('"+id+"',"+naar+")",30);
				} else {
					if(to) {
						clearTimeout(to);
					}
				}
			}
		}
		


function resetmenu() {
	g=document.getElementById('swilends-content-menu');	
	if(g){
		t=(((100) + (ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop)) + 'px'); 
		//alert(t);
		g.style.top=t;
	}
}