function pop(menuName,mostra) {
		 if ( $(menuName) == "CESTA_PEDIDO" ) {
		      if ( $(menuName).innerHTML == "" ) {
	               return false;			  
			  }	 
		 }
		 if (mostra) {
		     $(menuName).style.visibility = "visible";
		     } else {
		       $(menuName).style.visibility = "hidden";
	     }
}

/*
_maC = navigator.userAgent.toLowerCase().indexOf("mac")>=0;
if ( window.screen.width >= 1024 && (!_maC) ) {
     document.write('<div style="position:absolute;left:779px;top:0px">'); 
     document.write('        <table width="135" border="0" cellspacing="0">'); 
     document.write('          <tr align="center" valign="middle" bgcolor="#FFFFFF" class="texto"> '); 
     document.write('            <td height="23" align="left" bordercolor="#FF9900" bgcolor="#993300" class="texto"> '); 
     document.write('<font size="1"><strong><font color="#FFFFFF" face="Tahoma"><img src="imagens/seta_menu.gif" width="20" height="9">');  
     document.write('              AN&Uacute;NCIOS</font></strong></font></td></tr>'); 
     document.write('          <tr> ') 
     document.write('            <td height="230"> <div align="left"><img src="<?=$caminho_web?>img/skyscraper.gif" width="130" height="320"></div></td>'); 
     document.write('          </tr>'); 
     document.write('          <tr> </tr> <tr>  <td><strong></strong></td>  </tr>    </table>   </div>');
}
*/
<!--
//rollover de cores
function changecolor(target,newcolor){
         if( document.layers ){ // browser="NN4"; 
             document.layers[target].bgColor = newcolor; 
         } 
         if( document.all ){ // browser="IE"; 
             eval('document.all.' + target + '.style.backgroundColor = newcolor'); 
         } 
         if( !document.all && document.getElementById ){ // browser="NN6+ or IE5+ if you're willing to dump the !document.all stuff"; 
             $(target).style.backgroundColor = newcolor; 
         } 
}
// -->	

function montar_miolo( URL, TARGET, PARAMETROS, METODO ){
		 if (( URL != "" )&&( TARGET != "" )) {         
			   carrega(URL,TARGET,PARAMETROS,METODO); 
		 }
}
//Menu Contextual
	function setCor1(obj){
		obj.style.backgroundColor = 'efefef';
		obj.style.color = 'black';
	}
	
	function setCor2(obj){
		obj.style.backgroundColor = 'dddddd';
		obj.style.color = 'black';
	}
	
function menuConextoMostrar(e){
		var divMenu = document.getElementById("div_Menu_Contexto");
		var limitX = document.all ? document.body.clientWidth - window.event.clientX : window.innerWidth - e.clientX;
		var limitY = document.all ? document.body.clientHeight - window.event.clientY : window.innerHeight - e.clientY;
		
		//Verificação do eixo x (horizontal)
		divMenu.style.left = document.all ? ( limitX < divMenu.offsetWidth ? document.body.scrollLeft + window.event.clientX - divMenu.offsetWidth : document.body.scrollLeft + window.event.clientX) : (limitX < divMenu.offsetWidth ? window.pageXOffset + e.clientX - divMenu.offsetWidth : window.pageXOffset + e.clientX) +  "px";
		
		//Verificação do eixo y (vertical)
		divMenu.style.top = document.all ? ( limitY < divMenu.offsetHeight ? document.body.scrollTop + window.event.clientY - divMenu.offsetHeight : document.body.scrollTop + window.event.clientY) : (limitY < divMenu.offsetHeight ? window.pageYOffset + e.clientY - divMenu.offsetHeight : window.pageYOffset + e.clientY) + "px";
		
		divMenu.style.display = "inline";
		return false;
	}
	
	function menuContextoOcultar(){
		document.getElementById("div_Menu_Contexto").style.display = "none";
	}

function menu_contexto() {
         document.onclick       = menuContextoOcultar;
         document.oncontextmenu = menuConextoMostrar;
}

