jQuery(document).ready(function() {

	// Vertical Carousel Init - 5 items
	
	
	$(".gbl_carousel_vert_5 ul:first").each(function() {
	
	  var self = $(this);
	  
	  //var num_of_items = self.find("li").length;

	  var curpos= 1;
	  var pos= -1;
	  self.find("li").each(function() {
	  
	  if ((this.className!=null) && (this.className!="")) {
	    if (this.className.indexOf("gbl_carousel_currentasset")>-1) {
	      pos= curpos;
	    }
	  }
	    
	    curpos++;
	  });
	  if (pos==-1) { pos= 1; }
	  
      jQuery(self).mycarousel({
          vertical: true, scroll: 1, visible:5, animation: 0, start: pos
      }); 
	});
	
	//$(".gbl_carousel_vert_5 .gbl_carousel_currentasset");
	/*
    jQuery('.gbl_carousel_vert_5 ul:first').mycarousel({
        vertical: true, scroll: 1, visible:5, animation: 0, start: 5
    });
	*/
	
	$(".gbl_carousel_vert_6 ul:first").each(function() {
	
	  var self = $(this);
	  
	  //var num_of_items = self.find("li").length;

	  var curpos= 1;
	  var pos= -1;
	  self.find("li").each(function() {
	  
	  if ((this.className!=null) && (this.className!="")) {
	    if (this.className.indexOf("gbl_carousel_currentasset")>-1) {
	      pos= curpos;
	    }
	  }
	    
	    curpos++;
	  });
	  if (pos==-1) { pos= 1; }
	  
      jQuery(self).mycarousel({
          vertical: true, scroll: 1, visible:6, animation: 0, start: pos
      }); 
	});
	/*
	// Vertical Carousel Init - 6 items
    jQuery('.gbl_carousel_vert_6 ul:first').mycarousel({
        vertical: true, scroll: 1, visible:6, animation: 0
    });
    */

    
	// Recent Carousel
    jQuery('.pub_recentcarousel ul:first').mycarousel({
        scroll: 1, visible:4, animation: 0
    });
    
    // Forums Carousel
    jQuery('#gbl_forum_carousel ul:first').mycarousel({
        scroll: 1, visible:3, animation: 0
    });
    
    
    jQuery('.gbl_carousel_smallthumb_horiz_4 ul:first').mycarousel({
      scroll: 1, visible:4, animation: 0
    });
  
  // Forum page
  if (!(jQuery.browser.msie && jQuery.browser.version<7)) {
    $("#gbl_sf_blog_cat_filters .gbl_simplestruct_box1 li").each(function (i) {
      this.style.width = parseInt(this.childNodes[0].offsetWidth) + "px";
    });
    
    /*$("#gbl_sf_blog_cat_filters .gbl_simplestruct_box1 a").center( {
       horizontal: false
    });
    
    $("#gbl_sf_blog_cat_filters .gbl_simplestruct_box1 img").center( {
       horizontal: false
    });*/
    
  }
  
  
  // Category Filters Expanding Box
  $("#gbl_sf_blog_cat_filters .gbl_simplestruct_box1 li.last a").click(function() {
    if ( $("#gbl_sf_blog_cat_filters").hasClass("gbl_sf_blog_cat_filters_expanded") ) {
      $("#gbl_sf_blog_cat_filters").removeClass("gbl_sf_blog_cat_filters_expanded").addClass("gbl_sf_blog_cat_filters_contracted");
      $("#gbl_sf_blog_cat_filters .gbl_simplestruct_box3").hide();
      $("#gbl_sf_blog_cat_filters .gbl_simplestruct_box2").hide();
    } else {
		var items = $("#gbl_sf_blog_cat_filters .gbl_simplestruct_box2 li").size();
		if ( items > 0 ) {
			
			if ( items % 4 > 0 ) {
				var rows = Math.floor( items / 4 ) + 1;	
			} else {
				var rows = ( items / 4 );	
			}
			$("#gbl_sf_blog_cat_filters .gbl_simplestruct_box2").attr("style","height:"+(rows * 16) + "px;");
		}
      $("#gbl_sf_blog_cat_filters").removeClass("gbl_sf_blog_cat_filters_contracted").addClass("gbl_sf_blog_cat_filters_expanded");
	  
      $("#gbl_sf_blog_cat_filters .gbl_simplestruct_box2").show("slow");
      $("#gbl_sf_blog_cat_filters .gbl_simplestruct_box3").show();
    }
	return false;
  });
  
  $("#gbl_carousel_vert .mycarousel_next").click(function () {
    var body = $(this).parent().parent();
    body.height(body.height());
    body.css("background","Transparent url(/images/gbl/gbl_carousel/gbl_carousel_vert_bg_wh_body.jpg) repeat-y top left");
  });
  
  $("#gbl_carousel_vert .mycarousel_prev").click(function () {
    var body = $(this).parent().parent();
    body.height(body.height());
    body.css("background","Transparent url(/images/gbl/gbl_carousel/gbl_carousel_vert_bg_wh_body.jpg) repeat-y top left");
  });
    
});

