<!--
/*
function down() { 
	if (event.button==2) { 
		alert("Todos os direitos reservados à www.mimoveisribeirao.com.br."); 
	}
} 

function up() { 
	if (event.button==2) { 
		alert("Respeite os Direitos Reservados."); 
	 } 
} document.onmousedown=down; document.onmouseup=up; 

function MM_displayStatusMsg(msgStr) { //v1.0 
	status=msgStr; 
	document.MM_returnValue = true;
} */


//  colocar no input onKeyPress="return(mascara_moeda(this,'.',',',event))
function mascara_moeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 13) return true;
    key = String.fromCharCode(whichCode); // Valor para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
    aux = '';
    for(; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) objTextBox.value = '';
    if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
        objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
}

// Mascara de cep no input=text
function mascara_cep(cep) {
	if(cep.value.length == 5) {
		cep.value += '-';
	}
	JumpField(cep);
}
	
// Mascara de telefone no input=text
function mascara_tel(tel) {
	if(tel.value.length == 0) tel.value += '(';
	if(tel.value.length == 3) tel.value += ')';
	if(tel.value.length == 4) tel.value += ' ';
	if(tel.value.length == 9) tel.value += '-';
}
	
// Mascara de telefone no input=text
function mascara_data(data) {
	if(data.value.length == 2) data.value += '/';
	if(data.value.length == 5) data.value += '/';
}
	
// Pula de uma Campo a Outro Automático
function JumpField(fields) {

	if (fields.value.length == fields.maxLength) {
		for (var i = 0; i < fields.form.length; i++) {
			if (fields.form[i] == fields && fields.form[(i + 1)] && fields.form[(i + 1)].type != "hidden")
			{
				fields.form[(i + 1)].focus();
				break;
			}
		}
	}
}


function soNumeros(v){
    return v.replace(/\D/g,"")
}
function execmascara(){
    v_obj.value=v_fun(v_obj.value)
} 

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}
function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}
 
function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}
 
function soNumeros(v){
    return v.replace(/\D/g,"")
}
 
function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}
 
function cpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}
 
function cep(v){
    v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}
 
function cnpj(v){
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}
 
function romanos(v){
    v=v.toUpperCase()             //Maiúsculas
    v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
    //Essa é complicada! Copiei daqui: http://www.diveintopython.org/refactoring/refactoring.html
    while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
        v=v.replace(/.$/,"")
    return v
}
 
function site(v){
    //Esse sem comentarios para que você entenda sozinho ;-)
    v=v.replace(/^http:\/\/?/,"")
    dominio=v
    caminho=""
    if(v.indexOf("/")>-1)
        dominio=v.split("/")[0]
        caminho=v.replace(/[^\/]*/,"")
    dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
    caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
    caminho=caminho.replace(/([\?&])=/,"$1")
    if(caminho!="")dominio=dominio.replace(/\.+$/,"")
    v="http://"+dominio+caminho
    return v
}
 
function Mostrar(objeto) 
{
	var id = objeto.id;
	id = id.replace('_m','');
	var indice = document.getElementById( id + '_e' );
	var menu = document.getElementById( 'menu_' + id );
	menu.style.display = 'block';
	objeto.style.display = 'none';
	indice.style.display = 'block';
}
function Esconder(objeto)
{
	var id = objeto.id;
	id = id.replace('_e','');
	var indice = document.getElementById( id + '_m' );
	var menu = document.getElementById( 'menu_' + id );
	menu.style.display = 'none';
	objeto.style.display = 'none';
	indice.style.display = 'block';
}

// seleciona todos os itens de um checkbox
function seleciona()
{
if (F1.master.checked==true)
for (cont=0; cont<F1.c1.length;cont++)
{
F1.c1[cont].checked=true
}

if (F1.master.checked==false)
for (cont=0; cont<F1.c1.length; cont++)
{
F1.c1[cont].checked=false
}

}

// Remover itens selecionados.  url = excPedidos.php?ids=
function excluirSelecionados( id, url) {
	certeza(''+url+checkboxes(id), 'pedido(s)' )
}


// Removes leading whitespaces
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}


// sequencia de numeros do checkbox separado por virgula
function checkboxes(field,id) {
	var i = field.length;
	if( i == "undefined" || i == "" || i == null ) {
		text = id;
	} else {
		arr = new Array(i);
		var text="";
		for( var t=0; t<i; t++ ) {
			if(field[t].checked) {
				arr[t] = field[t].value;
				text = text + arr[t] + ",";
			}
		}
	}
	return text;
}


function enviar( url, pergunta, msg, pagina  ) {
 var num = confirm(" "+pergunta);
  if ( num == true ) {
    mesma_pagina(url);
	alert(" "+msg);
	mesma_pagina(pagina);

  }
}


function checarpopup() {
 	alert("DESABILITOU O BLOQUEADOR DE POP-UPS ?");
}

function confirmacao( url, texto  ) {
 var num = confirm(""+texto);
  if ( num == true ) {
     mesma_pagina(url);
  }
}


function certeza( url, baner ) {
 var num = confirm("Tem certeza que quer EXCLUIR "+baner+"?");
  if ( num == true ) {
     mesma_pagina(url);
  }
}


function verificar( url, baner ) {
 var num = confirm("Tem certeza que quer EXCLUIR "+baner+"?");
  if ( num == true ) {
     capa(url);
  }
}

function excluindo( url,codigo,text) {
 var num = confirm("Tem certeza que quer EXCLUIR "+text+"?");
  if ( num == true ) {
     enviaPagina(url,codigo,text);
  }
}

function campoObrigatorio(codigo,text) {
	if(codigo == "") {
		alert("Selecione "+text); 
		return false;
	}
	return true;
}

// Funções de Página e Window e Poup-up
function janelacentral( url, wd, hg ) {
     w = screen.width;
     h = screen.height;
     t = (h/2) - (hg/2);
     l = (w/2) - (wd/2);
     window.open(url, "", "width="+wd+", height="+hg+", scrollbars=yes, toolbars=no, top="+t+", left="+l);
}

function pagina(url) {
    window.open(url);
}

function abrePagina(url, config) {
	window.open(url,'',config);
}

function capa(url) {
	parent.parent.capa.location.href=url;
}

function mesma_pagina(url) {
	location.href=url;
}

function enviaPagina(url,codigo,text) {
	if(codigo!="") {
		capa(url);	
	}else {
		alert("Selecione "+text);
	}
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	var radioLength = radioObj.length;
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked ) {
			return radioObj[i].value;
		}
	}
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	var radioLength = radioObj.length;
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

-->
