/* Robert 110103 aanpassing breedte scroller */

var vid_arrTitle = new Array();
var vid_arrText = new Array();
var vid_arrVideo = new Array();
var vid_arrImg = new Array();
var vid_Img_voorloop="";


function bouwCarousel() {

var inhoudCarousel = ""
var tss=vid_arrVideo.length
var iR

inhoudCarousel += '<ul style="overflow:hidden; margin: 0pt; padding: 0pt; position: relative; list-style-type: none; z-index: 1;  height: 135px;" >'

for (iR=0;iR<tss;iR++) {
inhoudCarousel += '<li style="overflow: hidden; float: left; width: 145px; margin-right:5px; ">'
inhoudCarousel += '<img class="playvideo" style="background-image:url('
inhoudCarousel += vid_Img_voorloop+vid_arrImg[iR]
inhoudCarousel += ')" src="'
inhoudCarousel += "/sites/een.be/themes/een/images/video_overlay_small.png"
inhoudCarousel += '" id="video-'
inhoudCarousel += vid_arrVideo[iR]
inhoudCarousel += '" title="'
inhoudCarousel += vid_arrTitle[iR]
inhoudCarousel += '" tekst="'
inhoudCarousel += vid_arrText[iR]
inhoudCarousel += '">'
inhoudCarousel += '<p class="playvideo" id="video-'
inhoudCarousel += vid_arrVideo[iR]
inhoudCarousel += '">'
inhoudCarousel += vid_arrTitle[iR]
inhoudCarousel += '</p></li>'
} //einde for

inhoudCarousel += '</ul>'

document.getElementById('carousel').innerHTML=inhoudCarousel
document.getElementById('carousel').style.width=(iR*150) +'px'

var titel
//var tekst


$(document).ready(function(){
            $('.teaserInfo').css('display', 'none');
            $('.vrtVideoPLayer').css('border-bottom', '0px');

TINY.scroller.init('scroll','carousel','scrollbar','scroller','buttonclick');

            $('.playvideo').click(function(){
            var video = $(this).id();
            var nid = video.substr(6);
		titel=document.getElementById(video).getAttribute('title');       
		tekst=document.getElementById(video).getAttribute('tekst');

//beter met functie en autostart
            $.ajax({
              url: "/mediatheek/ajax/video/"+nid,
              global: false,
              type: "GET",
              dataType: "html",

              complete: function (XMLHttpRequest, textStatus) {
				document.getElementById('videoTitle').innerHTML='<h3>'+titel+'</h3>'
				document.getElementById('videoText').innerHTML='<p>'+tekst+'</p>'
              $('#videoZoneContainer').html(XMLHttpRequest.responseText);
                        $('.videoZone').css('width', '555px');
            		$('.videoTeaser').css('padding-bottom', '5px');
                        $('.teaserInfo').css('display', 'none');
                        $('.vrtVideoPLayer').css('border-bottom', '0px');
                        return false;
                }
          
            }); //einde ajax
 
            return false;
            }); //einde playvideo.click function

		}) //einde document.ready function


} //einde bouwCarousel
















//code adapted from TinyScroller by Michael Leigeber www.leigeber.com

var TINY={};

function T$(id){return document.getElementById(id)}
function T$$$(){return document.all?1:0}

TINY.scroller=function(){
	return{
		init:function(a,c,b,s,d){
			a=T$(a); a.c=c; a.s=s; c=T$(c); b=T$(b); s=T$(s); a.n=d||0;
			b.style.display='block'; a.style.overflow='hidden';
			var h=a.offsetHeight, t=c.offsetHeight;
			var beschikbareW=a.offsetWidth, totaleW=c.offsetWidth;
			if(totaleW<beschikbareW){
				b.style.display='none'
			}else{
				a.m=beschikbareW-totaleW; a.d=totaleW/beschikbareW; s.style.width=(beschikbareW*(beschikbareW/totaleW))+'px'; s.style.left=b.style.left=0;
				if (beschikbareW*(beschikbareW/totaleW)<32) { s.style.width='32px' }
/*				a.m=beschikbareW-totaleW; a.d=totaleW/beschikbareW; s.style.left=b.style.left=0;
alert(s.style.width)
s.style.width=(beschikbareW*(beschikbareW/totaleW));
if (s.style.width<40) { s.style.width=40 };
s.style.width+='px'; 
alert(s.style.width)
*/
				s.onmousedown=function(event){TINY.scroller.st(event,a.id); return false};
				s.onselectstart=function(){return false}
			}
			a.l=b.offsetWidth-s.offsetWidth
		},
		st:function(e,f){
			var a=T$(f), s=T$(a.s); a.bcs=TINY.cursor.left(e); a.bct=parseInt(s.style.left);
			if(a.mv){this.sp(f)}
			a.mv=function(event){TINY.scroller.mv(event,f)};
			a.sp=function(){TINY.scroller.sp(f)};
			if(T$$$()){
				document.attachEvent('onmousemove',a.mv); document.attachEvent('onmouseup',a.sp)
			}else{
				document.addEventListener('mousemove',a.mv,1); document.addEventListener('mouseup',a.sp,1)
			}
			if(a.d){s.className+=' '+a.n}
		},

		mv:function(e,f){
			var a=T$(f), m=TINY.cursor.left(e)-a.bcs+a.bct, s=T$(a.s), c=T$(a.c);
			if(m>=0&&m<a.l){
				s.style.left=m+'px'; c.style.left=(m*-1*a.d)+'px'
			}else if(m<0){
				s.style.left=0; c.style.left=0
			}else if(m>a.l){
				s.style.left=a.l+'px'; c.style.left=a.m+'px'
			}
		},


		sp:function(f){
			var a=T$(f), s=T$(a.s); if(a.d){s.className=s.className.replace(' '+a.n,'')}
			if(T$$$()){
				document.detachEvent('onmousemove',a.mv); document.detachEvent('onmouseup',a.sp)
			}else{
				document.removeEventListener('mousemove',a.mv,1); document.removeEventListener('mouseup',a.sp,1)
			}
			a.mv=0;
		}
	}
}();

TINY.cursor=function(){
	return{
		left:function(e){
		  return T$$$()?window.event.clientX+document.documentElement.scrollWidth+document.body.scrollWidth:e.clientX+window.scrollX
		}
	}
}();

