onDomReady(function(){changeClassById(document,'click',['a#change_search','search_nav','search_nav_on'],['search','search_box','search_box_on']);if($('key_search')){addEvent($('key_search'),'keyup',function(){if(this.value){var ajax=new ajaxRequest("xml.php?file=key_search&key="+this.value);ajax.callBack(function(data){$('set_key').innerHTML='';var xmlData=data.responseXML;var properties=xmlData.getElementsByTagName('result');var propertiesValues=xmlData.getElementsByTagName('value');if(properties.length>0){$('set_key').style.display='block';for(var i=0,l=properties.length;i<l;i++){var propertiesList=addElement('li',{'styles':{'cursor':'pointer'}});var propertyValue=propertiesValues[i].firstChild.nodeValue
propertiesList.innerHTML=properties[i].firstChild.nodeValue;addEvent(propertiesList,'click',function(event,propertyValue){$('key_search').value=propertyValue;$('set_key').style.display='none';},propertyValue);$('set_key').appendChild(propertiesList);}}else{$('set_key').style.display='none';}});ajax.get();}});}
$css('span.email').forEach(function(item){var email=item.firstChild.nodeValue.replace('[at]','@');;item.innerHTML='<a href="mailto:'+email+'">'+email+'</a>';});var hmenuItem=$el($('hmenu'),'li.menu_display');hmenuItem.forEach(function(item,i){var hmenuShow=$el(item,'ul')[0];var linkShow=$el(item,'a')[0];addEvent(item,'mouseenter',function(){addClass(linkShow,'link_display');hmenuShow.style.display='block';if(window.ie6){$css('select').forEach(function(item){item.style.visibility='hidden'})};});addEvent(item,'mouseleave',function(){removeClass(linkShow,'link_display');hmenuShow.style.display='none';if(window.ie6){$css('select').forEach(function(item){item.style.visibility='visible'})};});});if($('select_operation')){addEvent($('select_operation'),'change',function(){var selected=this.options[this.selectedIndex];var selectShow=(selected.value=='2')?$('select_rent'):$('select_buy');var selectHide=(selected.value=='2')?$('select_buy'):$('select_rent');selectHide.style.display='none';selectHide.removeAttribute('name');selectShow.style.display='block';selectShow.name='price';selectShow.options[0].selected='selected';});}
addEvent($('zone'),'change',function(){if($('subzone'))$('select_zone').removeChild($('subzone'));var selected=this.options[this.selectedIndex];if(selected.className=='select_child'){var selectLoading=addElement('span',{'id':'select_loading'});selectLoading.innerHTML="<div><img src='mozaik/images/loading.gif' alt='loading' /> Loading list...</div>";$('select_zone').appendChild(selectLoading);var ajax=new ajaxRequest('xml.php?file=subzone&id_parent='+selected.value);ajax.callBack(setSubZone);ajax.get();}});function setSubZone(data){var xmlData=data.responseXML;var options=xmlData.getElementsByTagName('options');$('select_zone').removeChild($('select_loading'));if(options.length>0){var select=addElement('select',{'id':'subzone','name':'subzone'});var firstOption=addElement('option',{'value':''});firstOption.innerHTML='Todas las colonias';select.appendChild(firstOption);for(var i=0,l=options.length;i<l;i++){var option=addElement('option',{'value':options[i].getAttribute('id')});if(options[i].getAttribute('class_name'))option.className=options[i].getAttribute('class_name');option.innerHTML=options[i].firstChild.nodeValue;select.appendChild(option);}
$('select_zone').appendChild(select);}}
if($('display_contact')){addEvent($('display_contact'),'click',function(event){stopEvent(event);if(hasClass(this,'nav_hide')){reverseClass(this,'nav_hide','nav_show');reverseClass($('display_images'),'nav_hide','nav_show');}
$('property_images').style.display='none';$('property_contact').style.display='block';});addEvent($('display_images'),'click',function(event){stopEvent(event);if(hasClass(this,'nav_hide')){reverseClass(this,'nav_hide','nav_show');reverseClass($('display_contact'),'nav_hide','nav_show');}
$('property_contact').style.display='none';$('property_images').style.display='block';});}});