/*  RodarFlash(arquivo.swf,texto=var1&var2&var3,_width,_height)  */

var versao_necessaria = 8;
var release = "9.0 r28";
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) 
{
   var words = navigator.plugins["Shockwave Flash"].description.split(" ");
   for (var i = 0; i < words.length; ++i)
   {
	  if (isNaN(parseInt(words[i])))
	  continue;
	  var versao_plugin = words[i];
   }
   var roda_flash = versao_plugin >= versao_necessaria;
}else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) 
{
   document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
   document.write('on error resume next \n');
   document.write('roda_flash = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & versao_necessaria)))\n');
   document.write('</SCR' + 'IPT\> \n');
}
//novo- monica-------------------------------------------------------------------------------------------------------------------------------------

function ajusteDiv()
{
	//Exibe a introdução
	document.getElementById('pgIntroducao').style.display = "block";
	var flash = document.getElementById('flash');
	var fundo = document.getElementById('fundo');
	document.body.scroll = 'no';
	document.body.style.overflow = 'hidden';
	fundo.style.width = screen.width+"px";
	fundo.style.height = screen.height+"px";
	flash.style.paddingLeft = (screen.width/2) - 380+"px";
	//flash.style.paddingTop = (screen.height/2) - 400+"px";
}
function ocultaDiv()
{
	document.body.scroll = 'auto';
	document.body.style.overflow = 'auto';
	document.getElementById('pgIntroducao').style.display = "none";
}

//----------------------------------------------------------------------------------------------------------------------------------------------------



function RodarFlash(path,variaveis,_width,_height, title)
{
	var px = screen.width/2;
	var py = screen.height/2;
	
	if( title == "" )
	{
		title = "flash";	
	}
	//  path direto para o site da adobe: 
	//  http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW
	//_________________________________________________________________________________________________\\
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
	if( roda_flash  )
	{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+release+'"  id="'+title+'" width="'+_width+'" height="'+_height+'">')
	document.write('<param name="movie" value="'+path+'?'+variaveis+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<embed src="'+path+'?'+variaveis+'" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"   name="'+title+'" swliveconnect="true" width="'+_width+'" height="'+_height+'" wmode="transparent">');

	document.write('</object>');
	
	}else
	{
		/*document.write('<div id="alternate" style="font-size:.8em; width:'+_width+'px; text-align:center; line-height:'+_height+'px; overflow:hidden; height:'+_height+'px; background-color:#cfcfcf;"><font face="Arial, Helvetica, sans-serif">Flash Player <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" title="Adobe Flash Player" target="_blank" style="color:#990000;">clique aqui</a></font></div>');
		*/
		if( !document.getElementById('plugin_flashplayer' ) )
		{
			document.write('<div id="plugin_flashplayer" style="border:solid,1,#000000; width:100%; position:absolute; top:0px; left:0%; right:0%; background-color:#ff0000; padding:10px; text-align:center; clear:both; font-size:.8em; line-height:1.5em; margin-left:auto; margin-right:auto"><font face="Arial, Helvetica, sans-serif" color="#FFFFFF">Este site requer o Adobe Flash Player 9, para instalar o plugin <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" title="Adobe Flash Player" target="_blank" style="color:#ffffff;">clique aqui</a><br />Saiba mais sobre o <a href="#" style="color:#ffffff;">Adobe Flash Player</a></font></div>');
		}
	}
}
function mudaNivel(atual, antigo)
{
	var vAtual = document.getElementById(atual);
	var vAntigo = document.getElementById(antigo);
	
	vAtual.style.zIndex = '3';
	vAntigo.style.zIndex = '2';
}
function atualiza_posicao()
{
	if (navigator.appName=="Microsoft Internet Explorer"){
		location.reload();
	}
}
function doPassVar(args)
{
	if( navigator.appName.substring(0,9) == "Microsoft" )
	{
		document.getElementById( "flash" ).setVariable( "externo", args);
	}else
	{
		window.document.flash.SetVariable("externo", args);
	}
}
function fnFoco()
{
	
	if( navigator.appName.substring(0,9) == "Microsoft" )
	{
		document.getElementById( "flash" ).focus();
	}else
	{
		window.document.flash.focus();
	}
}
function fnEscondeDiv( id, args )
{
	var div_some = document.getElementById(id);
	div_some.style.display = 'none';
	
	if( navigator.appName.substring(0,9) == "Microsoft" )
	{
		document.getElementById( "banner" ).SetVariable( "rodar", 'true');
	}
	else
	{
		window.document.banner.SetVariable( "rodar", args );
		//document.all.banner.setVariable( "rodar", 'true');	
	}
}


function trocaNivel(Div1,Div2)
{
	if(document.getElementById(Div1) != null)
	{
		document.getElementById(Div1).style.zIndex = "1"
	}
	
	if(document.getElementById(Div2) != null)
	{
		document.getElementById(Div2).style.zIndex = "0"
	}
}


/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
	for (i = 0; i < s.length; i++){   
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}

function stripCharsInBag(s, bag){
	var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++){   
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
	// EXCEPT for centurial years which are not also divisible by 400.
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)


	if (strMonth.length<1 || month<1 || month>12){

		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){

		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){

		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){

		return false
	}
	return true
}
