// os menus foram desligados para economizar banda
var menudisable = false;

function X() {
 // esconde submenus
/*
 LayerOff("layer2");
 LayerOff("layer3");
 LayerOff("layer4");
 LayerOff("layer5");
 LayerOff("layer6");
 LayerOff("layer7");
 LayerOff("layer8");
 LayerOff("layer9");
 LayerOff("layer10");
 LayerOff("layer11");
*/
 
 // desabilita menus
 menudisable = true;

 // desabilita banners
 clearInterval(intervalo);
}

function Y() {
 menudisable = false;
 document.RAPIDA.PALAVRASN1.focus();
}

//window.onload = Y;
window.onbeforeunload = X;

function findPosition(obj) {
 if (obj.offsetParent) {
  for (var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent) {
   posX += obj.offsetLeft;
   posY += obj.offsetTop;
  }

  return [posX, posY];
 }
 else {
  return [obj.x, obj.y];
 }
}

function FundoOn(td, corB) {
 if (menudisable) return;

 td.style.backgroundColor = corB;
}

function FundoOff(td, corA) {
 if (menudisable) return;

 td.style.backgroundColor = corA;
}

function LayerOn(layer) {
 if (menudisable) return;

 // contorna problema ie x combo
 if ((layer == "layer9") || (layer == "layer10") || (layer == "layer11")) {
  if (String(document.GERAL) != "undefined") {
   if (String(document.GERAL._ORDEMN2) != "undefined") {
    document.GERAL._ORDEMN2.style.visibility = "hidden";
   }
  
   if (String(document.GERAL._MODELON2) != "undefined") {
    document.GERAL._MODELON2.style.visibility = "hidden";
   }
  }
 }

 document.getElementById(layer).style.visibility = "visible";
}

function LayerOff(layer) {
 if (menudisable) return;
 
 document.getElementById(layer).style.visibility = "hidden";

 // contorna problema ie x combo
 if ((layer == "layer9") || (layer == "layer10") || (layer == "layer11")) {
  if (String(document.GERAL) != "undefined") {
   if (String(document.GERAL._ORDEMN2) != "undefined") {
    document.GERAL._ORDEMN2.style.visibility = "visible";
   }
  
   if (String(document.GERAL._MODELON2) != "undefined") {
    document.GERAL._MODELON2.style.visibility = "visible";
   }
  }
 }
}

function MenuOn(imagem, layer, td, corB) {
 if (menudisable) return;

 obj = document.getElementById(td);

/*
 x = findPosition(obj)[0];
 y = findPosition(obj)[1] + 22;

 // detecta se excede a tela e reposiciona o menu se preciso
 if ((x + 160) > document.body.clientWidth) {
  x = document.body.clientWidth - 160 - (((document.body.clientWidth) * 0.02) / 2);
 }

 FundoOn(obj, corB);

 document.getElementById(imagem).src = "/imgc/menu/" + imagem + "b.gif";

 if (layer != "") {
  document.getElementById(layer).style.top = y;
  document.getElementById(layer).style.left = x;

  LayerOn(layer);
 }
*/

 FundoOn(obj, corB);

 document.getElementById(imagem).src = "/imgc/menu/" + imagem + "b.gif";
}

function MenuOff(imagem, layer, td, corA) {
 if (menudisable) return;

 obj = document.getElementById(td);

/*
 if (layer != "") {
  LayerOff(layer);
 }
*/

 FundoOff(obj, corA);

 document.getElementById(imagem).src = "/imgc/menu/" + imagem + "a.gif";
}

/* Chama SWF e tira barra de ativação do IE */
function addSWF(URL, WIDTH, HEIGHT, TRANSPARENT) {
 document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '); 
 document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" ');
 document.write('width="'+ WIDTH +'" height="'+ HEIGHT +'">');
 document.write(' <param name="movie" value="'+ URL +'">');
 document.write(' <param name="quality" value="high">');

 if ( TRANSPARENT ) {
  document.write(' <param name="Wmode" value="transparent">'); 
 }

 document.write(' <embed src="'+ URL +'" quality="high" ');

 if ( TRANSPARENT ) {
  document.write('Wmode = "transparent" ');
 }

 document.write ('pluginspage="http://www.macromedia.com/go/getflashplayer" ');
 document.write ('type="application/x-shockwave-flash" width="'+ WIDTH +'" height="'+ HEIGHT +'"></embed> ');
 document.write ('</object>');
}


// Função para abrir popup 
function abremeuPOP() { 
  window.open('/promo/condicoes37.htm','a','width=375,height=160,left=200,top=200');
}


function pop_Siemens() { 
  window.open('http://www.antecipeofuturo.com.br/loja.asp?site=saraiva','a','width=779,height=523,left=200,top=200');
}


// Paginação para promos HTML
function htmPag(endPag, numPag, maxPag, styDiv, styLink){
	document.write('<div id="paginacao" style="' + styDiv + '"> página: <b>' + numPag + '</b> de <b>' + maxPag + '</b> - ');
	for (i = 1; i < (maxPag + 1); i++){
		if (i == 1 & numPag > 1){
			if(numPag == 2){
				document.write(' <a href="' + endPag + '.htm" style="' + styLink + '">« anterior</a> ');
			} else {
				document.write(' <a href="' + endPag + (numPag - 1) + '.htm" style="' + styLink + '">« anterior</a> ');
			}
		}
		if (i != numPag){
			if(i == 1){
				document.write(' <a href="' + endPag + '.htm" style="' + styLink + '">' + i + '</a> ');
			} else {
				document.write(' <a href="' + endPag + i + '.htm" style="' + styLink + '">' + i + '</a> ');
			}
		} else {
			document.write(' <b>&nbsp;' + i + '&nbsp;</b> ');
		}
		if (i < maxPag){
			document.write('');
		}
		if (i == (maxPag) & numPag != maxPag){
			document.write(' <a href="' + endPag + (numPag + 1) + '.htm" style="' + styLink + '">próxima »</a> ');
		}
	}
	document.write('</div>');
}







