function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


/* Corrige ActiveX do IE */
function ie_object_border_fix(id)
{
	var obj = document.getElementById(id);
	if ( obj['parentNode'] ) {
		var parentNode = obj['parentNode'];
		parentNode.innerHTML = parentNode.innerHTML;
	}
}

function windowPopup(url, features) {
	window.open(url, "", features)
}

function menu_site() {
	var secao;
	var endereco = document.location.href;

	var host = 'com.br/';

	endereco = endereco.substr(endereco.indexOf(host) + host.length);
	endereco = endereco.substr(0, endereco.lastIndexOf('.'));

	$('#menu a[href*=\'' + endereco + '\']').parents('ul:first').show();
}

function menu_conheca() {
	document.getElementById("menu_conheca").style.display="block";
	document.getElementById("menu_governanca").style.display="none";
	document.getElementById("menu_informacoes").style.display="none";
	document.getElementById("menu_servicos").style.display="none";
}

function menu_governanca() {
	document.getElementById("menu_conheca").style.display="none";
	document.getElementById("menu_governanca").style.display="block";
	document.getElementById("menu_informacoes").style.display="none";
	document.getElementById("menu_servicos").style.display="none";
}

function menu_informacoes() {
	document.getElementById("menu_conheca").style.display="none";
	document.getElementById("menu_governanca").style.display="none";
	document.getElementById("menu_informacoes").style.display="block";
	document.getElementById("menu_servicos").style.display="none";
}

function menu_servicos() {
	document.getElementById("menu_conheca").style.display="none";
	document.getElementById("menu_governanca").style.display="none";
	document.getElementById("menu_informacoes").style.display="none";
	document.getElementById("menu_servicos").style.display="block";
}

