function show_tip(id, url){
  	  
  	  var a = $("#tip2"+id);
	  var offset = a.offset();	

	  $("#tip"+id).remove();
	  $("body").append("<div id=\"tip"+id+"\" class=\"tooltip\" style=\"top:"+(offset.top+20)+"px;left:"+(offset.left+5)+"px;\"></div>");
      $("#tip"+id).html('czekaj... trwa pobieranie opisu.');
      
      $.post(url, {id: id },
  		
      	function(data){
    		if(data.length > 0){
    			$("#tip"+id).html(data); 
    		} else {
    			alert('Coś poszło nie tak');
    		}
  		});
  	
};

function show_portolio(url){

      $.post(url, {id:1},
  		function(data){
    		if(data.length > 0){
    			$("#realizacje_div").html(data); 
    		} else {
    			alert('Coś poszło nie tak');
    		}
  		});
   
}

function sendForm(div, action){
	var form = $("#"+div);
	form.attr('action', action);
	form.submit();
}



$(document).ready(function(){
      
    $('.tip').mouseover(function(){
  		
  	  var id = this.id;
  	  var tresc = $("#tresc_"+id).html();
  	  
  	  var a = $("#"+id);
	  var offset = a.offset();	
	  
	  $("#info_"+id).remove();
	  $("body").append("<div id=\"info_"+id+"\" class=\"tooltip\" style=\"top:"+(offset.top+20)+"px;left:"+(offset.left+5)+"px;\"></div>");
      $("#info_"+id).html(tresc);
		

    });
    
   	$('.tip').mouseout(function(){
  	  var id = this.id;
  	  var tresc = this.title;	  
	  $("#info_"+id).remove();
    });
    
	$(".wyniki tr:even").addClass("abc");
	$(".wyniki tr:odd").addClass("def");
	$(".wyniki tr").mouseover(function() {
    	$(this).addClass("tr_hover");
	}).mouseout(function() {
    	$(this).removeClass("tr_hover");
	});
	
	
   	$('.close_btn').click(function(){
   		alert('hello');
    	var id = this.id;

    	setTimeout(function(){$("#tip"+id).fadeOut();}, 300);
    	setTimeout(function(){$("#tip"+id).remove();}, 700);
    	 
    }); 
    
    $("#checked_box").toggle(
      function () {
      	$("#checked_box").attr('checked', 'true');
        $('.ptaszki').attr('checked', 'true');
      },
      function () {
      	$("#checked_box").removeAttr('checked');
        $('.ptaszki').removeAttr('checked');
      }
    );

	$('.kat_li').click(function(){
   		var div = $(this);
  	 	var id = div.attr('id');
  	 	var title = div.attr('title');
  	 	
  	 	if(title == 'open'){
  	 		$('#ul_'+id.substr(3, id.length)).hide();
			div.attr('title', 'close');
			div.css({'background' : 'url(http://dsz.com.pl/images/katalogi_sprite.png) no-repeat left'});
  	 	} else {
			$('#ul_'+id.substr(3, id.length)).show();
			div.attr('title', 'open');
			div.css({'background' : 'url(http://dsz.com.pl/images/katalogi_sprite.png) no-repeat right'});
  	 	}
    });
    
    $(".kolej_div").dblclick(function(){ 
    	var id = $(this).attr('id');
    	id = id.substring(2, id.length);
    	
    	$(".kolej_div").each(function(i){ 
    		var id_buf = $(this).attr('id');
    		id_buf = id_buf.substring(2, id_buf.length);
    		$(this).empty(); 
    		$(this).html('<div class="kolej_span">'+id_buf+'</div>');
    	});

    	$(this).empty(); 
    	$(this).html('<div class="kolej_span"><input type="text" class="kolejnoscInput" name="kolej_item['+id+']" value="'+id+'" /></div>');
    });
    
    $("#portolio_prev").click(function(){ 
    	$("#loader").show();
    	
    	$("#loader").hide();
    	return false;
	});
	
 });
