function markFaqItem(id)
{
  //var item = document.getElementById(id);
  //item.style.backgroundColor = '#E2E6FF';
}


function conClrValFrmTxtArea(id)
{
  if(id.value == 'Vložte svůj dotaz')
  {
    id.value = "";
  }
}

function conClrValFrmEmail(id)
{
  if(id.value == "Váš email")
  {
    id.value = "";
  }
}

function changeHeader()
{
  var cont = document.getElementById('WebTrailer');
  
  var videoCont = document.getElementById('WebTrailerCont');
  //videoCont.style.display = 'block';
  
  
  setOpacity(0,cont);
  //cont.style.display = 'block';
  
  
  objectGrdUpDown(cont,0,0,100,function(){
      var video = document.getElementById('WebTrailerCont');
      //cont.style.display = 'block';
      //objectGrdUpDown(cont,0,0,100,{});
      
    },45,2);
  
  

  window.setInterval('changeLogo()',5000);
}

var parm = 0;


function showContLogo()
{
   var trailer = document.getElementById('WebTrailer'); 
   //debugger;
   if(parm < 310)
   {
    if(trailer != null)
    {
      trailer.style.height = parm + 'px';
    }
    parm += 8;
    
    setTimeout('showContLogo()',15);
   }
   else
   {
    
    var video = document.getElementById('video');
    if(video != null)
    {
      video.style.display = 'block';
    }
    else
    {
      var video2 = document.getElementById('video2');
      if(video2 != null)
      {
        video2.style.display = 'block';
      }
    }
    
    parm = 0;
   }   
}

function showVideoCont()
{
   var videoCont = document.getElementById('VideoContainer'); 
   
   if(videoCont != null)
   {
     if(parm < 280)
     {
       
        videoCont.style.height = parm + 'px';
        parm += 8;
        setTimeout('showVideoCont()',5);
     }
     else
     {
        for(var i = 0; i < videoCont.childNodes.length;i++)
        {
          if(videoCont.childNodes[i].tagName == 'img')
          {
            var image = videoCont.childNodes[i];
          }
        }
        
        if(image != null)
        {
          image.style.display = 'block';
        }
     }   
   }
}

function Init()  // onload function
{  

  Cufon.replace('galeryHeader');
  Cufon.replace('.glrMenu p');
  Cufon.now();
  
   if(document.getElementById('galeryHeader'))
   {
      Cufon.replace("#galeryHeader", {
	     textShadow: '1px 1px rgba(0, 0, 0, 0.2)'
      });
   }
   
   var trailer = document.getElementById('WebTrailer'); 
   if(trailer != null)
   {
    trailer.style.display = 'block';
    setTimeout('showContLogo()',50);
   }
  
   
   var videoCont = document.getElementById('VideoContainer');
   
   if(videoCont != null)
   {
      videoCont.style.display = 'block';
      parm = 0;
      setTimeout('showVideoCont()',50);
   }
}

function changeLogo()    /// Function run by setInterval();
{
  var logo = document.getElementById('LogoAnim');
  var cont = document.getElementById('WebTrailer');
  
  var from;
  var to;
  
  //alert(cont.style.opacity);
  
  if(cont.style.opacity <= 5)
  {
    from = 0;
    to = 100;  
  }
  else
  {
    from = 100;
    to = 0;
  }
  
  objectGrdUpDown(cont,from,from,to,function(){},45,2);
  
  //logo.style.display = cont.style.display == '' ? 'none' : '';
  //cont.style.display = cont.style.display == '' ? 'none' : '';
}


function setOpacity(opacity,obj) {
  opacity = (opacity == 100)?99.999:opacity;

  if(obj != null)
  {
    // IE/Win
    obj.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+ opacity + ");";
  
    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity/100;
  
    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity/100;
  
    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity/100;
  }
}



function objectGrdUpDown(object,act,from,to,event,frameRate,speed)
{
     
     if((act > to && to > from) || (act < from && to > from) || act > 100 || act < 0)
     {  
          event();
          return;
     }
    
     setOpacity(act,object);
     
     if(from > to)
     {
        //object.style.display = '';
     }
     
     var next = function()
     {
       if(from > to)
       {
        act = act - speed;
       }
       else
       {
        act = act + speed;
       }
       objectGrdUpDown(object,act,from,to,event,frameRate,speed)
     }
     setTimeout(next,frameRate);
}

function makeObjHigher(obj,newHeight,speed,addon)
{
    // not fully implemented
   var actHeight = obj.style.height;
   if(actHeight == '')
   {
    actHeight = 0;
   }
   if(actHeight != newHeight)
   {
    
     if(newHeight > actHeight)
     {
       if((newHeight - actHeight) > addon )
       {
         obj.style.height = (actHeight - addon) + 'px';
       }
       else
       {
         obj.style.height = newHeight + 'px';
       }
     }
     if(newHeight+'px' < actHeight)
     {
     
     }
   
     var next = function()
     {
        makeObjHigher(obj,newHeight,speed,addon)
     }
   
     setTimeout(next,speed);
   }
}


/* Ajax  Start */
function createXhttp()
{
    var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
    if (!xmlhttp) {
        return false;
    }
    else
    {
      return xmlhttp;
    }
}

function send_xmlhttprequest(xmlhttp,state_change, method, url, content, headers) {
    xmlhttp.open(method, url);
    xmlhttp.onreadystatechange = function () {
        state_change(xmlhttp);
    };
    headers = headers || {};
    headers['X-Requested-With'] = headers['X-Requested-With'] || 'XMLHttpRequest';
    for (var key in headers) {
        xmlhttp.setRequestHeader(key, headers[key]);
    }
    xmlhttp.send(content);
}
/* Ajax End */


/* Galery section */
function glrShowCategory(catId)
{
    var content = document.getElementById('glrData');
    var xhttpGalShowCat = createXhttp();
    
    nothing = function(){};
    
    var glrOnLoaded = function()
    { 
      if(xhttpGalShowCat.readyState == 4 && xhttpGalShowCat.status == 200)  
      {
        var event = function ()
        { 
          content.innerHTML = xhttpGalShowCat.responseText;
          document.getElementById('glrMenu').style.display = 'none';
          objectGrdUpDown(document.getElementById('glrContent'),0,100,100,nothing,15,6);
        }

        glrContentFadeOut(event);
      }
    }
    
    send_xmlhttprequest(xhttpGalShowCat,glrOnLoaded, 'GET', './functions/galeryGetImages.php?id='+catId, null, []) 
    
}

function glrContentFadeOut( events )
{
  var content = document.getElementById('glrContent');
  if(content != null)
  {    
    objectGrdUpDown(content,100,100,0,events,25,10);
  }
}

function glrShowMenu()
{
    var funShowMenu = function ()
    {
      document.getElementById('glrMenu').style.display = 'block';
      var data = document.getElementById('glrData');
      data.innerHTML = "";
      var content = document.getElementById('glrContent');
      objectGrdUpDown(content,0,100,100,function(){},15,6);
    }
    glrContentFadeOut(funShowMenu);
}

function glrShowPhoto(id,catId)
{
    var showPhoto = function ()
    {
      var data = document.getElementById('glrData');
      data.innerHTML = "<div class=\"glrNavigation\"><button onclick=\"glrShowCategory(" + catId + ");\">Zpět do kategorie</button></div><img class=\"border\" src=\"./galery/images/" + id + ".jpg\" width=\"730\">";
      
      var content = document.getElementById('glrContent');
      objectGrdUpDown(content,0,100,100,function(){},15,6);
    }
    glrContentFadeOut(showPhoto);
}


