function RodarFlash(path,variaveis,_width,_height){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" 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+'" width="'+_width+'" height="'+_height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>')
	document.write('</object>')
}

// HOTSITE MENU ////////////////////////////////////////////////////////
function overMenu() {
	document.getElementById("todo").style.zIndex = 1;
	document.getElementById("hotsite_menu").style.zIndex = 2;
}

function overConteudo() {
	document.getElementById("todo").style.zIndex = 2;
	document.getElementById("hotsite_menu").style.zIndex = 1;
}

///////////////////////////////////////////////////////////////////////////

/// MONTA FLASH V.2 //////////////////////////////////////////////////////////////////////////////////
// Biblioteca para comunicar-se com o Flash
function getFlashMovieObject(movieName) {
	if (window.document[movieName]) {
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
		if (document.embeds && document.embeds[movieName]) {
		  return document.embeds[movieName]; 
		}
	}
	else {
		return document.getElementById(movieName);
	}
}

// Função que mostra/cria flash
function montaFlash(id, swfPath, params, swfParams, _largura, _altura) {
	// Detecta o Navegador e vé se precisa 
	var	flashMovie = document.getElementById("flash_"+id);
	if(screen.height <= 864){
		document.getElementById('galeria').style.position = "absolute";
	}	
	// Se estiver oculto ele mostra a div
	var naoOculta = true;
	if(document.getElementById(id).style.display == "none") {
		document.getElementById('fundoGaleria').style.display = "block";
		document.getElementById(id).style.display = "block";
		naoOculta = false;
	}

	// Verifica se já foi criado o RodarFlash(); ou se não for o IE
	if(!flashMovie || navigator.appName.indexOf("Microsoft Internet")==-1 && !naoOculta) {
		// Carrega o flash e envia os parametros
		criaFlash(id, swfPath, swfParams, _largura, _altura);
	}
	else {
		// Se já estiver criado, enviamos o param ao flash
		var flashMovie = getFlashMovieObject("flash_"+id);
		flashMovie.SetVariable("/:osParams", params);
	}
}

// Função que cria o Flash dentro da Div e envia o param pela primeira vez
function criaFlash(id, swfPath, swfParams, _largura, _altura){
	// Monta o flash dentro da Div
	var divFlash = document.getElementById(id);
	var rodarFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="flash_'+ id +'" width="'+ _largura +'" height="'+ _altura +'"><param name="movie" value="'+ swfPath +'?parametros='+ swfParams +'"><param name="quality" value="high"><param name="wmode" value="transparent"><embed src="'+ swfPath +'?parametros='+ swfParams +'" width="'+ _largura +'" height="'+ _altura +'" swliveconnect="true" name="flash_'+ id +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed></object>';
	divFlash.innerHTML = rodarFlash;
}

function ocultaFlash(id) {
	if(screen.height <= 864){
		document.getElementById('galeria').style.position = "fixed";
	}
	document.getElementById('fundoGaleria').style.display = "none";
	document.getElementById(id).style.display = "none";
}
/// FIM - MONTA FLASH ///////////////////////////////////////////////////////////////

// Pop up ////////
function openTermos(){
	window.open('termos_uso.aspx','','toolbar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes,menubar=no,width=345,height=500,left=100,top=100');
}

/////////Ajuste de página/////////////////
function openPg(pagina,largura,altura){
	window.open(pagina,'','toolbar=no,scrollbars=no,resizable=no,location=no,directories=no,status=yes,menubar=no,width='+largura+',height='+altura+',left=0,top=0');
}
//===================================================================================================

/////////Função data e hora/////////////////
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += (hours >= 12) ? " PM" : " AM"
timerRunning = true;

mydate = new Date();
myday = mydate.getDay();
mymonth = mydate.getMonth();
myweekday= mydate.getDate();
weekday= myweekday;
myyear= mydate.getFullYear();
year = myyear

if(myday == 0)
day = " Domingo, "

else if(myday == 1)
day = " Segunda, "

else if(myday == 2)
day = " Ter&ccedil;a, "

else if(myday == 3)
day = " Quarta, "

else if(myday == 4)
day = " Quinta, "

else if(myday == 5)
day = " Sexta, "

else if(myday == 6)
day = " S&aacute;bado, "

if(mymonth == 0)
month = " de Janeiro"

else if(mymonth ==1)
month = " de Fevereiro"

else if(mymonth ==2)
month = " de Mar&ccedil;o"

else if(mymonth ==3)
month = " de April"

else if(mymonth ==4)
month = " de Maio"

else if(mymonth ==5)
month = " de Junho"

else if(mymonth ==6)
month = " de Julho"

else if(mymonth ==7)
month = " de Agosto"

