// Função para ativação de modal - OBS NÃO MEXER EM NADA "Jesus"
var html        = '';
$(document).ready(function(){
    var _src        = '',
        _version    = Math.floor(Math.random()*11111); // retorna uma versão variável
        _host       = '', // Local de hospedagem
        _language   = location.pathname;
        checkHome   = _language.split('/');
        _language   = _language.split('/')[1].toLowerCase(); // check idioma
        
    if($.inArray('home.aspx', checkHome) > 0){
    
        if(location.host.split('.')[0] == 'adm'){
            _host = 'http://adm.votorantim.com.br/Style%20Library/SiteVotorantim/master/_modal/';
        }else{
            _host = 'http://www.votorantim.com.br/Style%20Library/SiteVotorantim/master/_modal/';
        }

        // verifica qual html deve ser carregado
        switch (_language) {
            case 'en-us': // Inglês
                _src = _host +'modal-en-us.htm?v='+ _version;
                break
            case 'es-es': // Espanhol
                _src = _host +'modal-es-es.htm?v='+ _version;
                break
            default: // Portugues
                _src = _host +'modal-pt-br.htm?v='+ _version;
        }

        // monta o html da modal
        html += '<div id="floater-inf" class="jqmWindow"><div class="container">';
        html += '<a class="link-vot" href="http://www.votorantim.com.br" title="Site Votorantim"><span></span></a>';
        html += '<a class="jqmClose" href="/" title="Fechar"><span>Fechar</span></a>';
        html += '<iframe src="'+_src+'" width="829" height="330" frameborder="0" scrolling="no" allowTransparency="true"></iframe>';
        html += '</div></div>';

        $.ajax({
            url: _host +'js/ativa-modal.js',
            data: {name: 'Chad'},
            dataType: 'jsonp',
            jsonp: 'callback',
            jsonpCallback: 'jsonpCallback',
            success: function(){
                //alert('Sucesso')
            },
            error       : function(xhr,er) {
                //alert('Erro no carregamento');
            }
        });
    
    }

});

function jsonpCallback(data){
    if(data.modal == true){
       
        $('#aspnetForm').prepend(html);
        if($('#floater-inf').length){
            $('#floater-inf').jqm({modal:true});
            $('#floater-inf').jqmShow();
        }
    }
}// ################### Fim ###################


function trimStr(s) {
	return new String('' + s.replace(/^\s*/, "").replace(/\s*$/, "") + '');
}
function replaceAll(string, token, newtoken) {
	while (string.indexOf(token) != -1) {
 		string = string.replace(token, newtoken);
	}
	return string;
}


