/*
Dancefoundation's YouTube player embed
WordPress Plugin by Dancefoundation, http://www.dancefoundation.com
*/

//check for ie
ie = false;
if (document.all) {
	var ie = true;
}

//a function to choose another youtube-video without reloading the page
function dfYoutubePlaylist_cy(ytSrc,containerId,type) {
	if (type == null || type == '') {
		type = 'v';
	}
	document.getElementById(containerId).innerHTML = eval("dfYoutubePlaylist_cf('',ytSrc,510,310,type)");
}

//a function to load flashmovies. it also prevents ie from adding the ugly border
function dfYoutubePlaylist_cf(FlashVars,movie,width,height,type) {
	dfYoutubePlaylist_cfStr = '<obj' + 'ect width="' + width + '" height="' + height + '" data="' + 'http://www.youtube.com/'+ type +'/'+ movie +'&rel=0&hl=en&fs=1&hd=1&iv_load_policy=3&showinfo=0&showsearch=0' + '" type="application/x-shockwave-flash">';
	dfYoutubePlaylist_cfStr += '<param name="movie" value="http://www.youtube.com/'+ type +'/'+ movie +'&rel=0&hl=en&fs=1&hd=1&iv_load_policy=3&showinfo=0&showsearch=0"/>';
	dfYoutubePlaylist_cfStr += '<param name="allowFullScreen" value="true"/>';
	dfYoutubePlaylist_cfStr += '<param name="allowscriptaccess" value="always"/>';
	//dfYoutubePlaylist_cfStr += '<param name="FlashVars" value="'+ FlashVars +'">';
	dfYoutubePlaylist_cfStr += '<embed src="http://www.youtube.com/'+ type +'/'+ movie +'&rel=0&hl=en&fs=1&hd=1&iv_load_policy=3&showinfo=0&showsearch=0" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" allowscriptaccess="always" allowfullscreen="true"/>';
	dfYoutubePlaylist_cfStr += '<' + '/object>';
	return dfYoutubePlaylist_cfStr;
}

//a function to load all movies with thumbs to a list
function dfYoutubePlaylist_dl(allVideos,containerId,targetContainerId) {
	allVideosArr = allVideos.split(', ');
	if (allVideosArr.length > 1) {
		allVideosLi = '<ul class="dfYoutubePlaylist_Ul" >';	
		for (var i=0; i < allVideosArr.length; i++) {
			thisLink = 'javascript:dfYoutubePlaylist_cy(\''+allVideosArr[i]+'\',\''+targetContainerId+'\');'
			allVideosLi += '<li>' + '<a href="'+thisLink+'">' + '<img class="dfYoutubePlaylist_Img"  alt="" src="http://img.youtube.com/vi/'+allVideosArr[i]+'/0.jpg" width="100" height="75" />' + '</'+'a></'+'li>';
		}
		allVideosLi += '</ul><a href=\"/videos\" title=\"View all videos\" class=\"all-videos\">All videos</a>';
		document.getElementById(containerId).innerHTML = allVideosLi;
	} else {
		document.getElementById(containerId).style.display = 'none';
	}
}