function muda_idioma_ptb() {

	if(String(document.location.href).indexOf("busca.asp") >= 0){
		var oForm = document.getElementById("buscaForm");
		oForm["idioma"].value = 'ptb';
		oForm.submit();
		return;
	}

	if(String(document.location.href).match(/[\/|index\.asp]$/)){
		document.location = String(document.location.href).replace(/$/,"?language=ptb");
		return
	}

	var endereco = document.location.href;

	endereco = endereco.replace(/\/enu\/|\/esp\//gi,"/ptb/");
	endereco = endereco.replace(/\=enu|\=esp/gi,"=ptb");
	endereco = endereco.replace(/\-enu\-|\-esp\-/gi,"-ptb-");
	endereco = endereco.replace(/\-enu.|\-esp./gi,"-ptb.");

	if(String(document.location.href).match(/\.[html|htm|asp]$/)){
		document.location = endereco.replace(/$|\?language=.*/,"?language=ptb");
	}else{
		document.location = endereco;
	}

}

function muda_idioma_enu() {

	if(String(document.location.href).indexOf("busca.asp") >= 0){
		var oForm = document.getElementById("buscaForm");
		oForm["idioma"].value = 'enu';
		oForm.submit();
		return;
	}

	if(String(document.location.href).match(/[\/|index\.asp]$/)){
		document.location = String(document.location.href).replace(/\/$/,"?language=enu");
		return
	}

	var endereco = document.location.href;

	endereco = endereco.replace(/\/ptb\/|\/esp\//gi,"/enu/");
	endereco = endereco.replace(/\=ptb|\=esp/gi,"=enu");
	endereco = endereco.replace(/\-ptb\-|\-esp\-/gi,"-enu-");
	endereco = endereco.replace(/\-ptb.|\-esp./gi,"-enu.");

	if(String(document.location.href).match(/\.[html|htm|asp]$/)){
		document.location = endereco.replace(/$|\?language=.*/,"?language=enu");
	}else{
		document.location = endereco;
	}

}

function muda_idioma_esp() {

	if(String(document.location.href).indexOf("busca.asp") >= 0){
		var oForm = document.getElementById("buscaForm");
		oForm["idioma"].value = 'esp';
		oForm.submit();
		return;
	}

	if(String(document.location.href).match(/[\/|index\.asp]$/)){
		document.location = String(document.location.href).replace(/\/$/,"?language=esp");
		return
	}

	var endereco = document.location.href;

	endereco = endereco.replace(/\/enu\/|\/ptb\//gi,"/esp/");
	endereco = endereco.replace(/\=enu|\=ptb/gi,"=esp");
	endereco = endereco.replace(/\-enu\-|\-ptb\-/gi,"-esp-");
	endereco = endereco.replace(/\-enu.|\-ptb./gi,"-esp.");

	if(String(document.location.href).match(/\.[html|htm|asp]$/)){
		document.location = endereco.replace(/$|\?language=.*/,"?language=esp");
	}else{
		document.location = endereco;
	}
}


/*
function muda_idioma_ptb() {
	var endereco = document.location.href;
	if (endereco.indexOf("ptb") > -1) {
		var idioma = "ptb";
	} else if (endereco.indexOf("enu") > -1) {
		var idioma = "enu";
	}
	var host = "http://mpx.infoinvest.com.br/static/ptb/";
	var host2 = "http://mpx.infoinvest.com.br/ptb/";

	if (endereco.indexOf("cadastro-4") > -1){
		document.location = "http://mpx.infoinvest.com.br/services/cadastro-4/cadastro_usuario.asp?action=new&idioma=ptb&database=mpx_ri_v1&moldura=1"
	} else if (endereco.indexOf("/" + idioma + "/") == -1){
		document.location = "http://mpx.infoinvest.com.br/?idioma=ptb";
	} else if (endereco.indexOf("static") == -1){
		endereco = endereco.substr(endereco.indexOf("/" + idioma + "/") + 5);
		endereco = endereco.substr(0, endereco.indexOf(idioma + "."));
		document.location = "http://mpx.infoinvest.com.br/ptb/" + endereco + "ptb.html";
	} else {
		endereco = endereco.substr(endereco.indexOf("/" + idioma + "/") + 5);
		endereco = endereco.substr(0, endereco.indexOf("?"));
		document.location = "http://mpx.infoinvest.com.br/static/ptb/" + endereco + "?idioma=ptb";
	}
}

function muda_idioma_enu() {
	var endereco = document.location.href;
	if (endereco.indexOf("ptb") > -1) {
		var idioma = "ptb";
	} else if (endereco.indexOf("enu") > -1) {
		var idioma = "enu";
	}
	var host = "http://mpx.infoinvest.com.br/static/enu/";
	var host2 = "http://mpx.infoinvest.com.br/enu/";

	if (endereco.indexOf("cadastro-4") > -1){
		document.location = "http://mpx.infoinvest.com.br/services/cadastro-4/cadastro_usuario.asp?action=new&idioma=enu&database=mpx_ri_v1&moldura=1"
	} else if (endereco.indexOf("/" + idioma + "/") == -1){
		document.location = "http://mpx.infoinvest.com.br/?idioma=enu";
	} else if (endereco.indexOf("static") == -1){
		endereco = endereco.substr(endereco.indexOf("/" + idioma + "/") + 5);
		endereco = endereco.substr(0, endereco.indexOf(idioma + "."));
		document.location = "http://mpx.infoinvest.com.br/enu/" + endereco + "enu.html";
	} else {
		endereco = endereco.substr(endereco.indexOf("/" + idioma + "/") + 5);
		endereco = endereco.substr(0, endereco.indexOf("?"));
		document.location = "http://mpx.infoinvest.com.br/static/enu/" + endereco + "?idioma=enu";
	}
}

function muda_idioma_ptb() {
	var endereco = document.location.href;
	var host = "http://mpx.infoinvest.com.br/static/enu/";
	var host2 = "http://mpx.infoinvest.com.br/enu/";

	if (endereco.indexOf("cadastro-4") > -1){
		document.location = "http://mpx.infoinvest.com.br/services/cadastro-4/cadastro_usuario.asp?action=new&idioma=ptb&database=mpx_ri_v1&moldura=1"
	} else if (endereco.indexOf("/enu/") == -1){
		document.location = "http://mpx.infoinvest.com.br/?language=ptb";
	} else if (endereco.indexOf("static") == -1){
		endereco = endereco.substr(endereco.indexOf("/enu/") + 5);
		endereco = endereco.substr(0, endereco.indexOf("enu."));
		document.location = "http://mpx.infoinvest.com.br/ptb/" + endereco + "ptb.html";
	} else {
		endereco = endereco.substr(endereco.indexOf("/enu/") + 5);
		endereco = endereco.substr(0, endereco.indexOf("?"));
		document.location = "http://mpx.infoinvest.com.br/static/ptb/" + endereco + "?language=ptb";
	}
}

function muda_idioma_enu() {
	var endereco = document.location.href;
	var host = "http://mpx.infoinvest.com.br/static/ptb/";
	var host2 = "http://mpx.infoinvest.com.br/ptb/";

	if (endereco.indexOf("cadastro-4") > -1){
		document.location = "http://mpx.infoinvest.com.br/services/cadastro-4/cadastro_usuario.asp?action=new&idioma=enu&database=mpx_ri_v1&moldura=1"
	} else if (endereco.indexOf("/ptb/") == -1){
		document.location = "http://mpx.infoinvest.com.br/?language=enu";
	} else if (endereco.indexOf("/static/") == -1){
		endereco = endereco.substr(endereco.indexOf("/ptb/") + 5);
		endereco = endereco.substr(0, endereco.indexOf("ptb."));
		document.location = "http://mpx.infoinvest.com.br/enu/" + endereco + "enu.html";
	} else {
		endereco = endereco.substr(endereco.indexOf("/ptb/") + 5);
		endereco = endereco.substr(0, endereco.indexOf("?"));
		document.location = "http://mpx.infoinvest.com.br/static/enu/" + endereco + "?language=enu";
	}
}
*/

function showPop(action, id){
	//Objs
	objDiv = document.getElementById(id);
	objBodyWidth = document.body.offsetWidth;
	objBodyHeight = document.body.offsetHeight;

	switch(action){
		case 'show':
			//Caminho da img
			objDiv.style.display = 'block';
			//seta Posicao no centro da pagina qndo carrega img
			objDiv.style.left = (objBodyWidth / 2) - (objDiv.offsetWidth / 2);
//			objDiv.style.top = (objBodyHeight / 2) - (objDiv.offsetHeight / 2);

			break;
		case 'hide':
			//Fecha Div
			objDiv.style.display = 'none';
			break;
	}
}

/**/

/** Esconde determinado elemento por ID **/
function showHideElement(action, objId){
//  obj = document.getElementById(objId);
	obj = $(objId);
	if(obj){
		switch(action){
			case 'show':
				obj.style.display = 'block';
				break;
			case 'hide':
				obj.style.display = 'none';
				break;

		}
	}
}
/**/

function windowPopup(url, widthWindow, heightWindow, scrollbars) {
	window.open(url, "", "width="+widthWindow+"px, height="+heightWindow+"px, resizable, scrollbars="+scrollbars)
}