else if(mymonth ==8 ) 
month = " de Setembro"

else if(mymonth ==9)
month = " de Outubro"

else if(mymonth ==10)
month = " de Novembro"

else if(mymonth ==11)
month = " de Dezembro"

//Funções do DHTML
function hideDHTML(){
	document.getElementById("dhtml").style.display = 'none';
}

function posicionaDHTML(){
	
	document.getElementById("dhtml").style.left = (screen.availWidth / 2) - 310+'px';
	document.getElementById("dhtml").style.top = (screen.availHeight / 2) - 280+'px';
}

function centralizaDHTML(largura, altura){
	document.getElementById("dhtml").style.left = (screen.availWidth / 2) - (largura/2)+'px';
	document.getElementById("dhtml").style.top = (screen.availHeight / 2) - (altura/2)+'px';
}

function posicionaFechar(largura,altura){
	document.getElementById("fecharDHTML").style.display = 'block';
	document.getElementById("fecharDHTML").style.top = (screen.availHeight / 2) - ((altura/2) + 10)+'px';
	document.getElementById("fecharDHTML").style.left = (screen.availWidth / 2) + (largura/2)+'px';
}
//Funções do DHTML - fim

function ajusteDiv(){
	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) - 435+"px";
	flash.style.paddingTop = (screen.height/2) - 350+"px";
}
function ocultaDiv(){
	document.body.scroll = 'auto';
	document.body.style.overflow = 'auto';
	document.getElementById('mapa').style.display = "none";
	document.getElementById('servicos').style.display = "block";
}

function ocultaInfos(){
	var largura; 
	largura = screen.width/2 - (312/2);
	var altura	= (screen.height/2) - 201;
	var infos	= document.getElementsByTagName("div");
	for(var i = 0; i<infos.length; i++)
	{
		var divInfo = infos[i];
		if(divInfo.getAttribute("nomeId")=="info")
		{
			document.getElementById(divInfo.getAttribute("id")).style.display	= "none";
			document.getElementById(divInfo.getAttribute("id")).style.position	= "absolute";
			document.getElementById(divInfo.getAttribute("id")).style.left		= largura+"px";
			document.getElementById(divInfo.getAttribute("id")).style.top		= altura+"px";
		}
	}
}
var info_anterior;
function desoculta(info)
{
	if(info_anterior){
		document.getElementById(info_anterior).style.display = "none";
	}
	document.getElementById(info).style.display = "block";
	info_anterior = info;
	//apareceFlash(infoSwf)
}
function desocultaInfo(info)
{
	document.getElementById(info).style.display = "block";
	//apareceFlash(infoSwf)
}
function ocultaDivInfo(info)
{
	document.getElementById(info).style.display = "none";
}
function fWindowOpen(pagina,largura,altura,scroll)
{
	window.open(pagina,'','toolbar=no,scrollbars='+scroll+',resizable=no,location=no,directories=no,status=yes,menubar=no,width='+largura+',height='+altura+',left=20,top=100');
}
// ### Include de Serviços ####
function abrirLinkMenu(qual)
{
	target = qual.value.substr(0,qual.value.indexOf(";"));
	url = qual.value.substr(qual.value.indexOf(";")+1, qual.value.length);
	if( target == "_blank" )
	{
		window.open(url);
	}
	else
	{
		window.location.href = url;
	}
	qual.selectedIndex = 0;
}
// ### Função para verificar o e-mail
var defaultEmptyOK = false
var whitespace = " \t\n\r";
function isEmail (s)
{  
	if (isEmpty(s)) 
		if (isEmail.arguments.length == 1) return defaultEmptyOK;
	else return (isEmail.arguments[1] == true);
	
	if (isWhitespace(s)) return false;
	var i = 1;
	var sLength = s.length;
	
	// look for @
	while ((i < sLength) && (s.charAt(i) != "@"))
	{
		i++;
	}
	
	if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	else i += 2;
	
	while ((i < sLength) && (s.charAt(i) != "."))
	{
		i++;
	}
	
	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
	else return true;
}
function isEmpty(s)
{
	return ((s == null) || (s.length == 0));
}
function isWhitespace(s)
{
	var i;
	
	// Is s empty?
	if (isEmpty(s)) return true;

	for (i = 0; i < s.length; i++)
	{   
		var c = s.charAt(i);
		
		if (whitespace.indexOf(c) == -1) return false;
	}
	
	return true;
}

function QueryString(ID)
{
    var URL = document.location.href;
    if(URL.indexOf('?' + ID + '=')>-1)
	{
		var qString = URL.split('?');
		var keyVal = qString[1].split('&');
		for(var i=0;i<keyVal.length;i++)
		{
			if(keyVal[i].indexOf(ID + '=')==0)
			{
			var val = keyVal[i].split('=');
			return val[1];
			}
		}
   		return "";
	}
    else
	{
    return "";
	}
}