function barra_status() {
         window.defaultStatus   = "||_Fincato Advogados_||";
}

function addbookmark(a,b) {
		window.external.AddFavorite(a,'||_Fincato Advogados_||');
}

//INICIO DAS FUNCOES NATIVAS DO DREAWEAVER
function MM_openBrWindow(theURL,winName,features) { //v2.0
         window.open(theURL,winName,features);
}

// script do calendario
<!-- Begin
var dDate = new Date();
var dCurMonth = dDate.getMonth();
var dCurDayOfMonth = dDate.getDate();
var dCurYear = dDate.getFullYear();
var objPrevElement = new Object();
var controleRec = "";

function fToggleColor(myElement) {
	var toggleColor = "#ff9900";
	if (myElement.id == "calDateText") {
		if (myElement.color == toggleColor) {
			myElement.color = "";
		} else {
			myElement.color = toggleColor;
		}
	} else if (myElement.id == "calCell") {
		for (var i in myElement.children) {
			if (myElement.children[i].id == "calDateText") {
				if (myElement.children[i].color == toggleColor) {
					myElement.children[i].color = "";
				} else {
					myElement.children[i].color = toggleColor;
				}
			}
		}
	}
}

function fSetSelectedDay(myElement){
	if (myElement.id == "calCell") {
		if (!isNaN(parseInt(myElement.children["calDateText"].innerText))) {
		myElement.bgColor = "#ff9900";
		myElement.style.color = "#000000";
		objPrevElement.bgColor = "";
		document.all.calSelectedDate.value = parseInt(myElement.children["calDateText"].innerText);
		objPrevElement = myElement;
		
		//for (var i in document.getElementById("calendario")) {
		//	alert(i);
		//}
		/* AQUI */
		var data_evento = document.getElementById("data_do_evento")
		if (data_evento)
		{  
			data_evento.value = document.all.calSelectedDate.value+"/"+document.all.tbSelMonth.value+"/"+document.all.tbSelYear.value
		}
		else{
			document.location.href = "agenda.php?tp=" + document.getElementById("tp").value + "&dt=" + document.all.calSelectedDate.value+"/"+document.all.tbSelMonth.value+"/"+document.all.tbSelYear.value;
		}
		esconde_cal();
      }
   }
}
function fGetDaysInMonth(iMonth, iYear) {
var dPrevDate = new Date(iYear, iMonth, 0);
return dPrevDate.getDate();
}
function fBuildCal(iYear, iMonth, iDayStyle) {
var aMonth = new Array();
aMonth[0] = new Array(7);
aMonth[1] = new Array(7);
aMonth[2] = new Array(7);
aMonth[3] = new Array(7);
aMonth[4] = new Array(7);
aMonth[5] = new Array(7);
aMonth[6] = new Array(7);
var dCalDate = new Date(iYear, iMonth-1, 1);
var iDayOfFirst = dCalDate.getDay();
var iDaysInMonth = fGetDaysInMonth(iMonth, iYear);
var iVarDate = 1;
var i, d, w;
if (iDayStyle == 2) {
aMonth[0][0] = "Domingo";
aMonth[0][1] = "Segunda";
aMonth[0][2] = "Terça";
aMonth[0][3] = "Quarta";
aMonth[0][4] = "Quinta";
aMonth[0][5] = "Sexta";
aMonth[0][6] = "Sábado";
} else if (iDayStyle == 1) {
aMonth[0][0] = "Dom";
aMonth[0][1] = "Seg";
aMonth[0][2] = "Ter";
aMonth[0][3] = "Qua";
aMonth[0][4] = "Qui";
aMonth[0][5] = "Sex";
aMonth[0][6] = "Sab";
} else {
aMonth[0][0] = "D";
aMonth[0][1] = "S";
aMonth[0][2] = "T";
aMonth[0][3] = "Q";
aMonth[0][4] = "Q";
aMonth[0][5] = "S";
aMonth[0][6] = "S";
}
for (d = iDayOfFirst; d < 7; d++) {
aMonth[1][d] = iVarDate;
iVarDate++;
}
for (w = 2; w < 7; w++) {
for (d = 0; d < 7; d++) {
if (iVarDate <= iDaysInMonth) {
aMonth[w][d] = iVarDate;
iVarDate++;
      }
   }
}
return aMonth;
}
function mes_anterior(iYear, iMonth){
  var mes;
  if (iMonth == 01){
	mes = 12;
  }
  else{
	mes = iMonth - 1;
  }
  return mes;
}
function ano_anterior(iYear, iMonth){
  var ano;
  if (iMonth == 01){
	ano = iYear - 1;
  }
  else{
	ano = iYear;
  }
  return ano;
}
function mes_posterior(iYear, iMonth){
  var mes;
  if (iMonth == 12){
	mes = 01;
  }
  else{
	mes = (iMonth*1) + 1;
  }
  return mes;
}
function ano_posterior(iYear, iMonth){
  var ano;
  if (iMonth == 12){
	ano = (iYear*1) + 1;
  }
  else{
	ano = iYear;
  }
  return ano;
}
function fDrawCal(iYear, iMonth, iday, iCellWidth, iCellHeight, sDateTextSize, sDateTextWeight, iDayStyle) {
var myMonth;
myMonth = fBuildCal(iYear, iMonth, iDayStyle);
document.write("<table id='calendario' width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border='0'>")
document.write("<tr bgcolor=\"#CCCCCC\">");
document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:10px;COLOR:#000;'>" + myMonth[0][0] + "</td>");

document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:10px;COLOR:#000;'>" + myMonth[0][1] + "</td>");
document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:10px;COLOR:#000;'>" + myMonth[0][2] + "</td>");
document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:10px;COLOR:#000;'>" + myMonth[0][3] + "</td>");
document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:10px;COLOR:#000;'>" + myMonth[0][4] + "</td>");
document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:10px;COLOR:#000;'>" + myMonth[0][5] + "</td>");
document.write("<td align='center' style='FONT-FAMILY:Arial;FONT-SIZE:10px;COLOR:#000;'>" + myMonth[0][6] + "</td>");
document.write("</tr>");
for (w = 1; w < 7; w++) {
document.write("<tr>")
for (d = 0; d < 7; d++) {
document.write("<td align='center' valign='middle' width='" + iCellWidth + "' height='" + iCellHeight + "' id=calCell style='CURSOR:pointer' onMouseOver='fToggleColor(this)' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this) onload=fSetDay(this,iday)>");
if (!isNaN(myMonth[w][d])) {
   document.write("<font id=calDateText onMouseOver='fToggleColor(this)' style='CURSOR:pointer;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)>" + myMonth[w][d] + "</font>");
} else {
   document.write("<font id=calDateText onMouseOver='fToggleColor(this)' style='CURSOR:pointer;FONT-FAMILY:Arial;FONT-SIZE:" + sDateTextSize + ";FONT-WEIGHT:" + sDateTextWeight + "' onMouseOut='fToggleColor(this)' onclick=fSetSelectedDay(this)> </font>");
}

document.write("</td>")
}
document.write("</tr>");
}
document.write("</table>");
}
function fUpdateCal(iYear, iMonth, way) {
if (way == "ant")
{
  document.getElementById("tbSelMonth").value = mes_anterior(iYear, iMonth);
  document.getElementById("tbSelYear").value =  ano_anterior(iYear, iMonth);
}
else if (way == "prox")
{
  document.getElementById("tbSelMonth").value = mes_posterior(iYear, iMonth);
  document.getElementById("tbSelYear").value = ano_posterior(iYear, iMonth);
}
var mes;
mes = document.getElementById("tbSelMonth").value;
myMonth = fBuildCal(document.getElementById("tbSelYear").value, mes);
switch (mes)
{
  case '1': document.getElementById("mes").innerHTML =  "Janeiro";break;
  case '2': document.getElementById("mes").innerHTML =  "Fevereiro";break;
  case '3': document.getElementById("mes").innerHTML =  "Março";break;
  case '4': document.getElementById("mes").innerHTML =  "Abril";break;
  case '5': document.getElementById("mes").innerHTML =  "Maio";break;
  case '6': document.getElementById("mes").innerHTML =  "Junho";break;
  case '7': document.getElementById("mes").innerHTML =  "Julho";break;
  case '8': document.getElementById("mes").innerHTML =  "Agosto";break;
  case '9': document.getElementById("mes").innerHTML =  "Setembro";break;
  case '10': document.getElementById("mes").innerHTML =  "Outubro";break;
  case '11': document.getElementById("mes").innerHTML =  "Novembro";break;
  case '12': document.getElementById("mes").innerHTML =  "Dezembro";break;
}
document.getElementById("ano").innerHTML =  document.getElementById("tbSelYear").value;
objPrevElement.bgColor = "";
document.all.calSelectedDate.value = "22";
for (w = 1; w < 7; w++) {
for (d = 0; d < 7; d++) {
if (!isNaN(myMonth[w][d])) {
calDateText[((7*w)+d)-7].innerText = myMonth[w][d];
} else {
calDateText[((7*w)+d)-7].innerText = " ";
         }
      }
   }
}
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
function mostra_cal(t,l,controle,dia,mes,ano){
	
   obj = document.getElementById("calLayer").style;
   obj.visibility="visible";
   
   if (t != 0 && l != 0){ 
      obj.top = t;
      obj.left = l;
   }else{
   	  obj.top = findPosY(controle)+1+"px";
	  obj.left = findPosX(controle)+"px";
   }   
}      
function mostra_cal2(t,l,controle,dia,mes,ano){
   obj = calLayer.style;
   obj.visibility="visible";
   controleRec= document.fdados.elements[controle].value;
   if (t != 0 && l != 0){ 
      obj.top = t;
      obj.left = l;
   }else{
      obj.top = window.event.y + document.body.scrollLeft;
      obj.left = window.event.x + document.body.scrollTop;
   }   
}      
function esconde_cal(){
   obj = document.getElementById("calLayer").style;
   obj.visibility="hidden";
}    

