// Scripts antigos ===================================================================

var timerID
var tempo = .5 		// tempo, em segundos, q o menu deve permanecer aberto depois do MouseOut
var numMenus = 5 	// numero de menus existentes no mundo (todos devem se chamar menuX)

function CallWindow(param) {

if (param == 'trabalheconosco')
	linkparam ="https://www.elancers.com.br/frames/gm/frame_geral.asp";

if (param == 'consorciodireto')
	linkparam ="https://www.consorciochevrolet.com.br";

if (param == 'concessionaria')
	linkparam ="http://www3.chevrolet.com.br/portalgm/concessionarias.jsp";

if (param == 'consorciochevrolet')
	linkparam ="http://www.consorciochevrolet.com.br";

if (param == 'celta')
	linkparam ="http://www.chevrolet.com.br";

window.open(linkparam);
}

function liga(param) { //acende o menu q eh mandado
	if (document.layers) { // netscape 4.0
		
		objeto = eval("document.layers."+param)
		objeto.visibility = "show";
	}
	if(document.all){  // IE compativel
	
		objeto = eval("document.all."+param);
		objeto.style.visibility = "visible";
	}
	if(!document.all && document.getElementById){ // netscape > 4
	
		document.getElementById(param).style.visibility="visible";
	}
}

function adminofertalance(param) {

        // 'N'=Pesquisa somente os não atualizados 'S'=Pesquisa os atualizados
	if (param=="S")
	   myaction = "adminofertalances.do?flagAtu=1&pgid=consorcio.ofertaLanceForm";
	else
	   myaction = "adminofertalances.do?flagAtu=0&pgid=consorcio.ofertaLanceForm";

	document.forms[2].action = myaction;
	document.forms[2].submit();
}

function updateofertalance(i) {
        var grupo = eval("document.forms[2].Grupo" + i + ".value");
        var serie = eval("document.forms[2].Serie" + i + ".value");
        var assem = eval("document.forms[2].Assembleia" + i + ".value");
        var cota  = eval("document.forms[2].Cota" + i + ".value");

        // Primeira vez, submete a store procedure para atualizar
	myaction = "adminofertalances.do?flagAtu=2&serie="+serie+"&grupo="+grupo+"&assem="+assem+"&cota="+cota+"&pgid=consorcio.ofertaLanceForm";

	document.forms[2].action = myaction;
        document.forms[2].submit();
}

function desliga(param) { // apaga o menu q eh mandado
	if (document.layers) {
		
		objeto = eval("document.layers."+param);
		timerID = setTimeout("objeto.visibility = 'hide'", tempo*1000);
	}
	if(document.all){  // IE compativel
	
		objeto = eval("document.all."+param);
		timerID = setTimeout("objeto.style.visibility = 'hidden'", tempo*1000);
	}
	if(!document.all && document.getElementById){ // netscape > 4
		//alert("desliga :: doc.getElementById :: "+param);
		objeto = document.getElementById(param);
		timerID = setTimeout("objeto.style.visibility = 'hidden'", tempo*500);
	}
}


function some(param) { // torna invisivel
	if (document.layers) {
		objeto = eval("document.layers."+param);
		objeto.visibility = "hide";
	}
	if(document.all){  // IE compativel
		objeto = eval("document.all."+param);
		objeto.style.visibility = "hidden";
	}
	if(!document.all && document.getElementById){ // netscape > 4
		objeto = document.getElementById(param);
		objeto.style.visibility = "hidden";
	}
}


function limpatempo() {
	if (timerID>0) clearTimeout(timerID);
}

function desligatudo() {
	clearTimeout(timerID)
	for (i=1; i<=numMenus; i++) {
		param = "menu"+i
		if (document.layers) {
			objeto = eval("document.layers."+param);
			objeto.visibility = 'hide';
		}
		if(document.all){  // IE compativel
			objeto = eval("document.all."+param);
			if (objeto != null) objeto.style.visibility = 'hidden';

		}
		if(!document.all && document.getElementById){ // netscape > 4
			objeto = document.getElementById(param);
			if (objeto != null) objeto.style.visibility = 'hidden';
		}
	}
}

function nivel0(param) {desligatudo();liga(param);}
function nivel1(param) {limpatempo(); liga(param);}

function fechaswf() {
	if(document.layers)
		document.layers['bola'].style.visibility = "hide";
	else if(document.all)
		document.all['bola'].style.visibility = "hidden";
	else
 		 document.getElementById('bola').style.visibility = "hidden";
}

