<!--
//*********************************************************************
//************ Bloco efeitos com CSS e Classes *************************
//*********************************************************************

function urldecode(texto){
	texto=texto.replace(/\+/g," ");
	texto=unescape(texto);
	return texto;
}

	
//*********************************************************************
//****************** Bloco de código para exibir a msgbo e mostra form
//*********************************************************************
function dasabilitarenter() {
	var tecla = event.keyCode;
	if ((tecla == 13)) { 
	return false;
	}
	return tecla;
}

// Código para o teclado 
function tecladown (digito){
	if (digito == ''){
		document.form.senha.value = '';
		return;	
	}
	var pass = document.form.senha.value;
	if (pass.length >= 8){
		return;
	}
	document.form.senha.value = document.form.senha.value + digito;
}
function teclaclick(tecla){
	return false;
}
function teclaup(tecla){
	tecladown(tecla);
}
// --

// -- Contador para objeto TextArea.
function limita(campo){
	var tamanho = document.form[campo].value.length;
	var tex=document.form[campo].value;
	if (tamanho>=1539) {
		document.form[campo].value=tex.substring(0,1539); 
	}
	return true;
}

function contacampo(campo, tamtxt) {
document.form[tamtxt].value =  1540-document.form[campo].value.length;
}
// --

function SetHelp(txt) { help.innerText = txt ; }



//*********************************************************************
//************ Bloco para formatar/mascaras dos campos *********
//*********************************************************************
//*********************************************************************
//************ Bloco funcoes de formularios  *************************
//*********************************************************************
// essa function deverar ser a  function generica para abrir janelas popup !!!!!!
// deveremos sempre que possivel usá-la

	
function abrir_janela(valor,medidas) {
self.OnError=null;
window.open(valor,'Popup','toolbar=no,location=no,scrollbars=yes,status=no,menubar=no,resizable=yes,' + medidas);
}

	function CheckAllBox(theform,l,compare) {
	var nobj=theform.elements.length ;
	  for (var i=0;i<nobj;i++) {
			var x = theform.elements[i];
			var cmp=x.name;
			parte=cmp.substring(0,l);
			if (parte == compare) {
			 (x.checked ==true) ? x.checked =false: x.checked =true;
			}
			if(i > nobj) break;
		 }
	}

	// abaixo estam as function que deveram ser mudadas  com o tempo
	//sempre deveremos usar  functions genericas !!!!!!!!
	function CheckAll_tmp(theform) {
	nobj=theform.elements.length ;
	  for (var i=0;i<nobj;i++) {
			var x = theform.elements[i];
			var cmp=x.name;
			parte=cmp.substring(0,3);
			if (parte == 'kil') {
			 x.checked = theform.selall.checked;
			}
			if(i > nobj) break;
		 }
	}
	
	
function CheckAll() {
nobj=document.form1.elements.length ;
  for (var i=0;i<nobj;i++) {
   		var x = document.form1.elements[i];
		var cmp=x.name;
		parte=cmp.substring(0,6);
		if (parte == 'acesso') {
		 x.checked = document.form1.selall.checked;
		}
		if(i > nobj) break;
	 }
}

function onError(){ return false; }





//*********************************************************************
//************ Bloco efeitos com CSS e Classes *************************
//*********************************************************************
function changeClasse(classe,Cignore,Cchange){
  source=event.srcElement;
 if (source.tagName==Cignore) return true;
    source.className=classe;
}

function setvisible(theform,val) {
nobj=theform.elements.length ;
  var x = theform.getElementsByTagName('div');
	for (var i=0;i<=x.length;i++)
	{
		if (x[i].id == 'visible' + val ){
			x[i].style.display = 'block';
		}else{
			x[i].style.display = 'none';
		}
		if(i > x) break;
	}

}

function montaExpand(obj,n) {
	var str="<a href=\"javascript: mostrarObj('" + obj +"','" + n + "')\"><img id='arrow_expand" + n +  "' src='../images/setadown.gif' border='0'></a>";
	document.write(str);
}

