$(function() {
	//Global variables
	for(var i in $.browser) {
		if ($.browser[i])
			BROWSER = i + (($.browser.msie)?$.browser.version.charAt(0):'');
	}
	//Sifr header
	$('#page-header h1').sifr(
		{ strSWF: 'flash/sabon-lt-std.swf', strColor: '#ffffff', strWmode: 'transparent', intPadding: [17, 0, 17, 4] },
		{ expressInstall: true }
	);
//Start of expand/collapse of team bios
	$("div.team-member").each(function() {
								   
	// Div for the Toggler to be Held
	$(this).append("<div class=\"bio-toggle\" style=\"clear:right;\">");

		// If this is a package that is going to be expanded
		// add a control for it
		if( $(this).is(".team-member") ) {
			// Since this is expandable hide the details
			$(this).find("div.bio-long").hide();
			// Add the Control
			$(this).find(".bio-toggle").append("<a href=\"#\">View Details</a>");
		}
	});


// Once the Package Toggler Control is clicked
// Toggle the details and chance the text
	$("div.bio-toggle a").toggle(function() {
		$(this).parents("div.team-member").find("div.bio-long").show();
		// Changes the Text of the Control
		$(this).html("Hide Details");
	}, function() {
		$(this).parents("div.team-member").find("div.bio-long").hide();
		// Changes the Text of the Control
		$(this).html("View Details");
	});
});
jQuery(function($){
	$('.post').postPreview();
	$('.share-link').initializeSharing();
});

(function($) {	
	$.fn.postPreview = function(options) {
		var defaults = {
			hideDetails : 'Read Less',
			viewDetails : 'Read Full Post'
		},
		opts = $.extend(defaults, options);
		return this.each(function() {
			$('.post-details a', this).toggle(function(event) {
				event.preventDefault();
				$('.share-panel').hide();
				var el = $(this);
				$.get('/direct/scrapbook-details.php', { event_id: this.id.substr(3), channel: this.rel, lang: 'en' },function(data) { 
					el.html(opts.hideDetails).parent().addClass('active').parent().children('.post-description').hide().html(data).slideDown('slow');
				});
			},function(event) { 
				event.preventDefault();
				$('.share-panel').hide();
				$(this).html(opts.viewDetails).parent().removeClass('active').parent().children('.post-description').slideUp('slow', function() { 
					$(this).html(''); 
				});
			});
		});
	};

	$.fn.initializeSharing = function() {
		return this.each(function() {
			$('.share-link').live('click',function(event) {
				event.preventDefault();
				$('.share-panel').hide();
				$(this).parents('.rss-item').find('.share-panel').css('display','inline');
			});
			$('.share-close').live('click',function(event){
				event.preventDefault();
				$(this).parents('.rss-item').find('.share-panel').hide();
			});
		});
	};

})(jQuery);