function shake_xy(n) {
	if (self.moveBy) {
		for (i = 10; i > 0; i--) {
			for (j = n; j > 0; j--) {
				self.moveBy(0,i);
				self.moveBy(i,0);
				self.moveBy(0,-i);
				self.moveBy(-i,0);
			}
		}
	}
}

function shake_x(n) {
	if (self.moveBy) {
		for (i = 10; i > 0; i--) {
			for (j = n; j > 0; j--) {
				self.moveBy(i,0);
				self.moveBy(-i,0);
			}
		}
	}
}

function shake_y(n) {
	if (self.moveBy) {
		for (i = 10; i > 0; i--) {
			for (j = n; j > 0; j--) {
				self.moveBy(0,i);
				self.moveBy(0,-i);
			}
		}
	}
}	

//Scripts Novos =========================================================================

//###################### Função para trocar a imagem de fundo dos ítens do Menu ########################

function mudaBackMenu(nome_da_div){

	divs = new Array(11);
	divs[0] = "gmac";
	divs[1] = "financiamento";	
	divs[2] = "consorcio";	
	divs[3] = "seguros";	
	divs[4] = "perguntas";
	divs[5] = "institucional";
	divs[6] = "tarifas";
	divs[7] = "faleGmac";
	divs[8] = "ouviGmac";
	divs[9] = "TrabalheConosco";
	divs[10] = "GMACUniversity";
	divs[11] = "SegundaVia";
	if (document.layers) { // netscape 4.0
	
		for (i=0;i<=11;i++) {
		
			if(divs[i] == nome_da_div){
				objeto = eval("document.layers."+divs[i]);
				objeto.className = "txt_menu_over";
			} else {
				objeto = eval("document.layers."+divs[i]);
				objeto.className = "txt_menu_out";
				
			}
		}
	}
	
	if(document.all){  // IE compativel
	
	for (i=0;i<=11;i++) {
		
			if(divs[i] == nome_da_div){
				objeto = eval("document.all."+divs[i]);
				objeto.className = "txt_menu_over";
			} else {
				objeto = eval("document.all."+divs[i]);
				objeto.className = "txt_menu_out";
				
			}
		}
		
	}
	if (!document.all && document.getElementById) {
	
		for (i=0;i<=11;i++) {
			if(divs[i] == nome_da_div){
				document.getElementById(divs[i]).className = "txt_menu_over";
			} else {
				document.getElementById(divs[i]).className = "txt_menu_out";
			}
		}
	}
}


//###################### Função para trocar a imagem de fundo dos ítens do Sub-Menu ########################

function mudaBackSubmenu(nome_da_div){

	divs = new Array(6);
	divs[0] = "seguroAutoChevrolet";
	divs[1] = "seguroChevroletPlus";
	divs[2] = "seguroProtMecChevrolet";
	divs[3] = "historico";
	divs[4] = "demoFinanc";
	divs[5] = "riscoOper";


	if (document.layers) { // netscape 4.0
	
		for (i=0;i<=5;i++) {
		
			if(divs[i] == nome_da_div){
				objeto = eval("document.layers."+divs[i]);
				objeto.className = "txt_menu_over";
				
			} else {
				objeto = eval("document.layers."+divs[i]);
				objeto.className = "txt_menu_out";
				//document.getElementById(divs[i]).className = "txt_menu_out";
			}
		}
	}
	
	if(document.all){  // IE compativel
	
	for (i=0;i<=5;i++) {
		
			if(divs[i] == nome_da_div){
				objeto = eval("document.all."+divs[i]);
				objeto.className = "txt_menu_over";
			} else {
				objeto = eval("document.all."+divs[i]);
				objeto.className = "txt_menu_out";
				//document.getElementById(divs[i]).className = "txt_menu_out";
			}
		}
		
	}
		if (!document.all && document.getElementById) 
		{
		
			for (i=0;i<=5;i++) {
				if(divs[i] == nome_da_div){
					document.getElementById(divs[i]).className = "txt_menu_over";
				} else {
					document.getElementById(divs[i]).className = "txt_menu_out";
				}
			}
		}
}


//############## Função para voltar o background inicial dos ítens do menu e do sub-menu ##################