// Fim script do calendario

// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// ugly workaround for missing support for selectorText in Netscape6/Mozilla
// call onLoad() or before you need to do anything you would have otherwise used
// selectorText for.
var ugly_selectorText_workaround_flag = false;
var allStyleRules;
// code developed using the following workaround (CVS v1.15) as an example.
// http://lxr.mozilla.org/seamonkey/source/extensions/xmlterm/ui/content/XMLTermCommands.js
function ugly_selectorText_workaround() {
	if((navigator.userAgent.indexOf("Gecko") == -1) ||
	   (ugly_selectorText_workaround_flag)) {
		return; // we've already been here or shouldn't be here
	}
	var styleElements = document.getElementsByTagName("style");
	
	for(var i = 0; i < styleElements.length; i++) {
		var styleText = styleElements[i].firstChild.data;
		// this should be using match(/\b[\w-.]+(?=\s*\{)/g but ?= causes an
		// error in IE5, so we include the open brace and then strip it
		allStyleRules = styleText.match(/\b[\w-.]+(\s*\{)/g);
	}

	for(var i = 0; i < allStyleRules.length; i++) {
		// probably insufficient for people who like random gobs of 
		// whitespace in their styles
		allStyleRules[i] = allStyleRules[i].substr(0, (allStyleRules[i].length - 2));
	}
	ugly_selectorText_workaround_flag = true;
}


// setStyleById: given an element id, style property and 
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v) {
	var n = document.getElementById(i);
	n.style[p] = v;
}

