//function TestDlugosci(){
//document.getElementById('divTest2').innerText=document.getElementById('inputTest').value;
//document.getElementById('divTest3').innerText=document.getElementById('divTest1').offsetWidth;
//}


//zmienne pomocnicze
var am=new Array();
var isOff=1;
var cId=0;
var cText=1;
var cHref=2;
var cWidth=3;
var cShow=4
var cClass=5;
var cFirst=6;



//publiczna - data aktualizacji dokumenu
function GetLastUpdate() {
  document.write(document.lastModified);
}


//publiczna - tworzenie spisu tresci (english)
function MapCreateEN(){
 MenuDefEN();
 MapCreate();
}


//publiczna - tworzenie menu (english)
function MenuCreateEN(){
 MenuDefEN();
 MenuCreate();
}


//pomocnicza - definicja menu (english)
function MenuDefEN(){
 var i;
 am=new Array();
 am[am.length]=new Array('ma','Home page','index.html','187','','','');
 am[am.length]=new Array('mb','General info','','187','','','');
  am[am.length]=new Array('mba','Basic definitions','_en/general/definitions.html','110','','','');
  am[am.length]=new Array('mbb','Sources','','110','','','');
 am[am.length]=new Array('mc','Labour market trends','','187','','','');
  am[am.length]=new Array('mca','Labour market indicators','_en/trends/indicators/indicators.html','190','','','');
   am[am.length]=new Array('mcaa','Activity rate','','130','','','');
    am[am.length]=new Array('mcaaa','Overall','_en/trends/indicators/activity/act_overall.html','100','','','');
    am[am.length]=new Array('mcaab','Bulgaria','_en/trends/indicators/activity/act_bulgaria.html','100','','','');
    am[am.length]=new Array('mcaac','Czech Republic','_en/trends/indicators/activity/act_czech.html','100','','','');
    am[am.length]=new Array('mcaad','Hungary','_en/trends/indicators/activity/act_hungary.html','100','','','');
    am[am.length]=new Array('mcaae','Poland','_en/trends/indicators/activity/act_poland.html','100','','','');
    am[am.length]=new Array('mcaaf','All 4 countries','_en/trends/indicators/activity/act_all.html','100','','','');
   am[am.length]=new Array('mcab','Employment rate','','130','','','');
    am[am.length]=new Array('mcaba','Overall','_en/trends/indicators/employment/emp_overall.html','100','','','');
    am[am.length]=new Array('mcabb','Bulgaria','_en/trends/indicators/employment/emp_bulgaria.html','100','','','');
    am[am.length]=new Array('mcabc','Czech Republic','_en/trends/indicators/employment/emp_czech.html','100','','','');
    am[am.length]=new Array('mcabd','Hungary','_en/trends/indicators/employment/emp_hungary.html','100','','','');
    am[am.length]=new Array('mcabe','Poland','_en/trends/indicators/employment/emp_poland.html','100','','','');
    am[am.length]=new Array('mcabf','All 4 countries','_en/trends/indicators/employment/emp_all.html','100','','','');
   am[am.length]=new Array('mcad','Unemployment rate','','130','','','');
    am[am.length]=new Array('mcada','Overall','_en/trends/indicators/unemployment/unemp_overall.html','100','','','');
    am[am.length]=new Array('mcadb','Bulgaria','_en/trends/indicators/unemployment/unemp_bulgaria.html','100','','','');
    am[am.length]=new Array('mcadc','Czech Republic','_en/trends/indicators/unemployment/unemp_czech.html','100','','','');
    am[am.length]=new Array('mcadd','Hungary','_en/trends/indicators/unemployment/unemp_hungary.html','100','','','');
    am[am.length]=new Array('mcade','Poland','_en/trends/indicators/unemployment/unemp_poland.html','100','','','');
    am[am.length]=new Array('mcadf','All 4 countries','_en/trends/indicators/unemployment/unemp_all.html','100','','','');
  am[am.length]=new Array('mcb','Labour force characteristics','','190','','','');
   am[am.length]=new Array('mcba','Age','','140','','','');
   am[am.length]=new Array('mcbb','Education','','140','','','');
   am[am.length]=new Array('mcbc','Urban/rural areas','','140','','','');
   am[am.length]=new Array('mcbd','Regions','','140','','','');
   am[am.length]=new Array('mcbe','Occupational groups','','140','','','');
  am[am.length]=new Array('mcc','Links','','190','','','');
  am[am.length]=new Array('mcd','Bibliography&publications','_en/trends/bibliography.html','190','','','');
 am[am.length]=new Array('md','Gender analysis','','187','','','');
  am[am.length]=new Array('mda','Gender pay gap','','170','','','');
    am[am.length]=new Array('mdaa','Overall','_en/gender/paygap/paygap_overall.html','100','','','');
    am[am.length]=new Array('mdab','Bulgaria','_en/gender/paygap/paygap_bulgaria.html','100','','','');
    am[am.length]=new Array('mdac','Czech Republic','_en/gender/paygap/paygap_czech.html','100','','','');
    am[am.length]=new Array('mdad','Hungary','_en/gender/paygap/paygap_hungary.html','100','','','');
    am[am.length]=new Array('mdae','Poland','_en/gender/paygap/paygap_poland.html','100','','','');
    am[am.length]=new Array('mdaf','All 4 countries','_en/gender/paygap/paygap_all.html','100','','','');
  am[am.length]=new Array('mdb','Social services','','170','','','');
    am[am.length]=new Array('mdba','Overall','_en/gender/socser/socser_overall.html','100','','','');
    am[am.length]=new Array('mdbb','Bulgaria','_en/gender/socser/socser_bulgaria.html','100','','','');
    am[am.length]=new Array('mdbc','Czech Republic','_en/gender/socser/socser_czech.html','100','','','');
    am[am.length]=new Array('mdbd','Hungary','_en/gender/socser/socser_hungary.html','100','','','');
    am[am.length]=new Array('mdbe','Poland','_en/gender/socser/socser_poland.html','100','','','');
    am[am.length]=new Array('mdbf','All 4 countries','_en/gender/socser/socser_all.html','100','','','');
  am[am.length]=new Array('mdc','Flexible&part time work','','170','','','');
  am[am.length]=new Array('mdd','Case studies','','170','','','');
    am[am.length]=new Array('mdda','Social services','_en/gender/casestudies/case_services.html','170','','','');
  am[am.length]=new Array('mde','Links','','170','','','');
  am[am.length]=new Array('mdf','Bibliography&publications','_en/trends/bibliography.html','170','','','');
 am[am.length]=new Array('me','Policies','','187','','','');
  am[am.length]=new Array('mea','EU Employment Policy','','170','','','');
  am[am.length]=new Array('meb','NAPs in CEE countries','','170','','','');
   am[am.length]=new Array('meba','New EU members','','120','','','');
   am[am.length]=new Array('mebb','EU candidates','','120','','','');
   am[am.length]=new Array('mebc','Others','','120','','','');
  am[am.length]=new Array('mec','Old EU countries','','170','','','');
  am[am.length]=new Array('med','Links','','170','','','');
  am[am.length]=new Array('mee','Bibliography&publications','','170','','','');
 am[am.length]=new Array('mf','Labour law','','187','','','');
  am[am.length]=new Array('mfa','EU level','_en/law/eu_level.html','120','','','');
  am[am.length]=new Array('mfb','CEE countries','','120','','','');
   am[am.length]=new Array('mfba','New EU members','','120','','','');
   am[am.length]=new Array('mfbb','EU candidates','','120','','','');
   am[am.length]=new Array('mfbc','Others','','120','','','');
  am[am.length]=new Array('mfc','Old EU members','','120','','','');
  am[am.length]=new Array('mfd','ILO conventions','_en/law/ilo_conv.html','120','','','');
 am[am.length]=new Array('mg','Working conditions','','187','','','');
  am[am.length]=new Array('mga','Garment Industry in Poland','_en/conditions/work_cond.html','187','','','');
   am[am.length]=new Array('mgaa','Report','_en/conditions/ccc_rep.html','187','','','');
 am[am.length]=new Array('mh','Relevant global trends','','187','','','');
 am[am.length]=new Array('mi','Events&lobbing','','187','','','');
  am[am.length]=new Array('mia','Events','_en/events/events.html','120','','','');
  am[am.length]=new Array('mib','Lobbying actions','','120','','','');
 am[am.length]=new Array('mj','Campaign','','187','','','');
 am[am.length]=new Array('mk','Visitors input','','187','','','');
  am[am.length]=new Array('mka','Forum','forum/index.php','120','','','');
  am[am.length]=new Array('mkb','Visitors input','','120','','','');
 am[am.length]=new Array('mz','Site map','_en/sitemap.html','187','','','');

 //ustawienia dodatkowe
 for(i=0;i<am.length;i++){
  am[i][cShow]='0';
  if(am[i][cId].substr(am[i][cId].length-1,1)=='a'){
   am[i][cFirst]='1';
  }
  if(am[i][cClass].length==0){
   if(am[i][cId].length>2){
    am[i][cClass]='msn';
   }else{
    am[i][cClass]='min';
   }
  }
 }
}


