var  ObiektXMLHttp = getXMLHttpRequest();

function getXMLHttpRequest() 
{
  var request = false;
  try 
  {
    request = new XMLHttpRequest();
  } 
  catch(err1) 
  {
    try 
    {
      request = new ActiveXObject('Msxml2.XMLHTTP');
    } 
    catch(err2) 
    {
      try 
      {
        request = new ActiveXObject('Microsoft.XMLHTTP');
      } 
      catch(err3) 
      {
        request = false;
      }
    }
  }
  return request;
}

function zmienZawartoscFade(zrodlo) 
{ 

 if(ObiektXMLHttp) 
  {
   var cel = document.getElementById('text');
   var cel2 = document.getElementById('sidebar');
   
   ObiektXMLHttp.open("GET", zrodlo,true);
   ObiektXMLHttp.send(null);
   
    ObiektXMLHttp.onreadystatechange = function() 
    {
     if (ObiektXMLHttp.readyState == 4)
       {
       if (zrodlo == 'php/oferta.php')
       {
           cel2.innerHTML = '<img style="z-index:50;margin-left:-70px;border:1px black solid;margin-bottom:-30px;" src="images/page2.jpg"/>';
       }
       if (zrodlo == 'php/oMnie.php')
       {
           cel2.innerHTML = '<img style="z-index:50;margin-left:-221px;margin-bottom:-30px;" src="images/page1.png"/>';
       }
       if (zrodlo == 'php/treningi.php')
       {
           cel2.innerHTML = '<img style="z-index:50;margin-left:-85px;" src="images/page4.png"/>';
       }
       if (zrodlo == 'php/akademia.php')
       {
           cel2.innerHTML = '<img style="z-index:50;border:1px black solid;margin-left:-85px;" src="images/page3.jpg"/>';
       }    
       if (zrodlo == 'php/referencje.php')
       {
           cel2.innerHTML = '<img style="z-index:50;margin-left:-85px;" src="images/page4.png"/>';
       }     
       if (zrodlo == 'php/konsultacja.php')
       {
           cel2.innerHTML = '<img style="z-index:50;margin-left:-70px;border:1px black solid;margin-bottom:-30px;" src="images/page2.jpg"/>';
       }   

       if (zrodlo == 'php/galeria.php')
       {
           cel2.innerHTML = '<img style="z-index:50;margin-left:-70px;border:1px black solid;margin-bottom:-30px;" src="images/page2.jpg"/>';
       }   

       if (zrodlo == 'php/kontakt.php')
       {
           cel2.innerHTML = '<img style="z-index:50;margin-left:-221px;margin-bottom:-30px;" src="images/page1.png"/>';
       }   
       
       $('#text').hide();
        cel.innerHTML = ObiektXMLHttp.responseText; 
        $('#text').fadeIn();
        updateScrollHeight();
       } 
    } 
  } 
}

function zmienZawartoscFadeGrafika(zrodlo) 
{ 

 if(ObiektXMLHttp) 
  {
   var cel = document.getElementById('text');
   var cel2 = document.getElementById('sidebar');
   ObiektXMLHttp.open("GET", zrodlo,true);
   ObiektXMLHttp.send(null);
   
    ObiektXMLHttp.onreadystatechange = function() 
    {
     if (ObiektXMLHttp.readyState == 4)
       {
               if (zrodlo == 'php/galeria.php')
       {
           cel2.innerHTML = '<img style="z-index:50;margin-left:-70px;border:1px black solid;margin-bottom:-30px;" src="images/page2.jpg"/>';
       } 
        
        $('#text').hide();
        
        
        cel.innerHTML = ObiektXMLHttp.responseText; 
        $('#text').fadeIn();
        
        
        $(function() {
          $('#gallery a').lightBox();
               updateScrollHeight();
        });
       } 
    } 
  } 
}

function zmienZawartosc(zrodlo) 
{ 

 if(ObiektXMLHttp) 
  {
   var cel = document.getElementById('text');
   ObiektXMLHttp.open("GET", zrodlo,true);
   ObiektXMLHttp.send(null);
   
    ObiektXMLHttp.onreadystatechange = function() 
    {
     if (ObiektXMLHttp.readyState == 4)
       {
        cel.innerHTML = ObiektXMLHttp.responseText; 
             updateScrollHeight();
       } 
    } 
  } 
}



