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" 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 980px 300px 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 980px 35px 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=Cyrela&idioma=" + idioma, "BalInt" + idioma, 
				"width=" + (screen.availWidth-10) + ",height=" + (screen.availHeight-60) + ",top=0,left=0,resizable=yes,scrollbars=yes,status=yes");
}

function recomende(){
	
	titulo = document.title.split(String.fromCharCode(187));
	titulo.shift();
	titulo.shift();
	titulo = titulo.join("-");
	
//	chBox("../home/recomende.asp?url=" + escape(location.href) + "&titulo=" + escape(titulo), 400, 300);
	
	janela("../home/recomende.asp?url=" + escape(location.href) + "&titulo=" + escape(titulo), 385, 240);
}


function Mostra(nome){
	if (navigator.appName=="Microsoft Internet Explorer"){
		var objeto = eval("document.all." + nome);
	}
	else {
		var objeto = eval("document.getElementById(\"" + nome + "\")"+"");
	}
	if(objeto){
		if (objeto.style.display == "none" ){
			objeto.style.display = "";
		}
		else {
			objeto.style.display = "none";
		}
	}
}

function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function flash(movie, flashvars, width, height, retorna){
	swfid = movie.split("/");
	swfid = swfid[swfid.length-1].replace(".swf", "");
	flashvars += "&podefscommand=" + podefscommand;
	strSWF= '<object id="' + swfid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,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);
}

function slideDown(div){

	if($("#" + div).css("display")=="none") 
	{
		$("#" + div).slideDown("normal");
	} 
	else 
	{
		$("#" + div).slideUp("normal");
	}

}


