﻿function gEBI(id)
{
 return document.getElementById(id);
}

var sitemapPref=new Array;
sitemapPref[1]=true;
sitemapPref[2]=true;
sitemapPref[4]=true;

function sitemapLoadPref()
{
 if(!sitemapPref[1]) sitemapHide(1);
 else sitemapShow(1);
 if(!sitemapPref[2]) sitemapHide(2);
 else sitemapShow(2);
 if(!sitemapPref[4]) sitemapHide(4);
 else sitemapShow(4);
}

function sitemapOv(n)
{
 if(gEBI('dp'+n))
 gEBI('dp'+n).style.color='#ff0000';
 if(gEBI('dd'+n))
 gEBI('dd'+n).style.color='#ff0000';
}

function sitemapOu(n)
{
 if(gEBI('dp'+n))
 gEBI('dp'+n).style.color='';
 if(gEBI('dd'+n))
 gEBI('dd'+n).style.color='';
}

function sitemapHide(n)
{
 delay=1;
 step=30;
 
 obj=gEBI('m'+n);
 objR=gEBI('rm'+n);
 
 obj.style.overflow='hidden';
 if(obj.offsetHeight>step)
 {
  obj.style.height=(obj.offsetHeight-step)+'px';
  
  if(obj.offsetHeight<40) objR.style.marginTop=obj.offsetHeight+'px';
  else objR.style.marginTop='40px';
  
  setTimeout('sitemapHide('+n+')', delay);
 }
 else
 {
  obj.style.display='none';
  objR.style.marginTop='0px';
  obj.style.height='1px';
  gEBI('c'+n).innerHTML='<img src="'+root+'graph/ic_treeOpen.gif" width="11" height="11" alt="+" align="left" style="margin-top: 2px; margin-right: 5px; cursor: pointer" onmouseover="changeImg(this, \'treeopen_ov\')" onmouseout="changeImg(this, \'treeopen\')" onclick="sitemapShow('+n+')" id="i'+n+'" />';
  gEBI('ddo'+n).style.display='block';
  sitemapPref[n]=false;
 }
} 

function sitemapShow(n)
{
 gEBI('ddo'+n).style.display='none';
 
 delay=1;
 step=30;
 
 obj=gEBI('m'+n);
 objR=gEBI('rm'+n);
 objC=gEBI('c'+n);
 objI=gEBI('i'+n);
 
 obj.style.overflow='hidden';
 obj.style.display='block';
 
 if(obj.offsetHeight<obj.scrollHeight)
 {
  obj.style.height=(obj.offsetHeight+step)+'px';

  if(obj.offsetHeight<40)
  {
   objR.style.marginTop=obj.offsetHeight+'px';
   objI.style.marginTop=obj.offsetHeight+'px';
  }
  else
  {
   objR.style.marginTop='40px';
   objI.style.marginTop='42px';
  }
  setTimeout('sitemapShow('+n+')', delay);
 }
 else
 {
  objR.style.marginTop='40px';
  obj.style.height=obj.scrollHeight+'px';
  objC.innerHTML='<img src="'+root+'graph/ic_treeClose.gif" width="11" height="11" alt="-" align="left" style="margin-top: 42px; margin-right: 5px; cursor: pointer" onmouseover="changeImg(this, \'treeclose_ov\')" onmouseout="changeImg(this, \'treeclose\')" onclick="sitemapHide('+n+')" id="i'+n+'" />';
  sitemapPref[n]=true;
 }
} 

page=new Array;
page[0]=root;
page[9]=root+'en';
page[1]='szkolenia';
page[101]='najblizsze-szkolenia';
page[2]='firma';
page[201]='ludzie';
page[202]='oferty-pracy';
page[203]='biura-na-swiecie';
page[3]='aktualnosci';
page[4]='nasze-atuty';
page[401]='trenerzy';
page[402]='centrum-szkoleniowe';
page[403]='referencje';
page[404]='nasi-klienci';
page[5]='wynajem-sal';
page[6]='kontakt';
 
function sitemapGo(n)
{
 document.location=page[n];
}

function sitemapShowAll()
{
 sitemapShow(1);
 sitemapShow(2);
 sitemapShow(3);
 sitemapShow(4);
}

function sitemapHideAll()
{
 sitemapHide(1);
 sitemapHide(2);
 sitemapHide(3);
 sitemapHide(4);
}


//preload obrazkow
function preload(imgObj,imgSrc)
{
 if (document.images)
 {
  eval(imgObj+' = new Image()');
  eval(imgObj+'.src = "'+imgSrc+'"');
 }
}



function changeImg(imgName,imgObj)
{
 try
 {
  if(gEBI(imgName))
  gEBI(imgName).src=eval(imgObj+".src");
  else
  imgName.src=eval(imgObj+".src");
 }
 catch(e)
 {}
}

function changeBgImg(imgName,imgObj)
{
 try
 {
  img=eval(imgObj+".src");
  if(gEBI(imgName))
  gEBI(imgName).style.backgroundImage='url('+img+')';
  else
  imgName.style.backgroundImage='url('+img+')';
 }
 catch(e)
 {}
}

function nlZapisz(l)
{
 email=gEBI('email').value;
 emailReg=/^[\w-_.]*[\w-_.]@[\w].+[\w]+[\w]$/;
 
 if(emailReg.exec(email))
 {
  if(l) gEBI('nlForm').action=root+'en/newsletter-zapisz';
  else gEBI('nlForm').action=root+'newsletter-zapisz';
  gEBI('nlForm').submit();
 }
}

function nlWypisz(l)
{
 email=gEBI('email').value;
 emailReg=/^[\w-_.]*[\w-_.]@[\w].+[\w]+[\w]$/;
 
 if(emailReg.exec(email))
 {
  if(l) gEBI('nlForm').action=root+'en/newsletter-wypisz';
  else gEBI('nlForm').action=root+'newsletter-wypisz';
  gEBI('nlForm').submit();
 }
}

function changeValue(obj, src, dest)
{
 if(obj.value==src) obj.value=dest;
}

preload("home",root+"graph/lg_tree.gif");
preload("home_ov",root+"graph/lg_tree_ov.gif");



//sitemap
preload("treeopen",root+"graph/ic_treeOpen.gif");
preload("treeopen_ov",root+"graph/ic_treeOpen_ov.gif");
preload("treeclose",root+"graph/ic_treeClose.gif");
preload("treeclose_ov",root+"graph/ic_treeClose_ov.gif");