//pomocnicza - inicjalizacja elementow spisu tresci na stronie
function MapCreate(){
 var i,sOut,iClass,sClass;
 for(i=0;i<am.length;i++){
  //wstawiam element na strone
  sOut=am[i][cText];
  if(am[i][cHref].length>0) {sOut='<a href="'+am[i][cHref]+'">'+sOut+'</a>';}
  iClass=am[i][cId].length-1;
  if(iClass>5) {iClass==5;}
  sClass='sm'+iClass;
  sOut='<div class='+sClass+'>'+sOut+'</div>';
  document.writeln(sOut);
 }
}


//pomocnicza - inicjalizacja elementow menu na stronie
function MenuCreate(){
 var i,sOut,iWidth;
 //elementry 1 poziomu
 for(i=0;i<am.length;i++){
  sOut='';
  sTmp='';
  if(am[i][cId].length==2){
   sOut=sOut+'<span class=mtx>'+am[i][cText]+'</span><span class=msi>';
   if(MenuExistChild(am[i][cId])!=0)
    sOut=sOut+'&rsaquo;</span>';
   else
    sOut=sOut+'&shy;</span>';
   sOut='<div class='+am[i][cClass]+' id='+am[i][cId]+' onmouseover="MenuEnter(this);"'+'>'+sOut+'</div>';
   if(am[i][cHref].length>0){
    sOut='<a style="{text-decoration: none;}" href="'+am[i][cHref]+'">'+sOut+'</a>';
   }
   //sOut='<xmp>'+sOut+'</xmp>';
   document.writeln(sOut);
  }
 }
 //pozostale elementy
 for(i=0;i<am.length;i++){
  sOut='';
  if(am[i][cId].length>2){
   sOut=sOut+'<span style="{width:'+am[i][cWidth]+'px;float:left}">'+am[i][cText]+'</span><span style="{width:7px;float:right}">';
   if(MenuExistChild(am[i][cId])!=0){
    sOut=sOut+'&rsaquo;</span>';
   }else{
    sOut=sOut+'&shy;</span>';
   }
   iWidth=parseInt(am[i][cWidth])+13;
   sOut='<div style="{width:'+iWidth+'px}" class='+am[i][cClass]+' id='+am[i][cId]+' onmouseover="MenuEnter(this);"'+'>'+sOut+'</div>';
   if(am[i][cHref].length>0){
    sOut='<a style="{text-decoration: none;}" href="'+am[i][cHref]+'">'+sOut+'</a>';
   }
   document.writeln(sOut);
  }
 }
}


