// Add class for Javascript flash of Unstlyed Content (FOUC)
$('html').addClass('js');

$('document').ready(function(){
	
	// Place anything in here you only want to apply to tablet and desktop screens
	if($(document).width() > 320) {		
		
		// Fancybox Media Viewer
		// Open on page load
		$('a.xmasMsg').fancybox({
			'overlayOpacity' :	0.5,
			'overlayColor'	 :	'#000',
			'titlePosition'	 :	'over',
			'autoScale'		 :	false	
		})//.trigger('click');

		$('a.fancybox-image').fancybox({		
			'overlayOpacity' :	0.5,
			'overlayColor'	 :	'#000',
			'titlePosition'	 :	'over'
		});
		
		$('a.fancybox-image-scale').fancybox({		
			'overlayOpacity' :	0.5,
			'overlayColor'	 :	'#000',
			'titlePosition'	 :	'over',
			'autoScale'		 :	true
		});
			
		$("a.fancybox-youtube").click(function() {
			$.fancybox({
			'padding'				: 0,
			'autoScale'				: false,
			'transitionIn'			: 'none',
			'transitionOut'			: 'none',
			'title'					: this.title,
			'href'					: this.href.replace(new RegExp('watch\\?v=', 'i'), 'v/'),
			'type'					: 'swf',
			'swf'					: {'wmode': 'transparent', 'allowfullscreen': 'true'},
			'width'					: 720,
			'height'				: 430,
			'hideOnOverlayClick'	: false,			
			'overlayOpacity'		: 0.5,
			'overlayColor'			: '#000'
			});
			return false;
		});		
		
		// Home Page Modal Dialog
		$('#homePageModal').dialog({ autoOpen: true, modal: true, resizable: false, width: '900px', title: 'Important Message' });
		$('#homePageModal a.closeDialog').click(function(){
			$('#homePageModal').dialog('close');
			return false;
		});
		
		// Job Application Form Modal Dialogs
		$('#applicationFormDialog').dialog({ autoOpen: false, modal: true, resizable: false, width: '330px', title: 'Job Application Form' });			
		$('a[class~=applicationForm]').click(function(){
			$('#applicationFormDialog').dialog('open');
			return false;
		});	
		$('#applicationFormDialog2').dialog({ autoOpen: false, modal: true, resizable: false, width: '330px', title: 'Job Application Form' });			
		$('a[class~=applicationForm2]').click(function(){
			$('#applicationFormDialog2').dialog('open');
			return false;
		});
		
		// ContentSubNav Image Links
		$('div.imageLinks a').hover(function(){
			$(this).children('div').animate({
				marginTop:'0px'
			}, {
				duration:100}
			);
			}, function(){
			$(this).children('div').animate({
				marginTop:'60px'
			}, {
				duration:100
			}
			);
		});
		
	}
	
	// Important Message (Close Button)
	$('#importantDivMsg .closeBtn').click(function(){
		$('#importantDivMsg').hide();
	});
	
	// Image preload and Image Scroller
	$('.bannerImg img').imgpreload(function(){
		$('.bannerImg').cycle({ fx: 'fade' });
	});
	
	// Automatic Icon Generator for 'downloadList' class
	$('ul.downloadList li a[href$=pdf]').parent('li').addClass('iconPDF');
	$('ul.downloadList li a[href$=jpg]').parent('li').addClass('iconJPG');
	$('ul.downloadList li a[href$=mp3]').parent('li').addClass('iconMP3');
	
	// Automatic Icon Generator for 'jobVacancy' class
	$('div.jobVacancy a.button[href$=pdf]').addClass('vacancy-iconPDF');
	$('div.jobVacancy a.button[href$=doc]').addClass('vacancy-iconWORD');	

	// Concerts and Productions
	$('div.production a.photosButton').hide();		
	$('div.production a.showDetails').css('visibility', 'visible');		
	
	$('div.production a.showDetails').click(function(){
		$(this).next('div.productionInfo').slideToggle('fast',function(){
				$(this).children('a.photosButton').slideDown('fast');
		});
	
		$(this).text($(this).text() == 'Details' ? 'Details' : 'Details');
		$(this).toggleClass('hideDetails');
		return false;
	});
		
});
