// JavaScript Document


window.onload = function(){
	
	
	
	

	
	new Spry.Widget.MenuBar("MenuBar1", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
	

	alinhaDivs("meio","esquerda");
	alinhaDivs("esquerda","corpo");
	window.consultor = 0;
	
	Depoimentos();
	
	var slideShow1 = new sandecom.SlideShow('slideShowCabecalho',
					{
						timeTransition     : 5,									
						fade               : 3,
						activeControl      : false
					});


	var slideShow2 = new sandecom.SlideShow('destaque',
					{
						timeTransition  : 5,								
						fade            : 5,
						activeControl   : true,
						
						bgTitle         : "#FFF",
						heightTitle     : 20,
						alphaTitle      : 80,
						
						borderPause     : "1px solid #978C77",
						bgPause         : "#999",
						colorPause      : "#F3F2EC",
						
						borderPlay      : "1px solid #7DC94E",
						bgPlay          : "#7DC94E",
						colorPlay       : "#FFF",
						
						borderIndexAct  : "1px solid #D29E39",
						bgIndexAct      : "#fff",
						colorIndexAct   : "#000",

						borderIndexInact: "1px solid #AFB5BB",
						bgIndexInact    : "#DDD",
						colorIndexInact : "#F3F2ED"
						
						
					});


	$("slideShowControl").style.marginTop = "0";
	
	

	
}


Depoimentos = function(){
	
	
	window.dep  = new Array();
	
	//var depFilhos   = document.getElementById("depoimento").childNodes;

	var depoimentos = $("depoimento")
	
	var depFilhos = depoimentos.childElements();
	
	
	var cont = depFilhos.length
	var j=0;
	for(var i=0;i<cont;i++){
		if (depFilhos[i].nodeName=="DIV"){
			window.dep[j] = depFilhos[i];
			j++;		
		}
	
	}
	
	
	removerElementosDepoimentos();
	document.getElementById("depoimento").style.display = "block";
	
	window.contDep = 0;
	
	
	trocarDepoimento();
}

removerElementosDepoimentos = function(){
	
	

	var depoimento = $("depoimento")
	
	var depFilhos = depoimento.childElements();
	
	
	var cont = depFilhos.length
	var j=0;
	for(var i=0;i<cont;i++){
		depoimento.removeChild(depFilhos[i]);
	}

}

trocarDepoimento = function(){
	
	
	
	removerElementosDepoimentos();
	
	var depoimento = $("depoimento");
	
	depoimento.appendChild(window.dep[window.contDep]);
	
	window.dep[window.contDep].style.display = "block";
	
	window.contDep = ++window.contDep % window.dep.length;
	
	setTimeout("trocarDepoimento()",5000);
	
}


displayConsultor = function(){
	

	var cons = $('consultorVirtual');

	
	if(window.consultor == 0){
		window.consultor = 1;
		cons.style.display = "block";
	}else{
		window.consultor = 0;
		cons.style.display = "none";
	}
	
}




alinhaDivs = function(div1, div2){

	var elem1 = document.getElementById(div1);
	var elem2 = document.getElementById(div2);
	
	var x = elem1.clientHeight;
	var y = elem2.clientHeight;			
		
	var tam = 0;
		
	if(x>=y){
		tam = x;	
	}else{
		tam = y;
	}
		
	elem1.style.height = tam + "px";
	elem2.style.height = tam + "px";
	
}


alinhaPrimeiroPelaSoma = function(div1, div2, div3, div4){

	//debugger;
	var elem1 = document.getElementById(div1);
	var elem2 = document.getElementById(div2);
	var elem3 = document.getElementById(div3);
	var elem4 = document.getElementById(div4);
	
		
	var x = elem1.clientHeight;
	var y = elem2.clientHeight;			
	
	if(elem3){
		
		y = y + elem3.clientHeight;
		
		if(elem4){
			y = y + elem4.clientHeight;
		}
	}
		
	var tam = 0;
		
	if(x<y){
		elem1.style.height = y + "px";
	}
	
	
}
