var pauzaMeziProlinanim = 3000;
var iProlinani = 15;
var opacityKrok = 0.05;
var pObr = 4;
var aLay = 1;
var aOpacity = 0;
var aObr = 1;
var timer = 0;
var i;
function zmenOpacity ( hodnota ) {
document.getElementById("obraz2").style.opacity = hodnota;
document.getElementById("obraz2").style.filter = 'alpha(opacity=' + (hodnota * 100) +')'; /* For IE8 and earlier */
}
function cyklujObrazky () {
if ( aObr >= pObr)
aObr = 1;
else
aObr++;
var p = "url(/img/design/ram/obraz" + aObr + ".jpeg)";
// vidime spodni vrstvu .. potaji menime horni zneviditelnenou localhost/superzahrady.cz/web/images/design/obraz" + aObr + ".jpeg)";
if ( aLay == 1 )
document.getElementById('obraz2').style.backgroundImage = p;
else
document.getElementById('obraz1').style.backgroundImage = p;
}
function prolni () {
timer = 0;
// dosavad byla videt prvni, spodni vrstva -> horni vtrstvu zvitelnujeme -> aOpacity zvysujem
if ( aLay == 1 ) {
for ( i = 0; i < 1; i += opacityKrok ) {
setTimeout("zmenOpacity(" + i + ")", iProlinani * timer);
timer++;
}
setTimeout("zmenOpacity(1)", iProlinani * timer);
aLay = 2;
}
// dosavad byla videt druha, vrchni vvrstva -> horni vrstvu zneviditelnujeme -> aOpacity snizujeme
else if ( aLay == 2 ) {
for ( i = 1; i > 0; i -= opacityKrok ){
setTimeout("zmenOpacity(" + i + ")", iProlinani * timer);
timer++;
}
setTimeout("zmenOpacity(0)", iProlinani * timer);
aLay = 1;
}
setTimeout("cyklujObrazky()", iProlinani * timer);
setTimeout("prolni()", iProlinani * timer + pauzaMeziProlinanim);
}
function initProlinani () {
document.getElementById('header').innerHTML = '
';
setTimeout("prolni()", pauzaMeziProlinanim);
}
function getBrowserWidth()
{
if (window.innerWidth)
{
return window.innerWidth;
}
else if (document.documentElement && document.documentElement.clientWidth != 0)
{
return document.documentElement.clientWidth;
}
else if (document.body)
{
return document.body.clientWidth;
}
return 0;
};
function positionFollowers(e)
{
if(getBrowserWidth()<=800) /* hodnota 800 koresponduje s CSS pri zmensovani okna, navigace se umisti pevne nahoru */
{
$('#nav').removeClass('fixed');
$('#nav').css('margin-top', '0px');
return;
}
MaxMarginTopNav = $('#maintext').height() - $('#nav').height() - 146 + 55;
if(MaxMarginTopNav<0)
MaxMarginTopNav = 0;
insetTop = $('#header').offset().top - parseInt($('#header').css("marginTop"), 10);
scrollerVisualTop = insetTop + $('#header').outerHeight(true) - 55;
mainVisualTop = $('#maintext').offset().top;
scrollerCssTop = scrollerVisualTop - mainVisualTop;
scrollerVisualBottom = $('#maintext').offset().top + $('#maintext').height() - $('#nav').height() - 146;
$('#maintext').css('max-height', $('#maintext').css('height'));
// document.title = $(window).scrollTop() + ' ' + scrollerVisualTop + ' ' + scrollerVisualBottom + ' ' + MaxMarginTopNav;
/* Fix to Bottom */
if ($(window).scrollTop() > scrollerVisualBottom)
{
$('#nav').removeClass('fixed');
$('#nav').css('margin-top', MaxMarginTopNav+'px');
$('#nav').css('margin-bottom', 0+'px');
}
/* Scroll with Page */
else if ($(window).scrollTop() > scrollerVisualTop)
{
$('#nav').addClass('fixed');
$('#nav').css('margin-top', '0px');
}
/* Fix to Top */
else
{
$('#nav').removeClass('fixed');
$('#nav').css('margin-top', '0px');
}
}
$(window).resize(positionFollowers);
$(window).scroll(positionFollowers);
$(window).load(positionFollowers);