function addToFavorites() {
	if (document.all) {
		window.external.addFavorite("http://www.votorantim.com.br/","Votorantim");
	}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

function htmlOkay() {
	showHideQuant = 0
	table = document.getElementsByTagName("table");
	for(i=0;i<table.length;i++) {
		if (table[i].className == "ms-listviewtable") showHideQuant += 1;
	}
	for(w=0;w<showHideQuant;w++) {
		this.num = w+1;
		for(s=1;s<200;s++) {
			obj = document.getElementById('titl'+this.num+'-'+s+'_');
			if (obj != null) {
				objTd = obj.getElementsByTagName("td")[0];
				objHtml = objTd .innerHTML;
				objHtml = objHtml.replace(/:&nbsp;/i, '');
				objHtml = objHtml.replace(/;return false/i, ";trocaSinal('btSinal"+this.num+"-"+s+"');return false");
				objHtml = objHtml.replace(/border=/i, 'style="display: none;" border=');
				if (objTd.getElementsByTagName("img")[1].src.split('/')[5] == "minus.gif") {
					objHtml = objHtml.replace(/<img id=/i, '<img id="btSinal'+this.num+'-'+s+'" src="/Style Library/SiteVotorantim/master/img/showHideMenos.gif" style="position:relative; top: 1px; left: -2px;" border="0"><img id=');
				} else {
					objHtml = objHtml.replace(/<img id=/i, '<img id="btSinal'+this.num+'-'+s+'" src="/Style Library/SiteVotorantim/master/img/showHideMais.gif" style="position:relative; top: 1px; left: -2px;" border="0"><img id=');
				}
				objTd.innerHTML = objHtml;
				objTd.getElementsByTagName("a")[1].style.display = "none";
				//objTd.getElementsByTagName("img")[1].height = "11";
			} else {
				break;
			}
		}
	}
}
function trocaSinal(ident) {
	objSinal = document.getElementById(ident);
	if (objSinal.src.split("/")[7] == "showHideMais.gif") {
		objSinal.src = "/Style Library/SiteVotorantim/master/img/showHideMenos.gif"
	} else {
		objSinal.src = "/Style Library/SiteVotorantim/master/img/showHideMais.gif"
	}
}
function bodyLoading(){
    idRodape = document.getElementById("rodape");
    if(idRodape != null) {
    	htmlOkay();
    } else {
    	setTimeout(bodyLoading, 100);
    }
}

bodyLoading();

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

var textoBusca = ""
function limpa_campo(obj) {
	textoBusca = obj.value;
	obj.value = "";
}
function busca_campo(obj) {
	if (obj.value=="") obj.value = textoBusca;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function hideSelects() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		versao_arr = navigator.appVersion.split(";");
		versao = versao_arr[1]
		if (versao == " MSIE 6.0") {
			amb_select = document.getElementsByTagName("select");
			for(i=1;i<amb_select.length;i++) {
				amb_select[i].style.display = "none"
			}
		}
	} 	
}
function showSelects() {
	if (navigator.appName == "Microsoft Internet Explorer") {
		versao_arr = navigator.appVersion.split(";");
		versao = versao_arr[1]
		if (versao == " MSIE 6.0") {
			amb_select = document.getElementsByTagName("select");
			for(i=1;i<amb_select.length;i++) {
				amb_select[i].style.display = "block"
			}
		}
	} 	
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function abre_ambientacao() {
	amb_obj = document.getElementById("flash_amb_full");
	amb_obj.style.height = "500px";
	hideSelects();
	
}
function fecha_ambientacao() {
	amb_obj = document.getElementById("flash_amb_full");
	amb_obj.style.height = "110px";
	showSelects();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function menutopo_opensub(obj) {
	/*
	if (navigator.appName == "Microsoft Internet Explorer") { 
		tags1 = "</TD>"; tags2 = "<DIV";
	} else {
		tags1 = "</td>"; tags2 = "<div";
	}
	conj = document.getElementById("conj1");
	menu_quant = conj.innerHTML.split(tags1).length;
	*/
	conj = document.getElementById("conj1");
	menu_quant = conj.getElementsByTagName('td').length + 1;
	
	for(i=1;i<menu_quant;i++) {
		submenu = document.getElementById("submenu"+i);
		if (submenu.innerHTML != "") {
			obj_inner_basic = submenu.getElementsByTagName('span')[0];
			objMenu = document.getElementById("submenu"+i+"_conj");
			obj_inner_basic.innerHTML = "";
			if (objMenu != null) objMenu.style.display = "none";
		}
	}
	submenuLast = document.getElementById("submenu"+(menu_quant-1)+"_conj");
	if (submenuLast != null) {
		submenuLast.style.marginLeft =  "-105px";
	}
	submenu = document.getElementById("sub"+obj.id);
	if (submenu.innerHTML != "") {
		obj_inner_basic = submenu.getElementsByTagName('span')[0];
		objMenu = document.getElementById("sub"+obj.id+"_conj");
		if (objMenu != null) {
			
			var largura = submenu.offsetWidth+ 'px';
			
			obj_inner_basic.style.width = largura;
			
			if (navigator.appName == "Microsoft Internet Explorer") { 
				topAba = "-48px"; topAbaHide = "0px";
			} else {
				topAba = "-66px"; topAbaHide = "-18px";
			}
			obj_inner_basic.innerHTML = "<div class='aba' style='width: "+largura+"; top: "+ topAba +";'></div><div class='aba_hide_seta' style='width: "+submenu.offsetWidth+"; top: "+topAbaHide +";'><img src='/Style Library/SiteVotorantim/master/img/none.gif' width='1' height='1' /></div>";
			objMenu.style.display = "block";
		}
	}
	hideSelects();
}
function menutopo_fechasub() {
	submenu_nome = objname.split("_");
	submenu = document.getElementById(submenu_nome[0]);
	if (submenu.innerHTML != "") {
		obj_inner_basic = submenu.getElementsByTagName('span')[0];
		objMenu = document.getElementById(submenu.id+"_conj");
		obj_inner_basic.innerHTML = "";
		if (objMenu != null) objMenu.style.display = "none";
	}
	showSelects();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
var temposub = ""
function menutopo_timer_fechasub(obj) {
	objname = obj
	temposub = setTimeout(menutopo_fechasub,500);
}
function menutopo_cancela_fechasub(obj) {
	clearTimeout(temposub);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function menutopo_opensub2(oName) {
	document.getElementById(oName).style.display = "block";
	
	submenu2obj = document.getElementById(oName);
	if (submenu2obj != null) {
		submenu2content = submenu2obj.innerHTML.split("</div>")[1];
		if (submenu2content == undefined) submenu2content = submenu2obj.innerHTML
		submenu2obj.innerHTML = "<div class='overArea'></div>"+submenu2content ;
	}
	
	eval("temposub2"+oName+"=''");
}
function menutopo_fechasub2(oName) {
	document.getElementById(oName).style.display = "none";
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
function menutopo_timer_fechasub2(oName) {
	eval("temposub2"+oName+" = setTimeout(function() { menutopo_fechasub2(oName) },100)");
}
function menutopo_cancela_fechasub2(oName) {
	clearTimeout(eval("temposub2"+oName.id));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
tamanho_atual = 1
function mudaTamanho(valor) { // 12,14,16
	meio = document.getElementById("conteudo");
	h1 = document.getElementsByTagName('h1');
	h2 = document.getElementsByTagName('h2');
	h3 = document.getElementsByTagName('h3');
	p = meio.getElementsByTagName('p');
	li = meio.getElementsByTagName('li');
	lat = document.getElementById('menu_internas');
	if (lat != null) lat = lat.getElementsByTagName('a');
	bread = document.getElementById('breadcrumb');
	if (valor=='menos') {
		if (tamanho_atual > 1) tamanho_atual -= 1
	}
	if (valor=='mais') {
		if (tamanho_atual < 4) tamanho_atual += 1
	}
	for(i=0;i<h1.length;i++) { h1[i].style.fontSize = String((16+(tamanho_atual*2))+"px") }
	for(i=0;i<h2.length;i++) { h2[i].style.fontSize = String((14+(tamanho_atual*2))+"px") }
	for(i=0;i<h3.length;i++) { h3[i].style.fontSize = String((12+(tamanho_atual*2))+"px") }
	for(i=0;i<p.length;i++) { p[i].style.fontSize = String((10+(tamanho_atual*2))+"px") }
	for(i=0;i<li.length;i++) { li[i].style.fontSize = String((10+(tamanho_atual*2))+"px") }
	if (lat != null) {
		for(i=0;i<lat.length;i++) { 
			lat[i].style.fontSize = String((10+(tamanho_atual*2))+"px");
			if (lat[i].className == "zz1_QuickLaunchMenu_1 ms-navitem zz1_QuickLaunchMenu_5") lat[i].style.fontSize = String((9+(tamanho_atual*2))+"px");
			if (lat[i].className == "zz1_QuickLaunchMenu_1 ms-navitem zz1_QuickLaunchMenu_5 ms-selectednav zz1_QuickLaunchMenu_11") lat[i].style.fontSize = String((9+(tamanho_atual*2))+"px");
		}
	}
	if (bread != null) bread.style.fontSize = String((8+(tamanho_atual*2))+"px");
}

//--------------------------------------------------------------------------------------------
function iconBand(caminho){
		url = location.href.toLowerCase();
		idiomaAtual = _Variations.Current.Title;
		urlLink = url.replace(idiomaAtual,caminho.toLowerCase());
		if((idiomaAtual == "en-us") && (caminho == "pt-br" || caminho == "es-es")) urlLink = urlLink.replace("pages", "paginas");
		if(caminho == "en-us") urlLink = urlLink.replace("paginas", "pages");
		location.href = urlLink;
}
//---------------------------------------------------------------------------------------------
function titleBread(){
	if(navigator.appName.indexOf('Internet Explorer')>0){
	 var bread = document.getElementById("breadcrumb").innerText.split(">");
	    }else{
	 var bread = document.getElementById("breadcrumb").textContent .split(">");
	    }
	document.title = "";
	for(i=0; i < bread.length; i++){
		if(i == ""+bread.length-1+""){
			document.title += bread[i];
		}else{
			document.title += bread[i]+" : ";
		}
	}
}

//------CÓDIGO SHOW/HIDE--------------------------------------------------------------------------------------
function abre(n) {
	obj1 = document.getElementById(n+"pergof").style.display = "none";
	obj2 = document.getElementById(n+"perfon").style.display = "block";
	obj3 = document.getElementById(n+"respos").style.display = "block";
}
function fecha(n) {
	obj1 = document.getElementById(n+"pergof").style.display = "block";
	obj2 = document.getElementById(n+"perfon").style.display = "none";
	obj3 = document.getElementById(n+"respos").style.display = "none";
}


function showHide(btShow,btclose,opentxt){
	obj1 = document.getElementById(btShow); obj1.style.display = "none";
	obj1 = document.getElementById(btclose); obj1.style.display = "block";
	obj1 = document.getElementById(opentxt); obj1.style.display = "block";
}
function closeHide(btShow,btclose,opentxt){
	obj1 = document.getElementById(btShow); obj1.style.display = "block";
	obj1 = document.getElementById(btclose); obj1.style.display = "none";
	obj1 = document.getElementById(opentxt); obj1.style.display = "none";
}

//------------------------------------------------------------------------------------------------------------------------------------
//------------FUNÇÕES PARA BOTÃO SHARE THIS DA CAMPANHA ---------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------

function abreSharethis() {
	obj = document.getElementById('sharethisFloater');
	obj.style.display = "block";
	obj.style.height = document.body.scrollHeight;
	obj.style.width = document.body.scrollWidth;
}

function fechaSharethis() {
	obj = document.getElementById('sharethisFloater');
	obj.style.display = "none";
}

//--------------------------------------------------------------------
$(function(){

/* rmdoi: removido "fade"s
    $('.box').hover(

        function(){
            $(this).find('.bg1').css('opacity', 0.7);
            $(this).find('.text-body').addClass('text-full');
            $(this).find('.bg1').fadeIn(100);
            $(this).find('.text-body').fadeIn(100);
        },
        function(){
            $(this).find('.text-body').removeClass('text-full');
            $(this).find('.bg1').fadeOut(100);
        }
    );
*/
    $('.box').hover(

        function(){
            $(this).find('.bg1').css('opacity', 0.9);
            $(this).find('.text-body').addClass('text-full');
            $(this).find('.bg1').css('display', 'block');
            $(this).find('.text-body').css('display', 'block');
        },
        function(){
            $(this).find('.text-body').removeClass('text-full');
            $(this).find('.bg1').css('display', 'none');
        }
    );
    
});


////////////////////
// 2010-sep-09: rdoi: FadeIn/Out do destaqueHome 2 
$('document').ready( function() {
	var intervaloTroca= 7; // em segundos
	$('.destaqueItem:last').css('visibility', 'hidden').fadeOut(0);
	setInterval(function() { 
		$('#destaqueHome2 .destaqueItem').each(function() {
			if ( $(this).css('visibility') == 'hidden' ) {
				$(this).css('visibility', 'visible');
				$(this).fadeIn(2000);
			} else {
  			 	$(this).fadeOut(2000, function() {$(this).css('visibility', 'hidden'); } );
			}
		});
	},intervaloTroca * 1000)
})
/////////////

//--------------------------------------------------------------------

function popUp (URL){ 
   window.open(URL,"janela1","width=791,height=539,scrollbars=NO") 
}

//###################### Remove combos ///////////////////////////////
//ctl00_m_g_6913f73d_5b43_46b1_aceb_707689c2b442_ctl03_DropTipo
//ctl00_m_g_6913f73d_5b43_46b1_aceb_707689c2b442_ctl03_DropTipo
function removeItemCboPTB()
{	
  var elSel = document.getElementById('ctl00_m_g_6913f73d_5b43_46b1_aceb_707689c2b442_ctl03_DropTipo');
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
	  if((i == 0) || (i==4) || (i==3)){
		  elSel.remove(i);
	  }  
  }
}

function removeItemCboEN()
{	
  var elSel = document.getElementById('ctl00_m_g_552ba79e_221a_4042_9237_7be29b5af62f_ctl03_DropTipo');
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
	  if((i == 2) || (i==4) || (i==0)){
		  elSel.remove(i);
	  }  
  }
}

function removeItemCboES()
{	
  var elSel = document.getElementById('ctl00_m_g_2060de62_2087_436d_aed4_2db5617c25fb_ctl03_DropTipo');
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
	  if((i == 0) || (i==4) || (i==3)){
		  elSel.remove(i);
	  }  
  }
}






