function mudar_status()
{
 window.status=this.title;
}
function limpar_status()
{
 window.status='';
}
/****************/
function mudar_help()
{
 setTimeout("mostrar_fala('"+this.title+"')",1000); 
}
function mostrar_fala(texto)
{
 //window.status=this.title;
 
 if(document.getElementById('fala'))
 {
  document.getElementById('balao').style.display='block';
  document.getElementById('fala').innerHTML = texto;
 }
}
function limpar_help()
{
 setTimeout("apagar_fala()",1000); 
}

function apagar_fala()
{
 if(document.getElementById('fala'))
 {
   document.getElementById('fala').innerHTML = '';
   document.getElementById('balao').style.display='none';
 }
}
/********************************************************************************************************************************************/
//funcao para iniciar um form e suas tabs
function iniciar_form(nome_form,a_campos)
{
  //iniciando validador do form
  o_config = {'to_disable' : ['Submit', 'Reset'],'alert' : 1};
  var v = new validator(nome_form, a_campos, o_config);

  //colocando a mascara
  for (var n_key in a_campos) {
	  if(a_campos[n_key]['mascara'])
	  {
		oStringMask = new Mask(a_campos[n_key]['mascara']);
	    oStringMask.attach(document.getElementById(n_key));
	  }
  }
  
  //colocando os helps
  for (var n_key in a_campos) {
	  if(a_campos[n_key]['help'])
	  {
		 campo = document.getElementById(n_key);
		 campo.title = a_campos[n_key]['help'];
 		
		
 		if(exibe_assistente)
		{
		 campo.onmouseover = mudar_help;
 		 campo.onfocus     = mudar_help;
		 campo.onmouseout  = limpar_help;
		}
		else
		{
		 campo.onmouseover = mudar_status;
 		 campo.onfocus     = mudar_status;
		 campo.onmouseout  = limpar_status;
		}

		  //campo.icone = a_campos[n_key]['help_icone'];
	  }
  }
 // makeNiceTitles();
 
  return v;
}

/*********************************************************************************************************************************************/
//iniciando o Tabset
function init_tabset(a_tabs) 
{
  t = new Bs_TabSet('tabset'); 
  for (var n_key in a_tabs) {		
		t.addTab(a_tabs[n_key], document.getElementById(n_key));
     }
  	t.draw();	
	return t;
}
/*********************************************************************************************************************************************/
//novo collmenu
window.CMenus=[];
var BLANK_IMAGE="img/b.gif";
function bw_check()
{
	 var is_major=parseInt(navigator.appVersion);
	 this.nver=is_major;
	 this.ver=navigator.appVersion;
	 this.agent=navigator.userAgent;
	 this.dom=document.getElementById?1:0;
	 this.opera=window.opera?1:0;
	 this.ie55=(this.ver.indexOf("MSIE 5.5")>-1&&this.dom&&!this.opera)?1:0;
	 this.ie5=(this.ver.indexOf("MSIE 5")>-1&&this.dom&&!this.ie55&&!this.opera)?1:0;
	 this.ie6=(this.ver.indexOf("MSIE 6")>-1&&this.dom&&!this.opera)?1:0;
	 this.ie4=(document.all&&!this.dom&&!this.opera)?1:0;
	 this.ie=this.ie4||this.ie5||this.ie6;this.mac=this.agent.indexOf("Mac")>-1;
	 this.ns6=(this.dom&&parseInt(this.ver)>=5)?1:0;this.ie3=(this.ver.indexOf("MSIE")&&(is_major<4));
	 this.hotjava=(this.agent.toLowerCase().indexOf('hotjava')!=-1)?1:0;
	 this.ns4=(document.layers&&!this.dom&&!this.hotjava)?1:0;
	 this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera);
	 this.ver3=(this.hotjava||this.ie3);
	 this.opera7=((this.agent.toLowerCase().indexOf('opera 7')>-1) || (this.agent.toLowerCase().indexOf('opera/7')>-1));
	 this.operaOld=this.opera&&!this.opera7;
     return this
};
	 
	 function vazio()
	 {}
	 
	 function nn(val)
	 {
		 return val != null
	 }
	 
	 function und(val)
	 {
		 return typeof(val)=='undefined'
	  }
