var re_object_card_window = function(url){
    window.open(url, "Rees" + Math.ceil(Math.random()*100), "resizable=yes,scrollbars=yes,status=no,left=0,top=0,width=620,height="+$(window).height());
}


$(document).ready(function() {
    
    
    $('.slideshow').cycle({
		fx: 'fade', 
        speed:   1000, 
        timeout: 5000, 
        pager:  '#nav' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
	$('.popup').bind('click', function(){
	   re_object_card_window($(this).attr('href'));
	   return false; 
	});
	
	$('#municipality').bind('change', function(){
            $.ajax({
                url:'location.php',
                data: {type:'city', estate_type: $('#estate_type').val(), municipality: $(this).val()},
                success: function(r){
                    $('#city').replaceWith(r);
                } 
            });

            $.ajax({
                url:'location.php',
                data: {type:'block', estate_type: $('#estate_type').val(), municipality: $(this).val()},
                success: function(r){
                    $('#block').replaceWith(r);
                } 
            });
       });


       $('.hint').hint();
       $('form').submit(function(){
           $('.hint').clear_hints();
       });

       $('#estate_type').change(function(){
           window.location.href = $('#' + $(this).val() + '_url').attr('href');
       });
    
    $('a[rel*=lightbox]').lightBox();
	
});
