var objBrow,LAST_ERR_VALUE="";
var ERRO=REPET_ERR=false;
var LAST_FIELD=CURRENT_FIELD=LAST_ERR_FIELD=null;
var SZ_DATE=8,
SZ_CEP=8,
SZ_MONEY=10,
SZ_CONTACORRENTE=6,
SZ_AGENCIA=4,
SZ_FLOAT=10,
SZ_CPF=11,
SZ_CNPJ=14,
SZ_CPF_CNPJ=SZ_CNPJ,
SZ_MONTH_YEAR=6,
SZ_TIME=4,
MAX_VALUE=9999999.99;

function bloqueiaEnter(ev) {
	if (ev.keyCode==13) {
		ev.returnValue=false;
		}
}

function simulaClickOnEnter(ev,field_button) {
	if (ev.keyCode==13) {
		ev.returnValue=false;
		field_button.click();
		}
}

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);

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 MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// description: draggable modal windows
// coding: softcomplex.com
// data: 09/21/2007

var N_BASEZINDEX =1000000000;
var RE_PARAM = /^\s*(\w+)\s*\=\s*(.*)\s*$/;

// this function makes the document numb to the mouse events by placing the transparent layer over it
function f_putScreen (b_show) {

	if (b_show == null && !window.b_screenOn)
		return;

	if (!b_show) {
		//window.b_screenOn = false;
		if (e_screen) {
            e_screen.style.display = 'none';

            // attach event
            if (document.removeEventListener) {
                document.removeEventListener('mousemove', f_dragProgress, false);
                window.removeEventListener('resize', f_putScreen, false);
                window.removeEventListener('scroll', f_putScreen, false);
            }
            if (window.detachEvent) {
                document.detachEvent('onmousemove', f_dragProgress);
                window.detachEvent('onresize', f_putScreen);
                window.detachEvent('onscroll', f_putScreen);
            }
            else {
                document.onmousemove = undefined;
                window.onresize = undefined;
                window.onscroll = undefined;
            }
            document.body.removeChild(e_screen);
            window.e_screen = null;
        }
        return;
	}

	// create the layer if doesn't exist
	if (window.e_screen == null) {
        window.e_screen = document.createElement("div");
		e_screen.innerHTML = "&nbsp;";
		document.body.appendChild(e_screen);

		e_screen.style.position = 'absolute';
		e_screen.id = 'eScreen';

		// attach event
		if (document.addEventListener) {
			document.addEventListener('mousemove', f_dragProgress, false);
			window.addEventListener('resize', f_putScreen, false);
			window.addEventListener('scroll', f_putScreen, false);
		}
		if (window.attachEvent) {
			document.attachEvent('onmousemove', f_dragProgress);
			window.attachEvent('onresize', f_putScreen);
			window.attachEvent('onscroll', f_putScreen);
		}
		else {
			document.onmousemove = f_dragProgress;
			window.onresize = f_putScreen;
			window.onscroll = f_putScreen;
		}
	}

	// set properties
	var a_docSize = f_documentSize();
	e_screen.style.left = a_docSize[2] + 'px';
	e_screen.style.top = a_docSize[3] + 'px';
	e_screen.style.width = a_docSize[0] + 'px';
	e_screen.style.height = a_docSize[1] + 'px';
	e_screen.style.zIndex = N_BASEZINDEX + a_windows.length * 2 - 1;
	e_screen.style.display = 'block';
}

// returns the size of the document
function f_documentSize () {

var n_scrollX = 0,
	n_scrollY = 0;

	if (typeof(window.pageYOffset) == 'number') {
		n_scrollX = window.pageXOffset;
		n_scrollY = window.pageYOffset;
	}
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop )) {
		n_scrollX = document.body.scrollLeft;
		n_scrollY = document.body.scrollTop;
	}
	else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
		n_scrollX = document.documentElement.scrollLeft;
		n_scrollY = document.documentElement.scrollTop;
	}

	if (typeof(window.innerWidth) == 'number')
		return [window.innerWidth, window.innerHeight, n_scrollX, n_scrollY];
	if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
		return [document.documentElement.clientWidth, document.documentElement.clientHeight, n_scrollX, n_scrollY];
	if (document.body && (document.body.clientWidth || document.body.clientHeight))
		return [document.body.clientWidth, document.body.clientHeight, n_scrollX, n_scrollY];
	return [0, 0];
}

function f_dialogOpenDiv (divToShow, s_title, s_features) {
    if (!window.a_windows)
		window.a_windows = [];

	// parse parameters
	var a_featuresStrings = s_features.split(',');
	var a_features = [];
	for (var i = 0; i < a_featuresStrings.length; i++)
		if (a_featuresStrings[i].match(RE_PARAM))
			a_features[String(RegExp.$1).toLowerCase()] = RegExp.$2;

	// create element for window
	var n_nesting = a_windows.length;

	var e_window = document.createElement("div");
	e_window.style.position = 'absolute';
	var n_width  = a_features.width  ? parseInt(a_features.width)  : 300;
	var n_height = a_features.height ? parseInt(a_features.height) : 200;
	var a_docSize = f_documentSize ();
	e_window.style.left = (a_features.left ? parseInt(a_features.left) : ((a_docSize[0] - n_width)  / 2) + a_docSize[2]) + 'px';
	e_window.style.top  = (a_features.top  ? parseInt(a_features.top)  : ((a_docSize[1] - n_height) / 2) + a_docSize[3]) + 'px';
	e_window.style.zIndex = N_BASEZINDEX + a_windows.length * 2 + 2;

      var flashes = [];
    flashes = document.getElementsByTagName("object");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "hidden";
    }

    var select = [];
    flashes = document.getElementsByTagName("select");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "hidden";
    }

    e_window.innerHTML = divToShow.innerHTML;
	document.body.appendChild(e_window);
	a_windows[n_nesting] = e_window;

    // put the screen
	f_putScreen(true);
}

