function windowBlank(path)
{
  window.open(path, '_blank', 'left=400, top=100, width=500, height=350, resizable=1, scrollbars=1');
  
  return false;
}

$.fn.nextUntil = function(expr) {
    var match = [];
 
    if ( expr.jquery )
      expr = expr[0];
 
    // We need to figure out which elements to push onto the array
    this.each(function(){
        // Traverse through the sibling nodes
        for( var i = this.nextSibling; i; i = i.nextSibling ) {
            // Make sure that we're only dealing with elements
            if ( i.nodeType != 1 ) continue;
 
            // If we find a match then we need to stop
            if ( expr.nodeType ) {
    if ( i == expr ) break;
            } else if ( jQuery.multiFilter( expr, [i] ).length ) break;
 
            // Otherwise, add it on to the stack
            match.push( i );
        }
    });
 
    return this.pushStack( match, arguments );
};

$(document).ready(function(){

$("a[href$='lightbox']").css({
 'color' : 'red'
});

$('strong.headtime').next("p").children(".vice-na-konci").hide();
	
	var options = {exact:"whole",style_name_suffix:false,keys: $("#phrase").val()};
	  jQuery(function(){
	    jQuery(document).SearchHighlight(options);
	  });
  $('strong.headtime').each(function () {
	      $(this).css("cursor", "pointer");
  });
  $('strong.headtime').click(function () {
    var url = $(this).next("p").children(".vice-na-konci").attr("href");
    if (url) {
      window.location = url;
    }
  });
  
  $('strong.headtime').each(function () {
    var url = $(this).next("p").children(".vice-na-konci").attr("href");
    if (!url) {
      $(this).css("text-decoration", "none");
      $(this).css("cursor", "default");
    }
  });
  //$('strong.headtime').hover( function () { $(this).css("text-decoration", "none") }, function () { $(this).css("text-decoration", "underline") });
  
  $('strong.headtime').prev("em").each(function() {
    $(this).text( $(this).text().replace(/[ ]*/g,"") );
  });
  
  $('.novinka > em').each(function() {
    $(this).text( $(this).text().replace(/[ ]*/g,"") );
  });
  
  $(".novinka > h3").hover( function() 
  {
    var url = $(this).parent(".novinka").children('p').children("a.oranzovyodkaz,a.vice-na-konci").attr('href');
    if (!url) {
      $(this).css("cursor", "default");
      return;
    }
    $(this).css("color", "#ff6600") 
  }, function ()
  {
    var url = $(this).parent(".novinka").children('p').children("a.oranzovyodkaz,a.vice-na-konci").attr('href');
    if (!url) return;
    $(this).css("color", "#008DB2") }
  );

  $(".novinka > h3").click(function() {
    var url = $(this).parent(".novinka").children('p').children("a.oranzovyodkaz,a.vice-na-konci").attr('href');
    if (!url)
    {
      $(this).hover(function() {}, function() {});
    } else {
      window.location = url;
    }
  });  
  
  $(".novinka > h3").each(function() {
    var url = $(this).parent(".novinka").children('p').children("a.oranzovyodkaz,a.vice-na-konci").attr('href');
    if (!url)
    {
      $(this).css("text-decoration", "none");
    } 
  });  

  $(".hideme").hide();
  $(".sbalitvse").hide();
  $(".showhide").click(function() { $(this).next("div.hideme").toggle(); });
  $(".showhide").hover( function () { $(this).css('color', '#FF6600') }, function () { $(this).css('color', '#008DB2') }  );
  //$(".hideme div a em").hover( function () { $(this).css('text-decoration', 'none') }, function () { $(this).css('text-decoration', 'underline') }  );
  $(".rozbalitvse").click(function() { $("div.hideme").show(); $(".sbalitvse").show(); $(this).hide(); return false; });  
  $(".sbalitvse").click(function() { $("div.hideme").hide(); $(".rozbalitvse").show(); $(this).hide(); return false; });  
  
  var anchor = jQuery.url.attr("anchor");
  if (anchor)
  {
    $("#"+anchor+".showhide").click();
  }
  
});

// minimalni a maximalni sirka okna pro fixni horni menu

function fixBg(){
  
  if ($(window).width() > 957) {
      $("#boxout").css("left", ("355px")); // sirka webu je 957, sirka boxoutu je 500 => 957-500=457 - vzdalenost zleva
    }
    else 
    if ($(window).width() < 957) {
      $("#boxout").css("left", ("auto"));
      $("#boxout").css("right", ("10px"));
    }
    else {
    }
}

function operaHacker(){
  
      if ($.browser.opera) {
          $(".boxobaldark .boxvlevo").css("padding-left","15px");
          $(".boxobaldark .boxvlevo ul").css("margin-left","16px");
          $(".boxobaldark .boxvpravo ul").css("margin-left","16px");
          $(".boxobal ul li").css("padding-top","0");
          $(".boxobaldark ul li").css("padding-top","0");
          $(".boxobal ul li").css("padding-bottom","3px");
          $(".boxobaldark ul li").css("padding-bottom","3px");
      }
}

window.onresize = function(){
  fixBg();
}
  
$(document).ready(function(){
  fixBg();
  operaHacker();
});