function mostrarObj(obj,n) {
	nobj=document.getElementById(obj);
	try{sobj=document.getElementById("arrow_expand"+n);}catch(e){}
	  if(nobj.style.display=='none'){
		nobj.style.display ='block';
		try{sobj.src='../images/setaup.gif';}catch(e){}
	  }else{
		nobj.style.display ='none';
		try{sobj.src='../images/setadown.gif';}catch(e){}
	 }
}


/*/
Tenho que posicionar os codigo abaixo em outro local para facilitar a leitura humana
/*/
function mostrarContents(contents,size,obj) {
try {
	if(obj=='') obj='divtooltips';
	var tooltips = document.getElementById(obj);
		
		if(obj=='divtooltips'){
			tooltips.innerHTML =  '';
			tooltips.style.display='none';	
			if(contents){
				tooltips.style.top=  Mouse.y
				tooltips.style.left=Mouse.x +10
				tooltips.style.width=size;
			  }
		}	
		tooltips.innerHTML =   urldecode(contents) ;
		tooltips.style.display='block';
}catch(e){}

}

function hideobj( obj ) {
	try{
	   document.getElementById(obj).style.display= (document.getElementById(obj).style.display=='none')? 'block' : 'none';
	}catch(e){}
}
function urldecode(texto){
	texto=texto.replace(/\+/g," ");
	texto=unescape(texto);
	return texto;
}
function trim( text ) {
	if(text==null) return null;
	return text.replace(/^[ \t]+|[ \t]+$/g, "");
}
function cookiesenable(){
	r=(navigator.cookieEnabled == 0)? false:true
	return  r;
	}
	
	
function aStatus() { 
var as = document.getElementsByTagName("a")
    for(var i = 0; i < as.length; i++) { 
    as[i].onmouseover = function() { 
                        //window.status = this.title != '' ? this.title : this.innerHTML; 
                        window.status='.';
						return true; 
                        }
    as[i].onmouseout = function() { 
                       window.status ='.'
                       return true; 
                       }
    } 
}




var active_combo = null;
var combo_cliente = null;

function seta_active_combo(id_cliente,nome_cliente) {


  if(typeof active_combo =="undefined") {
	  alert('Não achei o controle')
  }else{
   combo_cliente= document.getElementById(active_combo);
   }
   
   combo_cliente.options.length = 0;
   func = new Option(nome_cliente,id_cliente,true,true);
   combo_cliente.options[0] = func;
    try{
		 janela.close();
		  }catch(e){};

}


function formatar(objeto, sMask, evtKeyPress) {

var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

if(!sMask) sMask="00/00/0000";

//funcao para formatar campo CPF, DATA, TEL, CEP, COD

 

if(document.all) { // Internet Explorer

nTecla = evtKeyPress.keyCode;

} else if(document.layers) { // Nestcape

nTecla = evtKeyPress.which;

} else {

nTecla = evtKeyPress.which;

if (nTecla == 8) {

return true;

}

}

sValue = objeto.value;

// Limpa todos os caracteres de formata‡ão que

// j  estiverem no campo.

sValue = sValue.toString().replace( "-", "" );

sValue = sValue.toString().replace( "-", "" );

sValue = sValue.toString().replace( ".", "" );

sValue = sValue.toString().replace( ".", "" );

sValue = sValue.toString().replace( "/", "" );

sValue = sValue.toString().replace( "/", "" );

sValue = sValue.toString().replace( ":", "" );

sValue = sValue.toString().replace( ":", "" );

sValue = sValue.toString().replace( "(", "" );

sValue = sValue.toString().replace( "(", "" );

sValue = sValue.toString().replace( ")", "" );

sValue = sValue.toString().replace( ")", "" );

sValue = sValue.toString().replace( " ", "" );

sValue = sValue.toString().replace( " ", "" );

fldLen = sValue.length;

mskLen = sMask.length;

i = 0;

nCount = 0;

sCod = "";

mskLen = fldLen;

while (i <= mskLen) {

bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))

bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

if (bolMask) {

sCod += sMask.charAt(i);

mskLen++; }

