function getClip(type) {
	
	window.type = type;
	if(mijnTimer == 0)
	{
		  //alert("include/AJX/ajx_getWedstrijden.asp?id="+window.page+"&type="+type);
		  //Stel de pagina in die aangeroepen moet worden
		  ajxReloadClips.requestFile = "include/AJX/ajx_getWedstrijden.asp?id="+window.page+"&type="+type;
			
		  //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

		  //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;
		//alert(content);
		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)
		{
			//alert(nieuwPage);
			window.page = nieuwPage;
			if(type == 1){
				var newdiv = document.createElement('div');
				newdiv.setAttribute('id',teller+"-"+nieuwPage);
				newdiv.setAttribute('class',"clip");
				newdiv.innerHTML = content;	
				scrollContent.appendChild(newdiv);
				origDiv = scrollContent.childNodes[0];
				
				for(var i=0;i<scrollContent.childNodes.length;i++)
				{
					clipArray[i] = scrollContent.childNodes[i];
				}
				
				wedstrijdenPlaylist = new ClipScroller('scrollContent',clipArray.length,clipwidth,1,{transition: Fx.Transitions.quadOut, duration: 500});
				wedstrijdenPlaylist.moveLeft();
				mijnTimer = setTimeout("removeClip(scrollContent,this.origDiv,type);",550);
			}
			else if(type == 2)
			{
				var newdiv = document.createElement('div');
				newdiv.setAttribute('id',teller+"--"+nieuwPage);
				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++)
				{
					clipArray[i] = scrollContent.childNodes[i];
				}
				
				wedstrijdenPlaylist = new ClipScroller('scrollContent',clipArray.length,clipwidth,1,{transition: Fx.Transitions.quadOut, duration: 500});
				wedstrijdenPlaylist.move.custom(0, -clipwidth, 1);
				wedstrijdenPlaylist.moveRight();
				mijnTimer = setTimeout("removeClip(scrollContent,this.origDiv,type);",550);
			}
		}

	}
}

function removeClip(scrollContent,origDiv,type)
{
	if(type == 1){	
		swapElements(scrollContent.firstChild,scrollContent.lastChild)
		wedstrijdenPlaylist.move.custom(-clipwidth, 0, 1);
		//alert(scrollContent.childNodes.length);
		if(scrollContent.childNodes.length > 1){
			scrollContent.removeChild(scrollContent.lastChild);
		}
	}
	else if(type == 2){
		wedstrijdenPlaylist.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);
	}
}