// getStyleById: given an element ID and style property
// return the current setting for that property, or null.
// args:
//  i - element id
//  p - property
function getStyleById(i, p) {
	var n = document.getElementById(i);
	var s = eval("n.style." + p);

	// try inline
	if((s != "") && (s != null)) {
		return s;
	}

	// try currentStyle
	if(n.currentStyle) {
		var s = eval("n.currentStyle." + p);
		if((s != "") && (s != null)) {
			return s;
		}
	}
	
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[y] == i) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) ||
						   (rules[y].selectorText == i)) {
							return z[p];
						}
					}
				}
			}
		}
	}
	return null;
}

// setStyleByClass: given an element type and a class selector,
// style property and value, apply the style.
// args:
//  t - type of tag to check for (e.g., SPAN)
//  c - class name
//  p - CSS property
//  v - value
var ie = (document.all) ? true : false;

function setStyleByClass(t,c,p,v){
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					eval('node.style.' + p + " = '" +v + "'");
				}
			}
		}
	}
}

// getStyleByClass: given an element type, a class selector and a property,
// return the value of the property for that element type.
// args:
//  t - element type
//  c - class identifier
//  p - CSS property
function getStyleByClass(t, c, p) {
	// first loop over elements, because if they've been modified they
	// will contain style data more recent than that in the stylesheet
	var elements;
	if(t == '*') {
		// '*' not supported by IE/Win 5.5 and below
		elements = (ie) ? document.all : document.getElementsByTagName('*');
	} else {
		elements = document.getElementsByTagName(t);
	}
	for(var i = 0; i < elements.length; i++){
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if(node.attributes.item(j).nodeName == 'class') {
				if(node.attributes.item(j).nodeValue == c) {
					var theStyle = eval('node.style.' + p);
					if((theStyle != "") && (theStyle != null)) {
						return theStyle;
					}
				}
			}
		}		
	}
	// if we got here it's because we didn't find anything
	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if((allStyleRules[y] == c) ||
						   (allStyleRules[y] == (t + "." + c))) {
							return z[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) &&
						   ((rules[y].selectorText == c) ||
						    (rules[y].selectorText == (t + "." + c)))) {
							return z[p];
						}
					}
				}
			}
		}
	}

	return null;
}

