$(document).ready(function(){
	/**
	*	PNG FIX
	*/
	$(document).pngFix(); 
	/**
	*	TRIPTYQUE BOUNCE
	*/
	$("#triptyque div").mouseenter(function()
	{
      $(this).children("p").animate({color: '#ff0077'}, 500, function()
      {
      	$(this).animate({color: 'black'}, 300);
      });
	});
	/**
	*	INF
	*/
	$(".inf").fadeTo(3000, 1);
	/**
	*	LOGO
	*/
	var flashvars = {
		clickTAG: "http://www.angels.lu/"
	};
	var params = {
		wmode: "transparent"
	};
	var attributes = {};
	swfobject.embedSWF("http://www.angels.lu/wp-content/themes/angels/swf/logo.swf", "logo", "210", "140", "9.0.0","http://www.angels.lu/wp-content/themes/angels/swf/expressInstall.swf", flashvars, params, attributes);
	
	/**
	*	PICTURES
	*/
	$(".pi").mouseover(function()
	{
		$(this).find(".pi-img").clone().addClass("pi-img-hovered").prependTo($(this)).hide().fadeTo(2000,1);
		$(this).children("h2").animate({color: 'black'}, 500);
		$(this).addClass("hovered");
		$(".pi").not(".hovered").stop().fadeTo('fast',0.5);
	});
	
	$(".pi").mouseleave(function()
	{
		$('.pi-img-hovered').remove();
		$(this).children("h2").animate({color: "#ff0077"}, 500);
		$(this).removeClass("hovered");
		$(".pi").not(".hovered").stop().fadeTo('fast',1);
	});
	
	$('#pictures-content').cycle({
		fx: 'scrollHorz',
		pause: true,
		timeout: 0,
		speed: 2000,
		easing: "easeOutQuart",
		next: $('#pictures-next'),
		prev: $('#pictures-previous'),
		rev: false
	});

	if ($("#pictures-content > div").size() == 1)
	{
		$('#pictures-next, #pictures-previous').fadeTo("slow", 0.3).css("cursor", "default");
	}
	
	
	/**
	*	ANIMATIONS
	*/
	$(".an").mouseover(function()
	{
		$(this).find(".an-img").clone().addClass("an-img-hovered").prependTo($(this)).hide().fadeTo(2000,1);
		$(this).children("h2").animate({color: 'black'}, 500);
		$(this).addClass("hovered");
		$(".an").not(".hovered").stop().fadeTo('fast',0.5);
	});
	
	$(".an").mouseleave(function()
	{
		$('.an-img-hovered').remove();
		$(this).children("h2").animate({color: "#ff0077"}, 500);
		$(this).removeClass("hovered");
		$(".an").not(".hovered").stop().fadeTo('fast',1);
	});
	
	$('#animations-content').cycle({
		fx: 'scrollHorz',
		pause: true,
		timeout: 0,
		speed: 2000,
		easing: "easeOutQuart",
		next: $('#animations-next'),
		prev: $('#animations-previous'),
		rev: false
	});

	if ($("#animations-content > div").size() == 1)
	{
		$('#animations-next, #animations-previous').fadeTo("slow", 0.3).css("cursor", "default");
	}
	
	
	/**
	*	FEATURED
	*/
	$('#featured-project').cycle({
		fx: 'scrollHorz',
		pause: true,
		timeout: 6000,
		speed: 2000,
		easing: "easeOutQuart",
		rev: false
	});
							
	$(".fp").mouseover(function()
	{
		$(this).find(".fp-img").clone().addClass("fp-img-hovered").prependTo($(this)).hide().fadeTo(2000,1);
		$(this).addClass("hovered");
		$(".fp").not(".hovered").stop().fadeTo('fast',0.5);
	});
	
	$(".fp").mouseleave(function()
	{
		$('.fp-img-hovered').remove();
		$(this).removeClass("hovered");
		$(".fp").not(".hovered").stop().fadeTo('fast',1);
	});
	/**
	*	TESTIMONIES
	*/
	$('#testimonies-content').cycle({
		fx: 'scrollVert',
		pause: true,
		timeout: 8000,
		speed: 1000,
		easing: "easeOutQuart",
		next: $('#testimonies-next'),
		prev: $('#testimonies-previous'),
		rev: true,
		cleartype: false
	});
	/**
	*	VIDEOS
	*/
	$('#videos-content').cycle({
		fx: 'scrollHorz',
		pause: true,
		timeout: 4000,
		speed: 1000,
		easing: "easeOutQuart",
		next: $('#videos-next'),
		prev: $('#videos-previous'),
		rev: false
	});
	if ($("#videos-content > div").size() == 1)
	{
		$('#videos-next, #videos-previous').fadeTo("slow", 0.3).css("cursor", "default");
	}
	/**
	*	SHOWCASE
	*/
	function onBefore()
	{
		$(this).children('.overlay').hide();
		$('.overlay').slideUp();
	} 
	function onAfter()
	{ 
		$(this).children('.overlay').slideDown();
	}
	$('#showcase-content').cycle({
		fx: 'scrollHorz',
		pause: true,
		timeout: 8000,
		speed: 1000,
		before: onBefore,
		after: onAfter,
		easing: "easeOutQuart",
		next: $('#showcase-next'),
		prev: $('#showcase-previous'),
		pager: '#showcase-nav',
		rev: true
	});
	/**
	*	MODAL
	*/
	$('a[href="#"], .modal').click(function(e)
	{
    	e.preventDefault();
	});
	$('.modal').each(function()
	{
		$(this).qtip(
		{
			content:
			{
				title:
				{
					text: $(this).attr("title"),
					button: 'Close'
				},
				text: "Loading…",
				url: $(this).attr("href"),
				data: {},
			method: 'get'
			},
			position: {
				target: $(document.body),
				corner: 'center'
			},
			show: {
				when: 'click',
				solo: true
			},
			hide: 'unfocus',
			style: {
				width: { min: 400, max: 700 },
				padding: $(this).hasClass("nopadding") ? 0 : 10,
				border: {
					width: 5,
					radius: 10,
					color: '#ff0077'
				},
				title: {
					color: 'black',
					background: '#fee6ed'
				},
				color: 'black',
				background: '#ffffff'
			},
			api: {
				beforeShow: function()
				{
					url = this.options.content.url;
					data = this.options.content.data;
					method = this.options.content.method || 'get';
					this.loadContent(url, data, method);
					$('#blanket').fadeIn(this.options.show.effect.length);
				},
				beforeHide: function()
				{
					$('#blanket').fadeOut(this.options.hide.effect.length);
				},
				onHide: function()
				{
					this.elements.content.empty();
				},
				onRender: function()
		        {
					this.loadContent($(this).attr('href'));
		        }
				
			}
		});
	});
	$('<div id="blanket">').css(
	{
		position: 'absolute',
		top: $(document).scrollTop(),
		left: 0,
		height: $(document).height(),
		width: '100%',

		opacity: 0.6,
		backgroundColor: 'white',
		zIndex: 5000
	})
	.appendTo(document.body)
	.hide();
});
