	/*

	Class: Flashloader
	
	Description: 
	
		An object to load Flash movies into existing page tags. This is designed to work
		with our current content management system, which generates the appropriate tags
		for replacement.

		NOTE: YES - I looked at the Google swfobject. It is more code than I plan to implement
		anywhere unless I'm forced to at gunpoint. I'm sure it works great, but where possible
		I write anything and everything I can so that when something breaks I know where to look.
		
		The thing that I like the least about their code is it's extensive use of browser detection,
		which, though well done, I disagree with in principal. I would rather see an approach that
		generates for one version of Flash with support for current browsers. For instance my
		approach will play much better in 1 year when ActiveX is gone and I can do all of this
		server-side...  :O
		
	
	 */
	
	var Flashloader = Class.create();
	
	Flashloader.prototype = {
	
		_name: "Flashloader",
		_version: "0.5a",
		
		initialize: function() {
		
			this.$divs = $$(".flash");
			this.$base = "flash/";

			this.$divs.each(

				function($div) {
				
					$div.container = $div.ancestors()[0];
					$div.containerwidth = $div.container.getWidth();
					
					if ($div.containerwidth) {
					//	trace("containerwidth: "+$div.containerwidth);
					}

					$div.percentwidth = $div.getAttribute('percentwidth');
					
					// trace($div.percentwidth);
					
					$div.naturalwidth = $div.getAttribute('naturalWidth');
					$div.naturalheight = $div.getAttribute('naturalHeight');
										
					$div.ratio = $div.naturalheight/$div.naturalwidth;
					$div.width = Math.round ( ($div.containerwidth/100) * $div.percentwidth );

					// trace($div.width);

					$div.height = $div.width * $div.ratio;

					$div.url = $div.childNodes[0].nodeValue;
					
					$div.flashTag = "<div style='width:"+$div.width+"px; height:"+$div.height+"px;'>";
					$div.flashTag += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='100%' height='100%'>";
					$div.flashTag += "<param name='movie' value='"+this.$base+$div.url+"' />";
					$div.flashTag += "<param name='scale' value='showall' />";
					$div.flashTag += "<param name='wmode' value='transparent' />";
					$div.flashTag += "<param name='align' value='l' />";
					$div.flashTag += "<param name='salign' value='tl' />";
					$div.flashTag += "<!--[if !IE]>-->";
					$div.flashTag += "<object type='application/x-shockwave-flash' data='"+this.$base+$div.url+"' width='100%' height='100%' scale='showall' wmode='transparent' align='l' salign='tl' />";
					$div.flashTag += "<!--<![endif]-->";
					$div.flashTag += "<p class='flashalt'> * It appears that you do not have the Flash plugin installed. To install Flash, visit <a href='http://adobe.com/flash/' >Adobe</a></p>";
					$div.flashTag += "<!--[if !IE]>-->";
					$div.flashTag += "</object>";
					$div.flashTag += "<!--<![endif]-->";
					$div.flashTag += "</object>";
					$div.flashTag += "</div>";

					$div.replace($div.flashTag);
					$div.show();
							
						},this);
						
					setColumnHeights();
							
				}		

	/* END Flashloader */
		
	}
