
var total_portfolio = 0;
function init_portfolio(){
  $("#Portfolio .carousel img:first").fadeIn().addClass("active");
  total = $("#Portfolio .carousel img").length;
  if(total > 1)setInterval('next_portfolio();', 5000);
}

function next_portfolio(){
  var active_id = eval($("#Portfolio img.active").attr("id").substr(2));
  var next_id = active_id + 1;
  if(next_id > (total - 1))next_id = 0;
  
  $("#Portfolio img#pi"+next_id).css({"z-index": "2", "display": "none"}).fadeIn(500, function(){
    $(this).css("z-index", "1").addClass("active");  
    $("#Portfolio img#pi"+active_id).removeClass("active").css("display", "none"); 
  });
}

function buildFlyout(id, args){
  renderFlyout(id);
}

function renderFlyout(id){
  $("#flyoutContent").html($("#"+id).html());
  $("#flyoutShadow").show();
  $("#flyoutContent").show();
}

function hideFlyout(){
  $("#flyoutShadow").hide();
  $("#flyoutContent").hide();
}

$(document).ready(function(){    
  // Smooth scrollers
  $(".scroll-top").click( function(){ $.scrollTo(0, 1000); });
  
  init_portfolio();
});