function f_dialogOpen (s_url, s_title, s_features) {
	if (!window.a_windows)
		window.a_windows = [];

	// parse parameters
	var a_featuresStrings = s_features.split(',');
	var a_features = [];
	for (var i = 0; i < a_featuresStrings.length; i++)
		if (a_featuresStrings[i].match(RE_PARAM))
			a_features[String(RegExp.$1).toLowerCase()] = RegExp.$2;

	// create element for window
	var n_nesting = a_windows.length;

	var e_window = document.createElement("div");
	e_window.style.position = 'absolute';
	var n_width  = a_features.width  ? parseInt(a_features.width)  : 300;
	var n_height = a_features.height ? parseInt(a_features.height) : 200;
	var a_docSize = f_documentSize ();
	e_window.style.left = (a_features.left ? parseInt(a_features.left) : ((a_docSize[0] - n_width)  / 2) + a_docSize[2]) + 'px';
	e_window.style.top  = (a_features.top  ? parseInt(a_features.top)  : ((a_docSize[1] - n_height) / 2) + a_docSize[3]) + 'px';
	e_window.style.zIndex = N_BASEZINDEX + a_windows.length * 2 + 2;

      var flashes = [];
    flashes = document.getElementsByTagName("object");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "hidden";
    }

    var select = [];
    flashes = document.getElementsByTagName("select");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "hidden";
    }

    e_window.innerHTML =
		'<table border="0" class="' +
		(a_features.css ? a_features.css : 'dialogWindow') +
		'" style="z-index:10;"><tr><td><iframe frameBorder="0" name="'+s_title+'" style = "border:0 solid black" scrolling="no" width="' + n_width +
		'" height="' + n_height +
		(s_url!=''?'" src="' + s_url + '"':'')+'>  </iframe></td></tr></table>';
//    alert(e_window.innerHTML);
	document.body.appendChild(e_window);
    var txt = document.createTextNode(" ");
    document.body.appendChild(txt);

    a_windows[n_nesting] = e_window;

    // put the screen
	f_putScreen(true);
}

function f_dialogClose () {

	var n_nesting = a_windows.length - 1;
	// destroy element
	if (a_windows[n_nesting].removeNode)
		a_windows[n_nesting].removeNode(true);
	else if (document.body.removeChild)
		document.body.removeChild(a_windows[n_nesting]);
	a_windows[n_nesting] = null;
	a_windows.length = n_nesting;

    var flashes = [];
    flashes = document.getElementsByTagName("object");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "visible";
    }

    var select = [];
    flashes = document.getElementsByTagName("select");
    for (var f=0; f < flashes.length; f++){
        flashes[f].style.visibility = "visible";
    }
    // move the screen

    f_putScreen(n_nesting);

}


// drag'n'drop functions
function f_dragStart (s_name, e_event) {
	if (!e_event && window.event) e_event = window.event;

	// save mouse coordinates
	window.n_mouseX = e_event.clientX;
	window.n_mouseY = e_event.clientY;
	window.e_draggedWindow = window.a_windows[s_name];
	return false;
}
function f_dragProgress (e_event) {
	if (!e_event && window.event) e_event = window.event;
	if (!e_event || window.e_draggedWindow == null) return;

	var n_newMouseX = e_event.clientX;
	var n_newMouseY = e_event.clientY;

	window.e_draggedWindow.style.left = (parseInt(window.e_draggedWindow.style.left) - window.n_mouseX + n_newMouseX) + 'px';
	window.e_draggedWindow.style.top  = (parseInt(window.e_draggedWindow.style.top)  - window.n_mouseY + n_newMouseY) + 'px';

	window.n_mouseX = n_newMouseX;
	window.n_mouseY = n_newMouseY;
}

function f_dragEnd () {
	window.e_draggedWindow = null;
}

// end draggable modal windows


function linkexterno(pagina) {
	window.open("../comum/linkexterno.jsp?pagina="+pagina,"","top=0,left=0,width=800,height=400,menubar=yes, toolbar=yes,status=yes, resizable=yes,scrollbars=yes,location=yes")
}

function validarTexto(campo,nomecampo) {
	if(campo.value=="") {
		alert("Por favor, preencha o campo "+nomecampo);
		campo.focus();
		return false;
		}
	else
		return true;
}

function validarSelect(campo,nomecampo) {
	if(campo.value=="") {
		alert("Por favor, escolha uma opção no campo "+nomecampo);
		campo.focus();
		return false;
		}
	else
		return true;
}

function validarRadio(campo,nomecampo) {
	var preenchido=false;
	var i;
	for(i=0;i<campo.length;i++) {
		if(campo[i].checked)
			preenchido=true;
	}
					
	if(!preenchido) {
		alert("Por favor, escolha uma opção no campo "+nomecampo);
		campo[0].focus();
		return false;
		}
	else
		return true;
}

function checaCPF(CPF) {
 	var i;
	var numCPF='';
	for(i=0;i<CPF.length;i++) {
		if(!isNaN(CPF.substring(i,i+1))) {
			numCPF+=CPF.substring(i,i+1);}
	}
	CPF=numCPF
	if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
		CPF == "22222222222" ||	CPF == "33333333333" || CPF == "44444444444" ||
		CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
		CPF == "88888888888" || CPF == "99999999999")
		return false;
	soma = 0;
	for (i=0; i < 9; i ++)
		soma += parseInt(CPF.charAt(i)) * (10 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(CPF.charAt(9)))
		return false;
	soma = 0;
	for (i = 0; i < 10; i ++)
		soma += parseInt(CPF.charAt(i)) * (11 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(CPF.charAt(10)))
		return false;
	return true;
 }

