$(document).ready(function(){

TopbarLPocet = $('#Topbar-l').css('background-image').slice( $('#Topbar-l').css('background-image').search('l-')+2 , $('#Topbar-l').css('background-image').search('.jpg') );
TopbarRPocet = $('#Topbar-r').css('background-image').slice( $('#Topbar-r').css('background-image').search('r-')+2 , $('#Topbar-r').css('background-image').search('.jpg') );

if (document.URL.search(/\?Ktore=/) != -1) { document.location = document.URL.replace(/index.php\?Ktore=/, "#"); };

Menu();

$.historyInit(pageload);

$('#Menu a').click(function() {
 if ( $(this).attr('target') != '') { return; };
 $.historyLoad( $(this).attr('href').slice($(this).attr('href').search(/\?Ktore=/)+7) ); 
 return false;
});

});


	//jquery load history
function pageload(hash) {

if (!hash) {
 if (GlobalLang == 'sk') { hash = 'home.php'; }
 else { hash = "home-"+GlobalLang+".php"; };
} else {
 $('#Topbar-l').css('background-image', 'url(obsahpics/topbar/l-'+ (Math.floor(Math.random()*TopbarLPocet)+1) +'.jpg)');
 $('#Topbar-r').css('background-image', 'url(obsahpics/topbar/r-'+ (Math.floor( Math.random()*TopbarRPocet)+1) +'.jpg)');
};

if (hash.slice(0,9) == 'Kategoria') {return;};	//v ucastnici.php pri odkazovani na <a name='#Kategoria$$'>

$('#Status').fadeIn(200);

$('#Main').load(hash,
 function() {
  $('#Status').fadeOut(200);
  if ($('#Menu a[href*='+hash+']').attr('title')) {
   $('#Mainbar').html( $('#Menu a[href*='+hash+']').attr('title').replace('--', '&nbsp;•&nbsp;') );
  };
  if (GlobalLang != 'sk') {PrelozObsah(hash);};
  quiteview();
  $.tablesorter.defaults.widgets = ['zebra'];   
  $(document).ready(function() { $("table[class=tablesorter]").tablesorter();} );
  }
);

$('a[href*='+hash+']').blur();
}


	// jquery funkcie pre animovane submenu
function Menu() {

Povodne = '';	//ie quirk pri nacitani z linku

$('#MenuLinks a').hover(
function(){
 Povodne = $(this).css('color');
 $(this).css('color','#777');
 $('#'+$(this).attr('id').slice(0, $(this).attr('id').search(/Link/))+'Submenu:animated').stop(false, true);
 $('#'+$(this).attr('id').slice(0, $(this).attr('id').search(/Link/))+'Submenu').slideDown(200);
 $('ul[id*=Submenu]').not('#'+$(this).attr('id').slice(0, $(this).attr('id').search(/Link/))+'Submenu').slideUp(200);
},
function(){
 $(this).css('color',Povodne);
 $('#'+$(this).attr('id').slice(0, $(this).attr('id').search(/Link/))+'Submenu:animated').stop(false, true);
 $('#'+$(this).attr('id').slice(0, $(this).attr('id').search(/Link/))+'Submenu').hide();
}
);

$('ul[id*=Submenu]').hover( function(){ $(this).show(); }, function(){ $(this).slideUp(200); } );

$('ul.Submenu a').hover(
function(){ Povodne = $(this).css('color'); $(this).css('color','#ccc'); },
function(){ $(this).css('color',Povodne); }
);
$('ul[id*=Submenu] a').click( function(){ $(this).parents('ul').slideUp(100); });

}


	//zvysne funkcie

function PrehrajVideo(subor, sirka, vyska, autoplay) {
if (document.getElementById('Videoprehravac')) {

obrazok = subor.slice(0, subor.search(/\./));

flashvarsParams = "file=../video/"+subor+"&image=../video/"+obrazok+".jpg&screencolor=000000";

if (autoplay == 'autoplay') {
 flashvarsParams = flashvarsParams + "&autostart=true";
 if (document.body.scrollTop > 250) {window.scrollTo(0, 250)};
};

var s1 = new SWFObject("jwplayer/player.swf","ply",sirka,vyska,"9","#FFFFFF");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","always");
s1.addParam("flashvars",flashvarsParams);
s1.addParam("wmode","transparent");

s1.write("Videoprehravac");

if (autoplay == 'autoplay' && document.getElementById('Videoprehravac').style.backgroundColor != '#ffffff') {
 $("#Videoprehravac").hide();
 $("#Videoprehravac").ready(function () { $("#Videoprehravac").slideDown("slow"); });
};

document.getElementById('Videoprehravac').style.backgroundColor = '#ffffff';

};
}


function Toggle(Ktory, Rychlost) {
if (document.getElementById(Ktory).style.display == 'none') {
 if (Rychlost == 'hned') {
  document.getElementById(Ktory).style.display='block';
 } else {
  $('#'+Ktory).slideDown(300);
 };
} else {
 $('#'+Ktory).slideUp(300);
 //document.getElementById(Ktory).style.display='none';
 };
}

function UkazVsetky() { $('div[id*=Zaznam]').slideDown(200); }
function SkryVsetky() { $('div[id*=Zaznam]').slideUp(200); }

