$(document).ready(function() {

	$('a.lightbox').bind({
		click: function(){
			this.title = tempTitleProject;
		},
		mouseenter: function(){
			tempTitleProject = this.title;
			this.title = "";
		},
		mouseleave: function(){
			this.title = tempTitleProject;
		}
	});


	if ($('a.lightbox').length != 0) {
		$("a.lightbox").fancybox({
			'padding'			: 10,
			'margin'			: 100,
			'showCloseButton'	: false,
			'showNavArrows'		: true,
			'titleShow'			: true,
			'titlePosition'		: 'outside',
			'cyclic'			: true,
			'overlayColor'		: '#000',
			'overlayOpacity'	: 0.80,
			'centerOnScroll'	: true,
			'titleFormat'		: formatTitle
		});
	}

});

function formatTitle(title,currentArray,currentIndex,currentOpts) {
	//var tempTitle = '<span class="titleClass">' + title.replace('//','<br />') + "</span>";
	var tempTitle = '<span class="titleClass">' + tempTitleProject.replace(' ///','<br />') + "</span>";
	var replacer = new RegExp(" // ","g");
	var tempTitle = tempTitle.replace(replacer,'<span class="greyClass uppercaseClass">');
	var replacer = new RegExp(" :: ","g");
	var tempTitle = tempTitle.replace(replacer,'</span> ');

	html  = '';
	html += '<div class="fancyboxDescriptionClass">'
	html += '<div class="fancyboxDescriptionTextClass">' + (title && title.length ? tempTitle : '' ) + '</div>';
	html += '<div class="fancyboxDescriptionOptionsClass">';
	if (currentArray.length >= 2) html += '<a href="javascript:;" onclick="$.fancybox.prev();">prev</a> | ' + (currentIndex + 1) + ' of ' + currentArray.length + ' | <a href="javascript:;" onclick="$.fancybox.next();">next</a><br />';
	html += '<a href="javascript:;" onclick="$.fancybox.close();">close</a></div>';
	html += '<div class="clearClass"></div>'
	html += '</div>'
	return html;
}

