/*
 * jQuery Expanding Text
 *
 * Copyright (c) 2011 ArchYves
 */

$(document).ready(function(){
	if($(".expandingText").length){
		$(".expandingText").removeClass("default");
		$(".expandingText .readMore").before("<span class='dots'> &hellip; </span>");
		
		
		$(".expandingText h2").click(function() {
			stopVideo();
			$(this).parent().toggleClass("open");
		});
		$(".expandingText .readMore").click(function() {
			$(this).parent().parent().parent().addClass("open");
		});
		$(".expandingText .readLess").click(function() {
			stopVideo();
			$(this).parent().parent().parent().removeClass("open");
		});
	};
});

function stopVideo(){
	if($(".videoComponent:visible").length > 0){ 
		var playingVideo = $(".videoComponent").attr("id"); // Ervan uitgaande dat er maar 1 video in een panel komt
		document.getElementById(playingVideo).pauseVideo(); // Old School, anders doet de You Tube API het niet
	};
}
