jQuery(document).ready(function(){ // 2013 - 2026 vytvořil Dh4rter [napiste-mi/a/dmelicher^plus] jQuery('body').prepend(jQuery('#pravdohoda')); jQuery('#pravdohoda-ok a').click(function(){ document.cookie='pravdohoda_ok=1; path=/'; jQuery('#pravdohoda').fadeOut(); return false; }); }); jQuery(document).ready(function(){ jQuery('body').prepend(jQuery('#pravdohoda')); jQuery('#pravdohoda-ok a').click(function(){ document.cookie='pravdohoda_ok=1; path=/'; jQuery('#end').fadeOut(); return false; }); }); jQuery(document).ready(function(){ jQuery('body').prepend(jQuery('#pravdohoda')); jQuery('#pravdohoda-ok a').click(function(){ document.cookie='pravdohoda_ok=1; path=/'; jQuery('.dulezite').fadeOut(); return false; }); }); slider = function(item, parent, parentParent, onChangeStatue) { var prev = -1; var moving = false; var statue = false; var space = 2; var min = -space; var max = $(parent).width() - $(item).width() + space; setPos = function(left) { $(item).css('left', left); }; getPos = function() { return $(item).position().left; }; setStatue = function(newStatue) { statue = newStatue; onChangeStatue(statue); }; setOn = function() { setStatue(true); $(item).animate({left: max}); }; setOff = function() { setStatue(false); $(item).animate({left: min}); }; $(item).unbind('mousedown'); $(item).mousedown(function(event) { $(item).stop(); if(event.preventDefault) { event.preventDefault(); } $(item).css('background-position', 'left bottom'); $().unbind('mousemove'); $().bind('mousemove', function(e) { if(prev == -1) { prev = e.pageX; } newPosX = getPos() + e.pageX - prev; if(newPosX >= max) { setPos(max); } else if(newPosX <= min) { setPos(min); } else { moving = true; setPos(newPosX); prev = e.pageX; } }); }); $().unbind('mouseup'); $().mouseup(function() { $().unbind('mousemove'); prev = -1; $(item).css('background-position', 'top left'); if(moving) { if(getPos() == max) { setStatue(true); } else { $(item).animate({left: min}); } } }); setStatue(statue); }; var showed = false; if($.cookie('showed') == 'true') { showed = true; } var currentPage = 'uvod'; var showPage = function(duration) { if(duration == undefined) { duration = 300; } showed = -1; $("#page").animate({ marginTop: '0px', width: '274px', height: '133px', }, 0); $('#slider').css('left', -2); $('#spinac').css('display', 'none'); $("#page .inner1").show(300); $("#page").animate({ marginTop: '-34px', width: '970px', height: '380px', }, duration, 'linear', function() { showed = true; $.cookie('showed', true); }); $('#page #close').click(hidePage); } var hidePage = function() { showed = -1; $('#page').unbind('click'); $('#page .inner1').hide('slow'); $("#page").animate({ marginTop: '-34px', width: '274px', height: '133px', }, 300, 'linear', function() { $(this).css('display', 'none'); $('#spinac').css('display', 'block'); showed = false; $.cookie('showed', false); }); }; var initSlider = function() { slider($('#slider'), $('#parent'), $('#spinac'), function(statue) { if(statue == true) { // zvuk setTimeout(showPage, 300); } }); } var keyshortcut = function() { $().bind('keydown', function(event) { if(event.which == 27) { if(showed == -1) return; else if(showed == true) hidePage(); else showPage(); return false; } else if(showed == true && (event.which == 188 || event.which == 190)) { var page = null; if(event.which == 37) page = $('#menu3 li a[rel=' + currentPage + ']').parent().prev().find('a').attr('rel'); else page = $('#menu3 li a[rel=' + currentPage + ']').parent().next().find('a').attr('rel'); if(page != undefined) { moveToPage(page); return false; } //alert('zmena'); } }); }; var moveToPage = function(page) { currentPage = page; var to = $('#menu3 li a[rel=' + page + ']'); $('#page #menu3 li.current').animate({left: $(to).position().left + ($(to).width() / 2) - 27}); var left = $('#content .' + $(to).attr('rel')).position().left - parseInt($('#content .inner2').css('margin-left'), 10); $('#content .inner2').animate({marginLeft: -left}); } $(function() { keyshortcut(); initSlider(); if(showed == true) { showPage(0); } $('#page #close').click(hidePage); $('#menu3 li a').each(function() { $(this).click(function() { moveToPage($(this).attr('rel')); return false; }); }); $('a').click(function() { if($(this).attr('href').substr(0,1) == '#') { var page = $(this).attr('href').substr(1); moveToPage(page); return false; } }); });