var scroll;

$(document).ready(function(){
 //notice
 $('.notice').hide();
 $('.notice').fadeIn(1500);
 
 
 //citace
 $(".quotehandler").click(function(){
  $(this).siblings(".quote").slideToggle("slow"); 
 });
 
 //animace menu
 $(".menulist a img").hover(function(){
  $(this).animate({marginLeft: "+=10"},150);
 },function(){
  $(this).animate({marginLeft: "-=10"},150);
 });
 
 $("#objednatReklamu img").mouseenter(function(){
  $(this).clearQueue();
  $(this).fadeTo(300,0.6);
 });
  $("#objednatReklamu img").mouseleave(function(){
  $(this).clearQueue();
  $(this).fadeTo(300,1);
 });
 
 //inicializace chatu ( zbytek v chat/chat.js)
 if(arr= /[\?\&]pg\=([^\&]*)($|\&)/.exec(location.search)){
  if(arr[1]=='chat')chat();
 }
});

$(window).load(function(){
 //scrollovani ke kotve
 scroll= /[\?\&]scroll\=([^\&]*)($|\&)/.exec(location.search);
 if($.isArray(scroll)){
  $('html,body').animate({scrollTop:$('#'+scroll[1]).offset().top-10}, 1500);
 }
 highlight= /[\?\&]highlight\=([^\&]*)($|\&)/.exec(location.search);
 if($.isArray(highlight)){
  $('.clanekdiv').highlight(highlight[1], 1, "hls");
 }
});

jQuery.fn.extend({
    highlight: function(search, insensitive, hls_class){
      var regex = new RegExp("(<[^>]*>)|(\\b"+ search.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1") +")", insensitive ? "ig" : "g");
      return this.html(this.html().replace(regex, function(a, b, c){
        return (a.charAt(0) == "<") ? a : "<strong class=\""+ hls_class +"\">" + c + "</strong>";
      }));
    }
});

