
YUI({
    //Last Gallery Build of this module
    gallery: 'gallery-2010.09.01-19-12'
}).use('node', 'overlay', 'widget-anim', 'gallery-overlay-extras', function(Y){
 
        var overlay = new Y.Overlay({
	
			width       : 540,
            zIndex      : 10000,
            centered    : true,
            constrain   : true,
            render      : true,
            visible     : false,
            plugins     : [
                { fn: Y.Plugin.OverlayModal },
                { fn: Y.Plugin.OverlayKeepaligned },
                { fn: Y.Plugin.OverlayAutohide, cfg: {
                    focusedOutside : false  // disables the Overlay from auto-hiding on losing focus
                }}
            ],
			on : {
			  visibleChange : function(e) {
				  if(!e.newVal) {
					  overlay.setStdModContent('body', '');
				  }
			  }
			}
 
        });
        
 
		var btn = Y.Node.create('<button style="float: right;"><img src="/css/img/close.jpg"></button>');
		btn.on('click', Y.bind(overlay.hide, overlay))
  

	Y.delegate('click', function(e){
		e.preventDefault();
		Y.log(e);
		var target = e.currentTarget,
		    title = target.ancestor('.case-study').one('h3').get('text'),
			video = target.get('href');
			
		
//		overlay.setStdModContent('body','<object id="flv_video" width="530" height="337" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">'
//								       + '<param value="sameDomain" name="allowScriptAccess">'
//								       + '<param value="true" name="allowFullScreen">'
//								       + '<param value="" name="salign">'
//								       + '<param value="/swf/flowplayer-3.2.4.swf?movie='+video+'" name="movie">'
//								       + '<param value="high" name="quality">'
//								       + '<param value="#FFFFFF" name="BGCOLOR">'
//									   + '<embed height="337" width="530" align="middle" bgcolor="#FFFFFF" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="sameDomain" name="flv_video" quality="high" scale="showall" salign="" src="/swf/flowplayer-3.2.4.swf?movie='+video+'">'
//								       + '</object>'
//									   );
		
		overlay.setStdModContent(
				'body', 
				'<div id="player" style="width: 530px; height: 298px;"></div>');
		
		overlay.setStdModContent('footer', title);
		overlay.setStdModContent('footer', btn, 'before');
		
		overlay.show();
		flowplayer("player", "/swf/flowplayer-3.2.4.swf",{
			clip:{url: video, autoPlay:true },
			plugins : { controls : { url : "/swf/flowplayer.controls-3.2.2.swf" } }
		});
		overlay.centered();
		
		
	}, '#page_content_columns', '.case-study a.flv_video');
	
}); // close use()




