function LimpaCampo(CaixaTexto)
{
	CaixaTexto.value=''
}

function LimpaCampoCidade(CaixaTexto, CodigoTexto, cbVerLista)
{
	CaixaTexto.value='';
	CodigoTexto.value='';
	cbVerLista.checked=false;
}

function LimpaCampoCidadeTipoPesquisa(CaixaTexto, CodigoTexto, TipoPesquisa)
{
	CaixaTexto.value='';
	CodigoTexto.value='';
	TipoPesquisa.value=0;	
}

function Clique(Objeto)
{
	Objeto.click();   
//	alert(Objeto.id) 
//	Objeto.text='Marcelo'
}

function CliqueFocus(ObjetoClique, ObjFocus, ObjRecFocus)
{
	ObjFocus.value=ObjRecFocus;
	ObjetoClique.click();
/*	alert(Valor) */
}

function ProximoFocus(ObjFocus, ObjRecFocus)
{
	ObjFocus.value=ObjRecFocus;
}

function Focus(Objeto)
{
	Objeto.focus()
}

function AtribuirValor(Objeto, Valor)
{
	Objeto.value=Valor; 
}

function AtribuirDoisValores(Objeto1, Valor1, Objeto2, Valor2)
{
	Objeto1.value=Valor1;
	Objeto2.value=Valor2;
}

function URLMapaReserva(ObjHyperLink, ObjDataInicio, ObjAnunciante, Mapa)
{
    var DataAux;
    var AnucianteAux;
    var a = document.getElementById ( ObjHyperLink );

    DataAux=ObjDataInicio.value;
    AnuncianteAux=ObjAnunciante.value;
    a.href='MapaReserva.aspx?DataInicio=' + DataAux + '&Mapa=' + Mapa + '&Anunciante=' + AnuncianteAux;
}

function ContinuarImovel(ObjetoVerificar1, ObjetoVerificar2, ObjetoAtribuir, Valor)
{
	if (ObjetoVerificar1.value=='')
	{
		ObjetoAtribuir.value=Valor-1
	}
	else
	{
		if (ObjetoVerificar2.value=='0' || ObjetoVerificar2.value=='')
		{
			ObjetoAtribuir.value=Valor
		}
		else
		{
			ObjetoAtribuir.value=Valor+1
		}
	}	
}

function ContinuarAnuncio(ObjetoVerificar,ObjetoAtribuir, Valor)
{
	if (ObjetoVerificar.value=='')
	{
		ObjetoAtribuir.value=Valor-1
	}
	else
	{
		ObjetoAtribuir.value=Valor
	}
}

function AtribuirQuatroValores(Objeto1, Valor1, Objeto2, Valor2, Objeto3, Valor3, Objeto4, Valor4)
{
	Objeto1.value=Valor1;
	Objeto2.value=Valor2;
	Objeto3.value=Valor3;
	Objeto4.value=Valor4;
}

function TamanhoImagem()
{
	alert('Foto não pode conter mais de 100KB e mais de 250 pixels de altura e largura. Utilize um software de imagens para ajustar a foto. Por exemplo Microsoft Photo Editor!');
}

function AtribuirTresValores(Objeto1, Valor1, Objeto2, Valor2, Objeto3, Valor3)
{
	Objeto1.value=Valor1;
	Objeto2.value=Valor2;
	Objeto3.value=Valor3;
}

