Element.Events.click = { 
  base:'click',
  onAdd: function() {
    this.setStyle('cursor','pointer');
  },
  onRemove: function() {
    this.setStyle('cursor','');
  }
};
var Slideshow = {
     init:function(){
                if(slideshowImagesArray.length==0){
                    if(urlArray.length==1){
                        $('imgSlideShowElement1').addEvent('mouseover',function(){this.setStyle('cursor','pointer')});
                    
                         $('imgSlideShowElement1').addEvent('click',function(){
                                   document.location=urlArray[0];
                          });
                          
                          
                          $('imgSlideShowElement2').addEvent('mouseover',function(){this.setStyle('cursor','pointer')});
                    
                         $('imgSlideShowElement2').addEvent('click',function(){
                                   document.location=urlArray[0];
                          }); 
                    }
                
                }else{
               if(slideshowImagesArray.length==1){
           if(urlArray[0]!=''){
               if(urlArray[0].charAt( urlArray[0].length-1 )!='/' ){
                    urlArray[0]='http://www.gaasbeek.nl/'+urlArray[0]+'/';
               }
     
               $('imgSlideShowElement1').addEvent('click',function(){
                         document.location=urlArray[0];
                });
                $('imgSlideShowElement2').addEvent('click',function(){
                         document.location=urlArray[0];
                });
          }
               }else{
           rootdiv=$('imgslideshow');
           div1=$('imgSlideShowElement1');
           div2=$('imgSlideShowElement2');

         rootdiv.fade(1);
          div1.fade(1);
          div2.fade(0);
                var img=div2.getElementsByTagName('img');   
               var myfirstimage=div1.getElementsByTagName('img');        
          if(urlArray[0]!=''){     
               if(urlArray[0].charAt( urlArray[0].length-1 )!='/' ){
                    urlArray[0]='http://www.gaasbeek.nl/'+urlArray[0]+'/';
               }
               div1.addEvent('mouseover',function(){this.setStyle('cursor','pointer')});
               myfirstimage[0].addEvent('click',function(){
                         document.location=urlArray[0];
                });
          }  
          
          
          if(urlArray[1]!=''){
               if(urlArray[1].charAt( urlArray[1].length-1 )!='/' ){
                    urlArray[1]=urlArray[1]+'/';
               }
               img[0].addEvent('mouseover',function(){this.setStyle('cursor','pointer')});
               img[0].addEvent('click',function(){
                         document.location=urlArray[1];
                });
          }
          
                    (function() {  Slideshow.switchImage(img[0],slideshowImagesArray[1]) }).delay(1000);        
                    (function() {  Slideshow.start(1,slideshowImagesArray.length,0) }).delay(6000);
               } 
         }
     },
     start:function(i,length,switchs){
    
       if(switchs==0){

          div1.fade(0);
          div2.fade(1);

          switchs=1;
          i++;
          if(i==length){
               i=0;
          } 
          var img=div1.getElementsByTagName('img');
          if(urlArray[i]!=''){
               if(urlArray[i].charAt( urlArray[i].length-1 )!='/' ){
                         urlArray[i]='http://www.gaasbeek.nl/'+urlArray[i]+'/';
               }
               img[0].addEvent('mouseover',function(){this.setStyle('cursor','pointer')});
               img[0].addEvent('click',function(){
                         document.location=urlArray[i];
                });
          }
          (function() {  Slideshow.switchImage(img[0],slideshowImagesArray[i]) }).delay(1000);
       }else{

             div1.fade(1);
          div2.fade(0);

          switchs=0;
          i++;
          if(i==length){
               i=0;
          }
          var img=div2.getElementsByTagName('img');
          if(urlArray[i]!=''){
               if(urlArray[i].charAt( urlArray[i].length-1 )!='/' ){
                    urlArray[i]='http://www.gaasbeek.nl/'+urlArray[i]+'/';
               }
               img[0].addEvent('mouseover',function(){this.setStyle('cursor','pointer')});
               img[0].addEvent('click',function(){
                         document.location=urlArray[i];
                });
          }
          (function() {  Slideshow.switchImage(img[0],slideshowImagesArray[i]) }).delay(1000);   
       } 
       (function() {  Slideshow.start(i,length,switchs) }).delay(6000);
          
     },
     switchImage:function(id,image){
          id.src=image;
     }
};




