/*
qbrickCategoryPlayer
WordPress Plugin by Johan Lundberg (originally based Jonk's myYoutubePlaylist, http://jonk.pirateboy.net)
*/

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

//a function to choose another qbrick-video without reloading the page
function qbrickCategoryPlayer_cy(ytSrc,containerId,play) {	
	document.getElementById(containerId).innerHTML = eval("qbrickCategoryPlayer_cf('',ytSrc,880,495,play)"); /*height = 407px, according to photoshop file*/
}

//a function to load flashmovies. it also prevents ie from adding the ugly border
function qbrickCategoryPlayer_cf(FlashVars,movie,width,height,play) {
	if (play == 'play') {
		play = '&as=1';
	}
	else
		play = '&as=0';
	//http://vms.admin.qbrick.com/p3/modules/mediaplayer.swf?mcid=D2EE317778506593&as=0&fs=1&rp=0&cb=1&il=1&sp=1
	qbrickCategoryPlayer_cfStr = '<obj' + 'ect width="' + width + '" height="' + height + '" data="' + 'http://vms.admin.qbrick.com/p3/modules/mediaplayer.swf?mcid='+ movie +'78506593'+ play +'&fs=1&rp=1&cb=1&il=1&sp=1" type="application/x-shockwave-flash">';
	qbrickCategoryPlayer_cfStr += '<param name="movie" value="http://vms.admin.qbrick.com/p3/modules/mediaplayer.swf?mcid='+ movie +'78506593'+ play +'&fs=1&rp=1&cb=1&il=1&sp=1"/>';
	qbrickCategoryPlayer_cfStr += '<param name="allowFullScreen" value="true"/>';
	qbrickCategoryPlayer_cfStr += '<param name="allowscriptaccess" value="always"/>';	
	qbrickCategoryPlayer_cfStr += '<embed src="http://vms.admin.qbrick.com/p3/modules/mediaplayer.swf?mcid='+ movie +'78506593'+ play +'&fs=1&rp=1&cb=1&il=1&sp=1" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" allowscriptaccess="always" allowfullscreen="true"/>';
	qbrickCategoryPlayer_cfStr += '<' + '/object>';
	return qbrickCategoryPlayer_cfStr;
}

//a function to load all movies with thumbs to a list
function qbrickCategoryPlayer_dl(allVideos,containerId,targetContainerId,allImages) {
	
	allImagesArr = allImages.split(', ');
	allVideosArr = allVideos.split(', ');
	if (allVideosArr.length > 1) {
		allVideosLi = '<ul class="qbrickCategoryPlayer_Ul jcarousel-skin-tango" >';	
		for (var i=0; i < allVideosArr.length; i++) {
			thisLink = 'javascript:qbrickCategoryPlayer_cy(\''+allVideosArr[i]+'\',\''+targetContainerId+'\',\''+'play'+'\');'
			allVideosLi += '<li>' + '<a href="'+thisLink+'">' + '<img class="qbrickCategoryPlayer_Img"  alt="" src="'+allImagesArr[i]+'"/>' + '</'+'a></'+'li>';
		}
		allVideosLi += '</ul>';
		document.getElementById(containerId).innerHTML = allVideosLi;
	} else {
		document.getElementById(containerId).style.display = 'none';
	}
}

