/**
 * Team Strong Style jQuery functions
 *
 * @author Martin Bean <martin@mcbwebdesign.co.uk>
 */
$(document).ready(function() {
	videoLinks();
	externalLinks();
	initPopup();
});

//
function externalLinks() {
	$('a[rel="external"]').each(function() {
		var title = $(this).attr('title');
		$(this).attr('title', title + ' (opens in a new window)');
		$(this).addClass('external');
		$(this).click(function() {
			window.open($(this).attr('href'));
			return false;
		});
	});
};

//
function videoLinks() {
	$('.videos a').each(function() {
		$(this).removeAttr('rel');
		$(this).click(function() {
			var parts = $(this).attr('href').split('?v=');
			var videoURL = parts[1];
			var c = $('<div id="' + parts[1] + '"><div style="text-align:center;"><img src="' + images_url + '/facebox/loading.gif" /></div></div>');
			$(c).load('/video.php?v=' + videoURL, function(){
				jQuery.facebox(c);
			});
			return false;
		});
	});
};

// 
function initPopup() {
	$('a[rel="popup"]').facebox();
};