/** SCRIPTS GERAIS ************************/

////////// QUANDO CARREGAR O SITE /////////
window.onload = function (e) {
	
}

///////// FECHA AS PopUPs divs ////////////
function mostraOculta_DIV (obj) {
	var obj = document.getElementById(obj);
	if(obj.style.display != 'block') {
		obj.style.display = 'block';
	}
	else {
		obj.style.display = 'none';
	}
}

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("corpo").style.zIndex = 1;
	document.getElementById("hotsite_menu").style.zIndex = 2;
}

function overConteudo() {
	document.getElementById("corpo").style.zIndex = 2;
	document.getElementById("hotsite_menu").style.zIndex = 1;
}
///////////////////////////////////////////////////////////////////////////

// POPUP GERAL /////////////////////////////////////////////////
function openPop(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=100,top=100');
}
// POPUP TERMOS DE USO /////////////////////////////////////////////////
function abreTermos(){  
	window.open('termosdeuso.aspx','TermosdeUso','toolbars=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=468,height=450');  
}  

////////////////////////////////////////////////////////////////////////

/// 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);

	// 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) {
	document.getElementById('fundoGaleria').style.display = "none";
	document.getElementById(id).style.display = "none";
}
/// FIM - MONTA FLASH ///////////////////////////////////////////////////////////////


// Validar E-mail /////////////////////////////////////////////////////////
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;
}
///////////////////////////////////////////////////////////////////////////