//  Funções Macromedia
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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 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];}}
}

function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

// Outras Funções

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 topo(){
	window.scrollTo(0,0);
}

function janela(url, W, H){
	jan = window.open(url, "", "width=" + W + ",height=" + H + ",left=" + ((screen.availWidth - W) / 2) + ",top=" + ((screen.availHeight - H) / 2));
	jan.focus();
}

function abreMenu(){
	escondeCombos();
	if(!document.all&&document.getElementById){
		if(document.getElementById("div_rolagem")){
			document.getElementById("div_rolagem").style.overflow = "hidden";
			document.getElementById("div_rolagem").style.width = 724;
		}
	}
	adiv_menu = findObj("div_menu");
	adiv_menu.style.clip = "rect(0px 778px 285px 0px)";
}

function fechaMenu(){
	mostraCombos();
	if(!document.all&&document.getElementById){
		if(document.getElementById("div_rolagem")){
			document.getElementById("div_rolagem").style.overflow = "auto";
			document.getElementById("div_rolagem").style.width = 740;
		}
	}
	adiv_menu = findObj("div_menu");
	adiv_menu.style.clip = "rect(0px 778px 30px 0px)";
}

function escondeCombos(){
  if(document.all){
	for(x = 0; x < document.forms.length; x++){
		for(y = 0; y < document.forms[x].elements.length; y++){
			if(document.forms[x].elements(y).type=="select-one"){
				document.forms[x].elements(y).style.escondido = true;
				document.forms[x].elements(y).style.visibility = "hidden";
			}
		}
	}
  }
}

function mostraCombos(){
  if(document.all){
	for(x = 0; x < document.forms.length; x++){
		for(y = 0; y < document.forms[x].elements.length; y++){
			if(document.forms[x].elements(y).style.escondido==true){
				document.forms[x].elements(y).style.escondido = false;
				document.forms[x].elements(y).style.visibility = "";
			}
		}
	}
  }
}

addEvent(window, "load", function(){
	if(document.all){
		if(parseFloat(navigator.appVersion.split("MSIE")[1]) >= 5.5){
			flas = document.body.all.tags("OBJECT");
			for(x = 0; x < flas.length; x++) flas[x].setVariable("podefscommand", "sim");
		}
	}
}, false);

function MostraApaga(objeto, display){
	document.getElementById(objeto).style.display = display;
}
function EstadoDisplay(objeto){
	return document.getElementById(objeto).style.display;
}

function flash(movie, flashvars, width, height){
	return '<object 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 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>';
}