

function carrega(url,element){
	var el=$pick($(element),$('conteudo'));
	el.addClass('load');
	el.innerHTML="<img src=\"common\/img\/load.gif\"> Aguarde, carregando...";
	
	var myHTMLRequest = new Request({
		url:url,
		onSuccess:function(responseText, responseXML){
			el.innerHTML=responseText;
			el.removeClass('load')
		},
		onFailure:function(instance){
			el.innerHTML=instance.response;
			el.removeClass('load');
			el.innerHTML=instance;
		},
		evalScripts: true
	}).send();
}

function pesquisar(ideDestaque, codTipo, codFinalidade, codCidade, codBairro, valminimo, valmaximo, numdormitorios, numSuites, numBanheiros, numVagaGaragem, numAreaUtilmin, numAreaUtilmax){
	var el=$('conteudo');
	var url="pesquisa_ajax.asp?ideDestaque="+ideDestaque+"&codTipo="+codTipo+"&codFinalidade="+codFinalidade+"&codCidade="+codCidade+"&codBairro="+codBairro+"&valminimo="+valminimo+"&valmaximo="+valmaximo+"&numdormitorios="+numdormitorios+"&numSuites="+numSuites+"&numBanheiros="+numBanheiros+"&numVagaGaragem="+numVagaGaragem+"&numAreaUtilmin="+numAreaUtilmin+"&numAreaUtilmax="+numAreaUtilmax;
	el.innerHTML="<img src=\"common/img/load.gif\"> Aguarde, carregando lista de imóveis...";

	var myHTMLRequest = new Request({
		url:url,
		update:$('conteudo'),
		onSuccess:function(responseText, responseXML){
			el.innerHTML=responseText;
		},
		onFailure:function(instance){
			el.innerHTML=instance.response;
			el.innerHTML=instance;
		},
		evalScripts: true
	}).send();
}

function getBairros(campo){
	var c_value = "";
	try{
	var virgula = "";
		for (var i=0; i < campo.length; i++){
			if (campo[i].checked){
				c_value = c_value + virgula + campo[i].value;
				virgula="|";
			}
		}
	}catch(e){}
	return c_value;
}

function adquira(){
	alert("vai");
	var adquiraHTMLRequest = new Request.HTML({
		url:'adquira.asp',
		update:$('container'),
		evalScripts: true
	}).post($('adquira'));
}
function format_telefone(obj){
	var v=obj.value;
	v=v.replace(/\D/g,"") //Remove tudo o que n?o ? d?gito
	v=v.replace(/(\d{2})(\d)/,"($1) $2") //Coloca barra entre o segundo e o terceiro digito
	v=v.replace(/(\d{4})(\d)/,"$1-$2") //Coloca barra entre o quinto e o sexto digito
	obj.value = v;
	return v
}


// antigas
function getObj( whichLayer ){
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  return elem; 
}

function change( whichLayer ){
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;  // if the style.display value is blank we try to figure it out here

  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'"+id+"')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac("+i+",'"+id+"')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = getObj(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
}


function teste(){
	var x=document.getElementsByTagName("p");
	for(var i=0;i<x.length;i++){
		var text=x[i].firstChild.nodeValue;
		x[i].firstChild.nodeValue="checado";
		alert(text);
	}
}


function teste3(){
	var x=document.getElementsByTagName("p");
	for(var i=0;i<x.length;i++){
		x[i].childNodes[1].style.color="#00FF00";
		x[i].childNodes[1].setAttribute('style','{color:#ff0000;}');
		x[i].childNodes[1].firstChild.nodeValue="pegou2";

	}
}
function format_number(obj){obj.value=obj.value.replace(/\D/g,"")}
function addfoto(){
	var img=document.createElement('IMG');
	img.setAttribute('src',''+(foto+2));
	img.setAttribute('id','foto'+foto);
	foto++
	img.onmouseover = function(){
		opacity(this.id,0,100,500);
		
        }
	var node=document.getElementsByTagName("center")[0];
	node.appendChild(img);

}


