$(document).ready(function(){
    //zdarzenia dla listy i listow referencyjnych.
    $('#panel_center a').tooltip({
        track: true,
        delay: 0,
        showURL: false,
        showBody: " - ",
        fade: 250
    });

    $('#panel_right a').tooltip({
        track: true,
        delay: 0,
        showURL: false,
        showBody: " - ",
        fade: 250
    });
// zdarzenia dla funkcji galeria
$('.ukryte').show('slow');

$('#galeria').cycle({
    fx:     'fade',
    speed:  'fast',
    timeout: 0,
    next:   '#next',
    prev:   '#prev'
});




    //zdarzenia dla napisali o nas
    $("a#fancy_id").fancybox({
        'padding'	: 0,
        'width'         : '100%',
        'height'	: '100%',
        'autoScale'	: false,
        'opacity'	: true,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'none'
    });

    $("a.fancy_id").fancybox({
        'padding'	: 0,
        'width'         : '100%',
        'height'	: '100%',
        'autoScale'	: false,
        'opacity'	: true,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'none'
    });

//zdarzenia dla segmentow
$('.widoczne').hide();
$('div.pietro1').hide();
$('div.pietro2').hide();
$('a.parter0').addClass('czarne');

 $('a.parter0').live('click',function(){
     $('a').removeClass('czarne');
     $(this).addClass('czarne');
     $('div.nparter0').fadeOut('slow', function() {
        $('div.parter0').fadeIn('slow');
     });
     return false;
 });
 $('a.pietro1').live('click',function(){
     $('a').removeClass('czarne');
     $(this).addClass('czarne');
     $('div.npietro1').fadeOut('slow', function() {
        $('div.pietro1').fadeIn('slow');
     });
     return false;
 });
  $('a.pietro2').live('click',function(){
      $('a').removeClass('czarne');
       $(this).addClass('czarne');
     $('div.npietro2').fadeOut('slow', function() {
        $('div.pietro2').fadeIn('slow');
     });
     return false;
 });

 //zdarzenia dla mieszkan
//$('.widoczne').hide();
$('div.r2d').hide();
$('div.rtech').hide();
$('div.pietro').hide();
$('a.parter').addClass('czarne');

 $('a.r3d').live('click',function(){
     $('div.nr3d').fadeOut('slow', function() {
        $('div.nr3d').hide();
        $('div.r3d').fadeIn('slow');
     });
     return false;
 });
  $('a.r2d').live('click',function(){
     $('div.nr2d').fadeOut('slow', function() {
        $('div.nr2d').hide();
        $('div.r2d').fadeIn('slow');
     });
     return false;
 });
  $('a.rtech').live('click',function(){
     $('div.nrtech').fadeOut('slow', function() {
        $('div.nrtech').hide();
        $('div.rtech').fadeIn('slow');
     });
     return false;
 });

 $('a.parter').live('click',function(){
     $('a').removeClass('czarne');
     $(this).addClass('czarne');
     $('div.pietro').fadeOut('slow', function() {
        $('div.parter').fadeIn('slow');
     });
     return false;
 });
  $('a.pietro').live('click',function(){
      $('a').removeClass('czarne');
       $(this).addClass('czarne');
     $('div.parter').fadeOut('slow', function() {
        $('div.pietro').fadeIn('slow');
     });
     return false;
 });



    //zdarzenia dla galerii

    $('.img_panel_right_galeria').live('click',function(){
        var fotka='<img class="wysrodkowane2" src="'+$(this).attr("name")+'" alt="zdjęcie'+$(this).attr("title")+'" /><br/>';
        $('#fotka').fadeOut('slow', function() {
            $('#fotka').html(fotka);
            $('#fotka').fadeIn('slow');
        });
        return false;
    });
        
    //zdarzenia dla budynkow wielokondygnacyjnych
    var mapka=$('#mapka_').html();
    $('.poziom').live('click',function(){
        var plik=$(this).attr('id');
        var lng=$(this).attr('lng');
        $('a').removeClass('pogrubiony');
        $('a.'+plik+'_txt').addClass('pogrubiony');
        $.ajax({
            type: "POST",
            url: "src/oferta/mieszkanie/ajax.php",
            data: 	"poziom="+plik+
                        "&l="+lng,
            success: function(html){
                $("#mapka_").html(html);
                mapka=$('#mapka_').html();
                $('#panel_center a').tooltip({
                    track: true,
                    delay: 0,
                    showURL: false,
                    showBody: " - ",
                    fade: 250
                });
            }     
        });
        return false;
    });
    $('.kondygnacja').live('click',function(){
        var plik=$(this).attr('name');
        var lng=$(this).attr('lng');
        $('a').removeClass('pogrubiony');
        $('a.'+plik+'_txt').addClass('pogrubiony');
        $.ajax({
            type: "POST",
            url: "src/oferta/mieszkanie/ajax.php",
            data: 	"poziom="+plik+
                        "&l="+lng,
            success: function(html){
                $("#mapka_").html(html);
                mapka=$('#mapka_').html();
                $('#panel_center a').tooltip({
                    track: true,
                    delay: 0,
                    showURL: false,
                    showBody: " - ",
                    fade: 250
                });
            }
        });
        return false;
    });
    
    //zdarzenia dla referencje
    $('a.referencje').click(function(){
        var plik=$(this).attr('name');
        $('#list').fadeOut('slow', function(){
            $('#list').html('<img src="img/onas/referencje/'+plik+'_list.jpg" />');
            $('#list').fadeIn('slow');
        });
        return false;
    });

    $('a.lista').live('click', function() {
        var link=$(this).attr('href');
        $('#referencje').fadeOut('slow', function(){
            $('#referencje').load(link+" div#referencje");
            $('#referencje').fadeIn('slow');
        });
        return false;
    });

});//koniec $(document).ready



/*

$("#loader").ajaxStart(function(){
$(this).show();
});
$("#loader").ajaxStop(function() {
$(this).hide();
});


*/
/*
    $("a#fancy_id").live('mouseover', function() {
        $("a#fancy_id").fancybox({
            'padding'	: 0,
            'width'         : '100%',
            'height'	: '100%',
            'autoScale'	: false,
            'opacity'	: true,
            'transitionIn'	: 'elastic',
            'transitionOut'	: 'none'
        });
        return false;
    });

*/
