﻿/**

 * Progression is (C) 2007-2008 taka:nium and is released under the MIT License:

 * http://www.opensource.org/licenses/mit-license.php

 */



var progression,

	Progression,

	SWFObject,

	SWFForceSize;



( function() {

	var doc = document,

		swf = swfobject,

		$ = function( id ) { return doc.getElementById( id ); },

		$t = function( tagName ) { return doc.getElementsByTagName( tagName ); },

		$i = function( value, defaultValue ) {

			switch ( value ) {

				case null		:

				case undefined	: { return defaultValue; }

			}

			return value;

		},

		fc = "flashcontent",

		config = {},

		defaultConfig = {

			url					:"preloader.swf",

			replaceElementId	:"attention",

			width				:640,

			height				:480,

			adjustHorizontal	:false,

			adjustVertical		:false,

			centering			:true,

			version				:"9.0.45",

			useExpressInstall	:true,

			flashvars			:{},

			params				:{

				bgcolor				:"#FFFFFF",

				wmode				:"window",

				allowfullscreen		:true,

				allowscriptaccess	:"samedomain"

			},

			attributes			:{}

		};

	

	var embedSWF = function( c ) {

		config = c;

		( function( o, d ) {

			for ( var p in d ) {

				var oo = o[p];

				var dd = d[p];

				switch ( typeof( oo ) ) {

					case "object":{ arguments.callee( oo, dd ); break;}

					default:{ o[p] = $i( oo, dd ) }

				}

			}

		} )( c, defaultConfig );

		

		c.attributes.id = c.attributes.name = "external_" + fc;

		

		var cx = ( c.centering && !c.adjustHorizontal );

		var cy = ( c.centering && !c.adjustVertical );

		

		var w = c.adjustHorizontal ? "100%" : c.width + "px";

		var h = c.adjustVertical ? "100%" : c.height + "px";

		

		var left = cx ? "50%" : "0";

		var top = cy ? "50%" : "0";

		

		var mleft = cx ? "-" + Math.ceil( c.width / 2 ) + "px" : "0";

		var mtop = cy ? "-" + Math.ceil( c.height / 2 ) + "px" : "0";

		

		var xiURL = c.useExpressInstall ? "contents/scripts/swfobject/expressinstall.swf" : undefined;

		

		var list = [ "html", "body" ];

		for ( var i = 0, l = list.length; i < l; i++ ) {

			var tag = $t( list[i] )[0];

			if ( tag ) {

				tag.style.height = "100%";

				tag.style.overflow = "auto";

				tag.style.margin = "0";

				tag.style.padding = "0";

				tag.style.background = c.params.bgcolor;

			}

			else {

				swf.createCSS( list[i], "height:100%;overflow:auto;margin:0;padding:0;background:" + c.params.bgcolor + ";" );

			}

		}

		

		var flash = $( fc );

		if ( flash ) {

			var s = flash.style;

			s.width = w;

			s.height = h;

			s.left = left;

			s.top = top;

			s.marginLeft = mleft;

			s.marginTop = mtop;

		}

		else { swf.createCSS( "#" + fc, "width:" + w + "; height:" + h + "; left:" + left + "; top:" + top + "; margin-left:" + mleft + "; margin-top:" + mtop + ";" ); }

		//alert(c.height);

		swf.embedSWF( c.url, c.replaceElementId, c.width, c.height, c.version, xiURL, c.flashvars, c.params, c.attributes );

		swf.addLoadEvent( initSWF );

	};

	

	var initSWF = function() {

		( ( $( "disabled_javascript" ) || {} ).style || {} ).display = "none";

		var c = config;

		

		if ( SWFForceSize && c.adjustHorizontal && c.adjustVertical ) {

			var fs = new SWFForceSize( $( fc ), c.width, c.height );

			fs.onLoadDiv();

		}

	};

	

	progression = function() {};

	progression.embedSWF = embedSWF;

	

	

	

	

	

	var _url,

		_version,

		_width,

		_height,

		_useSWFForceSize,

		_flashvars,

		_params,

		_attributes;

	

	Progression = function( version ) {

		( ( $( "enableJavaScript" ) || {} ).style || {} ).display = "none";

		_version = version;

		doc.write( '<link rel="stylesheet" type="text/css" href="contents/styles/progression.css" />' );

	};

	Progression.prototype = {

		onLoad:function() {},

		init:function() {

			_useSWFForceSize = ( this.onLoad.toString().indexOf( "var forceSize = new SWFForceSize" ) > 0 );

			this.onLoad();

		}

	};

	

	SWFObject = function( url, id, width, height ) {

		_url = url;

		_width = width;

		_height = height;

		_flashvars = {};

		_params = {};

		_attributes = {};

	};

	SWFObject.prototype = {

		useExpressInstall:function( path ) {},

		setAttribute:function( name, value ) { _attributes[name] = value; },

		getAttribute:function( name ) { return _attributes[name]; },

		addParam:function( name, value ) { _params[name] = value; },

		getParams:function() { return _params[name]; },

		addVariable:function( name, value ) { _flashvars[name] = value; },

		getVariable:function( name ) { return _flashvars; },

		getVariables:function() { return _flashvars; },

		getVariablePairs:function() {},

		getSWFHTML:function() {},

		write:function( id ) {

			var html = $t( "head" )[0].innerHTML;

			html = html.split( " " ).join( "" ).split( "\t" ).join( "" );

			

			if ( !_useSWFForceSize ) { SWFForceSize = null; }

			

			progression.embedSWF( {

				url:_url,

				version:_version,

				width:parseInt( _width ),

				height:parseInt( _height ),

				adjustHorizontal:( _width == "100%" ),

				adjustVertical:( _height == "100%" ),

				centering:( html.indexOf( "left:50%;" ) > 0 && html.indexOf( "top:50%;" ) > 0 ),

				flashvars:{},

				params:{

					bgcolor:_params["bgcolor"],

					wmode:_params["wmode"],

					allowscriptaccess:_params["allowScriptAccess"]

				},

				attributes:{}

			} );

			return false;

		}

	};

} )();


