///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//// JavaScript Flash detection and deployment ////////////
///////////////////////////////////////////////////////////
///// 1. Player Version detection /////////////////////////
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// set player version here ////////////////////////////////
var MM_contentVersion = 8;
///////////////////////////////////////////////////////////
// set sub version here ///////////////////////////////////
var release = "8,0,0,0";
///////////////////////////////////////////////////////////
// check for flash player /////////////////////////////////
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 MM_PluginVersion = words[i];
    }
    var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0
&& (navigator.appVersion.indexOf("Win") != -1)) {
    document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
    // FS hide this from IE4.5 Mac by splitting the tag 
    document.write('on error resume next \n');
    document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
    document.write('</SCR' + 'IPT\> \n');
}
///////////////////////////////////////////////////////////
///// 2. Deployment function //////////////////////////////
///////////////////////////////////////////////////////////
function writeFlash(swf, flashVarString, w, h, bgcolor, menu, mode, swliveconn, q, id, salign, scale) {
    if (MM_FlashCanPlay) {
        document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
		+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + release + '" '
		+ 'width="' + w + '" height="' + h + '" id="' + id + '" align="">'
		+ '<param name="movie" value="' + swf + '">'
		+ '<param name="menu" value="' + menu + '"> '
		+ '<param name="quality" value="' + q + '"> '
		+ '<param name="wmode" value="' + mode + '"> '
		+ '<param name="swliveconnect" value="' + swliveconn + '"> '
		+ '<param name="bgcolor" value="' + bgcolor + '"> '
		+ '<param name="salign" value="' + salign + '"> '
		+ '<param name="scale" value="' + scale + '"> '
		+ '<param name="allowScriptAccess" value="sameDomain" />'
		+ '<param name="flashvars" value="' + flashVarString + '"> '
		+ '<embed src="' + swf + '" allowScriptAccess="sameDomain" flashvars="' + flashVarString + '" salign="' + salign + '" scale="' + scale + '" menu="' + menu + '" quality="' + q + '" wmode="' + mode + '" '
		+ ' bgcolor="' + bgcolor + '" width="' + w + '" height="' + h + '" name="' + swf + '" '
		+ ' align="" type="application/x-shockwave-flash" '
		+ ' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>');
    } else {
        document.write('você precisa instalar o Flash player ' + MM_contentVersion + ' or later to use this site. ');
        document.write('<em><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">');
        document.write('Clique aqui para instalar.</a></em>');
        //e.g. document.location.replace("text.html"); 
    }
}
///////////////////////////////////////////////////////////
///////// Altera valor de variável no flash ///////////////
function flashReady() {
    var movie = window.document.flashInside;
    movie.SetVariable = ("fReady", "1");
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//// Exibe alert do retorno ///////////////////////////////
///////////////////////////////////////////////////////////
var retorno;

function verificaRetorno() {
    if (retorno != null) {
        retorno();
    }
}
///////////////////////////////////////////////////////////
//// Mostra floaters das internas apos montagem ////////////////
///////////////////////////////////////////////////////////

window.onload = function() {

    if (retorno != null) {
        retorno();
    }
    //Ajax Preenche Lista de Lojas
    aj1 = new Ajax();
    aj1.Executa("populaloja", "item=loja", "");

    //Ajax Preenche Lista de Atividades
    aj2 = new Ajax();
    aj2.Executa("populaatividade", "item=atividade", "");

    //Ajax Preenche Palavra Chave
    aj3 = new Ajax();
    aj3.Executa("populapalavrachave", "item=palavrachave", "");

}
///////////////////////////////////////////////////////////
//// JUMP MENU ////////////////////////////////////////////
///////////////////////////////////////////////////////////
function MM_jumpMenu(targ, selObj, restore) {
    eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
    if (restore) selObj.selectedIndex = 0;
}
///////////////////////////////////////////////////////////
// POP-UP /////////////////////////////////////////////////
///////////////////////////////////////////////////////////
function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}
///////////////////////////////////////////////////////////
// MOSTRA-ESCONDE /////////////////////////////////////////
///////////////////////////////////////////////////////////
function toggleLayer(layer) {
    if (document.getElementById(layer).style.display == "none") {
        document.getElementById(layer).style.display = "";
        resizeInternaContainers();
    } else {
        document.getElementById(layer).style.display = "none";
    }
}
function showLayer(layer) {
    if (document.getElementById(layer).style.display == "none") {
        document.getElementById(layer).style.display = "";
    }
}
function hideLayer(layer) {
    if (document.getElementById(layer).style.display == "") {
        document.getElementById(layer).style.display = "none";
    }
}
/////////////////////// ABRE POPUP /////////////////////////
function popup(page, name, w, h, scroll) {
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable';
    window.open(page, name, settings);
}

function AbreHotsite(page, name, w, h, scroll) {
    clearInterval(hotsiteInterval);

    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    settings = 'height=' + h + ',width=' + w + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable';
    window.open(page, name, settings);
}
/////////////////////// MANAGER /////////////////////////
function AbrePopup(sUrl, nLargura, nAltura) {
    window.open(sUrl, "popup", "left=150,top=50,width=" + nLargura + ",height=" + nAltura + ",scrollbars=yes");
}
function abreUrl(url) {
    document.getElementById("iframeModulo").src = url;
}

function CarregaFilmes(codFilme, arrayFilme) {
    
    var array = arrayFilme.split(",");

    for (i = 0; i <= array.length - 1; i++) {
        document.getElementById(array[i]).className = "";
    }

    document.getElementById(codFilme).className = "Selecionado";

    $.get("/cinema_destaque_capa_json.asp", { 'codFilme': codFilme }, function(data) {
        RespostaRequisicaoCinema(data);
    });
}

