function getClip(type,fotoboekid) {
	window.type = type;	
	if(mijnTimer == 0)
	{
		  //Stel de pagina in die aangeroepen moet worden
		  ajxReloadClips.requestFile = "include/AJX/ajx_getWedstrijdfotoboek.asp?fotoboekid="+fotoboekid+"&id="+page;
			
		  //Stel de methode in waarop de parameters doorgegeven moeten worden
		  ajxReloadClips.method = "post";
		  //Voeg aan het object parameters toe die meegegeven moeten worden aan de pagina
		  //ajxReloadClips.setVar("id", window.komendewedstrijd);
		  ajxReloadClips.setVar("type", type);
		  //Stel de functie in de uitgevoerd wordt als er een respons is
		  ajxReloadClips.onCompletion = function() {setClips(type);}
	
		  //Voer de request uit
		  ajxReloadClips.runAJAX();	
	 }	
}

function setClips(type) {
	if(ajxReloadClips.response != ""){
		var content = ajxReloadClips.response;
		teller = teller +1;
		
		if(content.indexOf("page=") != -1)
		{
			var lengte = String(content).length;
			var iIndex = content.indexOf("page="); 
			var aantalPosities = lengte - iIndex;
			var nieuwPage = Right(content, aantalPosities);
			
			nieuwPage = nieuwPage.replace(";","");
			var scr = "</scr"+"ipt>";
			nieuwPage = nieuwPage.replace(scr,"");
			nieuwPage = nieuwPage.replace("page=","");
		}			
		
		if(nieuwPage != 0)
		{
			window.page = nieuwPage;
			if(type == 1){
				var newdiv = document.createElement('div');
				newdiv.setAttribute('id',teller+"-"+page);
				newdiv.setAttribute('class',"clip");				
				newdiv.innerHTML = content;	
				origDiv = scrollContent.childNodes[0];
				
				scrollContent.appendChild(newdiv);
				
				for(var i=0;i<scrollContent.childNodes.length;i++)
				{
					//clipArray[i] = scrollContent.childNodes[i];
					if(scrollContent.childNodes[i].innerHTML)
					{
						clipArray[i] = scrollContent.childNodes[i];
						//alert(scrollContent.childNodes[i].innerHTML);
					}
				}
				
				myScroller = new ClipScroller('scrollContent',clipArray.length,window.clipwidth,1,{transition: Fx.Transitions.quadOut, duration: 500});
				myScroller.moveLeft();
				mijnTimer = setTimeout("removeClip(scrollContent,this.origDiv,type);",550);
			}
			else if(type == 2)
			{		
				//alert('ja > 2');
				var newdiv = document.createElement('div');
				newdiv.setAttribute('id',teller+"--"+page);
				newdiv.setAttribute('class',"clip");			
				newdiv.innerHTML = content;						
				
				scrollContent.insertBefore(newdiv,scrollContent.childNodes[0]);
				origDiv = scrollContent.childNodes[1];
				for(var i=0;i<scrollContent.childNodes.length;i++)
				{
					if(scrollContent.childNodes[i].innerHTML)
					{
						clipArray[i] = scrollContent.childNodes[i];
						//alert(scrollContent.childNodes[i].innerHTML);
					}
				}
				
				myScroller = new ClipScroller('scrollContent',clipArray.length,clipwidth,1,{transition: Fx.Transitions.quadOut, duration: 500});
				myScroller.move.custom(0, -clipwidth, 1);
				myScroller.moveRight();
				mijnTimer = setTimeout("removeClip(scrollContent,this.origDiv,this.type);",550);	
			}
		}

	}
}

function removeClip(scrollContent,origDiv,type)
{
	//alert(type);
	if(type == 1){	
		swapElements(scrollContent.firstChild,scrollContent.lastChild)
		
		myScroller.move.custom(-clipwidth, 0, 1);
		//alert('ja');
		//alert(scrollContent.childNodes.length);
		if(scrollContent.childNodes.length > 1){
			scrollContent.removeChild(scrollContent.lastChild);
		}
	}
	else if(type == 2){
		myScroller.move.custom(-clipwidth, 0, 1);
		scrollContent.removeChild(scrollContent.lastChild);
	}
	mijnTimer=0;
}

function swapElements(item1,item2)
{
	
	var ie = document.all;
	
	if(ie){
		item1.innerHTML = item2.innerHTML;
	}
	else
	{//firefox
		//scrollContent.childNodes[0] = scrollContent.childNodes[1];
		scrollContent.replaceChild(item2,item1);
	}
}

function resetTimer()
{
	videoPlaylist.options.duration = 500;
	mijnTimer = 0;
}

function Left(str, n){
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else
		return String(str).substring(0,n);
}
function Right(str, n){
	if (n <= 0)
	   return "";
	else if (n > String(str).length)
	   return str;
	else {
	   var iLen = String(str).length;
	   return String(str).substring(iLen, iLen - n);
	}
}
