$(document).ready(function(){
	$('#calendar_container').fullCalendar({
    	events: $.fullCalendar.gcalFeed(
        	'https://www.google.com/calendar/feeds/leedsnewmuslims.org.uk_qraslqsh7knvkgpoqi5nkh3jm4%40group.calendar.google.com/public/basic'
        )
    });						   					   

				
	$('.swf_video').click(function(){
		
		var video = $(this).data('url'); 
		
		var flashvars = {
			'url'	: "http://www.leedsnewmuslims.org.uk" + video,
			'width'	:	'720',
			'height'	: 	'480',
			'bgcolor'	:	'0x000000',
			'autostart'	: 'true'
		};
	
		var params = {
			'movie' 	: "http://www.leedsnewmuslims.org.uk" + video,
			'menu'	: 'true'
		};
	
		$(this).fancybox({
			swf 			: {"flashvars" : flashvars, "params": params, wmode:"transparent"},
			href			: "/popups/video/",
			width			: flashvars.width,
			height			: flashvars.height,
			centerOnScroll	: true,
			onComplete		: function() {
				swfobject.embedSWF("http://www.leedsnewmuslims.org.uk/flvPlayer.swf", "video_container", "720", "480", "9.0.0", false, flashvars, params);
			}
		
		});
		return false;
	});
	
	$('form[name=send_a_message]').submit(function() {
	
		var $this = $(this);
		$.post("http://www.leedsnewmuslims.org.uk/contact/form_validation.php", $this.serialize(), function(response) {
			
			switch (response.type) {
				case "success":
					$this.find('.success_cover').fadeIn();
					$this.find('.form_content').hide();
					break;
					
				case "error":
					$this.find('.response_holder').quickResponse("error", response.message);
					break;
			}
		}, "json");		
		
		return false;
	});
	
	
	$('form[name=send_a_message-dev]').submit(function() {
	
		var $this = $(this);
		$.post("http://www.leedsnewmuslims.org.uk/contact/form_validation-dev.php", $this.serialize(), function(response) {
			
			switch (response.type) {
				case "success":
					$this.find('.success_cover').fadeIn();
					$this.find('.form_content').hide();
					break;
					
				case "error":
					$this.find('.response_holder').quickResponse("error", response.message);
					break;
			}
		}, "json");		
		
		return false;
	});
	
	// 	Popups

	//	Sign In
	var options = {
		content					: "http://www.leedsnewmuslims.org.uk/sign-in/form.php",
		validationUrl			: "http://www.leedsnewmuslims.org.uk/sign-in/form_validation.php",
		callback				: {
			onSuccess	: function(){ window.location = "/"; },
			onOpen		: function(){ Cufon.refresh(); }
		}
	};
	$(".sign_in").rpPopup(options);


	//	Forgotten Password
	var fp_options = {
		content					: "http://www.leedsnewmuslims.org.uk/forgotten-password/form.php",
		validationUrl			: "http://www.leedsnewmuslims.org.uk/forgotten-password/form_validation.php",
		callback				: {
			onSuccess : function(){ window.location = "/" },
			onOpen	: function(){Cufon.refresh();}
		}
	};
	
	$(".forgotten_password").live("click", function() {
		$.rpPopup.open(fp_options);
		return false;
	});
	
	
	//	Register
	var register_options = {
		content					: "http://www.leedsnewmuslims.org.uk/register/form.php",
		validationUrl			: "http://www.leedsnewmuslims.org.uk/register/form_validation.php",
		callback				: {
			onSuccess	: function(){ window.location = "http://www.leedsnewmuslims.org.uk/"; },
			onOpen		: function(){ Cufon.refresh(); }
		}
	};
	
	$(".register").live("click", function() {
		$.rpPopup.open(register_options);
		return false;		
	});
	
});