function _has(s,a){
s=String(s);
if(typeof(a)=="string")return s.indexOf(a)!=-1;
else{
	for(var i=0;i<a.length;i++)if(s.indexOf(a[i])!=-1)return true;
	return false;
}
}

function trim(s){return String(s).replace(/^\s+/,"").replace(/\s+$/,"");}
function _TRIM(){
var s=0,e=this.length;
while(s<e&&this.charAt(s)==' ')s++;
while(e>0&&this.charAt(e-1)==' ')e--;
return this.slice(s,e);
}
String.prototype.trim=_TRIM;

function justNumbersStr(s){return String(s).replace(/\D*/g,"");}
function onlySameNumber(s){return isNumeric(s)&& (new RegExp("^("+s.charAt(0)+")(\\1)*$")).test(s);}

function brow(){if(typeof objBrow!="object")objBrow=new Browser();return objBrow;}

function Browser(){
this.name=this.platform="Unknown";
this.majorver=this.version=this.minorver="";
this.mozilla=false;
this.init=_Init;
this.getName=function(){return this.name};
this.getMinorver=function(){return this.minorver};
this.getMajorver=function(){return this.majorver};
this.getVersion=function(){return parseFloat(this.version,10)};
this.getPlatform=function(){return this.platform}; 
this.isIE=function(){return(this.name=="IE")};
this.isNetscape=function(){return(this.name=="Netscape")};
this.isMozilla=function(){return this.mozilla};
this.isWindows=function(){return _has(this.platform,["Windows","WinNT"])};
this.isWinNT=function(){return _has(this.platform,["WinNT","Windows NT"])};
this.isWin95=function(){return _has(this.platform,["Win95","Windows 95"])};
this.isWin98=function(){return _has(this.platform,["Win98","Windows 98"])};
this.isLinux=function(){return _has(this.platform,"Unix")};
this.isMac=function(){return _has(this.platform,"Mac");};
this.init();
}
function _Init(){
var ua=navigator.userAgent,t="",ts="",i,bv;
bv=ua.slice(0,ua.indexOf("("));
ts=ua.slice(ua.indexOf("(")+1,ua.indexOf(")")).split(";");
for(i=0;i<ts.length;i++){
	t=ts[i].trim();
	if(_has(t,["MSIE","Opera"]))bv=t;
	else if(_has(t,["X11","SunOS","Linux"]))this.platform="Unix";
	else if(_has(t,["Mac","PPC","Win"]))this.platform=t;
}
var idx=bv.indexOf("MSIE"),lo="";
if(idx>=0)bv=bv.slice(idx);
if(bv.slice(0,7)=="Mozilla"){
	lo="";
	this.name="Netscape";
	if(ua.indexOf("Gecko/")!=-1){
		if(/Netscape/.test(ua)){
			var v=/([^\/]+)\s*$/.exec(ua);
			if(v&&v.length>1)lo=v[1]+" ";
		}else{
			this.mozilla=true;
			var v=/rv:([^\)]+)\)/.exec(ua);
			if(v&&v.length>1)lo=v[1]+" ";
		}
	}
	if(lo=="")lo=bv.slice(8);
}else if (bv.slice(0,4)=="MSIE"){
	this.name="IE";lo=bv.slice(5);
}else if (bv.slice(0,27)=="Microsoft Internet Explorer"){
	this.name="IE";lo=bv.slice(28);
}else if (bv.slice(0,5)=="Opera"){
	this.name="Opera";lo=bv.slice(6);
}
lo=lo.trim();
i=lo.indexOf(" ");
if(i>=0)this.version=lo.slice(0,i);
else this.version=lo;
j=this.version.indexOf(".");
if(j>=0){
	this.majorver=this.version.slice(0,j);
	this.minorver=this.version.slice(j+1);
}else this.majorver=this.version;
}


function removeCaracs(f,type){
	var vr=unformatField(f.value,type);
	if(f.value!=vr)f.value=vr;
	focusNetscape(f);
}

function formatType(f,tp,msgErr,adarg1,adarg2){
var vr=unformatField(f.value,tp);
LAST_FIELD=f;
var ret=isValidValue(vr,tp,adarg1,adarg2);
if(!ret){
	showError(tp,msgErr);
	return false;
}else f.value=getFmtValue((typeof ret=="boolean")?vr:ret,tp);
ERRO=false;
return true;
}

function focusNetscape(f){
CURRENT_FIELD=f;
var b=brow();
if(b.isNetscape()){
	if(ERRO){LAST_FIELD.focus();ERRO=false;}
}else if(b.isIE()&& parseInt(b.getMajorver(),10)>4)if(f.select)f.select();
}

function formatCamp(campo,tp,par1,par2,par3){
var ie=(brow().isIE()&&!brow().isMac()),v=brow().getVersion();

var nArg=formatCamp.arguments.length;
ERRO=false;
var vr=trim(campo.value);
if(!campo|| !vr ||vr.length==0){
//	if(/^(neg_)?(money|money2)$/.test(tp))campo.value="0,00";
	return false;
}
if(nArg==2)par1="";
if(tp=="interval"){
	if(nArg<=4) par3="";
	return formatType(campo,tp,par3,par1,par2);
}else return formatType(campo,tp,par1);
}

