
/*
 * FUNÇÃO PARA RECEBER COMANDOS DE UFCOMBO
 */

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function menuTopo_DoFSCommand(command, args) {
	var menuTopoObj = InternetExplorer ? menuTopo : document.menuTopo;
	//alert(command+" >> "+args);
	if (command=="lista") {
		if (args=="abrir") {
			playFlash();
		}
	}
	if (command=="voltar") {
		window.history.back();window.history.back();
	}
}
// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
	navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub menuTopo_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call menuTopo_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

/*
 * FUNÇÃO PARA RECEBER COMANDOS DE UFLISTA
 */

// Handle all the the FSCommand messages in a Flash movie
function uflista_DoFSCommand(command, args) {
	var uflistaObj = InternetExplorer ? uflista : document.uflista;
	//alert(command+" ::>> "+args);
	if (command=="lista") {
		if (args=="fechar") {
			closeFlash();
		}
	}
	if (command=="select") {
		window.document.menuTopo.SetVariable("uf",args.toUpperCase());
		window.document.uflista.SetVariable("close", "true");
		//lojas=("../lojas/estado.asp?uf="+args.toUpperCase());
		lojas="http://www.portobelloshop.com.br/portugues/lojas/estado.asp?uf="+args.toUpperCase();
		window.location.href=lojas;
	}
}
// Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
	navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub uflista_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call uflista_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}
function mostrar_uf(divname,tdname,varX,varY) {
	/*
	 * recebe ID do DIV que possui o submenu e o ID da TD que possui o botão do menu.
	 * seta estilo para visível e alinha propriedade LEFT do DIV para a mesma posição
	 * do TD
	 * recebe também uma possível variação no eixo X e/ou no eixo Y
	 * ! Netscape não executa duas alteraçõe seguidas no estilo
	 */
	if (!varX) varX=0;
	if (!varY) varY=0;
	document.getElementById(divname).style.visibility='visible';
	currentEle=document.getElementById(tdname);
	var topo=0;
	var esq=0;
	while(currentEle.tagName.toLowerCase() != 'body') {
		topo += currentEle.offsetTop;
		esq += currentEle.offsetLeft;
		currentEle = currentEle.offsetParent;
	}
	topo += document.getElementById(tdname).offsetHeight;
	//esq += document.getElementById(tdname).offsetWidth;
	div= document.getElementById(divname);
	div.style.top=topo+varY;
	div.style.left=esq+varX;
}
function playFlash() {
	//desce menu de estados
	mostrar_uf('div_lista_uf','td_uf',295,-22);
	//seta variável no Flash
	window.document.uflista.SetVariable("down", "true");
}
function closeFlash() {
	//oculta div que contém uflista
	document.getElementById("div_lista_uf").style.visibility='hidden';
}