
	$(document).ready(function(){
	
		$('.playHomeVideo').click(function(){
			var id 	= this.id.replace('section_','');
			var hc	= $(this).hasClass('showVideoContent');
			var c	= ''
			if (hc==true){
				c = 'showVideoContent'
			}
			playHomeVideo(id,c);
		});
		
	});
	
	var lf = 0
	function playHomeVideo(id,c){
		if ($('#homeVideoFrame').size()>0){
			return false;
		}
		
		if (c!=''){
			c = ' class="' +c+ '"'
		}
		$('body').prepend('<div id="homeVideoFrame"' +c+ '></div>');
		
		//--- originele "left" ophalen ----
		lf 	= $('#homeVideoFrame').css('left');
		lf	= lf.replace('px','');
		lf	= Number(lf);
		
		//--- locatie herberekenen ---
		relocateFrame('#homeVideoFrame');
		
		$('#homeVideoFrame').html('<iframe frameborder="0" scrolling="no" src="' +_root+ 'popup/video.asp?section=' +id+ '"></iframe>');
		$('#homeVideoFrame').prepend('<div id="homeVideoClose">Sluit dit scherm</div>');
		
		$('#homeVideoFrame #homeVideoClose').click(function(){
			$('#homeVideoFrame').remove();
		});
	}
	
	function relocateFrame(div){
		var h 		= $(window).height();
		var w 		= $(window).width();
		var hf 		= $(div).height();
		var wf 		= $(div).width();
		var top 	= Math.round((h-hf)/2)
		var left 	= Math.round((w-wf)/2)
		
		var dw		= $(document).width();
		var dw		= $('#wrapper').width();
		if (w>dw){
			left = lf
		}
		
		$(div).css({
			'top':(top+'px'),
			'left':(left+'px') 
		});
	}
	
	
	$(window).resize(function(){
								
		if ($('#homeVideoFrame').size()>0){
			relocateFrame('#homeVideoFrame');
		}
								
	});