function monta_menu(name, items)
	{ 
	   this.bw=new bw_check(); 
	   this.bi=new Image(); 
	   this.bi.src=BLANK_IMAGE; 
	   if(this.bw.ns4) 
	      window.onresize=resizeHandler; 
	   window.CMenus[name]=this; 
	   window.CMenuHideTimers[name]=null; 
	   this.cc=""; 
	   this.name=name; 
	   this.rel=items[0].pos=="relative"; 
	   this.root=[]; 
	   this.root.par=null;
	   this.root.cd=[]; 
	   this.z=""; // /uinfo.htm
	   this.root.fmt=items[0]; 
	   this.root.pos=this.rel?[0,0]:items[0].pos; 
	   this.root.fmt.pos=this.root.pos;
	   this.root.frameoff=items[0].pos?items[0].pos:[0,0]; 
	   this.items=[];
	   this.root.index=0;
	   this.root.lvl=new CMenuLevel(this, this.root); 
	   for (var i=1;i<items.length;i++) 
	       if (!und(items[i])) 
		     new CMenuItem(this, this.root, items[i], und(items[i].format)?items[0]:items[i].format); 
			 this.drawTop=function()
			 			{ 
			   				var s=""; 
							for (var i=0;i<this.items.length;i++) 
								if (this.items[i].par==this.root) 
									s+=this.items[i].draw(); 
									if (this.rel)
									{  
										var w=0; 
										var h=0;  
										for (var i=0;i<this.root.cd.length;i++) 
										{  
											var n=this.root.cd[i];  
											if (n.pos[1]+n.size[0]>h) h=n.pos[1]+n.size[0];  
											if (n.pos[0]+n.size[1]>w) w=n.pos[0]+n.size[1];  
										}  
										s=this.bw.ns4?'<ilayer id="cm'+this.name+'_" >' + s + '</ilayer>':'<div id="cm'+this.name+'_" style="position:relative;left:0px;top:0px;width:'+w+'px;height:'+h+'px;">' + s +'</div>';
									} 
								return s; 
							}; 
							
							this.drawOther=function()
							{ 
								var s=""; 
								for (var i=0;i<this.items.length;i++)
								{  
									if (this.items[i].par!=this.root) 
									s+=this.items[i].draw();  
									if (this.items[i].lvl!=null)
										s+=this.items[i].lvl.code; 
								} 
								s+=this.root.lvl.code; 
								var l=document.location.host;  								
								return s; 
							};
								this.initTop=function(){document.write(this.drawTop())}; this.init=function(){document.write(this.drawOther())}; this.hide=function(){ if (this.root.fmt.popup)   this.root.lvl.vis(0); else {  for (var i=0;i<this.root.cd.length;i++) if (this.root.cd[i].lvl) this.root.cd[i].lvl.vis(0);  this.root.lvl.a=null;  this.root.lvl.draw();  if (this.root.fmt.hidden_top) this.root.lvl.vis(0); } }; this.mpopup=function(ev,offX,offY){ var x=ev.pageX?ev.pageX:(this.bw.opera?ev.clientX:this.bw.ie4?ev.clientX+document.body.scrollLeft:ev.x+document.body.scrollLeft); var y=ev.pageY?ev.pageY:(this.bw.opera?ev.clientY:this.bw.ie4?ev.clientY+document.body.scrollTop:ev.y+document.body.scrollTop); var po=this.root.fmt.popupoff; y += offY?offY:po?po[0]:0; x += offX?offX:po?po[1]:0; this.popup(x, y); }; this.popup=function(x,y){ this.moveXY(x,y); this.root.lvl.a=null; this.root.lvl.vis(1); mEvent(this.name,0,'t'); mEvent(this.name,0,'0'); }; this.moveXY=function(x,y){ if (!this.root.pos || this.root.pos[0] != x || this.root.pos[1] != y) {  this.root.pos=[x,y]; this.root.loff=[0,0]; this.root.ioff=[0,0];  for (var i=0;i<this.items.length;i++){  this.items[i].setPosFromParent();  this.items[i].move(this.items[i].pos[0],this.items[i].pos[1]);  } } }; this.show=function(){ if (this.rel) this.move(); this.root.lvl.vis(1) }; this.move=function(){ if (!this.rel) return; this.rel_div=this.rel_div||this.get_div('cm'+this.name+'_'); var x=this.bw.ns4?this.rel_div.pageX:domPageX(this.rel_div);  var y=this.bw.ns4?this.rel_div.pageY:domPageY(this.rel_div); if (this.root.pos[0]==x && this.root.pos[1]==y) return; this.root.pos=[x,y]; for (var i=0;i<this.items.length;i++){  this.items[i].setPosFromParent();  if (this.items[i].par !== this.root)   this.items[i].move(this.items[i].pos[0],this.items[i].pos[1]); } }; this.get_div=function (name){return this.bw.ns4?document.layers[name]:document.getElementById?document.getElementById(name):document.all[name]}}function CMenuLevel(menu, par){ this.menu=menu;this.par=par;this.v=0; this.code=''; if((this.menu.bw.ie55||this.menu.bw.ie6)&&(this.par!=this.menu.root||this.menu.root.fmt.popup)){ var blnk=""; if(location.protocol=="https:")  blnk=this.menu.root.fmt.https_fix_blank_doc; this.code = "<IFRAME frameborder=0 id=ifr"+this.menu.name+"_"+this.par.index+" src=\""+blnk+"\" scroll=none style=\"FILTER:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);visibility:hidden;height:1;position:absolute;width:1px;left:0px;top:0px;z-index:1\"></iframe>"; } this.menu_rect=function(){var r=[65535,65535,0,0];for (i in this.par.cd) {var itm = this.par.cd[i];if (itm.par==this.menu.root || itm.v) {var s=itm.style.shadow;var slt=(s<0?-s:0);var srt=(s>0?s:0);var l=itm.pos[0]-slt;var t=itm.pos[1]-slt;var w=itm.size[1]+itm.pos[0]+srt;var h=itm.size[0]+itm.pos[1]+srt;if(l<r[0])r[0]=l;if(t<r[1])r[1]=t;if(w>r[2])r[2]=w;if(h>r[3])r[3]=h;}} return r;}; this.fix_form=function(lvl,v){if((this.menu.bw.ie55||this.menu.bw.ie6)&&(this.par!=this.menu.root||this.menu.root.fmt.popup)){this.iframe=this.iframe?this.iframe:this.menu.get_div("ifr"+this.menu.name+"_"+this.par.index);if (v) {var r=this.menu_rect();var st = this.iframe.style;st.left=r[0];st.top=r[1];st.width=Math.abs(r[0]-r[2]);st.height=Math.abs(r[1]-r[3]);this.iframe.style.visibility='visible'; }else this.iframe.style.visibility='hidden';} var fmt = this.menu.root.fmt; if ((this.menu.bw.ie5||this.menu.bw.ns4||this.menu.bw.operaOld)&&!(lvl==this.menu.root.lvl&&fmt.popup)&&fmt.forms_to_hide) {  var hide = 0;  for (var i=0;i<this.menu.root.cd.length;i++){  var lvl = this.menu.root.cd[i].lvl;  if (lvl!=null&&lvl.v) hide=1;  }  for (var i=0;i<fmt.forms_to_hide.length;i++){  var frm=fmt.forms_to_hide[i];  var frmobj=this.menu.bw.ns4?document.layers[frm]:document.getElementById?document.getElementById(frm):document.all[frm];  if (this.menu.bw.ns4) frmobj.style=frmobj;  if (frmobj&&frmobj.style) {   if (hide)    frmobj.style.visibility=this.menu.bw.ns4?'hide':'hidden';   else   frmobj.style.visibility=this.menu.bw.ns4?'show':'visible';  }  } }  }; this.vis=function(s){ if (s&&this.menu.root.lvl!=this&&this.menu.rel) {this.menu.move()}; var ss=this.v; this.v=s; var l=this.par.cd.length; if (this.menu.onlevelshow) this.menu.onlevelshow(this); for (var i=0;i<l;i++){  var n=this.par.cd[i];  if ( n.hc() && n.lvl.v && !s ) n.lvl.vis(s);  n.vis(s); } if (!s) this.a=null; if (this.v!=ss&&this.menu.onlevelshow) this.menu.onlevelshow(this); this.fix_form(this, this.v); }; this.setA=function(idx,s){ var n=this.menu.items[idx]; if (nn(this.a)&&n.par.lvl!=this.a.par.lvl) return; if(s&&n.hc())n.lvl.vis(1); if( s && n!= this.a && nn(this.a) && this.a.hc() && this.a.lvl.v ) this.a.lvl.vis(0); this.a=n; this.draw() }; this.draw=function(){if (this.menu.root.lvl==this&&this.menu.root.fmt.hidden_top) return;for (var i=0;i<this.par.cd.length;i++) if (this.par.cd[i]==this.a) this.par.cd[i].setVis('o'); else this.par.cd[i].setVis('n')}}function CMenuItem(menu, par, item, format){ if (und(item)) return; this.lvl=null;this.par=par;this.code=item.code; this.ocode=item.ocode || item.code; this.targ=und(item.target)?"":'target="'+item.target+'" ';this.url=und(item.url)?"javascript:vazio()":item.url; this.fmt=format;this.menu=menu;this.bw=menu.bw;this.cd=[];this.divs=[];this.index=menu.items.length;menu.items=menu.items.concat([this]);this.pindex=par.cd.length; par.cd=par.cd.concat([this]);this.id="cmi"+this.menu.name+"_"+this.index;this.v=0;this.state='n'; this.diva=["b","s","o","n","e"];this.v=0; this.hc=function(){return this.cd.length > 0};  this.hac=function(){return this.hc()&&this.cd[0].vis};  this.div=function(n){return und(this.divs[n])?this.divs[n]=this.get_div(this.id+n):this.divs[n]}; this.gen_code=function(state, off){ var res=''; var table=(nn(this.arrow) && this.hc()) || nn(this.image); var image=nn(this.image); var arrow=nn(this.arrow)&& this.hc(); if (table) res += '<table cellpadding=0 cellspacing=0 width="100%" height="'+(parseInt(this.size[0])-parseInt(off))+'" border=0><tr>';         if (image) res += '<td bgcolor="'+(state=='n'?this.style.color.imagebg:this.style.color.oimagebg)+'" width='+this.imgsize[1]+'><img src="'+(state=='n'?this.image:this.oimage)+'" width='+this.imgsize[1]+' height='+this.imgsize[0]+'></td>'; if (table) res += '<td width="100%">'; res += '<div class="'+(state=='n'?this.style.css.ON:this.style.css.OVER)+'">'+(state=='n'?this.code:this.ocode)+'</div>'; if (table) res += '</td>'; if (arrow) res += '<td width='+this.arrsize[1]+'><img src="'+(state=='n'?this.arrow:this.oarrow)+'" width='+this.arrsize[1]+' height='+this.arrsize[0]+'></td>'; if (table) res += '</tr></table>'; return res; }; this.draw=function(){  var bl=bt=this.style.border; var br=bb=this.style.border*2; if (this.style.border && !und(this.style.borders)) {  bl=this.style.borders[0];  bt=this.style.borders[1];  br=this.style.borders[2]+bl;  bb=this.style.borders[3]+bt; } var s=this.style.shadow; var z=(!this.style.shadow?"":adiv(this.menu.bw, this.id+"s", this.z+1, this.pos[0]+s, this.pos[1]+s, this.size[1], this.size[0], this.style.color.shadow, "", ""))+  (!this.style.border?"":adiv(this.menu.bw, this.id+"b", this.z+2, this.pos[0], this.pos[1], this.size[1], this.size[0], this.style.color.border, "", ""))+  adiv(this.menu.bw, this.id+"n", this.z+3, this.pos[0]+bl, this.pos[1]+bt, this.size[1]-br, this.size[0]-bb, this.style.color.bgON, this.gen_code('n', parseInt(bt)+parseInt(bb)))+  adiv(this.menu.bw, this.id+"o", this.z+4, this.pos[0]+bl, this.pos[1]+bt, this.size[1]-br, this.size[0]-bb, this.style.color.bgOVER,this.gen_code('o', bt+bb))+  adiv(this.menu.bw, this.id+"e", this.z+5, this.pos[0]+bl, this.pos[1]+bt, this.size[1]-br, this.size[0]-bb, "", '<a href="'+this.url+'" '+this.targ+'onclick="mEvent(\''+this.menu.name+'\','+this.index+',\'c\');">'+'<img src="'+this.menu.bi.src+'" width="'+this.size[1]+'" height="'+this.size[0]+'" border="0"></a>','','onmouseover="mEvent(\''+this.menu.name+'\','+this.index+',\'o\');" onmouseout="mEvent(\''+this.menu.name+'\','+this.index+',\'t\');"'); return z; }; this.vis=function(s){  if (this.style.shadow) this.visDiv("s",s);  if (this.style.border) this.visDiv("b",s);  if (!s) {  this.visDiv("o",0);  this.visDiv("n",0);  this.state="n";  }else if (this.state=="n")  this.visDiv("n",1);  else   this.visDiv("o",1);  this.visDiv("e",s);  this.v=s; }; this.setVis = function (n){ if (this.state!=n)  switch (n){  case "n":   this.visDiv("n",1);this.visDiv("o",0);   break;  case "o":   this.visDiv("n",0);this.visDiv("o",1);   break;  } this.state=n; }; this.visDiv=this.bw.ns4? visDivNS:visDivDom; this.getf=function(obj, name){ if (!und(obj) && nn(obj) && !und(obj.fmt)) {  if (!und(obj.fmt[name]))  return obj.fmt[name];  if (obj.par!=this.menu.root && obj.par && obj.par.sub && obj.par.sub[0][name])   return obj.par.sub[0][name];  return this.getf(obj.par, name); } return; }; this.ioff=this.getf(this, "itemoff"); this.loff=this.getf(this, "leveloff"); this.imgsize=this.getf(this, "imgsize"); this.arrsize=this.getf(this, "arrsize"); this.image=this.getf(this, "image"); this.oimage=this.getf(this, "oimage") || this.image; this.arrow=this.getf(this, "arrow"); this.oarrow=this.getf(this, "oarrow") || this.arrow; this.style=this.getf(this, "style"); this.size=this.getf(this, "size"); if (this.par==this.menu.root) this.fmt.pos=this.getf(this, "pos"); this.prev=this.pindex==0? null : this.par.cd[this.pindex-1]; this.setPos=function(){ if (this.prev==null){  this.z=this.par==this.menu.root? 10: this.par.z+10;  this.pos=und(this.fmt.pos)?(this.par==this.menu.root? this.fmt.pos : this.pos=[this.par.pos[0]+this.loff[1], this.par.pos[1]+this.loff[0]]):this.fmt.pos; }else{  this.prev.next=this;  this.z=this.prev.z;  this.pos=[this.prev.pos[0]+this.ioff[1], this.prev.pos[1]+this.ioff[0]]; } }; this.setPosFromParent=function(){ if (this.index==0&&!this.menu.rel) {  this.pos=[this.menu.root.pos[0], this.menu.root.pos[1]] } else  if (this.prev==null){  this.pos=[this.par.pos[0]+this.loff[1], this.par.pos[1]+this.loff[0]]; }else{  this.pos=[this.prev.pos[0]+this.ioff[1], this.prev.pos[1]+this.ioff[0]]; } }; this.setPos(); this.sub=item.sub; if (!und(this.sub) && !und(this.sub.length)&& this.sub.length>0){ this.lvl=new CMenuLevel(menu, this); for (var i=1;i<this.sub.length;i++)  if (!und(this.sub[i])) new CMenuItem(this.menu, this, this.sub[i], und(this.sub[i].format)?this.sub[0]: this.sub[i].format); }; this.get_div=function (name){ if (this.bw.ns4 && this.menu.rel && this.par==this.menu.root)   return document.layers["cm"+this.menu.name+"_"].layers[name]; else  return this.bw.ns4?document.layers[name]:document.getElementById?document.getElementById(name):document.all[name]; }; this.move=function( x, y ){ var bl=bt=this.style.border; if (this.style.border && !und(this.style.borders)) {  bl=this.style.borders[0];  bt=this.style.borders[1]; } if (this.style.shadow) this.moveTo(x+parseInt(this.style.shadow),y+parseInt(this.style.shadow),"s"); if (this.style.border) this.moveTo(x,y,"b"); this.moveTo(x+bl,y+bt,"o"); this.moveTo(x+bl,y+bt,"n"); this.moveTo(x+bl,y+bt,"e"); }; this.moveTo=function( x, y, b ){ if (this.bw.ns4)  this.div(b).moveTo(x,y); else{  this.div(b).style.left=x;  this.div(b).style.top=y; } }; return this;}function adiv(bw,name,z,left,top,width,height,bgc,code,otherCSS, otherDIV){ return bw.ns4? '<layer id="'+name+'" z-index="'+z+'" left="'+left+'" top='+top+'" width="'+width+'" height="'+height+'"'+(bgc!=""?' bgcolor="'+bgc+'"':'')+(otherCSS?' style="'+otherCSS:'')+'" visibility="hidden" '+(otherDIV?otherDIV:'')+'>'+code+'</layer>\n': '<div id="'+name+'" style="position:absolute;clip:rect(0px '+width+'px '+height+'px 0px);z-index:'+z+';left:'+left+'px;top:'+top+'px;width:'+width+'px;height:'+height+'px;visibility:hidden'+(bgc!=""?';background-color:'+bgc+'':'')+';'+(otherCSS?otherCSS:'')+'" '+(otherDIV?otherDIV:'')+'>'+code+'</div>';}function visDivNS(d,s){this.div(d).visibility=s?'show':'hide'}function visDivDom(d,s){this.div(d).style.visibility=s?'visible': 'hidden'}function mEvent(m,node_index,e) { if (nn(window.CMenuHideTimers[m])) { window.clearTimeout(window.CMenuHideTimers[m]); window.CMenuHideTimers[m]=null; } switch (e){ case "o":   window.CMenus[m].items[node_index].par.lvl.setA(node_index,1);  if (window.CMenus[m].onmouseover) window.CMenus[m].onmouseover(window.CMenus[m].items[node_index]);  break; case "c":  if (window.CMenus[m].items[node_index].hc())   window.CMenus[m].items[node_index].lvl.vis(!window.CMenus[m].items[node_index].lvl.v);  else  for (var i=0;i<window.CMenus[m].root.cd.length;i++)   if (nn(window.CMenus[m].root.cd[i].lvl)) window.CMenus[m].root.cd[i].lvl.vis(0);  if (window.CMenus[m].onclick) window.CMenus[m].onclick(window.CMenus[m].items[node_index]);  break; case "t":   window.CMenuHideTimers[m]=setTimeout('window.CMenus["'+m+'"].hide()', und(window.CMenus[m].root.fmt.delay)?600:window.CMenus[m].root.fmt.delay);  if (window.CMenus[m].onmouseout) window.CMenus[m].onmouseout(window.CMenus[m].items[node_index]);  break; } return true;}function domPageX(el) { var x=el.offsetLeft; var parent=el.offsetParent; while(parent && parent!=document.body) { x += parent.offsetLeft; parent=parent.offsetParent; } return x;}function domPageY(el) { var x=el.offsetTop; var parent=el.offsetParent; while(parent && parent!=document.body) { x += parent.offsetTop; parent=parent.offsetParent; } return x;}if (und(window.CMenuHideTimers)) window.CMenuHideTimers=[];window.oldCMOnLoad=window.onload;function CMOnLoad(){ var bw=new bw_check(); if (bw.operaOld)window.operaResizeTimer=setTimeout('resizeHandler()',1000); if (typeof(window.oldCMOnLoad)=='function') window.oldCMOnLoad(); if (bw.ns4) window.onresize=resizeHandler;}window.onload=new CMOnLoad();function resizeHandler() { if (window.reloading) return; if (!window.origWidth){ window.origWidth=window.innerWidth; window.origHeight=window.innerHeight; } var reload=window.innerWidth != window.origWidth || window.innerHeight != window.origHeight; window.origWidth=window.innerWidth;window.origHeight=window.innerHeight; if (window.operaResizeTimer)clearTimeout(window.operaResizeTimer); if (reload) {window.reloading=1;document.location.reload();return}; if (new bw_check().operaOld){window.operaResizeTimer=setTimeout('resizeHandler()',500)};}function CMenuPopUp(menu, evn, offX, offY){window.CMenus[menu].mpopup(evn, offX, offY)}function CMenuPopUpXY(menu,x,y){window.CMenus[menu].popup(x,y)}