function validaConteudo(event,el,tp)
{
var t=(typeof event.which!="undefined"&& event.which!=null?event.which:event.keyCode),key=String.fromCharCode(t);
if(t<20)return true;
var tp_sp=/^sp_/.test(tp);
if(/^((neg_)?(numeric|float(\d{0,1})|money(\d{0,1})))$/.test(tp)){
	return isNumeric(key)||(!/numeric/.test(tp)&&key==","&&el.value.indexOf(",")==-1)||(/^neg_/.test(tp)&&key=="-" && el.value.indexOf("-")==-1);
}else if(/^(sp_)?alfanumeric$/.test(tp))
	return isAlfaNumeric(key)||(tp_sp && key==" ");
else if(/^(sp_)?textnumber$/.test(tp))
	return isTextNumber(key)||(tp_sp && key==" ");
else{
	switch(tp){
		case "email":
		case "uppercase":return true;
		case "text":return isAlfa(key)|| /[ ]/.test(key);
		case "text_entry":return isTextNumber(key)||/[\.\-\/\,=]|\s/.test(key);
		case "default":return !/'|"/.test(key);
		default:return isNumeric(key);
	}
}
}

function saltaCampo(ev,field,tp,size){
	var tc,max,nargs=saltaCampo.arguments.length;
	if(/^(neg_)?float/.test(tp))max=(nargs>3)?size:SZ_FLOAT;
	else if(/^(neg_)?money/.test(tp)){
		if(!verifyMaxValue(field.value))max=(nargs>3)?size:SZ_MONEY;
		else field.value="0,00";
	}else if(/^(date|month_year|time|cpf|cnpj|cpf_cnpj|cep|contacorrente|agencia)$/.test(tp))
		max=eval("SZ_"+tp.toUpperCase());
	else if(/^(text|text_entry|uppercase|interval|(sp_)?alfanumeric|(sp_)?textnumber|default|(neg_)?numeric|email)$/.test(tp))
		max=size;
	tc=brow().isNetscape()?ev.which:ev.keyCode;
	if(String(field.value).length>=max && tc>=48){autoSkip(field);return true;}
	else return false;
}

function unformatField(valor,tipo){
	var vr=(typeof valor=="object")?valor.value:String(valor);
	var t=(arguments.length<1)?"default":String(tipo);
	if(!trim(vr)||trim(vr).length==0) return "";
	if(/^(date|month_year|time|cep|(neg_)?numeric|interval)$/.test(t))
		vr=(/^neg_/.test(t)&&vr.indexOf("-")==0?"-":"")+justNumbersStr(vr);
	else if(/^((neg_)?(float(\d{0,1})|money(\d{0,1})))$/.test(t))vr=toFloat(vr,_getNDec(t));
	else{
        if(/^(contacorrente)$/.test(t)){
            vr=justNumbersStr(vr);
            vr=repeatStr(vr,"0",SZ_CONTACORRENTE);
        }
		else if(/^(cpf|cnpj|cpf_cnpj)$/.test(t)){
			vr=justNumbersStr(vr);
			var isCPF=tipo=="cpf"||(tipo=="cpf_cnpj" && vr.length<=SZ_CPF);
			vr=repeatStr(vr,"0",isCPF?SZ_CPF:SZ_CNPJ);
			if(parseInt(vr,10)==0)vr="";
		} else if(t=="email")vr=trim(vr)
	}
	if(typeof valor=="object")valor.value=vr;
	else return vr;
}

function isValidValue(vr,tp,adarg1,adarg2){
var re,isNum=isNumeric(vr);
if(/^(cep)$/.test(tp))
	return isNum && vr.length==eval("SZ_"+tp.toUpperCase());
else if(/^(cep)$/.test(tp))
    return isNum && vr.length==eval("SZ_"+tp.toUpperCase());
else if(/^((neg_)?(float(\d{0,1})|money(\d{0,1})))$/.test(tp))
	return (!/^neg_/.test(tp)&&vr.indexOf("-")!=-1?false:isFloatNumber(vr));
else if(/textnumber$/.test(tp))
	return isTextNumber((tp.indexOf("sp_")==0)?removeStr(vr," "):vr);
else if(/text_entry$/.test(tp))
	return isTextNumber(vr.replace(/[\.\-\/\,=]|\s/g,""));
else if(/alfanumeric$/.test(tp))
	return isAlfaNumeric((tp.indexOf("sp_")==0)?removeStr(vr," "):vr);
else{
	switch(tp){
		case "time":
			switch(vr.length){
				case 1:vr="0"+vr+"00";break;
				case 2:vr+="00";break;
				case 3:vr="0"+vr+"0";break;
			}
			vr=repeatStr(vr,"0",4,"right");
			return(isNum && /^([0-1]\d[0-5]\d)|(2[0-3][0-5]\d)$/.test(vr))?vr:null;
		case "date":
			var obj=new DateValidation(vr);
			return (isNum && obj.isDate())?obj:null;
		case "month_year":
			var obj=new DateValidation("01"+vr);
			return (isNum && obj.isDate())?obj:null;
		case "text":return isAlfa(vr.replace(/[ ]/g,""));
		case "email":return isEmail(vr);
		case "cpf":return isCPF(vr);
		case "cnpj":return isCNPJ(vr);
		case "cpf_cnpj":return (vr.length <=SZ_CPF)?isCPF(vr):isCNPJ(vr);
		case "interval":
			vr=parseInt(vr,10);
			return vr>=adarg1 && vr<=adarg2;
		case "default":return !/'|"/.test(vr);
		default:return true;
	}
}
}

function isNumeric(v){return /^[0-9]+$/.test(v);}
function isAlfa(v){return /^[a-zA-ZáéíóúçãõâêôàÁÉÍÓÚÇÃÕÂÊÔÀ]+$/.test(v);}
function isAlfaNumeric(v){return /^[0-9a-zA-Z]+$/.test(v);}
function isTextNumber(v){return /^[0-9a-zA-ZáéíóúçãõâêôàÁÉÍÓÚÇÃÕÂÊÔÀ]+$/.test(v);}
function isFloatNumber(n){return /^\-?\d+(,\d+|\d*)$/.test(n);}
function isEmail(email)
{
	var v=trim(email);
	// exp1: Trata erros grosseiros (@...@ , .. , .@ , etc.)
	// exp2: Garante carac. validos e estrutura: <usuario>@<maquina>
	// exp3: Garante no minimo um ponto depois do "@" 
	var exp1= /(\@.*\@)|(.*\.\..*)|(.*\@\..*)|(^\.)|(\.$)|(\@\/)|(.*\@\-.*)|(.*\.$)/;
	var exp2= /^[_\w\d][\w\d\_\/\-\.]*\@[\d\w\-\.]+[0-9A-z]$/;
	var exp3= /.*\@.*[\.].*/;
	return(!exp1.test(v)&& exp2.test(v)&& exp3.test(v));
}

