var CREATE_SWF 		= {
	ID_CONTAINER			: null,
	BROWSER					: "NS",
	WIDTH_ATUAL				: 0,
	HEIGHT_ATUAL			: 0,
	_set_swf				: null,
	_objectMenu				: null,
	_objectWmode			: null,
	_embedWmode				: null,
	_embedMenu				: null,
	tmp_bg_swf_color		: null,
	WIDTH					: function(_width)
	{
	 	CREATE_SWF.ID_CONTAINER.style.width = _width+"px";
	},
	HEIGHT					: function(_height)
	{
		CREATE_SWF.ID_CONTAINER.style.height = _height+"px";
	},
	JRS_EMBED				: function(set_swf, set_w, set_h, set_id_container, flash_version, desable_menu, wmode, bg_swf_color)
	{
		 window.onload = function()
		 {
			if (navigator.appName.indexOf('Microsoft') != -1)CREATE_SWF.BROWSER = "IE";
			if(navigator.appName.indexOf('Netscape') != -1) CREATE_SWF.BROWSER = "NS";
			if(navigator.userAgent.indexOf("MSIE 8") != -1) CREATE_SWF.BROWSER = "NS";
			
			var versaoComparativa = 10;
			if(flash_version != undefined)versaoComparativa = flash_version;
			if(FLASH_VERSION.JRS_FLASH_DETECT()<versaoComparativa)return;
			 
			 CREATE_SWF._embedWmode = " wmode='transparent'";
			 CREATE_SWF._objectWmode = "<param name='wmode' value='Transparent'>";
			 if(wmode == undefined || wmode == false)
			 {
				 CREATE_SWF._embedWmode = "";
				 CREATE_SWF._objectWmode = "";
			 }
			 
			 CREATE_SWF.tmp_bg_swf_color = "#ffffff";
			 if(bg_swf_color != undefined) CREATE_SWF.tmp_bg_swf_color = bg_swf_color;
			 
			 CREATE_SWF._embedMenu = "";
			 if(desable_menu)
			 {
				 CREATE_SWF._embedMenu = " menu='false'";
				 CREATE_SWF._objectMenu = "<param name='menu' value='false'>";
			 }
			 CREATE_SWF._set_swf = set_swf;
			 CREATE_SWF.ID_CONTAINER = document.getElementById(set_id_container);
			 CREATE_SWF.WIDTH_ATUAL = set_w;
			 CREATE_SWF.HEIGHT_ATUAL = set_h;
			 var str = "<object  classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' id='main' width='";
			 	 str += CREATE_SWF.WIDTH_ATUAL;
				 str += "' height='";
			 	 str += CREATE_SWF.HEIGHT_ATUAL;
			 	 str += "' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab'>";
				 str += CREATE_SWF._objectMenu;
				 str += CREATE_SWF._objectWmode;
				 str += "<param name='movie' value='";
				 str += CREATE_SWF._set_swf;
				 str += ".swf' /><param name='quality' value='high' /><param name='bgcolor' value='";
				 str += CREATE_SWF.tmp_bg_swf_color;
				 str += "' /><param name='allowScriptAccess' value='sameDomain' /><embed src='";
				 str += CREATE_SWF._set_swf+".swf' quality='high' bgcolor='";
				 str += CREATE_SWF.tmp_bg_swf_color;
				 str += "' ";
				 str += CREATE_SWF._embedWmode;
				 str += CREATE_SWF._embedMenu;
				 str += " width='";
				 str += CREATE_SWF.WIDTH_ATUAL;
				 str += "' height='";
				 str += CREATE_SWF.HEIGHT_ATUAL;
				 str += "' name='main' align='middle' play='true' loop='false' quality='high' allowScriptAccess='sameDomain'";
				 str += "type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'/></object>";
			  CREATE_SWF.ID_CONTAINER.innerHTML = str;
		 }
	}
}

var NAVEGATE_SWF = {
	_appHash					: "",
	_swfIniciado				: false,
	_DocumentTitle				: "",
    jrsSetOnLoadTitle			: function()
	{
		if(window.location.hash.substring(1) != "")this._appHash = window.location.hash.substring(1);
		this._DocumentTitle = document.title;
		if(this._appHash == "")this._appHash = document.title;
		else document.title = decodeURI(this._appHash);
		_titleInit = this._appHash;
		if(CREATE_SWF.BROWSER == "IE")this.CREATE_IFRAME_IE();
		return decodeURI(this._appHash);
    },
	jrs_GetLinkDocumentInit		: function()
	{
		document.title = this._DocumentTitle;
		return this._DocumentTitle;
	},
	jrs_BACK					:function()
	{
		history.back();
	},
	jrs_FORWARD					: function()
	{
		history.forward();
	},
	jrs_SetLink					: function(title)
	{
		if(!this._swfIniciado)
		{
			window.setInterval(this.jrs_ControleDeHistorico, 100);
			this._swfIniciado = true;
		}
		if(CREATE_SWF.BROWSER == "IE")
		{
			document.getElementById("navega").src = "?"+title;
		}
		
		document.title = decodeURI(title.split("?id=")[0]);
		location.hash = "#"+title;
	},
	jrs_setHast					: function()
	{
		var title = navega.location.search.substring(1);
		document.title = decodeURI(title.split("?id=")[0]);
		location.hash = "#"+title;
	},
	CREATE_IFRAME_IE			: function()
	{
		i_frame = document.createElement("iframe");
		i_frame.setAttribute("id","navega");
		i_frame.setAttribute("name", "navega");
		i_frame.setAttribute("src","?"+this._appHash);
		i_frame.style.display = "none";
		i_frame.style.position = "absolute";
		CREATE_SWF.ID_CONTAINER.appendChild(i_frame);
		i_frame.attachEvent("onload", NAVEGATE_SWF.jrs_setHast);
	},
	jrs_ControleDeHistorico		: function()
	{ 
		var browserHash = window.location.hash.substring(1);
		if(browserHash == "") browserHash = _titleInit;
		if(browserHash != this._appHash)
		{
			this._appHash = browserHash;
			if(this._appHash == undefined) return;
			document["main"].sendToActionScript(this._appHash);
			if(this._appHash != "")document.title = decodeURI(this._appHash).split("?id=")[0];
		}
	}
}

var FLASH_VERSION 	= {
	JRS_FLASH_DETECT		: function ()
	{
		var tmp_versao = "";
		try { 
			try { 
				var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
				try
				{
					axo.AllowScriptAccess = 'always';
				} 
				catch(e)
				{
					tmp_versao = '6,0,0';
				} 
			}
			catch(e)
			{
			} 
			tmp_versao =  new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
		}
		catch(e)
		{ 
			try
			{ 
				if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
				{ 
					tmp_versao =  (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 
				} 
			}
			catch(e)
			{
			} 
		}
		if(tmp_versao == "")tmp_versao = '0,0,0';
		return tmp_versao.split(',').shift(); 
	}
};