
  var akt=1;
  var animspeed=6000;
  var aktfotka=0;
  var speed=7000;
  
  var aktfotka2=0;
  var prestr='';
  
  var aktmall=0;

  function showmall(idx){
		$('.mall').fadeOut(1500);
		$('.mall:eq('+idx+')').fadeIn(1500);
		$('#malls a').attr('class','inactivemall');
		$('#malls a:eq('+idx+')').attr('class','activemall');
		aktmall=idx;
  }
  
  function rotatemalls(){
    pocet=$('.mall').size();
    aktmall=(aktmall+1)%pocet;
    showmall(aktmall);
    malltimer=setTimeout('rotatemalls();',6000);
  }

  $(document).ready(function(){
							 
    $('#malls a').click(function(){
      if (malltimer){
        clearTimeout(malltimer);
      }
      if ($(this).attr('class')!='activemall'){
        showmall($('#malls a').index(this));
      }
      malltimer=setTimeout('rotatemalls();',6000);
    });
    
  
    /*$('.mall:not(:first)').hide();
    $('#malls a:first').attr('class','activemall');*/
    
    showmall(0);
    malltimer=setTimeout('rotatemalls();',6000);

		max=0;
		$('#sitemap>li').map(function(){
			max=Math.max(max,$(this).height());
		});
		$('#sitemap>li>div').height(max-24);
		$('#sitemap>li>div>ul').height(max-46);
		$('#sitemapcover,#sitemap2').height(max);
		$('#sitemap2').hide();

      xgal();
      $('#gal img').closest('a').attr('rel','lgal').lightbox();
      
      for (i=1;i<=$('#headergalin>div').size()-2;i++){
        prestr+='<li><a href="">'+i+'</a></li>';
      }
      if (prestr){
        $('#headergalcover ul').prepend(prestr);
      }
      
      $('#headergalcover ul a').attr('class','xnone').attr('href','javascript:;').click(function(){
        idx=$('#headergalcover ul a').index(this);
        pos=$('#headergalin>div:eq('+idx+')').position().top;
        hght=$('#headergalin>div:eq('+idx+')').height();
        if ($(this).attr('rel')=='hbutt'){
          $('#headerlogo').slideUp('slow');
          if (/*hght==389*/$('#headergal').height()==389 && $(this).attr('class')=="active"){
            hght=189;
          } else {
            hght=389;
          }
        } else {
          $('#headerlogo').slideDown('slow');
        }
        $('#headergalin').animate({top: '-'+pos+'px'},'slow');
        if ($('#headergal').height()!=hght){
          /*$('#headergal').animate({height: hght+'px'},'slow');
          $('#headergalcover').animate({height: (hght+20)+'px'},'slow');
          $('#headergallerycover,#headergallery').animate({height: (hght+20)+'px'},'slow');
          $('.investoverview').animate({paddingTop: (hght+60)+'px'},'slow');*/
          
          $('#headergal').css('height',hght+'px');
          $('#headergalcover').css('height',(hght+20)+'px');
          $('#headergallerycover,#headergallery').css('height',(hght+20)+'px');
          $('.investoverview').css('paddingTop',(hght+60)+'px');
          
          $('.investoverview').css('background-position','center '+(hght+110)+'px');

          h=Math.max($(window).height(),$('#content').height()+133);
          $('#container').height(h);
        }
        $('#headergalcover ul a').attr('class','xnone');
        $(this).attr('class','active');
      });
      $('#headergalcover ul a:first').attr('class','active');
        
    var pocet=$('#foldset>div').size();
    var max=0;
    for (i=0;i<pocet;i++){
      if (!$('#foldset>div:eq('+i+')').text()){
        $('#foldlist a[href=#'+($('#foldset>div:eq('+i+')').attr('id'))+']').hide();
        $('#foldset>div:eq('+i+')').hide();
      }
      max=Math.max(max,$('#foldset>div:eq('+i+')').height());
    }
    $('#foldset>div').height(max);
    
    $('#foldset>div:visible:not(:first)').hide();

    $('#foldlist a').click(function(){
      myFolds($(this).attr('href'));
      return false;
    });
    
    $('#foldlist>li:last').css('background-image','none');

    var h=Math.max($(window).height(),$('#content').height()+133);
    $('#container').height(h);

    $('.menuactive>ul').show();
    $('#menu>li').bind('mouseleave',function(){
      $(this).children('ul').hide();
    }).bind('mouseenter',function(){
      $(this).children('ul').show();
    });
    
    /*$('#headergallery>img:not(:first)').hide();
    setTimeout("slideshow()",speed);*/

    pocet=$('#rightcol h3:not([class=skipimg][class=img1][class=img3])').size();
    for (i=0;i<pocet;i++){
      htm='<img src="http://www.pareto.co.za/img/?img=2&nadpis='+encodeURI($('#rightcol h3:not([class=skipimg][class=img1]):eq('+i+')').text())+'" alt="" />';
      //alert(htm);
      $('#rightcol h3:not([class=skipimg][class=img1]):eq('+i+')').html(htm);
    }

    pocet=$('.archive h2').size();
    for (i=0;i<pocet;i++){
      ///only one with img=1
      htm='<img src="http://www.pareto.co.za/img/?img=1&nadpis='+encodeURI($('.archive h2:eq('+i+')').text())+'" alt="" />';
      //alert(htm);
      $('.archive h2:eq('+i+')').html(htm);
    }

    pocet=$('#hpleft h2').size();
    for (i=0;i<pocet;i++){
      ///only one with img=1
      htm='<img src="http://www.pareto.co.za/img/?nadpis='+encodeURI($('#hpleft h2:eq('+i+')').text())+'" alt="" />';
      //alert(htm);
      $('#hpleft h2:eq('+i+')').html(htm);
    }

    pocet=$('#rightcol h3[class=img1]').size();
    for (i=0;i<pocet;i++){
      htm='<img src="http://www.pareto.co.za/img/?img=1&nadpis='+encodeURI($('#rightcol h3[class=img1]:eq('+i+')').text())+'" alt="" />';
      //alert(htm);
      $('#rightcol h3[class=img1]:eq('+i+')').html(htm);
    }

    pocet=$('#rightcol h3[class=img3]').size();
    for (i=0;i<pocet;i++){
      htm='<img src="http://www.pareto.co.za/img/?img=3&nadpis='+encodeURI($('#rightcol h3[class=img3]:eq('+i+')').text())+'" alt="" />';
      //alert(htm);
      $('#rightcol h3[class=img3]:eq('+i+')').html(htm);
    }

  });
  
  function moveleft(){
    aktfotka2=((aktfotka2-1)+$('#gal img').size())%$('#gal img').size();
    xgal();
  }
  function moveright(){
    aktfotka2=(aktfotka2+1)%$('#gal img').size();
    xgal();
  }
  
  function xgal(){
        $('#gal img').hide();
        $('#gal img:eq('+aktfotka2+')').show();
        $('#gal span').text((aktfotka2+1)+'/'+$('#gal img').size()+' '+$('#gal img:eq('+aktfotka2+')').attr('title'));
  }
    
    
 function slideshow(){
    var pocetfotek=$('#headergallery>img').size();
    if (pocetfotek>1){
      var nextfotka=(aktfotka+1)%pocetfotek;
      $('#headergallery>img:eq('+aktfotka+')').fadeOut(2000);  
      $('#headergallery>img:eq('+nextfotka+')').fadeIn(2000); 
      aktfotka=nextfotka;
      setTimeout('slideshow()',speed);
    }
  }

  function myFolds(fid){
      $('#foldset>div').slideUp('slow');
      $(fid).slideDown('slow');
      if (fid=='#location'){
        $('#location iframe').attr('src',$('#location iframe').attr('src'));
      }
  }