//zdarzenie - najechanie mysza na element menu
function MenuEnter(el){
 var i,elDst,s,elRoot;
 //var el = window.event.srcElement;
 //var el = window.event ? window.event.srcElement : inEvent.currentTarget;
 var iItem=0,iShow=0,iLen=0;
 var ids,idd;
 var iLenMin=100,iLenMax=0;
  //alert(inEvent.className);
 //zaznaczamy ze menu jest aktywne
 isOff=0;
 //zmiana tla - element
 if(el.className.substr(0,2)=='mi') {el.className='mis';}
 //zmiana tla - podelementy
 if(el.className.substr(0,2)=='ms') {el.className='mss';}
 //wskaznik myszy
 if(MenuGetById(el.id,cHref).length>0)
  el.style.cursor="hand";
 else
  el.style.cursor="default";
 //element zrodlowy
 ids=el.id;
 //sprawdzenie pokazywania elementow
 for(i=0;i<am.length;i++){  
  idd=am[i][cId];
  iShow=0;
  //glowne - zawsze widoczne
  if(idd.length==2) {iShow++;}
  //podrzedne
  if((iShow==0)&&(idd.length<=ids.length+1)&&(idd.substr(0,ids.length)==ids)) {iShow++;}
  //rownorzedne
  if((iShow==0)&&(idd.length<=ids.length)&&(idd.substr(0,idd.length-1)==ids.substr(0,ids.length-1))) {iShow++;}
  //nadrzedne
  if((iShow==0)&&(idd.length<ids.length)&&(idd.substr(0,idd.length-1)==ids.substr(0,idd.length-1))) {iShow++;}
  //zaznaczenia
  if(iShow>0){
   am[i][cShow]="1";
  }else{
   am[i][cShow]="0";
  }
 }
 //sprawdzam min i max dlugosc id (tylko elementy podrzedne)
 for(i=0;i<am.length;i++){
  if(am[i][cId].length<iLenMin) {iLenMin=am[i][cId].length;}
  if(am[i][cId].length>iLenMax) {iLenMax=am[i][cId].length;}
 }
 iLenMin+=1;
 //pokazanie
 for(iLen=iLenMin;iLen<=iLenMax;iLen++){
  iItem=0;
  for(i=0;i<am.length;i++){
   if(am[i][cId].length==iLen){
    elDst=document.getElementById(am[i][cId]);
    if(am[i][cShow]=="1"){
     //if(iItem!=0){elDst.style.borderTopWidth=0;}
     //if(iItem!=0){am[i][cFirst]='1';}
     if(iItem==0){elRoot=document.getElementById(am[i][cId].substr(0,am[i][cId].length-1));}
     elDst.style.visibility="visible";
     elDst.style.left=MenuGetLeft(elRoot)+elRoot.offsetWidth-1;
     elDst.style.top=MenuGetTop(elRoot)+(iItem*(elRoot.offsetHeight));
     iItem+=1;
    }else{
     elDst.style.visibility="hidden";
    }
   }
  }
 }
 //koloruje wszystkie elementy nadrzedne w stosunku do aktualnego
 for(i=0;i<am.length;i++){
  elDst=document.getElementById(am[i][cId]);
  if(am[i][cId]==ids.substr(0,am[i][cId].length)){
   //elDst=document.getElementById(am[i][cId]);
   //zmiana tla - element
   if(elDst.className.substr(0,2)=='mi') {elDst.className='mis';if(am[i][cFirst]!='1'){elDst.style.borderTopColor='#CCCCFF';}}
   //zmiana tla - podelementy
   if(elDst.className.substr(0,2)=='ms') {elDst.className='mss';if(am[i][cFirst]!='1'){elDst.style.borderTopColor='#CCCCFF';}}
  }else{
   //zmiana tla - element
   if(elDst.className.substr(0,2)=='mi') {elDst.className='min';if(am[i][cFirst]!='1'){elDst.style.borderTopColor='#EEEEFF';}}
   //zmiana tla - podelementy
   if(elDst.className.substr(0,2)=='ms') {elDst.className='msn';if(am[i][cFirst]!='1'){elDst.style.borderTopColor='#EEEEFF';}}
  }
 }
}


