jQuery(document).ready(function() {
  jQuery("a.fancybox").fancybox({
    'autoScale'     : true,
    'transitionIn'  : 'fade',
    'transitionOut' : 'fade',
    'titlePosition' : 'inside',
    'overlayColor'  : '#666',
    'overlayOpacity': '0.65',
    'titleFormat'   : function(title, currentArray, currentIndex, currentOpts) {
      return '<span id="fancybox-title-inside">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
    }
  });
  
  jQuery('.carousel-horiz').jcarousel({
    scroll: 1,
    visible: 5
  });
});

jQuery(function() {
  $( "#sortable" ).sortable({
    placeholder: "ui-state-highlight",
    update: function(event, ui) {
      $( "#photo_sort_order" ).val($(this).sortable('toArray').toString());
    }});
  $( "#sortable" ).disableSelection();
  
});


function OS_add_file_input(target_name, name)
{
  var new_input = document.createElement("input");
    new_input.setAttribute("type", "file");
    new_input.setAttribute("id", name);
    new_input.setAttribute("name", name);
    new_input.setAttribute("onchange", "OS_add_file_input('" + target_name + "', '" + name + "');");
    
  var target = document.getElementById(target_name);
    target.appendChild(new_input);
}