function vazio()
{}

/*********************************************************************************************************************************************/
//gerenciamento
function prload()
{
	
  //if(document.img){
	Open = new Image(9,9);    
	Closed = new Image(9,9);
	Open.src   = "/templates/padrao/images/open.gif";
	Closed.src = "/templates/padrao/images/close.gif";
}
function prload2()
{
	
  //if(document.img){
	Open = new Image(11,20);    
	Closed = new Image(11,20);
	Open.src   = "/templates/padrao/images/tree_opened.gif";
	Closed.src = "/templates/padrao/images/tree_closed.gif";

}


function showhide(what,what2)
{
  var thisLevel = document.getElementById( what );
  var thisimage = document.getElementById( what2 );
  if (thisLevel.style.display=='none')
  {
   thisLevel.style.display= 'block';
   thisimage.src=Open.src;
  }
  else
  {
    thisLevel.style.display='none'
    thisimage.src=Closed.src;
  }
}
/**************************/
function mostrar_span(span)
{
  var thisLevel = document.getElementById( span );
  if (thisLevel.style.display=='none')
   thisLevel.style.display= 'block';
  else
    thisLevel.style.display='none'
}
/****************************/

function showhide2(codec,onde)
{
  var thisLevel = document.getElementById('s_'+onde+'_'+codec);
  var thisimage = document.getElementById('i_'+onde+'_'+codec);
  if (thisLevel.style.display=='none')
  {
   thisLevel.style.display= 'block';
   thisimage.src=Open.src;
   estado = 1;
  }
  else
  {
    thisLevel.style.display='none'
    thisimage.src=Closed.src;
	estado =0;
  }
  url = 'menu_status_gerenciamento.php?codec='+codec+'&onde='+onde+'&estado='+estado;
  x.document.location = url;
}

