$(document).ready(function() {

 $('#navH .p0 > li').gazeta(gfunc.nav);
 $('#navH .p0 > li').each(function(){
  if($(this).hasClass('active')){
   $(this).prev().addClass('beforeAcive');
   $(this).next().addClass('afterAcive');
  }
 });

 // search
 var selOptionsLength = $('#searchH_sel option').length;
 if(selOptionsLength > 0) {

  var searchHTML = '<div class="searchSel0">';

  //check for active element if not specified get first
  var activeSearch = $('#searchH_sel option').eq(0);
  if($('#searchH_sel option:selected').length > 0){
   activeSearch =  $('#searchH_sel option:selected')
  }
  searchHTML += '<a href="#" class="selectedVal" alt="'+activeSearch.attr("value")+'">'+activeSearch.text()+'</a>';
  
  // go trough services select and create proprer html
  for(var i = 0; i < selOptionsLength; i++){
   var currentOption = $('#searchH_sel option').eq(i);
   searchHTML += '<a href="#" class="'+currentOption.attr("value")+'" alt="'+currentOption.attr("value")+'">'+currentOption.text()+'</a>';
  }

  searchHTML += '</div>';

  //build it
  $('#searchH .b').wrap('<div class="searchSel">');
  $('.searchSel').prepend(searchHTML);

  $('#searchH .searchSel0').hover( function(){ $('#searchH0').addClass('hovered'); $('#navtop_wrap').addClass('navTopIndex'); }, function(){ $('#searchH0').removeClass('hovered'); $('#navtop_wrap').removeClass('navTopIndex'); });

  // change search type after click
  $('.searchSel0 a').click(function(e){
    e.preventDefault();
    if( $(this).hasClass('selectedVal') ) return;
    $('.searchSel0 .selectedVal').text( $(this).text() );
    $('.searchSel0 .selectedVal').attr( 'alt', $(this).attr('alt') );
    $('.searchSel0 a').removeClass('selected');
    $(this).addClass('selected');

    $('#searchH_sel option:selected').attr('selected','');
    $('#searchH_sel option[value='+$(this).attr("alt")+']').attr('selected','selected');
    $('#searchH_sel').change( function(){ searchH.searchH_sel = $(this).find(':selected').attr('value') } );  
    $('#searchH_sel').change();

    // google logo in search bar
    if($(this).attr('alt')=='internet') {
     if($('#searchH .t').val()=='') {$('#searchH .t').addClass('google')};
    } else {
     $('#searchH .t').removeClass('google');
    }
    $('#searchH .t.google').focus(function() {$(this).removeClass('google')});
    $('#searchH .t.google').blur(function() {
     if($(this).val()=='') {$(this).addClass('google')}
    }); 
  });
 }
 
  /* ie - ukrycie pustych wierszy */
  if($.browser.msie){
   $('#col_left .content_row').each(function() {
    if ($(this).gazeta(gfunc.emptyChild, '.holder_cl')) $(this).hide();
   });

   $('#holder_402, #holder_403').each(function() {
    if ($(this).gazeta(gfunc.emptyChild, '.wrap')) $(this).hide();
   });

   $('#bottom_wrap').each(function() {
    if ($(this).gazeta(gfunc.emptyChild, '#holder_401')) $('#holder_401').hide();
   });

   $('#bottom_wrap').each(function() {
    if ($(this).gazeta(gfunc.emptyChild, '#holder_404')) $('#holder_404').hide();
   });
   
   var wi = 0;
   $('.mod_tv_header .c1').children().each(function(){ wi += $(this).outerWidth() });
   $('.mod_tv_header .c1').css({ 'width': wi+10+'px' });
  }


});

