var VideoLibrary = {
    init : function() {
        VideoLibrary.createLibrary();
    },
    
    createLibrary : function() {
        VideoLibrary.fx = [];
        VideoLibrary.videoButtons = $$('#chakraCharts .button a, #videoList .sampleVideoButton a');
        VideoLibrary.contentPanes = $$('#contentContainer .content');		
        VideoLibrary.contentPanes.each(function(pane, i) {
	        VideoLibrary.fx[i] = new Fx.Style(pane, 'opacity', {wait: false, duration: 500}); 	        
            VideoLibrary.videoButtons[i].addEvent('click', function() {
                VideoLibrary.contentPanes.each(function(paneToDisplay, j) {
                    VideoLibrary.contentPanes[j].setStyle('display', 'none');
                });
				VideoLibrary.flashToDom('/assets/flash/flash-num.swf'.replace(/num/g, i));
                //VideoLibrary.contentPanes[i].setStyle('opacity', '0');
				if(i == 0){
					i = 7;
				}
                VideoLibrary.contentPanes[i-1].setStyle('display', 'block');
                //VideoLibrary.fx[i].start(0,1);
	        });
        });
    },
	
	flashToDom : function(srcFile) {
        $('videoDisplay').setHTML(VideoLibrary.flashInnerHtml.replace(/srcFile/g, srcFile));
    },
	
	flashInnerHtml: '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="420" height="280" id="ufoElementNodeId" align="middle"> <param name="quality" value="high" /> <param name="allowfullscreen" value="true" /> <param name="wmode" value="transparent" /> <param name="movie" value="srcFile" /> <param name="autoplay" value="true" /> <embed src="srcFile" quality="high" width="420" height="280" allowfullscreen="true" autoplay="true" wmode="transparent" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>'
	
	
}

window.addEvent('domready', VideoLibrary.init);