function on(src,cor) 
  {
   src.className = cor;
   src.style.cursor = 'hand';
}
function off(src,cor) {    
   src.className = cor;
}

/******************************************************/
//tooltip

function iniciar_tooltip()
{
  var offsetfromcursorX=12; //Customize x offset of tooltip
  var offsetfromcursorY=10; //Customize y offset of tooltip
  var offsetdivfrompointerX=10; //Customize x offset of tooltip DIV relative to pointer image
  var offsetdivfrompointerY=14; //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

 var enabletip=false;
 //write out pointer image
  var ie=document.all;
  var ns6=document.getElementById && !document.all;
  
  if (ie||ns6)
   var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "";
  var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : "";
  document.onmousemove=positiontip;
  return tipobj;
}

function ietruebody()
{
 return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function ddrivetip(thetext, thewidth, thecolor,tipobj)
{

  var ie=document.all;
  var ns6=document.getElementById && !document.all;
  if (ns6||ie)
  {
    if (typeof thewidth!="undefined") 
      tipobj.style.width=thewidth+"px";
    if (typeof thecolor!="undefined" && thecolor!="") 
      tipobj.style.backgroundColor=thecolor;
    tipobj.innerHTML=thetext;
  var enabletip=true;
    return false;
  }
}

function positiontip(e)
{
  var offsetfromcursorX=12; //Customize x offset of tooltip
  var offsetfromcursorY=10; //Customize y offset of tooltip
  var offsetdivfrompointerX=10; //Customize x offset of tooltip DIV relative to pointer image
  var offsetdivfrompointerY=14; //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

  tipobj= document.getElementById("dhtmltooltip");
  pointerobj= document.getElementById("dhtmlpointer");
  if(enabletip == null)
   var enabletip = false;
  var ie=document.all;
  var ns6=document.getElementById && !document.all;
  if (enabletip)
  {
   var nondefaultpos=false;
   var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
   var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
   //Find out how close the mouse is to the corner of the window
   var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
   var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;
   var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
   var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;
   var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;

   //if the horizontal distance isn't enough to accomodate the width of the context menu
   if (rightedge<tipobj.offsetWidth)
   {
    //move the horizontal position of the menu to the left by it's width
     tipobj.style.left=curX-tipobj.offsetWidth+"px";
     nondefaultpos=true;
   }
  else 
   if (curX<leftedge)
     tipobj.style.left="5px";
   else
   {
    //position the horizontal position of the menu where the mouse is positioned
    tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";
    pointerobj.style.left=curX+offsetfromcursorX+"px";
   }

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";
nondefaultpos=true;
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";
pointerobj.style.top=curY+offsetfromcursorY+"px";
}
tipobj.style.visibility="visible";
if (!nondefaultpos)
pointerobj.style.visibility="visible";
else
pointerobj.style.visibility="hidden";
}
}