// setStyleByTag: given an element type, style property and 
// value, and whether the property should override inline styles or
// just global stylesheet preferences, apply the style.
// args:
//  e - element type or id
//  p - property
//  v - value
//  g - boolean 0: modify global only; 1: modify all elements in document
function setStyleByTag(e, p, v, g) {
	if(g) {
		var elements = document.getElementsByTagName(e);
		for(var i = 0; i < elements.length; i++) {
			elements.item(i).style[p] = v;
		}
	} else {
		var sheets = document.styleSheets;
		if(sheets.length > 0) {
			for(var i = 0; i < sheets.length; i++) {
				var rules = sheets[i].cssRules;
				if(rules.length > 0) {
					for(var j = 0; j < rules.length; j++) {
						var s = rules[j].style;
						// selectorText broken in NS 6/Mozilla: see
						// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
						ugly_selectorText_workaround();
						if(allStyleRules) {
							if(allStyleRules[j] == e) {
								s[p] = v;
							}			
						} else {
							// use the native selectorText and style stuff
							if(((s[p] != "") && (s[p] != null)) &&
							   (rules[j].selectorText == e)) {
								s[p] = v;
							}
						}

					}
				}
			}
		}
	}
}

// getStyleByTag: given an element type and style property, return
// the property's value
// args:
//  e - element type
//  p - property
function getStyleByTag(e, p) {
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		for(var i = 0; i < sheets.length; i++) {
			var rules = sheets[i].cssRules;
			if(rules.length > 0) {
				for(var j = 0; j < rules.length; j++) {
					var s = rules[j].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[j] == e) {
							return s[p];
						}			
					} else {
						// use the native selectorText and style stuff
						if(((s[p] != "") && (s[p] != null)) &&
						   (rules[j].selectorText == e)) {
							return s[p];
						}
					}

				}
			}
		}
	}


	// if we don't find any style sheets, return the value for the first
	// element of this type we encounter without a CLASS or STYLE attribute
	var elements = document.getElementsByTagName(e);
	var sawClassOrStyleAttribute = false;
	for(var i = 0; i < elements.length; i++) {
		var node = elements.item(i);
		for(var j = 0; j < node.attributes.length; j++) {
			if((node.attributes.item(j).nodeName == 'class') ||
			   (node.attributes.item(j).nodeName == 'style')){
			   sawClassOrStyleAttribute = true;
			}
		}
		if(! sawClassOrStyleAttribute) {
			return elements.item(i).style[p];
		}
	}
}