function FechaTrabalheConosco(codVaga) {

    var btnVerDetalhes = document.getElementById("btnVerDetalhes");
    var btnFechar = document.getElementById("btnFechar");

    document.getElementById(codVaga).style.display = "none";

    $("#btnVerDetalhes" + codVaga).show();
    $("#btnFechar" + codVaga).hide();
}

function CarregaDetalheTrabalheConosco(codVaga, arrayVagas) {
    var btnVerDetalhes = document.getElementById("btnVerDetalhes");
    var btnFechar = document.getElementById("btnFechar");

    var array = arrayVagas.split(",");

    for (i = 0; i <= array.length - 1; i++) {
        document.getElementById(array[i]).style.display = "none";
        document.getElementById("btnVerDetalhes" + array[i]).style.display = "block";
        document.getElementById("btnFechar" + array[i]).style.display = "none";
    }

    document.getElementById(codVaga).style.display = "block";

    $("#btnVerDetalhes" + codVaga).hide();
    $("#btnFechar" + codVaga).show();

    $.get("/trabalhe_json.asp", { 'codVaga': codVaga }, function(data) {
        RespostaRequisicaoTrabalheConosco(data);
    });
}

function RespostaRequisicaoTrabalheConosco(paramData) {
    var jsonTrabalhe = eval('(' + paramData + ')');

    var codigo = jsonTrabalhe[0].codigoTrabalhe;

    //document.getElementById(jsonTrabalhe[0].codigoTrabalhe).innerHTML = jsonTrabalhe[0].codigoTrabalhe;
    document.getElementById("piso" + codigo).innerHTML = jsonTrabalhe[0].piso;
    document.getElementById("tipoLoja" + codigo).innerHTML = jsonTrabalhe[0].tipoLoja;
    document.getElementById("tipoPagamento" + codigo).innerHTML = jsonTrabalhe[0].tipoPagamento;
    document.getElementById("horario" + codigo).innerHTML = jsonTrabalhe[0].horario;
    document.getElementById("experiencia" + codigo).innerHTML = jsonTrabalhe[0].experiencia;
    document.getElementById("requisitos" + codigo).innerHTML = jsonTrabalhe[0].requisitos;
    document.getElementById("idade" + codigo).innerHTML = jsonTrabalhe[0].idade;
    document.getElementById("salario" + codigo).innerHTML = jsonTrabalhe[0].salario;
    document.getElementById("vaga" + codigo).innerHTML = jsonTrabalhe[0].vaga;
    document.getElementById("telefone" + codigo).innerHTML = jsonTrabalhe[0].telefone;
    document.getElementById("email" + codigo).innerHTML = jsonTrabalhe[0].email;
    document.getElementById("obs" + codigo).innerHTML = jsonTrabalhe[0].obs;

}

function RespostaRequisicaoCinema(paramData) {
    
    var jsonData = eval('(' + paramData + ')');
    

    document.getElementById("codFilme").innerHTML = jsonData[0].codFilme;
    document.getElementById("nomFilme").innerHTML = jsonData[0].nomFilme;
    document.getElementById("nomSala").innerHTML = jsonData[0].nomSala;
    document.getElementById("dscGenero").innerHTML = jsonData[0].dscGenero;
    document.getElementById("dscDuracao").innerHTML = jsonData[0].dscDuracao;
    document.getElementById("dscHorario").innerHTML = jsonData[0].dscHorario;
    document.getElementById("nomImpropriedade").innerHTML = jsonData[0].nomImpropriedade;
    document.getElementById("dscImagemLista").src = jsonData[0].dscImagemLista;
		document.getElementById("detalheCinema").setAttribute("onclick","pageTracker._trackEvent('Capa - Cinema: "+jsonData[0].nomFilme+" - Detalhes','Click - Imagem')");
    document.getElementById("dscImgClassificacao").src = jsonData[0].dscImgClassificacao;
    document.getElementById("detalheCinema").href = jsonData[0].detalheCinema;
    document.getElementById("convideAmigo").href = jsonData[0].convideAmigo;
		document.getElementById("convideAmigo").setAttribute("onclick","pageTracker._trackEvent('Capa - Cinema: "+jsonData[0].nomFilme+" - Detalhes','Click - Convite a um amigo')");
    document.getElementById("comentario").href = jsonData[0].comentario;
		document.getElementById("comentario").setAttribute("onclick","pageTracker._trackEvent('Capa - Cinema: "+jsonData[0].nomFilme+" - Detalhes','Click - Cometários')");
    document.getElementById("trailer").style.display = jsonData[0].trailer;
    document.getElementById("trailer").href = jsonData[0].dscTrailer;
		document.getElementById("trailer").setAttribute("onclick","pageTracker._trackEvent('Capa - Cinema: "+jsonData[0].nomFilme+" - Detalhes','Click - Ver Trailer')");
    document.getElementById("ExibeImgClassificacao").style.display = jsonData[0].ExibeImgClassificacao;
    document.getElementById("linkNomeFilme").href = jsonData[0].linkNomeFilme;
	  document.getElementById("linkNomeFilme").setAttribute("onclick","pageTracker._trackEvent('Capa - Cinema: "+jsonData[0].nomFilme+" - Detalhes','Click - Nome Filme')");

    document.getElementById("filmeAberto").style.display = "block";
    document.getElementById("filmeCarregaServ").style.display = "none";

}  //function

      function fechaFloater() {
        document.getElementById("Floater").style.display="none";
}