else {

sCod += sValue.charAt(nCount);

nCount++;

}

i++;

}

objeto.value = sCod;

if (nTecla != 8) { // backspace

if (sMask.charAt(i-1) == "9") { // apenas n£meros...

return ((nTecla > 47) && (nTecla < 58)); }

else { // qualquer caracter...

return true;

}

}

else {

return true;

}

}

function preencherCBox(val,div){
	retorno = objX.processarGeral('action=preencherCBox&Fp=1&compare=' + val,'include/jsxprocessar.php',div) ;
}


/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;
var lastone;
/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;
try{
    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0) 
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
           marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
			 newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
								  
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    lastone=theRowNum;
    return true;
	 
	 
	 

}catch(e){}

} 

function  change_bg_color(obj,cor){
	if(document.getElementById(obj).style.background != cor) document.getElementById(obj).style.background = cor;

	
}


/*************** functions  formatar valores (CW) *****/
function formata (campo,mascara,tecla) {
//	8 = BACKSPACE, 9 = TAB, 16 = ALT TAB, 37 = '<-', 39 = '->', 46 = DEL
   if (tecla == 8 || tecla == 9 || tecla == 16 || tecla == 37 || tecla == 39 || tecla == 46) return

   j=0;
   formatado = "";
   for (i=0; i<campo.value.length; i++) {
	   if (isNaN(campo.value.charAt(i))) continue; 
	   formatado = formatado + campo.value.charAt(i);
	   if (isNaN(mascara.charAt(++j)))
	      formatado = formatado + mascara.charAt(j++);
   }
  
   campo.value=formatado;
//  if (salto != 'ns') proximo(campo, mascara.length);
}

function formataN(campo,mascara,tecla) {

//  campo: objeto
//  mascara: string (ex.: '999.999.999,99')
//  tecla:  event.keyCode
//	8 = BACKSPACE, 9 = TAB, 16 = ALT TAB, 37 = '<-', 39 = '->', 46 = DEL, 32 = espaço

   if (tecla == 9 || tecla == 16 || tecla == 37 || tecla == 39 || tecla == 32) return

   formatado = "";
   i=campo.value.length;
   j=mascara.length;
   tc = i  // Tamanho do campo
   tm = j  // Tamanho da mascara de formatação

   var negativo = false

   // Verificando se o valor do campo -e negativo e se a mascara de formatação permite
   // valores negativos
   if ((campo.value.charAt(0) == '-') && (mascara.charAt(0) == '-')) {
      // Retiramos o sinal '-'
      campo.value= campo.value.substr(1)
      --i
      negativo = true
   }

   while (j >= 0) {
      while ((isNaN(campo.value.charAt(--i)) && i >= 0)) {};
      while ((mascara.charAt(--j) != '#') && (mascara.charAt(j) != '9') && (j >= 0))
//	  if ((tm - j) != (tc + 1)) formatado = mascara.charAt(j) + formatado
	     formatado = mascara.charAt(j) + formatado
      if (mascara.charAt(j) == '9')
	     if (i < 0)
	        formatado = '0' + formatado;
 	     else
	        formatado = campo.value.charAt(i) + formatado;
      else
	     if (i < 0)
	        j = -1
	     else
	        if (i == 0)
	           formatado = ((campo.value.charAt(i) == '0') ? '' : campo.value.charAt(i)) + formatado;
	        else
	           formatado = campo.value.charAt(i) + formatado;
   }
					
   if (formatado.charAt(0) == ".") {
      formatado = formatado.substr(1)
   }

   if (negativo || campo.value < 0)
      // Acresentamos o sinal '-' no início do campo formatado
      campo.value= "-" + formatado;
   else
      campo.value=formatado;
}


<!-- script para preencher os modelos -->

try{
	$(document).ready(function(){
	
	
	/* combo com as marcas, auto preencher os modelos 
	$("#marca").change(function(){
			  $.post("jsxprocessar.php",
			{ action: "preencherModelos", marca:  $("#marca").val() },
			function(data) {
				$("#modelo" ).html(data);
			});
			});
	*/
	});
}catch(e){}