// Setar os checkboxes
var check_id = '';
function setCheckboxes(the_form, do_check){
	     check_id = '';
         var elts      = document.forms[the_form].elements['box[]'];
         var elts_cnt  = (typeof(elts.length) != 'undefined') ? elts.length : 0;
         if ( elts_cnt ) {
              for ( var i = 0; i < elts_cnt; i++ ) {
                    elts[i].checked = do_check;
					if ( do_check ) { check_id = check_id + ',' + elts[i].value; }
              } 
              } else {
                elts.checked = do_check;
				if ( do_check ) { check_id = check_id + ',' + elts.value; }
         }
         return true;
}

function setCheckbox(objeto){
	     if ( objeto.checked ) {
		      check_id = check_id + ',' + objeto.value;
		      }else{
		       unsetCheckbox(objeto.value);
		 }
		 //check_id = check_id.replace(",,","");
		 //check_id = check_id.replace(/^,/,"");
		 //check_id = check_id.replace(/,$/,"");
         //alert('VALOR: ' + objeto.value + ' CHECKED: ' + objeto.checked + ' CHECK_ID: ' + check_id);
}

function unsetCheckbox(valor){
	
	     if ( check_id.lastIndexOf(valor) != -1 ) {
              array_checados = check_id.split(",");
			  check_id = ''; 
              /*
			  for ( x in array_checados ){
				    if ( array_checados[x] == valor ){
				         array_checados[x] = "";
					     } else {
						   if (( array_checados[x] != "" )||( array_checados[x] != "" )) {
						          check_id = check_id + "," + array_checados[x]; 
						   }
					}
		      }
			  */

		//var simpsons = ['Homer', 'Marge', 'Lisa', 'Bart', 'Meg'];
		array_checados.each( function(familyMember){
			
			if (( familyMember != valor )&&( familyMember != "" )) {
				
				check_id = check_id + "," + familyMember; 
				
			}
			
			
			
			
		});





			  //check_id = array_checados.join(",");
			  //check_id = check_id.replace(",,","");
			  //check_id = check_id.replace(/^,/,"");
			  //check_id = check_id.replace(/,$/,"");
         }
}

function checkCheckboxes(the_form){
	     check_id = '';
         var elts      = document.forms[the_form].elements['box[]'];
         var elts_cnt  = (typeof(elts.length) != 'undefined') ? elts.length : 0;
         if ( elts_cnt ) {
              for ( var i = 0; i < elts_cnt; i++ ) {
                    if ( elts[i].checked ) {
						check_id = check_id + ',' + elts[i].value;
				    } 
              } 
			  
         }
         return true;
}

function multiExclusao(the_form,script_excluir) {
		 if( confirm('Você tem certeza que deseja apagar este(s) item(s)???') ){
 	         checkCheckboxes(the_form);
			 carrega( '' + script_excluir + '?MID='+check_id+'', 'MIOLO', '', 'GET' );
		 }
}

function multiExclusaoFotos(the_form,script_excluir,gid) {
		 if( confirm('Você tem certeza que deseja apagar este(s) item(s)???') ){
 	         checkCheckboxes(the_form);
			 carrega( '' + script_excluir + '?MID='+check_id+'?GID='+gid+'', 'MIOLO', '', 'GET' );
		 }
}

