jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	
	return this;
};

function Link(div, tar)
{
	
 $(div).unload();

 $("div.promo_txt").animate({"top": "30px"}, "slow");
 $("div.box").animate({"width": "0px"}, "fast").animate({"width": "505px"}, "slow"); //animacja box

$(".box_content").load(tar, function()
          {
             $(div).find('a');
             
           }).fadeOut(1).delay(800,function(){$(div).fadeIn(700);});

};


 $(document).ready(function(){
  
		
//efekt gdy myszka nad dla logo i menu:
	$("a.pokaz").hover(function(){$(this).fadeOut(200);$(this).fadeIn(300);});
	$("a.pokaz_sub").hover(function(){$(this).fadeOut(200);$(this).fadeIn(300);});
	$("img#logo_img").hover(function(){$(this).fadeOut(300);$(this).fadeIn(500);});

//zwijanie wszytskich sub menu:


//sprawdzenie przeglądarki i odpowiednie dobranie wysokosci box i menu_space_bottom:
      
jQuery.each(jQuery.browser, function(i) {
  menu_height = $("html").height() -145;
  box_height = $("html").height() -183;
  



   $("#menu").css({height: menu_height + 'px'});
   $(".box").css({height: box_height + 'px'});
   $(".box_content").css({height: box_height -40 + 'px'});
});


  //znacznik aktywnego menu:
$("a.pokaz").click(function () {
	$("a.pokaz_sub").find("img:last").remove()
	$("ul.menu_ul_sub").slideUp("slow"); 
	 $("a.pokaz").find("img:last").remove()
$(this).prepend("<img src='gfx/w-prawo.png' class='menu_active' alt='' />");	
});


$("a.pokaz_sub").click(function () {
	 $("a.pokaz_sub").find("img:last").remove()
$(this).prepend("<img src='gfx/w-prawo.png' class='menu_active' alt='' />");	  
});


$("a.firma").click(function () {
	
	 $("a.pokaz").find("img:last").remove()
$(this).prepend("<img src='gfx/w-dol.png' class='menu_active' alt='' />");
	 $("ul.firma").slideToggle("slow"); 
});

$("a.olejek").click(function () {

	 $("a.pokaz").find("img:last").remove()
$(this).prepend("<img src='gfx/w-dol.png' class='menu_active' alt='' />");
	 $("ul.olejek").slideToggle("slow"); 
});

$("a.regulamin").click(function () {

	 $("a.pokaz").find("img:last").remove()
$(this).prepend("<img src='gfx/w-dol.png' class='menu_active' alt='' />");
	 $("ul.regulamin").slideToggle("slow"); 
});



  });