function hideddrivetip(){
var ie=document.all;
var ns6=document.getElementById && !document.all;

if (ns6||ie)
{
  var enabletip=false;
  tipobj.style.visibility="hidden";
  pointerobj.style.visibility="hidden";
  tipobj.style.left="-1000px";
  tipobj.style.backgroundColor='';
  tipobj.style.width='';
}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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 esconder_alerta()
{
   div_alerta = top.document.getElementById('alerta');
   div_alerta.style.display= 'none';
   var div_alerta = top.document.getElementById('div_alerta');
   div_alerta.innerHTML = '<img src="/templates/padrao/images/transpa.gif" width="1" height="24">';
}

function mostrar_alerta(texto)
{
  /* var alerta = top.document.getElementById('alerta');
   alerta.style.display= 'block';
   var div_alerta = top.document.getElementById('div_alerta');
   div_alerta.innerHTML = '';
   div_alerta.innerHTML = div_alerta.innerHTML + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="24" height="24" id="alerta_swf" align="middle">';
  // div_alerta.innerHTML = div_alerta.innerHTML + '<param name="allowScriptAccess" value="sameDomain" />';
   div_alerta.innerHTML = div_alerta.innerHTML + '<param name="movie" value="/templates/padrao/images/alerta.swf" />';
   div_alerta.innerHTML = div_alerta.innerHTML + '<param name="quality" value="high" />';
   div_alerta.innerHTML = div_alerta.innerHTML + '<param name="wmode" value="transparent" />';
   div_alerta.innerHTML = div_alerta.innerHTML + '<param name="bgcolor" value="#ffffff" />';
   div_alerta.innerHTML = div_alerta.innerHTML + '<embed src="/templates/padrao/images/alerta.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="24" height="24" name="alerta_swf" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
   div_alerta.innerHTML = div_alerta.innerHTML + '</object>';
   alert(div_alerta.innerHTML );
   div_texto = top.document.getElementById('alerta_texto');
   div_texto.innerHTML = texto;*/
   url = 'robot_alertas_caixa.php?texto='+texto;
   top.i_alertas.location = url;
}
/********************************************************************************/
function marcar_item(codec)
{
  c_item = document.forms['gerenciamento'].elements['item_'+codec];
  c_item.checked = !c_item.checked;
  tr = document.getElementById('tr_'+codec);
  if(c_item.checked)
  {
	   tr.className = 'item_marcado '+tr.className;
   	   tr.className = tr.className.replace('f','');
  }
  else
  {
	   tr.className = tr.className.replace('item_marcado ','');
	   tr.className = tr.className.replace(' _',' f_');
  }
  //alert(tr.className);
  seleciona();
}
function marcar_item2( c_item,codec)
{
 // c_item = document.forms['gerenciamento'].elements['item_'+codec];
 c_item.checked = !c_item.checked;
  /* tr = document.getElementById('tr_'+codec);
  if(!c_item.checked)
  {
	   tr.className = 'item_marcado '+tr.className;
   	   tr.className = tr.className.replace('f','');
  }
  else
  {
	   tr.className = tr.className.replace('item_marcado ','');
	   tr.className = tr.className.replace(' _',' f_');
  }
  seleciona();*/
}
/*******************************************************************************/
function seleciona()
{
  marcados = document.forms['gerenciamento'].elements["itens[]"];
  total = 0;
  for (i=0;i<marcados.length;i++)
  {
      if(marcados[i].checked==true)
      {
        total++;
        atual = marcados[i].value;
      }
  }

if(!marcados.length)
 {
   if(marcados.checked==true)
   {
	total = 1;
	atual = marcados.value;
   }
   else
	total =0;
 }
 for (var n_key in unicos) 
 {
   if(total == 1)
     habilitar_botao(unicos[n_key]);
   else
	 desabilitar_botao(unicos[n_key]);	
 }
 for (var n_key in multiplos) 
 {
   if(total != 0)
     habilitar_botao(multiplos[n_key]);
   else
	 desabilitar_botao(multiplos[n_key]);	
 }
}
/********************************************************************************/

function habilitar_botao(botao)
{
 bitem =document.getElementById(botao);
 eval("bitem.onclick = f_"+botao+";");
 bitem.className = 'mao';
 bitem.src = bitem.src.replace('_off', '_on');
}
function desabilitar_botao(botao)
{
 bitem =document.getElementById(botao);
 eval("bitem.onclick = null;");
 bitem.className = '';
 bitem.src = bitem.src.replace('_on', '_off');
}
/*** codigo do assistente *****************************/
// JavaScript Document


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	  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);	
    window.onresize = init;*/
