/******************************************************************************************
 * - BOOT settings application // html settings - flash basic settings apllication
 * [ v.: 1.0 ]
 * [ 10/12/2010 ]
 * 
 * * [ v.: 1.1 ]
 * *[ 11/07/2011 ]
*******************************************************************************************/

var windowClientHeight;

var branch;

var facebookAppID;

var xml_url = 'xml/settings.xml';

var buffer 	= $( '#flashcontent' );
	buffer.prepend( '<div class="control" id="buffer"></div>' );
	buffer.hide();

Config = 
{			
	boot: function()
	{	
		$.ajax({
			url			: xml_url,
			type		: 'GET',
			dataType	: 'text',
			beforeSend  : function()
			{
				buffer.show( 'slow' );
			},
			success: function( data )
			{	
				var obj 				= $.xmlDOM( data ),
					flashWidth 			= obj.find( 'html-settings width' ).attr( 'v' ),
					flashWidth 			= ( flashWidth=='0' ) ? '100%' : flashWidth,
					flashHeight 		= obj.find( 'html-settings height' ).attr( 'v' ),
					flashHeight 		= ( flashHeight=='0' ) ? '100%' : flashHeight,
					flashForceWidth		= obj.find( 'html-settings width' ).attr( 'force' ),
					flashForceHeight	= obj.find( 'html-settings height' ).attr( 'force' ),
					player_version 		= obj.find( 'html-settings player-version' ).attr( 'v' ),
					source_swf 			= obj.find( 'html-settings main-file' ).attr( 'v' ),
					bgcolor 			= obj.find( 'html-settings bgcolor' ).attr( 'v' ),
					allowfullscreen		= obj.find( 'html-settings allowfullscreen' ).attr( 'v' ),
					wmode				= obj.find( 'html-settings wmode' ).attr( 'v' ),
					forcesize 			= obj.find( 'html-settings forcesize' ).attr( 'v' ),
					scale 				= obj.find( 'html-settings scaleMode' ).attr( 'v' ),
					seo 			    = obj.find( 'html-settings seo' ).attr( 'v' );
				
				facebookAppID       	= obj.find( 'html-settings facebook-id' ).attr( 'v' );
				
				var params = 
				{
					quality				: 'high',
					scale				: scale,
					wmode				: wmode,
					allowscriptaccess	: 'always',
					allowfullscreen		: allowfullscreen,
					bgcolor				: bgcolor
				};
				
				if( seo=='true' ){/** TODO: build HTML - ( flash deve chamar function JS passando o 'content.xml' || html passa o xml para o flash )**/};
				
				var flashvars 	= { config	:data, protocolType:PROTOCOL, userAgent:window.navigator.userAgent.toString() };
				var attributes 	= { id		:'flashcontent', name:'flashcontent'};
				
				swfobject.embedSWF( source_swf, 'flashcontent', flashWidth, flashHeight, player_version, 'playerProductInstall.swf', flashvars, params, attributes );
				
				if( forcesize=='true' )var forceSizeFlash = new SWFForceSize( 'flashcontent', flashForceWidth, flashForceHeight );
			},
			complete: function()
			{
				
			},
			error: function( msg )
			{
				$( '#noflash' ).show( 'slow' );
			}
		});
	}
}

/** onReady **/
$( 'document' ).ready(
		function()
		{
			$( '#noflash' ).hide();
			
			Config.boot();
			
			windowClientHeight = document.body.clientHeight;
		}
);