function isInPar()
{
	String.prototype.contains = function(t) { return this.indexOf(t) >= 0 ? true : false }
	
	var	strPath = document.referrer;
	
	if(strPath.contains('inpar'))
	{
		return true;
	}
	else
	{
		return false;
	}
}

// Formulários do Flash
var info_anterior;
function desoculta(info)
{
	if(info_anterior){
		document.getElementById(info_anterior).style.display = "none";
	}
	document.getElementById(info).style.display = "block";
	info_anterior = info;
	//apareceFlash(infoSwf)
}
function desocultaInfo(info)
{
	document.getElementById(info).style.display = "block";
	//apareceFlash(infoSwf)
}
function ocultaDivInfo(info)
{
	document.getElementById(info).style.display = "none";
}

//Formata Valores Monetarios
function FormataValor(campo, event) {

		    var tecla = event.keyCode;
		    if (event.keyCode == null) {
		        tecla = event.which;
		    }
		    
		    vr = document.getElementById(campo.id).value;
		    vr = vr.replace("/", "");
		    vr = vr.replace("/", "");
		    vr = vr.replace(",", "");
		    vr = vr.replace(".", "");
		    vr = vr.replace(".", "");
		    vr = vr.replace(".", "");
		    vr = vr.replace(".", "");
		    tam = vr.length + 1;

		    if (tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105) {
		        if (tam <= 2) {
		            document.getElementById(campo.id).value = vr;
		        }
		        if ((tam > 2) && (tam <= 5)) {
		            document.getElementById(campo.id).value = vr.substr(0, tam - 2) + ',' + vr.substr(tam - 2, tam);
		        }
		        if ((tam >= 6) && (tam <= 8)) {
		            document.getElementById(campo.id).value = vr.substr(0, tam - 5) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
		        }
		        if ((tam >= 9) && (tam <= 11)) {
		            document.getElementById(campo.id).value = vr.substr(0, tam - 8) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
		        }
		    }
		}

		//Formata Valores Monetarios
		function FormataValorNumerico(campo, event) {

		    var tecla = event.keyCode;
		    if (event.keyCode == null) {
		        tecla = event.which;
		    }

		    vr = document.getElementById(campo.id).value;
		    vr = vr.replace("/", "");
		    vr = vr.replace("/", "");
		    vr = vr.replace(",", "");
		    vr = vr.replace(".", "");
		    vr = vr.replace(".", "");
		    vr = vr.replace(".", "");
		    vr = vr.replace(".", "");
		    tam = vr.length;

		    if (tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105) {
		        if (tam <= 2) {
		            document.getElementById(campo.id).value = vr;
		        }
		        if ((tam > 2) && (tam <= 5)) {
		            document.getElementById(campo.id).value = vr.substr(0, tam - 2) + '.' + vr.substr(tam - 2, tam);
		        }
		        if ((tam >= 6) && (tam <= 8)) {
		            document.getElementById(campo.id).value = vr.substr(0, tam - 5) + '.' + vr.substr(tam - 5, 3) + '.' + vr.substr(tam - 2, tam);
		        }
		        if ((tam >= 9) && (tam <= 11)) {
		            document.getElementById(campo.id).value = vr.substr(0, tam - 8) + '.' + vr.substr(tam - 8, 3) + '.' + vr.substr(tam - 5, 3) + '.' + vr.substr(tam - 2, tam);
		        }
		    }
		}


		//====================================================================================================
		// Somente Numérico
		//====================================================================================================
		function SomenteNumerico(event)//onKeyDown
		{
		    var keyCode = event.keyCode;
		    if (event.keyCode == null) {
		        keyCode = event.which;
		    }

		    // teclas de controle
		    if ((keyCode == null) || (keyCode == 0) || (keyCode == 8) || (keyCode == 9) || (keyCode == 13) || (keyCode == 27) || (keyCode > 34 && keyCode < 41) || (keyCode == 45) || (keyCode == 46) || (keyCode == 188) || (keyCode == 190) || (keyCode == 194) || (keyCode == 110))
		        return true;

		    // validação somente para numéricos
		    else if (!keyCode.shiftKey && !keyCode.ctrlKey && !keyCode.altKey) {
		        if ((keyCode > 47 && keyCode < 58) || (keyCode > 95 && keyCode < 106)) {
		            if (keyCode > 95) {
		                keyCode -= (95 - 47);
		            }

		            return true;
		        }
		        else {
		            return false;
		        }
		    }

		    // qualquer outra tecla
		    else {
		        return false;
		    }
	       
		}