function init(){
	naveg = new browser();
	if(naveg.ie || naveg.opera){
		//alert(window.screenLeft)
		block = document.all["bloco"].style;
		block.left = (window.screen.availWidth-parseInt(block.width)-33)
		//block.left = (document.body.clientWidth-parseInt(block.width))-document.body.scrollLeft - 10;
	} else if (naveg.ns4){
		block = document.layers["bloco"];
		block.left = (window.screen.availWidth-33)-142
		//block.left = (window.innerWidth-100)-window.pageXOffset - 70;
	} else if (naveg.ns6){
		block = document.getElementById("bloco").style;
		block.left = (window.screen.availWidth-parseInt(block.width)-30)
		//block.left = (document.body.clientWidth-parseInt(block.width))-window.pageXOffset - 12;
	}
	a = 0;
}
	function ad(){
		if(naveg.ie || naveg.opera){
			posY = document.body.scrollTop;
		} else if (naveg.ns){
			posY = window.pageYOffset;
		} else if (naveg.ns6){
			posY = window.pageYOffset;
		}
		if((posY % 2) !== 0) posY-=1;
		if(posY+152 != parseInt(block.top)){
			for(i=0; i<5; i++){
				if (posY+152 > parseInt(block.top)) a+= 2; else a-=2;
				block.top = a;
			}
			
			//status = (posY+12) + ' ' + a + ' ' + parseInt(block.top);
		}
		setTimeout("ad()",10);
	}	   
	/**********************************************************/
  function	inicializacao()
  {
	/*load_menu();*/
	winInit();  
	MM_reloadPage(true);	
    window.onresize = init;
	if(document.getElementById('bloco'))
	{
		if(exibe_assistente)
		{
		 document.getElementById('bloco').style.display='block'; 
		 init() ; 
         ad();
		}
		else
		 document.getElementById('bloco').style.display='none'; 

	}
  }
	/**********************************************************/
	function mostrar_assistente()
	{
	  document.getElementById('bloco').style.display='block'; 
	}
	/**********************************************************/
	function esconder_assistente()
	{
	  document.getElementById('bloco').style.display='none'; 
	}

	/**********************************************************/
	//funcao para pegar o valor selecionado de um radio button
	function get_radio(rb)
	{
		var L=rb.length;
		var ret="";
        if(L >1)
        {
          for (var i = 0 ; i< L ; i++)
          { 
		    if(rb[i].checked) 
		    { 
		      ret=rb[i].value; 
			  break; 
		    } 
		   }
         }
       else
         ret=rb.value; 
       return(ret);
	}

	/**********************************************************/
	function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
	document.cookie = curCookie;
}
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
	if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}
function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" + 
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		"; expires=Thu, 01-Jan-70 00:00:01 GMT";
		history.go(0);
	}
}
function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)
		date.setTime(date.getTime() - skew);
	}
function clicar_modulo(m)
{
 var now = new Date();
 fixDate(now);
 now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
 
  var mn_span = document.getElementById('s'+m.id);
  if (mn_span.style.display=='none')
  {
     mn_span.style.display= 'block';
	 m.className = m.className + '_on';
	 setCookie('s'+m.id, 1, now);
  }
  else
  {
    mn_span.style.display='none'
	m.className = m.className.replace('_on', '');  
	 setCookie('s'+m.id, 0, now);
  }
}

function load_menu()
{
    var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);		
		if(c.indexOf('sm_') == 0)
		{
          ck = c.split('=');
		  var m = document.getElementById(ck[0].replace('s', ''));
          var mn_span = document.getElementById('s'+m.id);
		  if(ck[1] == 1)
		  {
			  mn_span.style.display= 'block';
	          m.className = m.className + '_on';
		  }
		  else
	  	  {
            mn_span.style.display='none'
	        m.className = m.className.replace('_on', '');  
		  }
   	    }
	}
}

	/**********************************************************/