function _getNDec(t){
	var arr=t.match(/(\d+)\s*$/);
	return arr?parseInt(arr[1],10):2;
}

function invertStr(s){
	var t="",i;
	for(i=0;i<s.length;i++)t=s.charAt(i)+t;
	return t;
}

function removeStr(src,arg){
	var v=(typeof arg=="string")?[arg]:arg;
	var r="";
	for(var i=0;i<v.length;i++)r=changeStr(src,v[i],"");
	return r;
}

function repeatStr(src,str,size,orient){
	var r=String(src);
	if(!orient)orient="left";
	while(r.length < size)r=orient.toLowerCase()=="right"?(r+str):(str+r);
	return r;
}

function repeatNStr(vr,n){
var r="",i;
for(i=0;i<n;i++)r+=vr;
return r;
}

function changeStr(src,from,to)
{
	src=String(src);
	var i,li=0,lFrom= from.length,dst="";
	while((i=src.indexOf(from,li))!=-1){
		dst+=src.substring(li,i)+to;
		li=i+lFrom;
	}
	dst+=src.substring(li);
	return dst;
}

function DateValidation(d){
	this.dtSrc=d;
	this.dtValue="";
	this.isDate=_isDate;
	this.getDateValue=function() {return(this.dtValue);};
	this.getMonthDateValue=function() {return(this.dtValue.slice(3));} 
}
function _isDate(){
	var vrs=/^(0[1-9]|[1-2][0-9]|3[0-1])(0[1-9]|1[0-2])(\d{2}|19\d{2}|20\d{2})$/.exec(justNumbersStr(this.dtSrc));
	if(!vrs || vrs.length<4)return false;
	var d=parseInt(vrs[1],10),m=parseInt(vrs[2],10),a=parseInt(vrs[3],10);		
	if(a<100)a+=(a<30?2000:1900);
	if(/^(4|6|9|11)$/.test(m) && d==31)return false;
	if(m==2){
		var bissexto=(((a%4==0)&&a%100!=0)||a%400==0);
		if(d>29 ||(d==29 && !bissexto))return false;
	}
	this.dtValue=repeatStr(d,"0",2)+"/"+repeatStr(m,"0",2)+"/"+a;
	return true;
}
function DateObj(d){
	d=trim(d);
	if(!d)return;
	var t=d.length;
	if(t==10||t==8||t==6){
		this.isValid=true;
		this.srcDate=d;
		this.date=d.replace(/\//g,"");
		this.day=this.date.slice(0,2);
		this.month=this.date.slice(2,4);
		this.year=this.date.slice(4);
		var a=parseInt(this.year,10);
		if(a<100){a+=(a<30?2000:1900);this.year=String(a);}

		this.daysTo=_DaysTo;
		this.lesserThan=function(d){return Number(this.year+this.month+this.day) < Number(d.year+d.month+d.day)};
		this.biggerThan=function(d){return !this.lesserThan(d)&& !this.equal(d)};
		this.equal=function(d){return this.date==d.date.replace(/\//g,"");};
		this.biggerOrEqualThan=function(d){return this.biggerThan(d)||this.equal(d)};
		this.lesserOrEqualThan=function(d){return this.lesserThan(d)||this.equal(d)};
	}else this.isValid=false;
}
function _DaysTo(d){
	var msDay=24*60*60*1000;
	var s=new Date(this.month+"/"+this.day+"/"+this.year);
	var f=new Date(d.month+"/"+d.day+"/"+d.year);
	return Math.floor((f.getTime()-s.getTime())/msDay);
}
function isInInterval(dtIn,dtFi,pIn,pFi,msg1,msg2,msg3){
	var iDt=new DateObj(dtIn),fDt=new DateObj(dtFi);
	var iPer=new DateObj(pIn),fPer=new DateObj(pFi);
	if(!msg1||msg1=="")msg1='Data inicial maior que a data final. Digite novamente.';
	if(!msg2||msg2=="")msg2='Data inicial fora do período disponível. Digite novamente.';
	if(!msg3||msg3=="")msg3='Data final fora do período disponível. Digite novamente.';
	if(iDt.isValid&&fDt.isValid&&iPer.isValid&&fPer.isValid){
		if(fDt.lesserThan(iDt)){alert(msg1);return false;}
		else if(iDt.lesserThan(iPer)){alert(msg2);return false;}
		else if(fPer.lesserThan(fDt)){alert(msg3);return false;}
		return true;
	}
}
function isInDaysLimit(dtIn,dtFi,dias,msg){
	if(!msg)msg="O intervalo entre as datas não pode ultrapassar "+dias+(dias>1?" dias":" dia")+". Digite novamente.";
	var sDt=new DateObj(dtIn),fDt=new DateObj(dtFi);
	if(sDt.isValid && fDt.isValid){
		if((sDt.daysTo(fDt)+1)>dias){alert(msg);return false;}
		return true;
	}
}

function getFmtValue(vr,tp){
	if(tp=="cpf_cnpj")tp=(vr.length <=SZ_CPF)?"cpf":"cnpj";
	if(/^(neg_)?money/.test(tp))return fmtMoney(vr,_getNDec(tp));
	else{
		switch(tp){
			case "time":return vr.slice(0,2)+":"+vr.slice(2,4); 
            case "contacorrente":return vr.slice(0,5)+"-"+vr.slice(5,6);
			case "date":return vr.getDateValue();
			case "month_year":return vr.getMonthDateValue();
			case "cep":return vr.slice(0,5)+"-"+vr.slice(5,8);
			case "uppercase":return vr.toUpperCase();
			case "cpf":return vr.slice(0,3)+"."+vr.slice(3,6)+"."+ vr.slice(6,9)+ "-"+vr.slice(9,11);
			case "cnpj":return vr.slice(0,2)+"."+vr.slice(2,5)+"."+vr.slice(5,8)+"/"+vr.slice(8,12)+"-"+vr.slice(12,14);
			default:return vr;
		}
	}
}
function fmtMoney(vr,ndec){
	var neg=vr.indexOf("-")==0;
	if(verifyMaxValue(vr)){ERRO=true;return "0,00";}
	vr=toFloat(vr,ndec);
	var vraux="",p,pDec=vr.indexOf(","),vrDec=vr.slice(pDec+1);
	for(var i=pDec;i>(neg?1:0);i--){
		p=i-pDec;
		if(i!=pDec&&(p%3==0))vraux+=".";
		vraux+=vr.charAt(i-1);
	}
	return (neg?"-":"")+invertStr(vraux)+","+vrDec;
}
function setMaxValue(vr){MAX_VALUE=vr;}
function verifyMaxValue(vr){return vr.length>0 &&(parseFloat(vr)>MAX_VALUE);}
function toFloat(src,ndec){
   src=trim(src);
	if(!/^\-?([0-9]|\.)*\,{0,1}[0-9]*$/.test(src)||src.charAt(0)==".")return src;
	var tam=src.length,pDec=src.indexOf(",");
	if(src.length==0)src="0";
	if(pDec==-1){
		var p=src.indexOf(".");
		if(p!=-1&&p==(tam-ndec-1))src=src.replace(/\.(\d*)$/,",$1");
		else return removeStr(src,".")+","+repeatNStr("0",ndec);
		pDec=src.indexOf(",");
	}
	src=removeStr(src,".");
	if(pDec==0)return "0"+src+repeatNStr("0",ndec+1-src.length);
	else{
		if(pDec>(tam-ndec-1))src+=repeatNStr("0",pDec-(tam-ndec-1));
		pDec=src.indexOf(",");
		return parseInt(src.slice(0,pDec),10)+src.slice(pDec,pDec+ndec+1);
	}
}


function showError(type,msgU){
ERRO=true;
var b=brow(),canShow=true;
if(typeof type=="object"){
	alert(msgU);
	focusCamp(type);
	return;
}
if(b.isIE() && parseInt(b.getMajorver(),10)<5){
	if(CURRENT_FIELD && LAST_ERR_FIELD==CURRENT_FIELD && LAST_ERR_VALUE==CURRENT_FIELD.value){
		REPET_ERR=true;
		CURRENT_FIELD.value=LAST_ERR_VALUE="";
		LAST_ERR_FIELD=null;
		canShow=false;
	}else{
		LAST_ERR_FIELD=CURRENT_FIELD;
		LAST_ERR_VALUE=(CURRENT_FIELD?CURRENT_FIELD.value:null);
		REPET_ERR=false;
	}
}
if(canShow){
	var m=". Digite novamente.";
	switch(type){
		case "date":msg="Data inválida"+m;break;
		case "time":msg="Hora inválida"+m;break;
		case "cep":msg="CEP inválido"+m;break;
		case "email":msg="E-mail incorreto"+m;break;
		case "cpf":msg="CPF inválido"+m;break;
		case "cnpj":msg="CNPJ inválido"+m;break;
		case "cpf_cnpj":msg="CPF/CNPJ inválido"+m;break;
		case "month_year":msg="Mês e ano inválidos"+m;break;
		default:msg="Valor inválido"+m;
	}
	alert((!msgU || msgU=="")?msg:msgU);
}
if(brow().isNetscape())LAST_FIELD.value="";
if(LAST_FIELD)LAST_FIELD.focus();
}
function autoSkip(field,orient){
	var ind=-1,f=field.form;
	for(i=0;i<f.elements.length;i++)
		if(field==f.elements[i]){ind=i;break;}
	focusCampByPos(f,ind,orient);
}

function focusCampByPos(fr,ind,orient){
	orient=orient?orient:"down";
	var iNext=(orient=="down"?1:-1),el;
	if((typeof fr.elements[ind+iNext])=="undefined"){
      if(ind!=-1)if(fr.elements[ind]&&fr.elements[ind].blur)fr.elements[ind].blur();
		return;
   }
	for(var i=ind+iNext;i<fr.elements.length;i+=iNext){
		el=fr.elements[i];
		if(/^(text|password|select.*|radio|checkbox.*)$/.test(el.type) && !el.disabled){el.focus();return;}
   }
	if(fr.elements[ind]&&fr.elements[ind].blur)fr.elements[ind].blur();
}

function isCNPJ(cnpj) 
{
	if(cnpj.length==0) return false;
	cnpj= trim(cnpj);
	var digs=[],i;
	for(i=0; i<14; i++)
		digs[i]= parseInt(cnpj.charAt(i),10);
	var sDig=0,soma=0,resto=0,dVer1=-1,dVer2=-1;
	var fat1=[5,4,3,2,9,8,7,6,5,4,3,2];
	var fat2=[6,5,4,3,2,9,8,7,6,5,4,3,2];
	for(var i=0; i<12; i++)
		sDig+= (digs[i]*fat1[i]);
	resto= sDig % 11;
	dVer1= (resto==0)?0:(11 - resto)%10;
	if(digs[12]==dVer1) 
	{
		sDig=resto=0;
		for(i=0;i<13;i++) 
			sDig+= (digs[i]*fat2[i]);
		resto=sDig%11;
		dVer2=(resto==0)?0:(11-resto)%10;
	}
	return digs[12]==dVer1 && digs[13]==dVer2;
}

function isCPF(cpf)
{
	var OK;
	cpf= justNumbersStr(trim(cpf));
	if(onlySameNumber(cpf)) return false;
	var size=cpf.length;
	if(size>10)
	{
		var vr=cpf.substring(0,size-2)
		var resto= getVerificationDigit(vr);
		OK= resto==parseInt(cpf.charAt(size-2));
		if(OK)
		{
			vr+=resto;
			resto=getVerificationDigit(vr);
			OK= resto==parseInt(cpf.charAt(size-1));
		}
	}
	return OK;
}

function getVerificationDigit(S)
{
	var s=0,i;
	var inv=invertStr(justNumbersStr(S));
   for(i=0;i<inv.length;i++)
        s+=(i+2)*parseInt(inv.charAt(i));
   s*=10;
   return (s%11)%10;
}

function textCounter(field, maxlimit) {
if (field.value.length > maxlimit) 
	field.value = field.value.substring(0, maxlimit);
}

function addwishlist(ref) {
	var wishlistatual=getCookie("wishlistatual");
	var newitem=ref+'||';
	if(wishlistatual!=null && wishlistatual!='') {
		if(wishlistatual.indexOf('||'+newitem)==-1) {
			wishlistatual=wishlistatual+newitem;
			register_cookie('wishlistatual',wishlistatual);
		}
	} else {
		register_cookie('wishlistatual','||'+newitem);
	}
	alert("O Carro foi adicionado à sua lista.");
}

function verwishlist() {
	var wishlistatual=getCookie("wishlistatual");
	if(wishlistatual==null || wishlistatual=='') {
		alert("Sua lista está vazia\nUse o link disponível ao lado dos anúncios\npara adicionar carros à sua lista");
	} else {
		janela=window.open("../ache/wishlist.jsp?popup=1&lista="+wishlistatual,'wishlist','top=100,left=100,width=650,height=500,scrollbars=yes');
		janela.focus();
	}
}

function getCookie(Name)
	{
	var search = Name + "=";
	if (document.cookie.length > 0)
		{
		offset = document.cookie.indexOf(search)
		if (offset != -1)
			{
			offset += search.length
			end = document.cookie.indexOf(";", offset)
			if (end == -1)
				end = document.cookie.length
			return unescape(document.cookie.substring(offset, end))
			}
		}
	}

function setCookie(name, value, expire)
	{
	document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
	}

function register_cookie(nome,valor)
	{
	var c_today = new Date();
	var c_expires = new Date();
	c_expires.setTime(c_today.getTime() + 1000*60*60*24*5);
	setCookie(nome,valor,c_expires);
	}

function checkAll(formId, cName, check ) {
    for (i=0,n=formId.elements.length;i<n;i++)
        if (formId.elements[i].name.indexOf(cName) !=-1)
            formId.elements[i].checked = check;
}
function confirma(texto,obj) {
	acao=obj.onclick;
	obj.onclick="";
	if(confirm("Você tem certeza que deseja "+texto+" ?"))
		acao.call();
	else
		obj.onclick=acao;
	return false;
}	

<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 6;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;
// -----------------------------------------------------------------------------
// -->

document.write('<script language="VBScript" type="text/vbscript">\n');
document.write('<!-- // Visual basic helper required to detect Flash Player ActiveX control version information\n');
document.write('Function VBGetSwfVer(i)\n');
document.write('  on error resume next\n');
document.write('  Dim swControl, swVersion\n');
document.write('  swVersion = 0\n');
document.write('  \n');
document.write('  set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))\n');
document.write('  if (IsObject(swControl)) then\n');
document.write('    swVersion = swControl.GetVariable("$version")\n');
document.write('  end if\n');
document.write('  VBGetSwfVer = swVersion\n');
document.write('End Function\n');
document.write('// -->\n');
document.write('</script>\n');

<!-- // Detect Client Browser type
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Can't detect in all other cases
	else {

		flashVer = -1;
	}
	return flashVer;
}
// If called with no parameters this function returns a floating point value
// which should be the version of the Flash Player or 0.0
// ex: Flash Player 7r14 returns 7.14
// If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// loop backwards through the versions until we find the newest version
	for (i=25;i>0;i--) {
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);
		}
		if (versionStr == -1 ) {
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];

			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
                return versionNum >= reqVer && versionMinor >= reqMinorVer;
			}
		}
	}
	return (reqVer ? false : 0.0);
}
// -->
var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

