// remap jQuery to $
(function($){})(window.jQuery);


/* trigger when page is ready */
$(document).ready(function (){

	     /*$("a#play-flv-video").fancybox({
	         'scrolling': false,
	         'titleShow': false,
			 'overlayColor':'#000',
	         'padding'  : 0,
			 'showCloseButton'	: true,
	         'onStart'  : function() {
	             $("#player").show();
	             $f("player",
	                     "assets/swf/flowplayer-3.1.5.swf",
	                     "assets/video/11-06-22_TW_Trailer_720.mov");
	         },
	         'onClosed'  : function() {
	             $("#player").hide();
	             $f().unload();
	         }
	     });
	*/
	
		$("a#requestScreening").fancybox({
			'scrolling'		: 'no',
			'titleShow'		: false,
			'overlayColor'	:'#000',
			'width'			: 580,
			'height'		: 320,
			'autoDimensions': false,
			'padding'		: 0,
			'opacity'		: 0.7,
			'showCloseButton' : true,
			'onClosed'		: function() {
			    $("#login_error").hide();
			}
		});
		
		$("a#requestScreeningsPage").fancybox({
			'scrolling'		: 'no',
			'titleShow'		: false,
			'overlayColor'	:'#000',
			'width'			: 580,
			'height'		: 320,
			'autoDimensions': false,
			'padding'		: 0,
			'opacity'		: 0.7,
			'showCloseButton' : true,
			'onClosed'		: function() {
			    $("#login_error").hide();
			}
		});
		
		$("a#FaroeTextLink").fancybox({
			'scrolling'		: 'yes',
			'titleShow'		: false,
			'overlayColor'	:'#000',
			'width'			: 580,
			'height'		: 550,
			'autoDimensions': false,
			'padding'		: 0,
			'opacity'		: 0.7,
			'showCloseButton' : true,
			'onClosed'		: function() {
			    $("#login_error").hide();
			}
		});
		
		
		$("#play-flv-video").click(function() {
			$.fancybox({
					'padding'		: 0,
					'autoScale'		: false,
					'transitionIn'	: 'none',
					'transitionOut'	: 'none',
					'title'			: this.title,
					'width'			: 720,
					'height'		: 450,
					'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type'			: 'swf',
					'swf'			: {
					   	 'wmode'		: 'transparent',
						'allowfullscreen'	: 'true'
					}
				});

			return false;
		});
		
		$("#request_form").bind("submit", function() {

			if ($("#contact_name").val().length < 1 || $("#contact_email").val().length < 1) {
			    $("#login_error").show();
			   $.fancybox.resize();
			    return false;
			}

			$.fancybox.showActivity();

			$.ajax({
				type		: "POST",
				cache	: false,
				url		: "ajax/requestScreeningData.php",
				data		: $(this).serializeArray(),
				success: function(data) {
					$.fancybox(data);
				}
			});

			return false;
		});

});


/* optional triggers

$(window).load(function() {
	
});

$(window).resize(function() {
	
});

*/
