
/* Light Box Plug-in */
var lightbox = {
	init: function (filename,title) {
		var lightbox = new Element ('div', {'class': 'uI_LightBox Overlay'}).inject(document.body, 'bottom');
		var container = new Element ('div', {'class': 'uI_LightBox VideoBox'}).inject(lightbox, 'bottom');
		var content = "<div class=\"Title\">" + title + "<div class=\"Close\"><img src=\"http://www.securitysystemsvancouver.com/close.png\" alt=\"close\" /><span>Close</span></div></div><embed src=\"http://www.securitysystemsvancouver.com/videos/flvplayer.swf\" width=\"640\" height=\"360\" allowScriptAccess=\"Always\" allowfullscreen=\"true\" flashvars=\"file=" + filename + "&autostart=true\" />";
		
		/* Gather window center */
		var windowCenter = (window.getWidth()-container.getWidth())/2;
		
		/* Center container */
		container.setStyles({'top': '100px', 'left': windowCenter + 'px'});
		
		/* Set lightbox opacity */
		lightbox.setStyle('opacity', '0.9');
		
		/* Dispose of light box on click */
		lightbox.addEvent('click', function () { this.dispose(); });
		
		/* Load Content */
		container.set('html', content);
		
		/* Add Event to Close Button */
		$$('.Close').addEvent('click', function () { lightbox.dispose(); });				
	}
}

/* Dom Events */
window.addEvent('domready', function () {
	$$('.thumbnail').addEvent('click', function () {
		/* Initialize Lightbox */
		var title = this.get('title');
		var filename = this.get('id');
		(!/x64/i.test(navigator.userAgent)) ? lightbox.init(filename,title) : alert('Flash is not supported on this browser');
	});
});