function Visivel(ValorRef, ObjTeste, Obj)
{
	if(ValorRef==ObjTeste.value)
		{Obj.className='';}
	else
		{Obj.className='cssInvisivel';}
}

		
function CalculaTroco(ObjValor, ObjTaxa, ObjReceber, ObjTroco)
{
	var vlraux, vlr;
	var txaux, tx;
	var recaux, rec;
	var trocoaux, troco;

	if(ObjValor.value!='')
	{
		vlraux=ObjValor.value;
		vlr='';
		for(i=0;i<vlraux.length;i=i+1)
		{
			if(vlraux.charAt(i)!='.')
			{
				if(vlraux.charAt(i)==',')
				{
					vlr=vlr + '.'
				}
				else
				{
					vlr=vlr + vlraux.charAt(i)
				}
			}
		}
	}
	else
	{
		vlr='0';
	}
	
	if(ObjTaxa.value!='')
	{
		txaux=ObjTaxa.value;
		tx='';
		for(i=0;i<txaux.length;i=i+1)
		{
			if(txaux.charAt(i)!='.')
			{
				if(txaux.charAt(i)==',')
				{
					tx=tx + '.'
				}
				else
				{
					tx=tx + txaux.charAt(i)
				}
			}
		}
	}
	else
	{
		tx='0';
	}

	if(ObjReceber.value!='')
	{
		recaux=ObjReceber.value;
		rec='';
		for(i=0;i<recaux.length;i=i+1)
		{
			if(recaux.charAt(i)!='.')
			{
				if(recaux.charAt(i)==',')
				{
					rec=rec + '.'
				}
				else
				{
					rec=rec + recaux.charAt(i)
				}
			}
		}
	}
	else
	{
		rec='0';
	}

	troco=rec*1-(vlr*1+tx*1);
	trocoaux=String(troco);
	troco='';
	for(i=0;i<trocoaux.length;i=i+1)
	{
		if(trocoaux.charAt(i)!=',')
		{
			if(trocoaux.charAt(i)=='.')
			{
				troco=troco + ','
			}
			else
			{
				troco=troco + trocoaux.charAt(i)
			}
		}
	}
	ObjTroco.value=troco;
}

function DelayToolTip(objTempo, objClique, objDiv)
{
    var t = document.getElementById ( objTempo );

    if (t.value*1>999)
    {
        if (t.value*1>2000)
        {
            var d = document.getElementById(objDiv);
            if (d.style.display != 'block')
            {
                var b = document.getElementById ( objClique );
                b.click();
            }
        }
        else
        {
    		t.value=t.value*1+50;
    		var f;
    		f = "DelayToolTip('" + objTempo + "','" + objClique + "','" + objDiv + "')";
            setTimeout(f,50);
         }
    }   
}


function AbreLocacaoPopUp(e, ObjPopUp, ObjTitulo, ObjCliente, ObjLocacao, Locacao, ObjHospedagem, UrlHospedagem, ObjImovel, Imovel, ObjImovelDescr, ImovelDescr, ObjAtualiza, Atualiza)
{
    var d = document.getElementById ( ObjPopUp );
 
    if (d.style.display != 'block')
    {
        var a = document.getElementById ( ObjLocacao );
        var n = document.getElementById ( ObjTitulo );
        var cl = document.getElementById ( ObjCliente );
        var h = document.getElementById ( ObjHospedagem );
        var oa = document.getElementById ( ObjAtualiza );
        var im = document.getElementById ( ObjImovel );
        var imd = document.getElementById ( ObjImovelDescr );

        a.value=Locacao;
        if (cl.text==undefined) 
            {n.innerHTML=cl.outerText;} 
        else 
            {n.innerHTML=cl.text;}

        h.href=UrlHospedagem;
        oa.value=Atualiza;
        im.value=Imovel;
        imd.value=ImovelDescr;
        
        var ev=(!e)?window.event:e;//IE:Moz
        var x;
        var y;
        if (ev.pageX)
        {//Moz
            x = ev.pageX;
            y = ev.pageY;
        }
        else 
            if(ev.clientX)
            {//IE
                if(document.documentElement)
                {//IE 6+ strict mode
                    x = ev.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
                    y = ev.clientY + document.body.scrollTop + document.documentElement.scrollTop;
                }
                else 
                    if(document.body)
                    {//Other IE
                        x = ev.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
                        y = ev.clientY + document.body.scrollTop + document.documentElement.scrollTop;
                    }
                     else 
                     {
                        x=0; y=0;
                     }
             }
             else 
             {
                x=0; y=0;
             }

        x = x + 'px';
        y = y * 1 - 5;
        y = y + 'px';
        d.style.left = x;
        d.style.top = y;        
        d.style.display='block';
    }
}

function dicionariotraduzir(texto, langpair)
{   
    
	var link = "http://translate.google.com/translate_t?text=$text&langpair=$langpair";
    var arquivo = file(link);
    return arquivo;
    code =  strip_tags(arquivo[5]);
    ptInicial =  strpos(code,':');
    ptFinal = strpos(substr(code,ptInicial),'Translate');
    return trim(substr(code,ptInicial,ptFinal));
}
