// Download functions
	
var fancyboxDownloadLink = function(href) {
	return '<a href="' + href + '" style="color: #FFF !important; text-decoration: none;">Download this file</a>'; 
}

var fancyboxDownloadable = function(classes) {
	if (classes != undefined && classes != null && classes.search(/downloadable/i) >= 0) {
		return true; 
	}
	return false; 
}

// Initialize Fancybox

function initializeFancybox() {

	jQuery("a.fancybox.youtube").click(function() {
		jQuery.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'elastic',
			'transitionOut' : 'fade',
			'title' : this.title,
			'width' : 680,
			'height' : 495,
			'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type' : 'swf',
			'swf' : {
				'autoplay' : 'true', 
				'wmode' : 'transparent',
				'allowfullscreen' : 'true'
			}
		});
		
		return false;
	});
	
	jQuery("a.fancybox.scholarship").click(function() {
		jQuery.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'elastic',
			'transitionOut' : 'fade',
			'title' : this.title,
			'width' : 830,
			'height' : 495,
			'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type' : 'swf',
			'swf' : {
				'autoplay' : 'true', 
				'wmode' : 'transparent',
				'allowfullscreen' : 'true'
			}
		});
		
		return false;
	});

	jQuery("a.fancybox.swf").click(function() {
		jQuery.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'elastic',
			'transitionOut' : 'fade',
			'title' : this.title,
			'href' : this.href,
			'type' : 'swf',
			'swf' : {
				'autoplay' : 'true', 
				'wmode' : 'transparent',
				'allowfullscreen' : 'true'
			}
		});
		
		return false;
	});

	jQuery("a.fancybox.no-overlay-swf").click(function() {
		jQuery.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'elastic',
			'transitionOut' : 'fade',
			'title' : this.title,
			'href' : this.href,
			'type' : 'swf',
			'swf' : {
				'autoplay' : 'true', 
				'wmode' : 'transparent',
				'allowfullscreen' : 'true'
			}
		});
		
		return false;
	});

	jQuery("a.fancybox.audio").click(function() {
		jQuery.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'elastic',
			'transitionOut' : 'fade',
			'title' : fancyboxDownloadable(this.className) ? fancyboxDownloadLink(this.href) : this.title,
			'href' : '/public/flash/nonverblaster.swf?controlColor=0x000000&controlBackColor=0x999999&autoplay=true&mediaurl=' + this.href,
			'type' : 'swf',
			'width' : 400, 
			'height' : 35, 
			'swf' : {
				'autoplay' : 'true', 
				'wmode' : 'transparent',
				'allowfullscreen' : 'true', 
				'mediaurl': this.href, 
				'flashvars': 'controlColor=0x000000&controlBackColor=0x999999&autoplay=true&mediaurl=' + this.href 
			}
		});
		
		return false;
	});

	jQuery("a.fancybox.pdf").click(function() {
		jQuery.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'elastic',
			'transitionOut' : 'fade',
			'title' : this.title,
			'href' : this.href,
			'frameHeight': '90%',
			'frameWidth': '50%',
			'overlayShow': true,
			'hideOnContentClick': false, 
			'type' : 'iframe',
			'height' : '90%', 
			'width' : '50%' 
		});
		
		return false;
	});

	jQuery("a.fancybox.img").click(function() {
		jQuery.fancybox({
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'elastic',
			'transitionOut' : 'fade',
			'title' : this.title,
			'href' : this.href,
			'frameHeight': '90%',
			'frameWidth': '50%',
			'overlayShow': true,
			'hideOnContentClick': false, 
			'type' : 'image',
			'height' : '90%', 
			'width' : '50%' 
		});
		
		return false;
	});

	jQuery("a.fancybox.desktop").click(function() {
		jQuery.fancybox({
			'padding' : 0,
			'autoScale' : true,
			'transitionIn' : 'elastic',
			'transitionOut' : 'fade',
			//'title' : this.title,
			'title' : fancyboxDownloadable(this.className) ? fancyboxDownloadLink(this.href) : this.title,
			'href' : this.href,
			'frameHeight': '90%',
			'frameWidth': '50%',
			'overlayShow': true,
			'hideOnContentClick': true, 
			'type' : 'image',
			'height' : '90%', 
			'width' : '50%' 
		});
		
		return false;
	});
/*
	jQuery("a.fancybox.swf img").each(function() { fancyboxVideoOverlay(this); }); 
	jQuery("a.fancybox.youtube img").each(function() { fancyboxVideoOverlay(this); }); 
	jQuery("a.fancybox.overlay img").each(function() { fancyboxVideoOverlay(this); });  
	jQuery("span.poster_frame img").each(function() { fancyboxVideoOverlay(this); });  
*/
	jQuery("a.fancybox.image").fancybox();
}

jQuery(document).ready(function() {
	initializeFancybox(); 
}); 

