
function setContentMinHeight(){var contentsHeight=$('#content').innerHeight();$('#header_container').css({"top":contentsHeight});}
function animatePromotions(postponeTime){var initialLabelDelay=900;var labelVisibilityTime=6000;var defaultEffectDuration=400;var slowEffectDuration=600;var totalPromotionVisibilityTime=slowEffectDuration+initialLabelDelay+(3*defaultEffectDuration)+labelVisibilityTime-900;var allPromotions=$('.promo_photo_holder');allPromotions.each(function(i){var promo_photo=$(this).find('.promo_photo');var promo_label=$(this).find('.promo_label');promo_photo.delay(postponeTime).delay(i*totalPromotionVisibilityTime).fadeIn(slowEffectDuration).delay(initialLabelDelay+(2*defaultEffectDuration)+labelVisibilityTime).delay(0,function(){if(i==allPromotions.length-1){animatePromotions(0);}promo_photo.dequeue();}).fadeOut(defaultEffectDuration);promo_label.delay(postponeTime).delay(i*totalPromotionVisibilityTime).delay(initialLabelDelay).slideToggle(defaultEffectDuration).delay(labelVisibilityTime).fadeOut(defaultEffectDuration);});}
function set_classic_search_prices(){if($("input[name=offer_type_id]:checked").val()=='1'){$('.classicSearchBuy').css('display','inline');$('.classicSearchBuy').removeAttr('disabled');$('.classicSearchRent').css('display','none');$('.classicSearchRent').attr('disabled','disabled');}
else if($("input[name=offer_type_id]:checked").val()=='2'){$('.classicSearchBuy').css('display','none');$('.classicSearchBuy').attr('disabled','disabled');$('.classicSearchRent').css('display','inline');$('.classicSearchRent').removeAttr('disabled');}}
function set_furnished(){var the_radio_val=$("input[name=offer_type_id]:checked").val();jQuery.ajax({data:'offer_type_id='+the_radio_val,success:function(request){jQuery('#offer_type_furr').html(request);},type:'post',url:'/search/offer_type_furr'});}
function stop_slideshow(){var allPhotos=$('.slideshowPhoto');allPhotos.each(function(){$(this).stop(true,true);$(this).css("display","none");});jQuery.fx.off=true;}
function set_photos_switch(){var photo=$("#main_photo");$("a[rel='slideshow']").each(function(){$(this).attr("rel",$(this).attr("href"));$(this).css("cursor","pointer");$(this).removeAttr("href","#");$(this).removeAttr("target");$(this).click(function(){stop_slideshow();$("#slideshow_photo_holder").css("display","none");$("#main_photo_holder").css("display","block");photo.css("background-image","url("+$(this).attr("rel")+")");});});}
function start_slideshow(postponeTime){jQuery.fx.off=false;var defaultEffectDuration=200;var slowEffectDuration=400;var photoVisibilityTime=3000;var allPhotos=$('.slideshowPhoto');$("#slideshow_photo_holder").css("display","block");$("#main_photo_holder").css("display","none");var totalSlideshowVisibilityTime=slowEffectDuration+photoVisibilityTime+defaultEffectDuration;allPhotos.each(function(i){$(this).delay(postponeTime).delay(i*totalSlideshowVisibilityTime).fadeIn(slowEffectDuration).delay(defaultEffectDuration+photoVisibilityTime).delay(0,function(){if(i==allPhotos.length-1){start_slideshow(0);}$(this).dequeue();}).fadeOut(defaultEffectDuration);});}
function cleanup_children(scope){var parents_selected=$("#"+scope).find('.parentCheck:checked');var all_children=$("#"+scope).find('.childCheck');var parents_selected_ids=[];if(parents_selected.length>0){parents_selected.each(function(){parents_selected_ids.push($(this).val());});}
all_children.each(function(){if(parents_selected.length>0){var child_class=$(this).attr("class");var child_parent_id=child_class.substring(child_class.indexOf("parent_id")+10,child_class.length);if(child_parent_id===''||$.inArray(child_parent_id,parents_selected_ids)==-1){$(this).parent().css("display","none");$(this).attr('checked',false);}
else{$(this).parent().css("display","block");}}
else{$(this).parent().css("display","block");}});}
function toggle_parent_children(scope,parent_id){var parent=$("#"+scope).find('#parent_id_'+parent_id);var parent_children=$("#"+scope).find('.parent_id_'+parent_id);cleanup_children(scope);parent_children.each(function(){if(parent.attr('checked')){$(this).parent().css("display","block");$(this).attr('checked',true);}
else{$(this).attr('checked',false);}});}
function filter_children_by_parent(scope){var all_parent_checkboxes=$("#"+scope).find('.parentCheck');all_parent_checkboxes.each(function(){$(this).click(function(){toggle_parent_children(scope,$(this).val());});});}
function set_observer_select(scope,observer_id){var the_observer=$("#"+observer_id);adapt_content_for_low_res();var all_checked_checkboxes_length=$("#"+scope).find(".omega").find('input:checked').length;if(all_checked_checkboxes_length==1){var the_checkbox=$("#"+scope).find(".omega").find('input:checked').first();jQuery.ajax({data:'city_id='+the_checkbox.val(),success:function(request){jQuery('#locations_container').html(request);},type:'post',url:'/search/get_locations_by_city'});}
else{jQuery.ajax({data:'city_id='+'',success:function(request){jQuery('#locations_container').html(request);},type:'post',url:'/search/get_locations_by_city'});}}
function activate_observer_selection(scope,observer_id){var all_checkboxes=$("#"+scope).find('input');all_checkboxes.each(function(){$(this).click(function(){set_observer_select(scope,observer_id);});});set_observer_select(scope,observer_id);}
function adapt_content_for_low_res(){var windowWidth=$(window).width();if(windowWidth<1015){$('body').css({"margin-left":"-135px"});}
else{$('body').css({"margin-left":"0"});}}
$('#content').ready(function(){setContentMinHeight();});$(window).load(function(){adapt_content_for_low_res();setContentMinHeight();animatePromotions(0);});$(window).resize(function(){adapt_content_for_low_res();});
