/* 
	JS Document 
	Projeto: Santa Bárbara | Site 2008
	Autor: Bruno Augusto <bruno.augusto@bhtec.com.br>
*/

// Tratamento do Submenu
function abreSubmenu(elem){
	
	var container = document.getElementById('Submenu');
	var submenus = container.getElementsByTagName('ul');
	var el = document.getElementById(elem);
	
	for(var i = 0; i < submenus.length; i++){
		submenus[i].style.display = 'none';
	}
	
	if(el){
		el.style.display = "block";
	}
}



// Funcionamento do menu dropdown para IE 6
over = function() {
	var sfEls = document.getElementById("Enderecos").getElementsByTagName("td");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {this.className+=" over";}
		sfEls[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" over\\b"), "");}
	}
}

if (window.attachEvent) window.attachEvent("onload", over);


// Trabalhando Font-sizes
var fntSize = 12;

function aumentaFonte(elem){

	var el;
	
	if(document.getElementById(elem)){
		el = document.getElementById(elem);
	} else {
		el = elem;
	}//if
	
	for(var i=0; i<el.childNodes.length; i++){
		
		if(el.childNodes[i].tagName != undefined){
			el.childNodes[i].style.fontSize = fntSize + "px";
			if(el.childNodes[i].childNodes.length > 0){
				//alert('entrei');
				aumentaFonte(el.childNodes[i]);
			}
		}
				
	}//for
		
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		 if (ieversion == 6){
			 regulaRodape();
		 }
	}	
}

function diminuiFonte(elem){
	
	var el;
	
	if(document.getElementById(elem)){
		el = document.getElementById(elem);
	} else {
		el = elem;
	}//if
	
	for(var i=0; i<el.childNodes.length; i++){
		
		if(el.childNodes[i].tagName != undefined){
			el.childNodes[i].style.fontSize = fntSize + "px";
			if(el.childNodes[i].childNodes.length > 0){
				//alert('entrei');
				diminuiFonte(el.childNodes[i]);
			}
		}
				
	}//for
	
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		 if (ieversion == 6){
			 regulaRodape();
		 }
	}
}

function incrementaFonte(){
	if(fntSize < 16)
		fntSize++;
}

function decrementaFonte(){
	if(fntSize > 12)
		fntSize--;
}

function regulaRodape(){
	var rodape = document.getElementById('Rodape');
	rodape.style.top = document.body.scrollHeight - rodape.offsetHeight + "px";
}


// Carregar o flash
function loadFlash(archive, width, height, flashvars, img){
	
	document.write("<object type='application/x-shockwave-flash' data='"+  archive +"' width='"+ width +"' height='"+ height +" '><param name='movie' value='"+ archive +"' /><param name='wmode' value='transparent' /><param name='flashvars' value='"+ flashvars +"' /><img src='" + img + "' width='"+ width +"' height='"+ height +"' alt='' title='' /></object>");
		
}


// Lightbox 

function lightbox(arquivo,largura,altura)
{
	// Criando o objeto flash
document.getElementById("contlight").innerHTML='<OBJECT classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" WIDTH="' + largura + '" HEIGHT="' + altura + '" id="flash" ALIGN="top"><PARAM NAME=movie VALUE="' + arquivo +'"><PARAM NAME=loop VALUE=false><PARAM NAME=quality VALUE=best><PARAM NAME=wmode VALUE=transparent><PARAM NAME=salign VALUE=LT><PARAM NAME=wmode VALUE=transparent><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src="' + arquivo + '" loop=false quality=best salign=LT bgcolor=#FFFFFF wmode=transparent WIDTH="' + largura + '" HEIGHT="' + altura + '" NAME="flash" ALIGN="top" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';

// Posicionando o Flash 
	document.getElementById("contlight").style.top = (document.body.offsetHeight - altura)/2 +"px";
	document.getElementById("contlight").style.left = (document.body.offsetWidth - largura)/2 +"px";
	
// Corrigindo o bug do ie6

 var userAgent=navigator.userAgent, version=0;
 browser = navigator.appName;
 version = parseFloat(userAgent.substring(userAgent.indexOf('MSIE')+4,userAgent.length));
 	
 if (browser == "Microsoft Internet Explorer" && version < "7.0" )
 {
	document.getElementById("contlight").style.top = "0";
 }
 
 // Criando a mascara escura no fundo
 
	if (document.getElementById('Pagina').offsetHeight < document.body.offsetHeight)
	{
	document.getElementById("lightbox").style.height = document.body.offsetHeight +"px";
	}
	else
	{
	document.getElementById("lightbox").style.height = document.getElementById('Pagina').offsetHeight +"px";
	}
	
	
document.getElementById("lightbox").style.width = document.body.offsetWidth +"px";

// Fazendo o conteúdo aparecer

document.getElementById("lightbox").style.display = "block";
}


function lightboxfechar()
{
    document.getElementById("contlight").innerHTML='&nbsp;';
	document.getElementById("lightbox").style.display = "none";
}


//SEGMENTO

function toggleSegmento(el, mudaSimbolo){
	var toggleEl = document.getElementById(el);

	toggleEl.style.display = (toggleEl.style.display == "none") ? "block" : "none";
	
	if(!mudaSimbolo.innerText){
		mudaSimbolo.textContent = (mudaSimbolo.text == "+") ? "-" : "+";
	} else {
		mudaSimbolo.innerText = (mudaSimbolo.innerText == "+") ? "-" : "+";
	}

}