

jQuery.gallery = {
	items : [],
	nav:{},
	
	add:function(id,linkObj,type,src,param)
	{
		var gal={};
		
		gal.obj=(typeof linkObj == "object") ? linkObj : jQuery("#"+linkObj);
		gal.type=type;
		gal.src=src;
		gal.param=param || null;
		
		gal.show=function()
		{
			jQuery.gallery.show(id);
		}
		
		if (this.items.length == 0) 
		{
			this.nav.first = gal;
		}
		else 
		{
			gal.next=this.nav.first;
			gal.prev = this.nav.last;
			gal.prev.next = gal;
			this.nav.first.prev = gal;
		}
		this.nav.last=gal;
		
		this.items[id]=gal;
		
		if(gal.obj.hasClass('selected')) this.nav.selected=gal;
		
	},
	
	next:function()
	{
		if(this.nav.selected && typeof this.nav.selected.next == "object") this.nav.selected.next.show();
	},
	
	prev:function()
	{
		if(this.nav.selected && this.nav.selected.prev == "object") this.nav.selected.prev.show();
	},
	
	show:function(id)
	{
		var gal=this.items[id];
		this.nav.selected=gal;
		
		jQuery('#botnav_r .selected').removeClass('selected');
		if(gal.obj) gal.obj.addClass('selected');
		
		if(typeof gal.param == "object" && gal.type=="2")
		{
			//jQuery.showAkModal(gal.src,' ',gal.param.w,gal.param.h);	
			if (jQuery('#galMovie')) 
			{
				jQuery('#galImage').hide();
				jQuery('#galMovie').show();
			}
			else
			{
				document.location.href=gal.src;
			}
		}
		else
		{
			if (jQuery('#galMovie')) {
				jQuery('#galImage').show();
				jQuery('#galMovie').hide();
			}
			
			jQuery('#galImage').attr('src',gal.src);
			jQuery('#galImage').attr('width',gal.param.w);
			jQuery('#galImage').attr('height',gal.param.h);
		}
	}
};


(function() {

  //
  // plugin definition
  //

  jQuery.fn.gallery = function(options) {

    // iterate and reformat each matched element

    return this.each(function() {

      $this = jQuery(this);
	  jQuery.gallery.active.push($this[0]);


    });

  };
})

//
// end of closure
//



function showCredits(show)
{
	if(show)
	{
		$("#desc").css("display","none");
		$("#credits").css("display","inline");
	}
	else
	{
		$("#desc").css("display","inline");
		$("#credits").css("display","none");
	}
}

function savePos(obj)
{
   $.ajax({
   type: "POST",
   url: "?ajax=1",
   data: $('#content').position(),
   success: function(msg){
     document.location.href=obj.href;
   }
 });

}

$(function()
{
	if($('.scroll-pane').jScrollPane)
	{
		$('.scroll-pane').jScrollPane({scrollbarWidth:13,dragMinHeight:34,dragMaxHeight:34,animateTo:false});
	}	
	if(typeof scrollOffset != "undefined") $('.scroll-pane').get(0).scrollTo(scrollOffset*-1);
	
});