/* jartom */

$(document).ready(function(){
  var visible_p = $("#form_p").css("display");
  var visible_o = $("#form_o").css("display");

  if(visible_p=="none") {
    show_p = 0;
  } else {
    show_p = 1;
  }
  if(visible_o=="none") {
    show_o = 0;
  } else {
    show_o = 1;
  }
  
  $('#slider1')
  .anythingSlider({
		width								: 200,  
  	height							: 140,
  	buildArrows					: false,
  	buildNavigation     : false,
  	hashTags            : false, 
  	autoPlay            : true,
  	pauseOnHover        : true,
  	delay               : 3000, 
  	animationTime       : 600, 
  	resizeContents      : false,
  	easing              : "linear"
	});
	/*
  .anythingSliderFx({
   '.caption-bottom' : [ 'caption-Bottom', '50px' ]
  })
  .find('div[class*=caption]')
    .css({ position: 'absolute' })
    .prepend('<span class="close">x</span>')
    .find('.close').click(function(){
      var cap = $(this).parent(),
       ani = { bottom : -50 }; // bottom
      cap.animate(ani, 400, function(){ cap.hide(); } );
  });
  */
  
});

var loading = '<img src="../_img/_ico/loading.gif" alt="loading" width="16" height="16">';

function add_note(id_n,id_s) {
  var box = "#notes_"+id_s;
  $(box).html(loading).load("notes.php?notes_input=1&id_oferta="+id_n+"&id_search="+id_s+"&echo=1", {}, function(){
    var ct = parseInt($("#licz_notes").html());
    ct++;
    $("#licz_notes").html(ct);
  });
}

function del_note(id_n,id_s) {
  var box = "#notes_"+id_s;
  $(box).html(loading).load("notes.php?notes_delete=1&id_oferta="+id_n+"&id_search="+id_s+"&echo=1", {}, function(){
    var ct = parseInt($("#licz_notes").html());
    ct--;
    $("#licz_notes").html(ct);
  });
}

function del_note_rel(id_n,id_s) {
  var box = "#notes_"+id_s;
  $(box).html(loading).load("notes.php?notes_delete=1&id_oferta="+id_n+"&id_search="+id_s+"", {}, function(){
    window.location.href = 'index.php?p=7';
  });
}

function add_note_info(id_n) {
  var box = "#notes_add";
  $.get("notes.php?notes_input=1&id_oferta="+id_n+"&return=1", function(data){
  //$(box).load("notes.php?notes_input=1&id_oferta="+id_n+"&ret=1", {}, function(){
    //window.location.href = 'index.php?p=7';

    if(data=="1") {
      var ct = parseInt($("#licz_notes").html());
      ct++;
      $("#licz_notes").html(ct);
      $(box).html("<br><div id=\"notes_info\" style=\"color: green;\" align=\"center\">Nieruchomość została dodana do notesu.<div>");
    } else {
      $(box).html("<br><div id=\"notes_info\" style=\"color: red;\" align=\"center\">Nieruchomość już istnieje w notesie.<div>");
    }
    
    $("#notes_info").fadeOut(5000);

  });
}

function show_form_pytanie() {
  if(show_o==1) {
    $("#form_o").toggle();
    show_o = 0;
  }
  $("#form_p").toggle();
  if(show_p==1) { show_p = 0; }
  else{ show_p = 1; }
}

function show_form_obejrzyj() {
  if(show_p==1) {
    $("#form_p").toggle();
    show_p = 0;
  }
  $("#form_o").toggle();
  if(show_o==1) { show_o = 0; }
  else{ show_o = 1; }
}
