//functions to be executed on page load
$(function(){
	
	//Open all links with rel="external" in new window
	$(function(){
		$('a').filter(function(){
			return (!this.target && (this.href.indexOf(window.location.hostname) == -1 || this.href.match(/\.pdf$/i)));
		}).attr('target', '_blank');
	});
	
	
	
	$(".gallery-link").click(function() {
		var gallery = $(this).parent().parent().attr("id");
		$("#"+gallery+" .thumbs ul li a:first").trigger("click");	
		return false;
	});
	
	$("a[rel=skud],a[rel=boxing],a[rel=sail]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titleShow'  		: false,
		'padding' : 10
	});
	
	var $donate = $("#donate"),
		$window = $(window),
		offset = $donate.offset();

	$window.scroll(function() {
		if ($window.scrollTop() > (offset.top-100)) {
			$(".donate").fadeOut(250);
			
		}
		else {
			$(".donate").fadeIn(250);	
		}
	});
	
	$(".donate").live('click',function() {
		var donateTop = $("#donate").offset().top;
		$("html,body").animate({scrollTop: donateTop},500);
		location.hash = $(this).attr("href");	
		return false;
	});
	
	$(".back-link").live('click',function() {
		$("html,body").animate({scrollTop: 0},500);
		location.hash = "home";
		return false;
	});
		
});

//functions to be executed inline
var mylib =
{
	function_name :
	{
		init : function()
		{
			alert('First Function Initialized');
		}
	},
	another_function_name :
	{
		init : function()
		{
			alert('Second Function Initialized');
		}
	}
}
