google.setOnLoadCallback(function() {
//TABS
    $('#tabs').tabs({ spinner: '<img src="/themes/default_site/css/images/ajax-loader.gif"/>' });
	$('#tabs2').tabs({ spinner: '<img src="/themes/default_site/css/images/ajax-loader.gif"/>' });
	//{ 'option', 'spinner', '<img src="/themes/default_site/css/images/ajax-loader.gif" title="loading now..."/>' }

//FLASH OBJECT OPACITY
	$(".embedHolder object").append('<param name="wmode" value="transparent">');
	$(".embedHolder embed").attr("wmode", "transparent");
	$(".embedHolder").each(
		function () {
			var cont = '<div class="embedHolder">' + $(this).html() + '</div>';
			$(this).replaceWith(cont);
		}
	);
	
//FACEBOOK LINK POPUPS


  

		                
		                $('a[href^="http://www.facebook.com/sharer.php"]').click(function (e) {
		                		jQuery.modal('<iframe src="'+this.href+'&output=embed"></iframe><p class="larger"><a target="_blank" href="'+this.href+'">View larger</a></p>');
		                		return false;
		                	});
// SIDEBAR MAGIC

	$('#sidebar, #navbar').css('position', 'fixed');

	// only continue if the content is bigger than the sidebar
	if ($('#articles').height() > $('#sidebar').height()) {	
		// now, highjack the scroll and the resize of the window and pass it to adjustSidebar
		$(window).bind('scroll resize', adjustSidebar);
		// make sure the sidebar gets a decent start position too (viz. after a refresh)
		adjustSidebar();
	
	}
	
	// function to adjust the position of the sidebar
	function adjustSidebar() {
		
		// define ze percentage scrolled as the offset from the top divided by the height of the document (minus the height of the viewport)
		var perc = $(window).scrollTop() / ($(document).height() - $(window).height());
		
		// only adjust the sidebar if it is bigger than the viewport (minus the header)
		if (($('#sidebar').height() + 300) > ($(window).height() + $('#header').height())) {
		
			// define the possible end position of the sidebar as the difference between the height of the sidebar and the height of the viewport + take some extra padding into account
			var endPos = $('#sidebar').height() - $(window).height() + 300;
		
			// adjust position of the sidebar by adjusting the top position
			$('#sidebar').css('top', ((-1) * (endPos * perc)) + 'px');
		
		} else {
			$('#sidebar').css('top', '0');
		}
		
		// after a look or two, we decided to keep our pink bodybuilder fixed after all ... et.phoning.home
		return;
		
		// define the possible end position of the navbar
		var nendPos = $(window).height() - 515;
		
		// adjust position of the sidebar by adjusting the top position
		$('#navbar').css('top', ((-1) * (nendPos * perc) + 395) + 'px');
		
		// what, that's it sherlock!
		
	}



});