function getImageWidth(myImage) {
	var x, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.width;
	} else {
		return getElementWidth(myImage);
	}
	return -1;
}

function getImageHeight(myImage) {
	var y, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.height;
	} else {
		return getElementHeight(myImage);
	}
	return -1;
}

function findImage(name, doc) {
	var i, img;
	for (i = 0; i < doc.images.length; i++) {
    	if (doc.images[i].name == name) {
			return doc.images[i];
		}
	}
	for (i = 0; i < doc.layers.length; i++) {
    	if ((img = findImage(name, doc.layers[i].document)) != null) {
			img.container = doc.layers[i];
			return img;
    	}
	}
	return null;
}

function getImage(name) {
	if (document.layers) {
    	return findImage(name, document);
	}
	return null;
}

function getElementHeight(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.height;
	} else {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		if (op5) { 
			xPos = elem.style.pixelHeight;
		} else {
			xPos = elem.offsetHeight;
		}
		return xPos;
	} 
}

function getElementWidth(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.width;
	} else {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		if (op5) {
			xPos = elem.style.pixelWidth;
		} else {
			xPos = elem.offsetWidth;
		}
		return xPos;
	}
}

// Zoom das IMG
    imgLoad1 = new Image(); 
    imgLoad2 = new Image(); 
    imgLoad1.src = "img/load1.gif";
    imgLoad2.src = "img/load2.gif";    

    function showZoom(img, id, type, width) {
		//alert(img+', '+id+', '+type+', '+width);
        var browser = navigator.userAgent.toLowerCase();        
        var iwidth = (width > 131) ? (-37):(-17);
    	with(document.getElementById("" + id + type)) {
            removeAttribute("style");
        	if (!browser.match(/msie/)) style.position="absolute";
        	style.background="#FFFFFF";
        	style.minWidth="120px";
        	style.minHeight="120px";
        	style.border="1px solid #CCCCCC";
        	style.zIndex="1";
            style.marginTop="-20px";
           	style.marginLeft = iwidth;
           	if (browser.match(/msie/)) style.marginLeft = (iwidth - 120);
           	if (browser.match(/msie/) && (type=="b")) { style.marginLeft = (iwidth - 95); }
           	if (browser.match(/opera/) && (type=="c")) { style.marginTop = "-80px"; }
    	}

        with(document.getElementById("" + id + type)) {
            removeAttribute("style");
            if (browser.match(/msie/)) style.position="absolute";
            style.cursor = "url('img/lupa.gif'), pointer";
            src = (width > 80) ? (imgLoad2.src):(imgLoad1.src);
        	src = img; 
    	}
    }

    function hideZoom(img, id, type, dis) { 
    	with(document.getElementById("" + id + type)) {
            removeAttribute("style");        	
        	if (dis == 1) {
        	    style.opacity = 0.3;
        	    style.filter = "gray alpha(opacity=50)";
        	}
        	src = img;
        }

    	
    	with (document.getElementById("" + id + type)) {
            removeAttribute("style");
    	}
    }
// Fim do Zoom das IMG

function limpar_foto( CAMPO ){
         eval('document.MYFORM.'+CAMPO+'.value=""');
         carrega( 'noticias/foto_limpar.php', 'FOTO_PREVIEW', '', 'GET' );
}

function abrePopup(TARGET,LARGURA,ALTURA){
         window.open(TARGET, "EditorAvancado","menubar=0,location=0,resizable=0,scrollbars=yes,status=yes,left=100px,top=100px,width="+LARGURA+"px,height="+ALTURA+"px");
}


