var current_id = 'img-0';
var holding = false;

function display_layer(id){
  if(current_id != false && current_id != id){
    close_layer(current_id);
  }
  holding = id;
  show_layer(id);
}

function show_layer(id){
  if(holding == id){
    new Effect.Appear(id, {duration: 1.5});
    current_id = id;
  }
}

function close_layer(id){
  new Effect.Fade(id, {duration: 0.5});
}


/*
* Next and previous funtions for the portfolio images
*/
var current_count = 0;
function next_image(){
  if(current_count + 1 < total_images){
    current_count++;
    display_layer('img-' + current_count);
  }
  fade_controls();
}

function previous_image(){
  if(current_count - 1 >= 0){
    current_count--;
    display_layer('img-' + current_count);
  }
  fade_controls();
}

function fade_controls(){
  if(current_count == 0){
    $('arrow_left').className = 'transparent';
  }else if(current_count + 1 == total_images){
    $('arrow_right').className = 'transparent';
  }else{
    $('arrow_right').className = '';
    $('arrow_left').className = '';
  }
}