var appVer = navigator.appVersion.toLowerCase();
var iePos  = appVer.indexOf('msie');
var ieVer = 0;
var podefscommand = "nao";
var iebug = false;

if (iePos !=-1) {
	ieVer = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
	if(ieVer < 7) iebug = true;
	if(ieVer > 5.5) podefscommand = "sim";
}

if(podefscommand) document.write('<scr' + 'ipt for="menu_flash" event="FSCommand(funcao)">eval(funcao);</sc' + 'ript>');

function $(id){
	return document.all? document.all[id] : document.getElementById(id);
}

var tags = { "select":iebug, "applet":true };
var apagou = [];

function abremenu(){
	document.getElementById("div_menu").style.clip = "rect(0 500px 580px 0)";
	for(tag in tags){
		if(tags[tag]){
			items = document.getElementsByTagName(tag);
			for(x = 0; x < items.length; x++){
				if(items[x].style.visibility==""){
					apagou[tag+"-"+x] = true;
					items[x].style.visibility = "hidden";
				}
			}
		}
	}
}

function fechamenu(){
	document.getElementById("div_menu").style.clip = "rect(0 205px 240px 0)";
	for(tag in tags){
		if(tags[tag]){
			items = document.getElementsByTagName(tag);
			for(x = 0; x < items.length; x++){
				if(apagou[tag+"-"+x]) items[x].style.visibility = "";
			}
		}
	}
}

function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  }
}

function form(campo){
	if(window.navigator.appName.toLowerCase().indexOf("microsoft") > -1){
		return document.formulario.item(campo);
	}
	else {
		return document.formulario[campo];
	}
}

function abrir(url){
	window.open(url, "_blank");
}

function janela(url, w, h){
	try {
		jan = open(url, "", "width=" + w + ",height=" + h + ",left=" + ((screen.availWidth-w)/2) + ",top=" + ((screen.availHeight-h)/2));
		jan.focus();
	}
	catch(e){
		alert(idioma=="port"? "Por favor desabilite seu anti-popup." : "Please disable your anti-popup.");
	}
}

function webcast(tri, ano){
	janela("../apresentacoes/webcast.asp?tri=" + tri + "&ano=" + ano, 790, 502);
}

function balancos(){
	window.open("http://balancos.interativos.mediagroup.com.br/?empresa=IOCHPE&idioma=" + idioma, "BalInt" + idioma, 
				"width=" + (screen.availWidth-10) + ",height=" + (screen.availHeight-60) + ",top=0,left=0,resizable=yes,scrollbars=yes,status=yes");
}

function recomende(){
	if(idioma=="port") txt = "Veja esta página interessante";
	else txt = "See this interessant page";	
	open("mailto:?Subject=" + escape(document.title) + "&Body=" + escape(txt + ": \n\n" + self.location.href));
}

function flash(movie, flashvars, width, height, retorna){
	swfid = movie.split("/");
	swfid = swfid[swfid.length-1].replace(".swf", "");
	strSWF= '<object id="' + swfid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '">'+
			'<param name="movie" value="' + movie + '">'+
			'<param name="quality" value="high">'+
			'<param name="wmode" value="transparent">'+
			'<param name="FlashVars" value="' + flashvars + '">'+
			'<embed name="' + swfid + '" src="' + movie + '" width="' + width + '" height="' + height + '" flashvars="' + flashvars + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>'+
			'</object>';
	if(!retorna) this.document.write(strSWF);
	else return(strSWF);
}