//zdarzenie - schowanie wszystkich podmenu
function MenuOff(){
var i,elDst;
 //wychodzimy gdy menu nie jest aktywne
 if(isOff==1) {return;}
 //deaktywacja menu
 for(i=0;i<am.length;i++){
  elDst=document.getElementById(am[i][cId]);
  if(am[i][cId].length>2){
   elDst.style.visibility="hidden";
  }
   //zmiana tla - element
   if(elDst.className.substr(0,2)=='mi') {elDst.className='min';}
   //zmiana tla - podelementy
   if(elDst.className.substr(0,2)=='ms') {elDst.className='msn';}
 }
 //zaznaczamy ze menu nie jest aktywne
 isOff=1;
}


//pomocnicza - pobranie polozenia (left) elementu wzgledem przegladarki
function MenuGetLeft(el){
 var iRet=0;
 while(el.offsetParent!=null){
  iRet+=el.offsetLeft;
  el=el.offsetParent;
 }
 iRet+=el.offsetLeft;
 return(iRet);
}


//pomocnicza - pobranie polozenia (top) elementu wzgledem przegladarki
function MenuGetTop(el){
 var iRet=0;
 while(el.offsetParent!=null){
  iRet+=el.offsetTop;
  el=el.offsetParent;
 }
 iRet+=el.offsetTop;
 return(iRet);
}


//pomocnicza - sprawdzenie czy dany element posiada podelementy
function MenuExistChild(pId){
 var i;
 for(i=0;i<am.length;i++){
  if((am[i][cId].length>pId.length)&&(am[i][cId].substr(0,pId.length)==pId))
   return(1);
 }
 return(0);
}


//pomocnicza - pobranie dowolnej wlasciwosci elementu menu na podstawie ID
function MenuGetById(pId,pIndex){
 var i;
 for(i=0;i<am.length;i++){
  if((am[i][cId]==pId))
   return(am[i][pIndex]);
 }
 return('');
}


