//Chama a função carrega_funcoes ao carregar a página

window.onload = carrega_funcoes_funcionalidade;


//Função que chama outras funções

function carrega_funcoes_funcionalidade()

{

categoria_01();
categoria_02();
categoria_03();
categoria_04();
categoria_05();

}


//Função para exibir opções da categoria 01 no select

function categoria_01()

{

gE("nome_subdominio").onchange = function()

{

if (gE("categoria_01"))

{

var ajax = Ajax();

var nome_subdominio = this.value;

ajax.open("GET", "XMLcategoria_01.php?nome_subdominio=" + nome_subdominio, true);

ajax.onreadystatechange = function()

{

if(ajax.readyState == 1)

{

carregando_ajax();

}

if(ajax.readyState == 4)

{

if(ajax.responseXML)

{

XML = ajax.responseXML;

if(XML.getElementsByTagName("categoria").length > 0)

{

//Remove as opções dos campos select seguintes ao modificado.

if (gE("categoria_01"))

{

primeiro = gE("categoria_01");

if (primeiro.hasChildNodes())

{

while (primeiro.childNodes.length >= 1)

{

primeiro.removeChild(primeiro.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

primeiro.add(x,null); //Nos padrões

}

catch(ex)

{

primeiro.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

primeiro.add(y,null); //Nos padrões

}

catch(ex)

{

primeiro.add(y); //Somente no IE

}

}

if (gE("categoria_02"))

{

segundo = gE("categoria_02");

if (segundo.hasChildNodes())

{

while (segundo.childNodes.length >= 1)

{

segundo.removeChild(segundo.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

segundo.add(x,null); //Nos padrões

}

catch(ex)

{

segundo.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

segundo.add(y,null); //Nos padrões

}

catch(ex)

{

segundo.add(y); //Somente no IE

}

}

if (gE("categoria_03"))

{

terceiro = gE("categoria_03");

if (terceiro.hasChildNodes())

{

while (terceiro.childNodes.length >= 1)

{

terceiro.removeChild(terceiro.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

terceiro.add(x,null); //Nos padrões

}

catch(ex)

{

terceiro.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

terceiro.add(y,null); //Nos padrões

}

catch(ex)

{

terceiro.add(y); //Somente no IE

}

}

if (gE("categoria_04"))

{

quarto = gE("categoria_04");

if (quarto.hasChildNodes())

{

while (quarto.childNodes.length >= 1)

{

quarto.removeChild(quarto.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

quarto.add(x,null); //Nos padrões

}

catch(ex)

{

quarto.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

quarto.add(y,null); //Nos padrões

}

catch(ex)

{

quarto.add(y); //Somente no IE

}

}

if (gE("categoria_05"))

{

quinto = gE("categoria_05");

if (quinto.hasChildNodes())

{

while (quinto.childNodes.length >= 1)

{

quinto.removeChild(quinto.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

quinto.add(x,null); //Nos padrões

}

catch(ex)

{

quinto.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

quinto.add(y,null); //Nos padrões

}

catch(ex)

{

quinto.add(y); //Somente no IE

}

}

//Adiciona opções do BD no campo select seguinte ao modificado.

for (i=0; i<XML.getElementsByTagName("opcoes").length; i++)

{

z = document.createElement('option');
z.text = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;
z.value = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;

try

{

primeiro.add(z,null); //Nos padrões

}

catch(ex)

{

primeiro.add(z); //Somente no IE

}

}

gE("carregando_ajax_01").style.display="none";

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

}

ajax.send(null);

}

}

}


//Função para exibir opções da categoria 02 no select

function categoria_02()

{

gE("categoria_01").onchange = function()

{

if (gE("categoria_02"))

{

var ajax = Ajax();

var nome_subdominio = gE("nome_subdominio").value;
var categoria_01 = this.value;

ajax.open("GET", "XMLcategoria_02.php?nome_subdominio=" + nome_subdominio + "&categoria_01=" + categoria_01, true);

ajax.onreadystatechange = function()

{

if(ajax.readyState == 1)

{

carregando_ajax();

}

if(ajax.readyState == 4)

{

if(ajax.responseXML)

{

XML = ajax.responseXML;

if(XML.getElementsByTagName("categoria").length > 0)

{

//Remove as opções dos campos select seguintes ao modificado.

if (gE("categoria_02"))

{

segundo = gE("categoria_02");

if (segundo.hasChildNodes())

{

while (segundo.childNodes.length >= 1)

{

segundo.removeChild(segundo.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

segundo.add(x,null); //Nos padrões

}

catch(ex)

{

segundo.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

segundo.add(y,null); //Nos padrões

}

catch(ex)

{

segundo.add(y); //Somente no IE

}

}

if (gE("categoria_03"))

{

terceiro = gE("categoria_03");

if (terceiro.hasChildNodes())

{

while (terceiro.childNodes.length >= 1)

{

terceiro.removeChild(terceiro.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

terceiro.add(x,null); //Nos padrões

}

catch(ex)

{

terceiro.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

terceiro.add(y,null); //Nos padrões

}

catch(ex)

{

terceiro.add(y); //Somente no IE

}

}

if (gE("categoria_04"))

{

quarto = gE("categoria_04");

if (quarto.hasChildNodes())

{

while (quarto.childNodes.length >= 1)

{

quarto.removeChild(quarto.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

quarto.add(x,null); //Nos padrões

}

catch(ex)

{

quarto.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

quarto.add(y,null); //Nos padrões

}

catch(ex)

{

quarto.add(y); //Somente no IE

}

}

if (gE("categoria_05"))

{

quinto = gE("categoria_05");

if (quinto.hasChildNodes())

{

while (quinto.childNodes.length >= 1)

{

quinto.removeChild(quinto.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

quinto.add(x,null); //Nos padrões

}

catch(ex)

{

quinto.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

quinto.add(y,null); //Nos padrões

}

catch(ex)

{

quinto.add(y); //Somente no IE

}

}

//Adiciona novas opções no campo select seguinte ao modificado.

for (i=0; i<XML.getElementsByTagName("opcoes").length; i++)

{

z = document.createElement('option');
z.text = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;
z.value = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;

try

{

segundo.add(z,null); //Nos padrões

}

catch(ex)

{

segundo.add(z); //Somente no IE

}

}

gE("carregando_ajax_01").style.display="none";

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

}

ajax.send(null);

}

}

}


//Função para exibir opções da categoria 03 no select

function categoria_03()

{

gE("categoria_02").onchange = function()

{

if (gE("categoria_03"))

{

var ajax = Ajax();

var nome_subdominio = gE("nome_subdominio").value;
var categoria_01 = gE("categoria_01").value;
var categoria_02 = this.value;

ajax.open("GET", "XMLcategoria_03.php?nome_subdominio=" + nome_subdominio + "&categoria_01=" + categoria_01 + "&categoria_02=" + categoria_02, true);

ajax.onreadystatechange = function()

{

if(ajax.readyState == 1)

{

carregando_ajax();

}

if(ajax.readyState == 4)

{

if(ajax.responseXML)

{

XML = ajax.responseXML;

if(XML.getElementsByTagName("categoria").length > 0)

{

//Remove as opções dos campos select seguintes ao modificado.

if (gE("categoria_03"))

{

terceiro = gE("categoria_03");

if (terceiro.hasChildNodes())

{

while (terceiro.childNodes.length >= 1)

{

terceiro.removeChild(terceiro.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

terceiro.add(x,null); //Nos padrões

}

catch(ex)

{

terceiro.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

terceiro.add(y,null); //Nos padrões

}

catch(ex)

{

terceiro.add(y); //Somente no IE

}

}

if (gE("categoria_04"))

{

quarto = gE("categoria_04");

if (quarto.hasChildNodes())

{

while (quarto.childNodes.length >= 1)

{

quarto.removeChild(quarto.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

quarto.add(x,null); //Nos padrões

}

catch(ex)

{

quarto.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

quarto.add(y,null); //Nos padrões

}

catch(ex)

{

quarto.add(y); //Somente no IE

}

}

if (gE("categoria_05"))

{

quinto = gE("categoria_05");

if (quinto.hasChildNodes())

{

while (quinto.childNodes.length >= 1)

{

quinto.removeChild(quinto.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

quinto.add(x,null); //Nos padrões

}

catch(ex)

{

quinto.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

quinto.add(y,null); //Nos padrões

}

catch(ex)

{

quinto.add(y); //Somente no IE

}

}

//Adiciona novas opções no campo select seguinte ao modificado.

for (i=0; i<XML.getElementsByTagName("opcoes").length; i++)

{

z = document.createElement('option');
z.text = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;
z.value = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;

try

{

terceiro.add(z,null); //Nos padrões

}

catch(ex)

{

terceiro.add(z); //Somente no IE

}

}

gE("carregando_ajax_01").style.display="none";

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

}

ajax.send(null);

}

}

}


//Função para exibir opções da categoria 04 no select

function categoria_04()

{

gE("categoria_03").onchange = function()

{

if (gE("categoria_04"))

{

var ajax = Ajax();

var nome_subdominio = gE("nome_subdominio").value;
var categoria_01 = gE("categoria_01").value;
var categoria_02 = gE("categoria_02").value;
var categoria_03 = this.value;

ajax.open("GET", "XMLcategoria_04.php?nome_subdominio=" + nome_subdominio + "&categoria_01=" + categoria_01 + "&categoria_02=" + categoria_02 + "&categoria_03=" + categoria_03, true);

ajax.onreadystatechange = function()

{

if(ajax.readyState == 1)

{

carregando_ajax();

}

if(ajax.readyState == 4)

{

if(ajax.responseXML)

{

XML = ajax.responseXML;

if(XML.getElementsByTagName("categoria").length > 0)

{

//Remove as opções dos campos select seguintes ao modificado.

if (gE("categoria_04"))

{

quarto = gE("categoria_04");

if (quarto.hasChildNodes())

{

while (quarto.childNodes.length >= 1)

{

quarto.removeChild(quarto.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

quarto.add(x,null); //Nos padrões

}

catch(ex)

{

quarto.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

quarto.add(y,null); //Nos padrões

}

catch(ex)

{

quarto.add(y); //Somente no IE

}

}

if (gE("categoria_05"))

{

quinto = gE("categoria_05");

if (quinto.hasChildNodes())

{

while (quinto.childNodes.length >= 1)

{

quinto.removeChild(quinto.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

quinto.add(x,null); //Nos padrões

}

catch(ex)

{

quinto.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

quinto.add(y,null); //Nos padrões

}

catch(ex)

{

quinto.add(y); //Somente no IE

}

}

//Adiciona novas opções no campo select seguinte ao modificado.

for (i=0; i<XML.getElementsByTagName("opcoes").length; i++)

{

z = document.createElement('option');
z.text = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;
z.value = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;

try

{

quarto.add(z,null); //Nos padrões

}

catch(ex)

{

quarto.add(z); //Somente no IE

}

}

gE("carregando_ajax_01").style.display="none";

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

}

ajax.send(null);

}

}

}


//Função para exibir opções da categoria 05 no select

function categoria_05()

{

gE("categoria_04").onchange = function()

{

if (gE("categoria_05"))

{

var ajax = Ajax();

var nome_subdominio = gE("nome_subdominio").value;
var categoria_01 = gE("categoria_01").value;
var categoria_02 = gE("categoria_02").value;
var categoria_03 = gE("categoria_03").value;
var categoria_04 = this.value;

ajax.open("GET", "XMLcategoria_05.php?nome_subdominio=" + nome_subdominio + "&categoria_01=" + categoria_01 + "&categoria_02=" + categoria_02 + "&categoria_03=" + categoria_03 + "&categoria_04=" + categoria_04, true);

ajax.onreadystatechange = function()

{

if(ajax.readyState == 1)

{

carregando_ajax();

}

if(ajax.readyState == 4)

{

if(ajax.responseXML)

{

XML = ajax.responseXML;

if(XML.getElementsByTagName("categoria").length > 0)

{

//Remove as opções dos campos select seguintes ao modificado.

if (gE("categoria_05"))

{

quinto = gE("categoria_05");

if (quinto.hasChildNodes())

{

while (quinto.childNodes.length >= 1)

{

quinto.removeChild(quinto.firstChild);

}

}

x = document.createElement('option');
x.text = "Selecione...";
x.value = "Selecione...";

try

{

quinto.add(x,null); //Nos padrões

}

catch(ex)

{

quinto.add(x); //Somente no IE

}

y = document.createElement('option');
y.text = "...";
y.value = "";
y.setAttribute("disabled", "disabled");

try

{

quinto.add(y,null); //Nos padrões

}

catch(ex)

{

quinto.add(y); //Somente no IE

}

}

//Adiciona novas opções no campo select seguinte ao modificado.

for (i=0; i<XML.getElementsByTagName("opcoes").length; i++)

{

z = document.createElement('option');
z.text = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;
z.value = XML.getElementsByTagName("opcoes")[i].firstChild.nodeValue;

try

{

quinto.add(z,null); //Nos padrões

}

catch(ex)

{

quinto.add(z); //Somente no IE

}

}

gE("carregando_ajax_01").style.display="none";

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

else

{

gE("carregando_ajax_01").style.display="none";

erro_ajax();

}

}

}

ajax.send(null);

}

}

}


//Função para exibir imagem no GreyBox

function exibir_imagem(titulo, imagem)

{

GB_showImage(titulo, imagem);

//GB_showImageSet(titulo, imagem);

}