function htmlspecialchars(ch) {
   ch = ch.replace(/&/g,"&amp;")
   ch = ch.replace(/\"/g,"&quot;")
   ch = ch.replace(/\'/g,"&#039;")
   ch = ch.replace(/</g,"&lt;")
   ch = ch.replace(/>/g,"&gt;")
   return ch
}

function unhtmlspecialchars(ch) {
   ch = ch.replace(/&amp;/g,"&")
   ch = ch.replace(/&quot;/g,"\"")
   ch = ch.replace(/&#039;/g,"\'")
   ch = ch.replace(/&lt;/g,"<")
   ch = ch.replace(/&gt;/g,">")
   return ch
}

function base64_encode(input) {
	     input = unhtmlspecialchars(input);
		 return escape(input);
}

function base64_decode(input) {
     	 return unescape(input);
}

function aviso_calendario(){
         alert("Para selecionar datas use o calendário ao lado!!!!");
		 return false;
}

// funcoes pra adiconar campos
var numRows = 0;
var scrollCount = 0;

function addRow(id, addheight, skip_add) {
	var html = ""; 

	if (!skip_add)
		numRows++;

	scrollCount++;

    if ( (numRows%2) == 0 ) {
          estilo_atual = "linha_par_tabelas";		
		  }else{
           estilo_atual = "linha_impar_tabelas";		
	}

	var elm = document.createElement("div");
	elm.id = 'row_' + numRows;

	html += '<table width="500" border="0" cellspacing="0" cellpadding="0">';
	html += '	  <tr>';
	html += '    	<td class="'+ estilo_atual +'">legenda '+ numRows +'</td>';
	html += '    	<td class="'+ estilo_atual +'"><input type="text" name="LEGENDA_'+ numRows +'" />';
	html += '	<a href="javascript:delRow(\'row_'+ numRows +'\')" class="mceButtonNormal"><img src="img/tool_upload_del.gif" alt="Remover foto '+ numRows +'" title="Remover foto '+ numRows +'" border="0" /></a></td>';
	html += '    	</tr>';
	html += '	  <tr>';
	html += '    	<td class="'+ estilo_atual +'">foto '+ numRows +'</td>';
	html += '	    <td class="'+ estilo_atual +'">';
	html += '		<input type="hidden" name="FOTO_'+ numRows +'" id="FOTO_'+ numRows +'" value="" onchange="carrega( \'galerias/foto_preview.php?SOURCE=\'\+this.value\+\'\', \'FOTO_PREVIEW_'+ numRows +'\', \'\', \'GET\' );" />';
	html += '      <div id="FOTO_PREVIEW_'+ numRows +'"  ';
	html += '	style="border:1px solid #ccc;width:100px;height:100px;font-weight:bold;color:#ccc;text-align:center;vertical-align:middle;padding-top:20px;cursor: url(\'img/lupa.gif\'), pointer;"';
	html += ' onClick="javascript:mcImageManager.open(\'MYFORM\',\'FOTO_'+ numRows +'\',\'\',\'\',{remove_script_host : true});"';
	html += '	>';
	html += 'Clique para adicionar uma foto';
	html += '</div>';
	html += '<div id="FOTO_LIMPAR_'+ numRows +'" style="width:100px;height:10px;font-weight:bold;color:#ccc;text-align:center;vertical-align:middle;cursor: url(\'img/lupa.gif\'), pointer;" onClick="limpar_foto(\'FOTO_'+ numRows +'\');">';
	html += 'limpar<img src="img/tool_del.gif" alt="[ Exluir esta foto desta noticia!!! ]" />';
	html += '</div>';
	html += '		</td>';
	html += '    	</tr>';
	html += '	</table>';

	elm.innerHTML = html;
	document.getElementById(id).appendChild(elm);
	document.forms['MYFORM'].numfiles.value = numRows;
}

function delRow(id) {
	var elm = document.getElementById(id);
	if (elm) {
		elm.parentNode.removeChild(elm);
		scrollCount--;
		document.forms['MYFORM'].numfiles.value = (document.forms['MYFORM'].numfiles.value - 1);
	}
}

function init() {
	var myRows = parseInt(numRows);
	if (myRows != 0) {
		for (var i=0; i<myRows; i++) {
			addRow('addPosition', false, true);
		}
	}

}

function enquete(jan) {
		resultado=window.open('',jan,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,copyhistory=no,width=274,height=250");
}