﻿// JScript File

var img, img2;
function preloadImages()
{
    img = new Image();
    img.src = "../_img/menu_fundo.gif";
    
    img2 = new Image();
    img2.src = "../_img/menu_fundo_over.gif";

}



function carregaFlash(video)
{
		if (video !== 0)
		{
			document.getElementById('flash').innerHTML = 
			"<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=\"267\" height=\"213\" id=\"Untitled-2\" align=\"middle\">"+
			"<param name=\"allowScriptAccess\" value=\"sameDomain\" />"+
			"<param name=\"movie\" value=\"x.swf?carrega=" + 
			video + "\" /> "+
			"<embed src=\"x.swf\" quality=\"high\" bgcolor=\"#ffffff\" width=\"267\" height=\"213\" name=\"Untitled-2\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />"+
			"</object>";
		}
		else
		{
			document.getElementById('flash').innerHTML = 
			"<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=\"267\" height=\"213\" id=\"Untitled-2\" align=\"middle\">"+
			"<param name=\"allowScriptAccess\" value=\"sameDomain\" />"+
			"<param name=\"movie\" value=\"x.swf?carrega=0\" /> "+
			"<embed src=\"x.swf\" quality=\"high\" bgcolor=\"#ffffff\" width=\"267\" height=\"213\" name=\"Untitled-2\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />"+
			"</object>";	
		}

}


function xmlLoader(url)
{
    if(window.XMLHttpRequest)
    {
        
        var Loader = new XMLHttpRequest();
        Loader.open("GET", url ,false);
        Loader.send(null);
        return Loader.responseXML;
        
    }
    else if(window.ActiveXObject)
    {
                
        var Loader = new ActiveXObject("Msxml2.DOMDocument.3.0");
        Loader.async = false;
        Loader.load(url);
        return Loader;
        
    }
}

function xmlEstado(xml, UF)
{
    if(navigator.appName != "Netscape")
    {
        for(var i=0; i<xml.childNodes[1].childNodes.length; i++)
        {
            if(xml.childNodes[1].childNodes[i].attributes[0].nodeValue==UF)
            {
                document.getElementById('informacao_texto').innerHTML = xml.childNodes[1].childNodes[i].attributes[1].nodeValue + " - IUV: " + xml.childNodes[1].childNodes[i].attributes[2].nodeValue + " - Risco: " + xml.childNodes[1].childNodes[i].attributes[3].nodeValue;
                document.getElementById('informacao_opcao').innerHTML = "<a href='indice_uf.aspx?id=" + xml.childNodes[1].childNodes[i].attributes[0].nodeValue + "' >Outras cidades do estado</a>";
                document.getElementById('informacao_opcao2').innerHTML = "<a href='javascript:void(0)' onclick=\"document.getElementById('informacao').style.display = 'none';\">Voltar</a>";
                
            }
        }    
    }
    else
    {
        var xmlNo = xml.firstChild;
        for(var i=1;i<xml.firstChild.childNodes.length;i=i+2)
        {
            if(xmlNo.childNodes[i].attributes['id'].nodeValue==UF)
            {
                document.getElementById('informacao_texto').innerHTML = xmlNo.childNodes[i].attributes['nome'].nodeValue + " - IUV: <span style='color:#E9925C'>" + xmlNo.childNodes[i].attributes['indice'].nodeValue + "</span> - Risco: <span style='color:#E9925C'>" + xmlNo.childNodes[i].attributes['risco'].nodeValue + "</span>";
                document.getElementById('informacao_opcao').innerHTML = "<a href='indice_uf.aspx?id=" + xmlNo.childNodes[i].attributes['id'].nodeValue + "' >Outras cidades do estado</a>";
                document.getElementById('informacao_opcao2').innerHTML = "<a href='javascript:void(0)' onclick=\"document.getElementById('informacao').style.display = 'none';\">Voltar</a>";
            }
        }    
    }
}

function UFonclick(evt, estado )
{
    fechaFoto();
    xml = xmlLoader("nomes.xml");
    xmlEstado(xml, estado);
    //document.getElementById('informacao').style.left = evt.clientX + "px";
    //document.getElementById('informacao').style.top = evt.clientY + "px";
    img = new Image();
    img.src = "../_img/imagens/estado_" + estado + ".gif";
    //document.getElementById('estado_imagem')innerHTML = "<table style='text-align:center; vertical-align:middle;' height='300' width='320'><tr><td><img name='mapa_cidade' src='../_img/imagens/estado_" + estado + ".gif' /></td></tr></table>";
    nome = 'ctl00_cphSecundario_image' + estado;
    document.getElementById(nome).style.display = 'block';
    document.getElementById('informacao').style.display = 'block';
    
    if (document.getElementById(nome).width >= document.getElementById(nome).height)
    {
        fatororiginal = document.getElementById(nome).width / document.getElementById(nome).height;
        fatornovo = 300 / 290;
        if (fatororiginal >= fatornovo)
        {
            document.getElementById(nome).width = 300;
            document.getElementById(nome).height = document.getElementById(nome).height / (document.getElementById(nome).width / 290);
        }
        else
        {
            document.getElementById(nome).width = (document.getElementById(nome).width / (document.getElementById(nome).height / 300));
            document.getElementById(nome).height = 290;
        }
    }
    else
    {
        fatororiginal = document.getElementById(nome).height / document.getElementById(nome).width;
        fatornovo = 290 / 300 ;
        if ((document.getElementById(nome).width / document.getElementById(nome).height) <= (300 / 290))
        {
            document.getElementById(nome).width = document.getElementById(nome).width / (document.getElementById(nome).height / 300);
            document.getElementById(nome).height = 290;
        }
        else
        {
            document.getElementById(nome).width = 300;
            document.getElementById(nome).height = document.getElementById(nome).height / (document.getElementById(nome).width / 290);
        }
    }
}

function fechaFoto()
{
    document.getElementById('ctl00_cphSecundario_imageac').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imageal').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imageam').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imageap').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imageba').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagece').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagees').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagego').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagema').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagemg').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagems').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagepa').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagepb').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagepe').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagepi').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagepr').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagerj').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagern').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagero').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagerr').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagers').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagesc').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagese').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imagesp').style.display = 'none';
    document.getElementById('ctl00_cphSecundario_imageto').style.display = 'none';
}


function mais(valor)
{
    if (valor == "nenhum")
    {
        document.getElementById('nenhum').style.display = 'block';
        document.getElementById('baixo').style.display = 'none';
        document.getElementById('alto').style.display = 'none';
    }
    
    if (valor == "baixo")
    {
        document.getElementById('nenhum').style.display = 'none';
        document.getElementById('baixo').style.display = 'block';
        document.getElementById('alto').style.display = 'none';
    }
    
    if (valor == "alto")
    {
        document.getElementById('nenhum').style.display = 'none';
        document.getElementById('baixo').style.display = 'none';
        document.getElementById('alto').style.display = 'block';        
    }
}    
   