function limpaBack(){

	divs = new Array(14);
	divs[0] = "gmac";
	divs[1] = "financiamento";	
	divs[2] = "consorcio";	
	divs[3] = "seguros";	
	divs[4] = "perguntas";
	divs[5] = "institucional";
	divs[6] = "tarifas";
	divs[7] = "faleGmac";
	divs[8] = "seguroAutoChevrolet";
	divs[9] = "seguroChevroletPlus";
	divs[10] = "seguroProtMecChevrolet";
	divs[11] = "historico";
	divs[12] = "demoFinanc";
	divs[13] = "riscoOper";	
	
	if (document.layers) { // netscape 4.0
	
		for (i=0;i<=13;i++) {
		
				objeto = eval("document.layers."+divs[i]);
				objeto.className = "txt_menu_out";
				//document.getElementById(divs[i]).className = "txt_menu_out";
			
		}
	}
	
	if(document.all){  // IE compativel
	
	for (i=0;i<=13;i++) {
				
				objeto = eval("document.all."+divs[i]);
				objeto.className = "txt_menu_out";
			
		}
		
	}
	
	if (!document.all && document.getElementById) {
	
		for (i=0;i<=13;i++) {
		
			document.getElementById(divs[i]).className = "txt_menu_out";
		} 
	}
}



//################################## Função para abrir o sub-menu ########################################

function abreSubmenu(nome){
	if (document.layers) { // netscape 4.0
	
		objeto = eval("document.layers."+nome)
		objeto.display = "";
	}

	if(document.all){  // IE compativel
		
		objeto = eval("document.all."+nome);
		objeto.style.display = "";
	}
	if (!document.all && document.getElementById) 
	{
		
		document.getElementById(nome).style.display = "";
	}
}


//################################## Função para fechar o sub-menu ########################################

function fechaSubmenu(nome){
	
	if (document.layers) { // netscape 4.0
	
		objeto = eval("document.layers."+nome)
		objeto.display = "none";
	}

	if(document.all){  // IE compativel
	
		objeto = eval("document.all."+nome);
		objeto.style.display = "none";
	}
	if (!document.all && document.getElementById) 
	{
		
		document.getElementById(nome).style.display = "none";
	}
	
	//document.getElementById(nome).style.display = "none";
}


//######################### Função para abrir as opções do Fale Conosco ####################################

function abrirDiv(nomeDiv){

	divs = new Array(3);
	divs[0] = "clienteCadIB";
	divs[1] = "clienteSemCadIB";
	divs[2] = "naoCliente";



if (document.layers) { // netscape 4.0
		for (i=0;i<=2;i++) {
			if(divs[i] == nomeDiv){
				document.layers.divs[i].display = "";
			} else {
				document.layers.divs[i].display = "none";
			}
		}
	}

	if(document.all){  // IE compativel
	
	for (i=0;i<=2;i++) {
			if(divs[i] == nomeDiv){
				document.all[divs[i]].style.display = "";
			} else {
				document.all[divs[i]].style.display = "none";
			}
		}
		//objeto = eval("document.all."+param);
		//objeto.style.visibility = "visible";
	}
	
	if(!document.all && document.getElementById)
	{
		for (i=0;i<=2;i++) {
			if(divs[i] == nomeDiv){
				document.getElementById(divs[i]).style.display = "";
			} else {
				document.getElementById(divs[i]).style.display = "none";
			}
		}
	}
}


//###################################### Função para abrir pop-up ##########################################

function pop_up(nome){
  window.open(nome,'','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550,height=400,left=150,top=150');
}

function openFaleConoscoPortal(){
  window.open("http://www3.chevrolet.com.br/faleconosco/index.jsp","FaleConoscoGM", " left=5, top=5, width=700, height=500, scrollbars=yes, resizable=yes");
}

//########################## Função para o SELECT do TOPO 1 #############################

function selectURLTopo1(objselect,value){

	if (value == ""){
		alert("Por Favor escolha uma opção válida");
		objselect.selectedIndex = 0;
		return false;
	}
	
	if(value == "MapLink"){
		OpenMapLink();
		return false;
	}
	
	digito = value.substring(value.length-1,value.length);
	
	if (digito == 2){
		// Para abrir a URL em uma nova janela
		url = value.substring(0,value.length-2);
		window.open(url);
	}else if(digito == 3){
		// Sua opinião vale um celta - página com tamanho específico
		url = value.substring(0,value.length-2);
		window.open( sPathSHTM + '/promocoes/valecelta/index.htm','','width=620,height=535,screenX=150,screenY=150,top=50,left=150,norezise');
	}else if(digito == 4){
		// Trilhas Chevrolet - página com tamanho específico
		url = value.substring(0,value.length-2);
		window.open('http://www.zone.com.br/wvagencia/gm/hotsites/index.htm?diretorio=amigos2005','gm_webventure','width=750,height=500,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0');
	}else{
		// Para abrir a URL na mesma janela
		top.location.href=(value);
	}
}

//########################## Função: Abre MapLink em Popup #############################

function OpenMapLink() {

window.open('http://maplink.uol.com.br/chevrolet/index.htm','','width=600,height=400,menubar=no,status=no,location=no,history=no,scrollbars=yes,norezise');

}