function flashMe(id,src,width,height,wmode,vreturn,vmap){
	vreturn = (!(vreturn == undefined || vreturn == ''));
	vmap = (!(vmap == undefined || vmap == ''));
    url = src.split("?");
    if(url.length>2) {
        url[1]=url[1]+'?'+url[2];
    }
    var content;

    if(hasRightVersion){
		content = '<OBJECT id="'+id+'" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="'+height+'" width="'+width+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>';
		content += '<PARAM NAME="Movie" VALUE="'+url[0]+'">';
		if(wmode!=""){
			content += '<PARAM NAME="WMode" VALUE="'+wmode+'">';
		}
		content += '<PARAM NAME="swLiveConnect" VALUE="true">';
		content += '<PARAM NAME="AllowScriptAccess" VALUE="always">';
        if(url[1]!=""){
            content += '<PARAM NAME="FlashVars" VALUE="'+url[1]+'">';
		}
		content += '<EMBED MAYSCRIPT name="'+id+'" src="'+url[0]+'" AllowScriptAccess="always" quality="high" bgcolor="#FFFFFF" WIDTH="'+width+'" HEIGHT="'+height+'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"\n';
		if(url[1]!=""){
			content += ' FlashVars="'+url[1]+'"';
		}
		if(wmode!=""){
			content += ' wmode="'+wmode+'"';
		}
		content += ' contenteswLiveConnect="true"></EMBED>';
		content += '</OBJECT>';
	} else {
		gif = src.replace(/swf\//,"imagens/");
		gif = gif.replace(/.swf/,".gif");
		if(vmap){
			content = '<img src="'+gif+'" width="'+width+'" height="'+height+'" border="0" useMap="#'+id+'map" />';
		} else {
			content = '<a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" target="_blank"><img src="'+gif+'" width="'+width+'" height="'+height+'" border="0" /></a>';
		}
	}
	if(!vreturn){
		document.write(content);
	} else {
		return content;
	}
}
function getFlashMovieObject(movieName){
	if (window.document[movieName]) {
		return window.document[movieName];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
		if (document.embeds && document.embeds[movieName]) return document.embeds[movieName];
	}  else {
		return document.getElementById(movieName);
	}
}

function StopFlashMovie(movieName){
	var flashMovie=getFlashMovieObject(movieName);
	flashMovie.StopPlay();
}

function PlayFlashMovie(movieName){
	var flashMovie=getFlashMovieObject(movieName);
	flashMovie.Play();
	//embed.nativeProperty.anotherNativeMethod();
}

function RewindFlashMovie(movieName){
	var flashMovie=getFlashMovieObject(movieName);
	flashMovie.Rewind();
}
function NextFrameFlashMovie(movieName){
	var flashMovie=getFlashMovieObject(movieName);
	// 4 is the index of the property for _currentFrame
	var currentFrame=flashMovie.TGetProperty("/", 4);
	var nextFrame=parseInt(currentFrame);
	if (nextFrame>=10)
		nextFrame=0;
	flashMovie.GotoFrame(nextFrame);
}
function ZoominFlashMovie(movieName){
	var flashMovie=getFlashMovieObject(movieName);
	flashMovie.Zoom(90);
}
function ZoomoutFlashMovie(movieName){
	var flashMovie=getFlashMovieObject(movieName);
	flashMovie.Zoom(110);
}
function SendDataToFlashMovie(movieName,varName,varValue)
{
	var flashMovie=getFlashMovieObject(movieName);
	flashMovie.SetVariable("/:"+varName, varValue);
}
function ReceiveDataFromFlashMovie(movieName,varName){
	var flashMovie=getFlashMovieObject(movieName);
	return flashMovie.GetVariable("/:"+varName);
}
function montaFSCommand(qual,vreturn){
	vreturn = (!(vreturn == undefined || vreturn == ''));
	var functionName = qual+"_DoFSCommand = function(command,args) { eval(command + \"('\" + args + \"')\");}";
	eval(functionName);
	var content = '<SCRIPT LANGUAGE=VBScript\> \n';
	content += 'on error resume next \n';
	content += 'Sub '+qual+'_FSCommand(ByVal command, ByVal args)\n';
	content += ' call '+qual+'_DoFSCommand(command, args)\n';
	content += 'end sub\n';
	content += '</SCRIPT\>';
	if(!vreturn){
		document.write(content);
	} else {
		return content;
	}

}

function icarrosToogleStatus(idToToogle) {
    var elemento=MM_findObj(idToToogle);
    if(elemento.className && elemento.className.indexOf('ativo')!=-1) {
        pos=elemento.className.indexOf('ativo');
        if(pos!=-1) {
            elemento.className=elemento.className.substring(0,pos)+elemento.className.substring(pos+5);
        }
    } else {
        elemento.className=elemento.className+" ativo";
    }
}

function icarrosShowTab(tabTitleToShow,resize) {
    var parentElement= tabTitleToShow.parentNode;
    var found=false;
    var pos=0;
    for(var i in parentElement.childNodes) {
        var elemento=parentElement.childNodes[i];
        if(elemento.className && elemento.className.indexOf('tabTitle')!=-1) {
            pos=elemento.className.indexOf('tabTitleativo');
            if(pos!=-1 && elemento!=tabTitleToShow) {
                elemento.className=elemento.className.substring(0,pos)+elemento.className.substring(pos+13);
            }
            if(elemento==tabTitleToShow) {
                found=true;
                if(pos==-1) elemento.className=elemento.className+" tabTitleativo";
            }
        } else if(elemento.className && elemento.className.indexOf('tabContent')!=-1) {
            pos=elemento.className.indexOf('tabContentativo');
            if(pos!=-1 && !found) {
                elemento.className=elemento.className.substring(0,pos)+elemento.className.substring(pos+15);
            }
            if(found) {
                found=false;
                if(pos==-1)
                    elemento.className=elemento.className+" tabContentativo";
                if(resize)
                    parentElement.style.height=(elemento.offsetTop+elemento.offsetHeight+20)+'px';
            }
        }
    }
}
function icarrosResizeTab(tabParentName) {
    var parentElement=MM_findObj(tabParentName);
    for(var i in parentElement.childNodes) {
        var elemento=parentElement.childNodes[i];
        if(elemento.className && elemento.className.indexOf('tabContentativo')!=-1) {
            parentElement.style.height=(elemento.offsetTop+elemento.offsetHeight+20)+'px';
            break;
        }
    }
}


function showFacesErrors() {
    errorElement=MM_findObj("errorMessages");
    if(errorElement.innerHTML.toLowerCase().indexOf("<ul")!=-1) {
        f_dialogOpenDiv(errorElement, 'Erros encontrados', 'width=500,height=300');
    }
}

