﻿(function(){ 
var dep = {"jQuery":"http://code.jquery.com/jquery-latest.min.js"}; 
var init = function(){  
 
/* Options (in any order): 
 
 target (number|string)
    target div
 
*/ 
(function($){
    $.videoShow = function(target, group) { 
        
        $.videoShow.settings.target = target + "-carousel";
        var groups = new String(group).split(',');
        $.each(groups, function(index) {            
            $.videoShow.settings.group += this + "-carousel" + ((index != groups.length-1) ? "," : "");
        });

        $($.videoShow.settings.group).hide();
        $($.videoShow.settings.target).show();
               
        // Se nao tiver sido criado um carousel ainda para esta aba 		
        if($.videoShow.settings.ready.indexOf($.videoShow.settings.target) < 0)
        {
            $.videoShow.settings.ready += $.videoShow.settings.target + ",";

            $($.videoShow.settings.target).jcarousel({
                scroll: 3,
                initCallback: function(carousel) {
                    $($.videoShow.settings.target + '-next').bind('click', function() {
                        carousel.next();
                        return false;
                    });

                    $($.videoShow.settings.target + '-prev').bind('click', function() {
                        carousel.prev();
                        return false;
                    });
                },
                buttonNextHTML: null,
                buttonPrevHTML: null,
                wrap: "last"
            });
        }		
        return true;     
    } 
 
    //Defaults 
    $.videoShow.settings = {
        target: "",
        group: "",
        ready: ""
    }; 
 
  //Version 
  $.videoShow.version = "1.0"; 
 
  //Auto-run 
  //$(function(){ $(".videoshow").idTabs(); }); 
})(jQuery); 
 
 
 
} //init 
 
// Check Dependencies 
var check = function(o,s){ 
  s = s.split('.'); 
  while(o && s.length) o = o[s.shift()]; 
  return o; 
} 
 
// Add Script 
var head = document.getElementsByTagName("head")[0]; 
var add = function(url){ 
  var s = document.createElement("script"); 
  s.type = "text/javascript"; s.src = url; 
  head.appendChild(s); 
} 
 
// Save Self 
var s = document.getElementsByTagName('script'); 
var src = s[s.length-1].src; 
 
// Load Dependencies 
var ok=true; 
for(d in dep) { 
  if(check(this,d)) continue; 
  ok=false; 
  add(dep[d]); 
} if(ok) return init(); 
 
// Reload Self 
add(src); 
 
})(); 