// funkcje ogłoszeń

function rozwin(x, txt1, txt2)
{
    if (x.innerHTML == txt1)
    {
        $("a[class*='pokaz_opisy']").html(txt2);
        $("i.opis").fadeIn('slow'); //addClass('opis_on');
        
    }else
    {
        $("a[class*='pokaz_opisy']").html(txt1);
        $("i.opis").fadeOut('slow');
    }
    
    x.blur();
    
    return false;
}

function wyczysc_form()
{
    location.href = '/szukaj,,,,,.html';
}

function ulubione(id)
{
    $('#ulu_'+id).load('box.php?mod=main&pg=ulubione&id='+id);
    $('#ulu_'+id).blur();
    
    return false;
}


var closeId = 0;

function zamknij()
{

    $('div[class*="wiecej_cont"]').each(function (){
        $(this).fadeOut('slow');
    });
    $('a[class*="wiecej_li"]').removeClass('li_hover');

    clearTimeout(closeId);
    closeId = 0;    
}

$(document).ready(function() { 
    
   $('a[class="tytul_click"]').click(function (ev)
   {
       $('#opis_'+$(this).attr('rel')).toggle('slow');
       ev.preventDefault();
       $(this).blur();
   });
    
   $('li[class*="wiecej_tr"]').mouseenter(function ()
   {
       zamknij();
       id = $(this).attr('id') + '_content';
       off = $(this).offset();
       a_top = Math.round($('#' + id).height() / 2);
       a_top = parseInt(off.top - a_top);
       if (a_top < 10) a_top = 10;
       left = parseInt(off.left + $(this).innerWidth());
       
       $('#' + id).css({'left': left + 'px', 'top': a_top + 'px'});
       $('#' + id).fadeIn('slow'); 
       $('#' + $(this).attr('id') + '_a').addClass('li_hover');
              
   });
   
   $('li[class*="wiecej_tr"]').mouseleave(function ()
   {
        closeId = setTimeout("zamknij();", 1000);
   });
   
   $('div[class*="wiecej_cont"]').mouseenter(function ()
   {
       if (closeId!=0)
       {
           clearTimeout(closeId);
           closeId = 0; 
       }
   });
   
   $('div[class*="wiecej_cont"]').mouseleave(function ()
   {
        closeId = setTimeout("zamknij();", 1000);
   });
   
   $(document).click(function ()
   {                                              
       zamknij();
   });
   
   $("#menu_fnd").autocomplete('box.php', {extraParams: {mode:'fraza', mod: 'main', pg: 'hint'} });
   $("#glowna_fnd").autocomplete('box.php', {extraParams: {mode:'fraza', mod: 'main', pg: 'hint'} });
   $("#menu_miasto").autocomplete('box.php', {extraParams: {mode:'miasto', mod: 'main', pg: 'hint'} });
                                                                                                         
});

