function bannerLoop1()
{
    if(document.getElementById('banner1') != null)
    {
        window.setTimeout('Effect.Fade(\'banner1\', {duration:3.5})');
        window.setTimeout('Effect.SlideUp(\'banner1txt\', {duration:3.5})');
 
        //document.getElementById('banner2txt').style.opacity = '0.00001';                
        //document.getElementById('banner2txt').style.visibility = 'visible';                
        //document.getElementById('banner2txt').style.opacity = '0.00001';     

        window.setTimeout('Effect.SlideDown(\'banner2txt\', {duration:3.5})');        
        window.setTimeout(bannerLoop2,5000);        
    }
}
function bannerLoop2()
{
    if(document.getElementById('banner1') != null)
    {
        window.setTimeout('Effect.Appear(\'banner1\', {duration:3.5})');    
        window.setTimeout('Effect.SlideUp(\'banner2txt\', {duration:3.5})');
        window.setTimeout('Effect.SlideDown(\'banner1txt\', {duration:3.5})');
        window.setTimeout(bannerLoop1,5000);        
    }    
}

function moveDiv()
{
    if(document.getElementById('okno') != null)
    {    
        var mdiv = document.getElementById('okno');
         mdiv.style.left  = mdiv.offsetParent.offsetLeft-30;
         mdiv.style.top = mdiv.offsetParent.offsetTop+10;
    }
}

function getPageSize()
{
            
         var xScroll, yScroll;
        
        if (window.innerHeight && window.scrollMaxY) {    
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
        
        var windowWidth, windowHeight;
        
        if (self.innerHeight) {    // all except Explorer
            if(document.documentElement.clientWidth){
                windowWidth = document.documentElement.clientWidth; 
            } else {
                windowWidth = self.innerWidth;
            }
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }    
        
        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
            pageHeight = windowHeight;
        } else { 
            pageHeight = yScroll;
        }
    
        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){    
            pageWidth = xScroll;        
        } else {
            pageWidth = windowWidth;
        }

        return [pageWidth,pageHeight];
    }
    
    
function mailFormFade()
{
    $('bottomshadow2').style.backgroundImage = '';
    $('bottomshadow').style.backgroundImage = '';
    $('rightshadow2').style.backgroundImage = '';
    $('rightshadow').style.backgroundImage = '';
    $('cornershadow').style.backgroundImage = '';
    new Effect.Fade($('moverlay'), { duration: 0.5});
    new Effect.Fade($('mailform'), { duration: 0.5});
    new Effect.Fade($('confirmation'), { duration: 0.5});

}
    
function mailFormAppear()
{ 
    $('moverlay').setStyle({ height: getPageSize()[1]+'px', width: getPageSize()[0]+'px' });            
    if($('aplink'))
        $('aplink').blur();
    new Effect.Appear($('moverlay'), { duration: 3, from: 0.0, to: 0.35});            
    new Effect.Appear($('mailform'), { duration: 1, from: 0.0, to: 1});           
    $('moverlay').hide().observe('click', (function() { mailFormFade(); })); 
    window.setTimeout('$(\'rightshadow\').style.backgroundImage = \'url(img/mailform/shadowright.png)\'',1000);
    window.setTimeout('$(\'bottomshadow\').style.backgroundImage = \'url(img/mailform/shadowbottom.png)\'',1000);
    window.setTimeout('$(\'rightshadow2\').style.backgroundImage = \'url(img/mailform/shadowright.png)\'',1000);
    window.setTimeout('$(\'cornershadow\').style.backgroundImage = \'url(img/mailform/shadowcorner.png)\'',1000);
    window.setTimeout('$(\'bottomshadow2\').style.backgroundImage = \'url(img/mailform/shadowbottom.png)\'',1000);
}

var formSending = false;
function mailFormSend()
{
    if(formSending)
    {
        alert('sending');
        return false;
    }
       
   var parms = {};
   parms['usermail'] = $('usermail').value;
   parms['subject'] = $('subject').value;
   parms['mailtext'] = $('mailtext').value;
   parms['sessionid'] = sessionid;
   
   if(parms['usermail'] == '')
   {
       alert('Email adresa je prázdna');
       $('usermail').focus();
       return false;
   }
   
   if(parms['mailtext'] == '')
   {
       alert('Text správy je prázdny');
       $('mailtext').focus();
       return false;
   }
   
    var oOptions = {
        method: "post",
        parameters: parms,
        asynchronous: false,
        onSuccess: function (oXHR, oJson)
        {
            $('mailform').style.opacity = '0.85';
            $('confirmation').style.display ='block';
            if(oXHR.responseText == 'index')
            {
                window.navigate.href = 'index.html';
            }else{
                $('conftext').innerHTML = oXHR.responseText;
            }
        },
        onFailure: function (oXHR, oJson)
        {
            alert(oXHR.statusText);
        }    
    };
    formSending = true;
    request = new Ajax.Request('sendmail.php',oOptions);
    formSending = false;
}


