
jQuery.noConflict();

// * * * * * * * * * * * * * * * * * * * * * * * *

jQuery(document).ready(function() {

 


// contact slide out


        jQuery('.slide-out-div').tabSlideOut({
            tabHandle: '.handle',                     //class of the element that will become your tab
            pathToTabImage: '/wp-content/themes/jtwofilms/img/contact.jpg', //path to the image for the tab //Optionally can be set using css
            imageHeight: '28px',                     //height of tab image           //Optionally can be set using css
            imageWidth: '172px',                       //width of tab image            //Optionally can be set using css
            tabLocation: 'top',                      //side of screen where tab lives, top, right, bottom, or left
            speed: 300,                               //speed of animation
            action: 'hover',                          //options: 'click' or 'hover', action to trigger animation
            topPos: '200px',                          //position from the top/ use if tabLocation is left or right
            leftPos: '0px',                          //position from left/ use if tabLocation is bottom or top
            fixedPosition: false                      //options: true makes it stick(fixed position) on scroll
        });

    

   jQuery('.jtwo-ico-footer-home a').hover(function(){
		         jQuery(this).stop().animate({'opacity' : '0'}, 500);
		 }, function(){jQuery(this).stop().animate({'opacity' : '1'}, 500);});


  jQuery('.button-facebook a').hover(function(){
		         jQuery(this).stop().animate({'opacity' : '0'}, 500);
		 }, function(){jQuery(this).stop().animate({'opacity' : '1'}, 500);});
	 
 
	
	jQuery('.button-twitter a').hover(function(){
		         jQuery(this).stop().animate({'opacity' : '0'}, 500);
		 }, function(){jQuery(this).stop().animate({'opacity' : '1'}, 500);});
	 
 

	jQuery('.button-vimeo a').hover(function(){
		         jQuery(this).stop().animate({'opacity' : '0'}, 500);
		 }, function(){jQuery(this).stop().animate({'opacity' : '1'}, 500);});
	 
 // set up the options to be used for jqDock...
  var dockSize =  (jQuery(document).width()) / 20;
  jQuery('#foot').css('height', function() {
  return dockSize + 30;
});


  

  var dockOptions =
    { size: dockSize, labels: true , fadeIn: 500 };
  // ...and apply...
  jQuery('#menu').jqDock(dockOptions);
	
	// * * * * * * * * * * * * * * * * * * * * * * * * 
	// Home page
	
	//move the image in pixel
	var move = -29;
	
	//zoom percentage, 1.2 =120%
	var zoom = 1.2;

	//On mouse over those thumbnail
	jQuery('#content-home .item').hover(function() {
		
		//Set the width and height according to the zoom percentage
		width = jQuery('#content-home .item').width() * zoom;
		height = jQuery('#content-home .item').height() * zoom;
		
		//Move and zoom the image
		jQuery(this).find("img").stop(false,true).animate({"width":width, "height":height,"top":move, "left":move}, {duration:300},'linear');
		
		//Display the caption
		jQuery(this).find('div.caption').stop(false,true).fadeIn(750);
	},
	function() {
		//Reset the image
		jQuery(this).find('img').stop(false,true).animate({'width':jQuery('.item').width(), 'height':jQuery('#content-home .item').height(), 'top':'0', 'left':'0'}, {duration:300},'linear');	

		//Hide the caption
		jQuery(this).find('div.caption').stop(false,true).fadeOut(750);
	});
	
	//On mouse over those thumbnail
	jQuery('#content-home .middle').hover(function() {
		
		//Set the width and height according to the zoom percentage
		width = jQuery('#content-home .middle').width() * zoom;
		height = jQuery('#content-home .middle').height() * zoom;
		
		//Move and zoom the image
		//jQuery(this).find("img").stop(false,true).animate({"width":width, "height":height,"top":move, "left":move}, {duration:300},'linear');
		
		//Display the caption
		jQuery(this).find('div.caption').stop(false,true).fadeIn(750);
	},
	function() {
		//Reset the image
		//jQuery(this).find('img').stop(false,true).animate({'width':jQuery('.middle').width(), 'height':jQuery('#content-home .middle').height(), 'top':'0', 'left':'0'}, {duration:300},'linear');	

		//Hide the caption
		jQuery(this).find('div.caption').stop(false,true).fadeOut(750);
	});
	
	// #featured fader setup
	jQuery('#jtwo-middle img:first').fadeIn(1000, function() {
jQuery("#jtwo-middle").cycle(
                {
                         fx:     "none", 
                         timeout: 100,
                         speed:1
						 
                          
                          
                         
                          
                }
        ).cycle('pause').hover(function() {
                        jQuery(this).cycle('resume');
      },function(){
            jQuery(this).cycle('pause');
      });
	  
	});
	 

	

	

});



// Webography

jQuery(document).ready(function(){
	/* The code here is executed on page load */
	
	/* Replacing all the paragraphs */
	jQuery('.webog-content').replaceWith(function(){
	
		/* The style, class and title attributes of the p are copied to the slideout: */
		
		return '\
		<div class="slideOutTip '+jQuery(this).attr('class')+'" style="'+jQuery(this).attr('style')+'">\
			\
			<div class="tipVisible">\
				<div class="tipIcon"><div class="plusIcon"></div></div>\
				\
			</div>\
			\
			<div class="slideOutContent">\
                                <p class="tipTitle">'+jQuery(this).attr('title')+'</p>\
				<div>'+jQuery(this).html()+'</div>\
			</div>\
		</div>';
	});

	jQuery('.slideOutTip').each(function(){

		/*
			Implicitly defining the width of the slideouts according to the width of its title,
			because IE fails to calculate it on its own.
		*/
		
		jQuery(this).width(110);
	});
	
	/* Listening for the click event: */
	
	jQuery('.slideOutTip').bind('mouseenter mouseleave',function(){
		var tip = jQuery(this);
		
		/* If a open/close animation is in progress, exit the function */
		if(tip.is(':animated'))
			return false;

		if(tip.find('.slideOutContent').css('display') == 'none')
		{
			tip.trigger('slideOut');
		}
		else tip.trigger('slideIn');

	});
	
	jQuery('.slideOutTip').bind('slideOut',function(){

		var tip = jQuery(this);
		var slideOut = tip.find('.slideOutContent');
		
		/* Closing all currently open slideouts: */
		jQuery('.slideOutTip.isOpened').trigger('slideIn');
		
		/* Executed only the first time the slideout is clicked: */
		if(!tip.data('dataIsSet'))
		{
			tip	.data('origWidth',tip.width())
				.data('origHeight',tip.height())
				.data('dataIsSet',true);
			
			if(tip.hasClass('openTop'))
			{
				/*
					If this slideout opens to the top, instead of the bottom,
					calculate the distance to the bottom and fix the slideout to it.
				*/
				
				tip.css({
					bottom	: tip.parent().height()-(tip.position().top+tip.outerHeight()),
					top		: 'auto'
				});
				
				/* Fixing the title to the bottom of the slideout, so it is not slid to the top on open: */
				tip.find('.tipVisible').css({position:'absolute',bottom:3});
				
				/* Moving the content above the title, so it can slide open to the top: */
				tip.find('.slideOutContent').remove().prependTo(tip);
			}
			
			if(tip.hasClass('openLeft'))
			{
				/*
					If this slideout opens to the left, instead of right, fix it to the
					right so the left edge can expand without moving the entire div:
				*/
				tip.css({
					right	: Math.abs(tip.parent().outerWidth()-(tip.position().left+tip.outerWidth())),
					left	: 'auto'
				});
				
				tip.find('.tipVisible').css({position:'absolute',right:3});
			}
		}
		
		/* Resize the slideout to fit the content, which is then faded into view: */
		
		tip.addClass('isOpened').animate({
			width	: 700,
			height	: slideOut.outerHeight()
		},function(){
			slideOut.fadeIn();
		});

	}).bind('slideIn',function(){
		var tip = jQuery(this);

		/* Hide the content and restore the original size of the slideout: */
		
		tip.find('.slideOutContent').fadeOut('fast',function(){
			tip.animate({
				width	: tip.data('origWidth'),
				height	: tip.data('origHeight')
			},function(){
				tip.removeClass('isOpened');
			});
		});

	});
});




jQuery(document).ready(function() {

	

	// contact form setup
	jQuery("#foot-contact, #onpage-contact").alajaContact({
		emptyTextError: getOption("empty-contact-form", "Don't be shy! Please <strong>type something</strong> and "), //
		emptyEmailError: getOption("no-contact-email", "We don't Spam. <strong>Add your Email</strong> and "), //
		enableAutoGrow: true // textarea auto grow (false - to disable)
	});

	// #showroom slider setup
	jQuery("#showroom").alajaShow({
		height: getOption("showroom-height", 300), // height in pixels (or "auto")
		width: 620, // width in pixels (or "auto")
		pixelsPerSecond: getOption("showroom-pps", 30), // overage speed of the image transition
		minDisplayTime: getOption("showroom-delay", 3000), // minimal time (in milliseconds) to display one image (can override "pixelsPerSecond")
		effect: getOption("showroom-transition-fx", "cross"), // slide direction ("up", "down", "cross" or simple "fade")
		IE: true // just simple fader in IE
		//, easing: "easeOutBounce" // easing style, other styles you can visualize here: http://www.robertpenner.com/easing/easing_demo.html
	});

});


// utilities onload

jQuery(document).ready(function() {

	// flag body.js / body.no-js
	jQuery("body").addClass("js").removeClass("no-js");

	// topmenu search
	if (jQuery(".search a", "#topmenu").length) {
		jQuery(".search a", "#topmenu").click(function() {
			var input = jQuery(".search input", "#topmenu");
			var form = jQuery(".search form", "#topmenu");

			jQuery(this).
				text(jQuery(this).text() + ":"). // comment this line to disable adding the ":"
				unbind().
				bind("click", function() { input.focus(); return false; });
			form.
				css({ display: "inline" });
			input.
				data("width", input.width()).
				css({ width: "1px" }).
				focus().
				animate({ width: input.data("width") });

			return false;
		});
	}

	// sleek page scrolling
	jQuery.localScroll({ duration: 500, easing: "easeInExpo" });

	// sleek image preload
	jQuery("#logo, #content").alajaImagePreloader();

	// setup Alaja Show
	jQuery(".alajaShow", "#content").alajaShow();

	// setup Alaja Tweet
	jQuery("ins.tweet").alajaTweet({ excludeReplies: true, showAge: true, clearTags: true });

	// togglers
	jQuery("dl.toggle").each(function() {
		var 
			holder = jQuery(this),
			trigger = holder.find("dt").css({ cursor: "pointer" }),
			triggerText = trigger.text(),
			triggerOn = "&ndash; " + triggerText,
			triggerOff = "+ " + triggerText,
			target = holder.find("dd").hide();

		trigger.html(triggerOff);

		trigger.toggle(function() {
			trigger.html(triggerOn);
			holder.addClass("active");
		}, function() {
			trigger.html(triggerOff);
			holder.removeClass("active");
		});

		trigger.click(function() {
			target.slideToggle("fast");
			return false;
		});
	});

	// Alaja fancybox setup
	{
		var // default video playback window size
			videoWidth = getOption("video-width", 680),
			videoHeight = getOption("video-height", 495);

		var fancyboxRegion = "#content, #featured, .middle";
		var grab_param = function(name, url) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)", regex = new RegExp(regexS), results = regex.exec(url); return (results == null) ? null : results[1]; }
		var get_w = function(href) { var res = grab_param("width", href); if (res == null) return videoWidth; return parseInt(res); }
		var get_h = function(href) { var res = grab_param("height", href); if (res == null) return videoHeight; return parseInt(res); }
		var formatTitle = function(title, currentArray, currentIndex, currentOpts) { if (currentArray.length == 1 && !title) return ""; title = (title) ? title : ""; if (currentArray.length > 1) title = (currentIndex + 1) + " / " + currentArray.length + ". " + title; return "<span id=\"fancybox-title-over\">" + title + "</span>"; };
		var fancyboxImageDefaults = { titleFormat: formatTitle, titlePosition: "over", transitionIn: (jQuery.browser.msie) ? "none" : "elastic", transitionOut: "none", easingIn: "easeInExpo", easingOut: "easeOutExpo", padding: 0, centerOnScroll: true, hideOnContentClick: true, showCloseButton: false, opacity: true };
		var fancyboxVideoDefaults = { width: videoWidth, height: videoHeight, padding: 0, autoScale: false, hideOnContentClick: false, hideOnOverlayClick: false, transitionIn: "none", transitionOut: "none", centerOnScroll: true, title: "", type: "swf", swf: { wmode: "transparent", allowfullscreen: true} };
		var fancyboxMovDefaults = jQuery.extend({}, fancyboxVideoDefaults, { type: "mov", mov: { wmode: "transparent", autoplay: true, showlogo: false, type: "video/quicktime", cache: true, scale: "tofit", bgcolor: "white", postdomevents: true, controller: false} });

		jQuery("a.lightbox:not(.white, .black, .youtube, .vimeo, .mov)", fancyboxRegion).fancybox(fancyboxImageDefaults);
		jQuery("a.lightbox.white", fancyboxRegion).fancybox(jQuery.extend({}, fancyboxImageDefaults, { overlayColor: "white", overlayOpacity: 4 / 5 }));
		jQuery("a.lightbox.black", fancyboxRegion).fancybox(jQuery.extend({}, fancyboxImageDefaults, { overlayColor: "black", overlayOpacity: 3 / 4 }));
		jQuery("a.lightbox.youtube", fancyboxRegion).click(function() { jQuery.fancybox(jQuery.extend({}, fancyboxVideoDefaults, { href: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + "&autoplay=1", width: get_w(this.href), height: get_h(this.href) })); return false; });
		jQuery("a.lightbox.vimeo", fancyboxRegion).click(function() { jQuery.fancybox(jQuery.extend({}, fancyboxVideoDefaults, { href: this.href.replace(new RegExp("([0-9])", "i"), "moogaloop.swf?autoplay=1&clip_id=$1"), width: get_w(this.href), height: get_h(this.href) })); return false; });
		jQuery("a.lightbox.mov", fancyboxRegion).click(function() { jQuery.fancybox(jQuery.extend({}, fancyboxMovDefaults, { href: this.href, width: get_w(this.href), height: get_h(this.href) })); return false; });
	}

	// wordpress magic "read more" post link
	alajaMagicMore();

});


// * * * * * * * * * * * * * * * * * * * * * * * *
// WordPress related
{

	function getOption(name, def) {

		var 
			val = jQuery("meta[name=\"js." + name + "\"]").attr("content"),
			num = parseInt(val);

		return (num) ? num : (val) ? val : def;
	}

	function alajaMagicMore() {

		var 
			containerClass = ".magic-more",
			resistBlock = ".magic-res",
			text = "Read more&hellip;",
			cntrl = jQuery("<p><a href=\"#reveal\">" + text + "</a></p>"),
			hider = jQuery("<div/>", { "class": "to-reveal", css: { display: "none"} });

		jQuery(containerClass + " span[id^=\"more-\"]", "#content").each(function() {

			var 
				more = jQuery(this),
				parent = more.parentsUntil(containerClass),
				hide = parent.nextAll(":not(" + resistBlock + ")");

			if (hide.length) {
				var trigger = cntrl.clone();

				hide.wrapAll(hider.clone());
				parent.after(trigger);

				trigger.find("a").click(function() {
					trigger.fadeOut(function() {
						hide.parent().fadeIn();
					});

					return false;
				});
			}
		});
	}
}



// --------------------------------------------------------------------------
// Alaja jQuery plugins

/*
* Alaja Tweet, Alaja Show, Alaja Contact, Alaja Image Preloader
* Copyright 2010 Alaja Web Solutions
* All rights reserved.
*/

(function($) {

	// * * * * * * * * * * * * * * * * * * * * * * * * 
	// Alaja Tweet

	$.fn.alajaTweet = function(options) {

		var defaults = {
			excludeReplies: false,
			clearTags: false,
			showAge: false,
			cutOff: 20 * 2
		};

		var options = $.extend(defaults, options);

		return this.each(function() {
			var 
				holder = $(this),
				username = this.getAttribute("cite"),
				url = "http://twitter.com/status/user_timeline/" + username + ".json?count=" + options.cutOff + "&callback=?";

			holder.fn = {

				init: function() {
					$.getJSON(url, function(data) {
						$(data).each(function(i, t) {

							if (t.in_reply_to_user_id != null && options.excludeReplies)
								return;

							holder.fn.placeTweet(t);
							return false;
						});
					});
				},

				placeTweet: function(t) {
					var 
						html = t.text,
						age = holder.fn.getAge(t),
						recreateUrls = function(t) { return t.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi, "<a href=\"$1\">$1</a>"); },
						clearTags = function(t) { return t.replace(/[\#]+([A-Za-z0-9-_]+)/gi, ""); };

					html = recreateUrls(html);
					if (options.clearTags)
						html = clearTags(html);
					if (options.showAge)
						html = html + " (" + age + ")";

					holder.html(html);
				},

				getAge: function(t) {
					var 
						age = Date.parse(t.created_at.replace(/^([a-z]{3})( [a-z]{3} \d\d?)(.*)( \d{4})$/i, "$1,$2$4$3")),
						rage = parseInt(((new Date()).getTime() - age) / 1000), // relative age in seconds
						plur = function(s, n) { return n + " " + s + (n == 1 ? "" : "s") + " ago"; };

					if (rage < 60) return "less than a minute ago";
					if ((rage /= 60) < 60) return plur("minute", ~ ~rage);
					if ((rage /= 60) < 24) return plur("hour", ~ ~rage);
					return plur("day", ~ ~(rage /= 24));
				}
			}

			holder.fn.init();

		});
	}

	// * * * * * * * * * * * * * * * * * * * * * * * * 
	// Alaja Show

	$.fn.alajaShow = function(options) {

		var defaults = {
			height: "auto",
			width: "auto",
			minDisplayTime: 4000,
			pixelsPerSecond: 30,
			effect: "cross",
			easing: "jswing",
			bgColorContainer: "#main"
		};

		var options = $.extend(defaults, options);

		return this.filter(":has(img ~ img)").each(function() {

			var 
				holder = $(this).css({ opacity: 0 }).prepend($(this).find("img.active").clone().removeClass("active")),
				imgs = holder.find('img:not(.active)'), cache,
				fadeTime = options.minDisplayTime / 1.5, timer,
				imgeq = 0, counter = 0,
				buffer,
				height, width;

			holder.fn = {

				init: function() {

					if (!holder.fn.isReady())
						return;

					clearInterval(initTimer);

					height = (options.height == "auto") ? holder.height() : options.height;
					width = (options.width == "auto") ? holder.width() : options.width;

					buffer = $("<div/>", { "class": "buffer",
						css: {
							backgroundColor: $(options.bgColorContainer).css("backgroundColor"),
							backgroundRepeat: "no-repeat",
							display: "block",
							position: "absolute",
							width: width, height: height,
							opacity: 0,
							zIndex: 10
						}
					});

					holder.
						css({ display: "block", position: "relative", width: width, height: height, opacity: 1 }).
						html(null);

					if ($.browser.msie || options.effect == "fade") {
						holder.
							html(imgs).
							cycle({ timeout: options.minDisplayTime });
						return;
					}

					holder.fn.go();
				},

				// are the images ready?
				isReady: function() {
					var result = true;

					cache = $.map(imgs, function(img, i) {
						return { w: $(img).width(), h: $(img).height(), src: $(img).attr("src") };
					});

					$(cache).each(function() {
						if (this.w == 0 || this.h == 0 || this.src == "") { result = false; return false; }
					});

					return result;
				},

				// setup the timers
				go: function() {
					clearInterval(timer);
					timer = setInterval(function() { holder.fn.go() }, holder.fn.next());
				},

				// next slide calculations
				next: function() {
					var 
						img = imgs.eq(imgeq),
						offheight = Math.max(0, cache[imgeq].h - height),
						offwidth = width - cache[imgeq].w,
						duration = Math.max((offheight / options.pixelsPerSecond) * 1000, options.minDisplayTime);

					holder.fn.addSlide(img, offheight, offwidth, duration);
					imgeq = (imgeq + 1 == imgs.length) ? 0 : imgeq + 1;
					counter = counter + 1;

					return duration;
				},

				// add to the holder & animate new slide
				addSlide: function(img, offheight, offwidth, duration) {
					var 
						startBgPos = offwidth / 2 + "px 0px",
						endBgPos = offwidth / 2 + "px -" + offheight + "px";

					if (options.effect == "down" || (options.effect == "cross" && counter % 2)) {
						var a = startBgPos;
						startBgPos = endBgPos;
						endBgPos = a;
					}

					var slide = buffer.clone().css({ backgroundImage: "url(" + cache[imgeq].src + ")", backgroundPosition: startBgPos });

					holder.append(slide);

					slide.
						animate({ opacity: 1 }, { queue: false, duration: fadeTime }).
						animate({ backgroundPosition: endBgPos }, duration, options.easing, function() { $(this).animate({ opacity: 0 }, { duration: fadeTime, complete: function() { $(this).remove(); } }) });
				}
			}

			var initTimer = setInterval(function() { holder.fn.init() }, 100);

		});
	};

	// * * * * * * * * * * * * * * * * * * * * * * * * 
	// Alaja Image Preloader

	$.fn.alajaImagePreloader = function(options) {

		var defaults = { animationCurfew: 500, preloadedImageClass: "preloaded" };
		var options = $.extend(defaults, options);

		return this.each(function() {

			var imgList = $(this).find("img:not(." + options.preloadedImageClass + ")");
			var startedIn = (new Date()).getTime();

			imgList.parent("a").css({ border: "none" });

			if ($.browser.msie) return;
			imgList.each(function() {
				var img = $(this);
				img.data("src", img.attr("src")).attr("src", "").css({ opacity: 0 });
			});

			load(0);

			function load(id) {
				var img = imgList.eq(id);

				if (img.length) {
					img.attr("src", img.data("src"));
					img.load(function() {
						var loaded = $(this).addClass(options.preloadedImageClass);

						if ((new Date()).getTime() - startedIn > options.animationCurfew)
							loaded.animate({ opacity: 1 }, 'slow', function() { $(this).attr("style", ""); });
						else
							loaded.attr("style", "");
					});

					load(id + 1);
				}
			}
		});

	};


	// * * * * * * * * * * * * * * * * * * * * * * * * 
	// Alaja Contact

	$.fn.alajaContact = function(options) {

		var defaults = {
			emptyTextError: "Don't be shy! Type something and re-",
			emptyEmailError: "We don't spam! Add your Email and re-",
			enableAutoGrow: true
		};

		var options = $.extend(defaults, options);

		return this.filter("form").each(function() {
			var form = $(this);
			var textarea = form.find("textarea");
			var label = form.find("label.textarea");
			var submit = form.find("input[type=submit]");
			var error = form.find("span.error");
			var newsubmit = $("<a/>", { href: "#", text: submit.val() });

			if (options.enableAutoGrow)
				textarea.attr("rows", 2).elastic();

			submit.replaceWith(newsubmit);

			newsubmit.click(function() {
				var 
					message = textarea.val(),
					isEmptyText = !(jQuery.trim(message).length > 0),
					isEmptyEmail = !(message.match(/[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}/));

				if (isEmptyText || isEmptyEmail) {
					error.html(isEmptyText ? options.emptyTextError : options.emptyEmailError);
					label.focus();
					return false;
				}

				error.html("");
				newsubmit.remove();

				$.post(form.attr("action"), form.serialize(), function(msg) {
					form.fadeOut(function() { form.replaceWith(msg).fadeIn() });
				});

				return false;
			});
		});
	};

	// * * * * * * * * * * * * * * * * * * * * * * * *

	$.iSafari = function() {
		return (/Apple/.test(navigator.vendor));
	}

})(jQuery);



// --------------------------------------------------------------------------
// jQuery 3rd party plugins


/*
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
* Open source under the BSD License. 
* Copyright 2008 George McGinley Smith
* Copyright 2001 Robert Penner
* All rights reserved.
*/
; jQuery.easing['jswing'] = jQuery.easing['swing']; jQuery.extend(jQuery.easing, { def: 'easeOutExpo', swing: function(x, t, b, c, d) { return jQuery.easing[jQuery.easing.def](x, t, b, c, d) }, easeInQuad: function(x, t, b, c, d) { return c * (t /= d) * t + b }, easeOutQuad: function(x, t, b, c, d) { return -c * (t /= d) * (t - 2) + b }, easeInOutQuad: function(x, t, b, c, d) { if ((t /= d / 2) < 1) return c / 2 * t * t + b; return -c / 2 * ((--t) * (t - 2) - 1) + b }, easeInCubic: function(x, t, b, c, d) { return c * (t /= d) * t * t + b }, easeOutCubic: function(x, t, b, c, d) { return c * ((t = t / d - 1) * t * t + 1) + b }, easeInOutCubic: function(x, t, b, c, d) { if ((t /= d / 2) < 1) return c / 2 * t * t * t + b; return c / 2 * ((t -= 2) * t * t + 2) + b }, easeInQuart: function(x, t, b, c, d) { return c * (t /= d) * t * t * t + b }, easeOutQuart: function(x, t, b, c, d) { return -c * ((t = t / d - 1) * t * t * t - 1) + b }, easeInOutQuart: function(x, t, b, c, d) { if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b; return -c / 2 * ((t -= 2) * t * t * t - 2) + b }, easeInQuint: function(x, t, b, c, d) { return c * (t /= d) * t * t * t * t + b }, easeOutQuint: function(x, t, b, c, d) { return c * ((t = t / d - 1) * t * t * t * t + 1) + b }, easeInOutQuint: function(x, t, b, c, d) { if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b; return c / 2 * ((t -= 2) * t * t * t * t + 2) + b }, easeInSine: function(x, t, b, c, d) { return -c * Math.cos(t / d * (Math.PI / 2)) + c + b }, easeOutSine: function(x, t, b, c, d) { return c * Math.sin(t / d * (Math.PI / 2)) + b }, easeInOutSine: function(x, t, b, c, d) { return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b }, easeInExpo: function(x, t, b, c, d) { return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b }, easeOutExpo: function(x, t, b, c, d) { return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b }, easeInOutExpo: function(x, t, b, c, d) { if (t == 0) return b; if (t == d) return b + c; if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b; return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b }, easeInCirc: function(x, t, b, c, d) { return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b }, easeOutCirc: function(x, t, b, c, d) { return c * Math.sqrt(1 - (t = t / d - 1) * t) + b }, easeInOutCirc: function(x, t, b, c, d) { if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b; return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b }, easeInElastic: function(x, t, b, c, d) { var s = 1.70158; var p = 0; var a = c; if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3; if (a < Math.abs(c)) { a = c; var s = p / 4 } else var s = p / (2 * Math.PI) * Math.asin(c / a); return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b }, easeOutElastic: function(x, t, b, c, d) { var s = 1.70158; var p = 0; var a = c; if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3; if (a < Math.abs(c)) { a = c; var s = p / 4 } else var s = p / (2 * Math.PI) * Math.asin(c / a); return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b }, easeInOutElastic: function(x, t, b, c, d) { var s = 1.70158; var p = 0; var a = c; if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5); if (a < Math.abs(c)) { a = c; var s = p / 4 } else var s = p / (2 * Math.PI) * Math.asin(c / a); if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b }, easeInBack: function(x, t, b, c, d, s) { if (s == undefined) s = 1.70158; return c * (t /= d) * t * ((s + 1) * t - s) + b }, easeOutBack: function(x, t, b, c, d, s) { if (s == undefined) s = 1.70158; return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b }, easeInOutBack: function(x, t, b, c, d, s) { if (s == undefined) s = 1.70158; if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b; return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b }, easeInBounce: function(x, t, b, c, d) { return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b }, easeOutBounce: function(x, t, b, c, d) { if ((t /= d) < (1 / 2.75)) { return c * (7.5625 * t * t) + b } else if (t < (2 / 2.75)) { return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b } else if (t < (2.5 / 2.75)) { return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b } else { return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b } }, easeInOutBounce: function(x, t, b, c, d) { if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b; return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b } });


/*
* jQuery.ScrollTo - Easy element scrolling using jQuery.
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 5/25/2009
*/
; (function(d) { var k = d.scrollTo = function(a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function(a) { return d(window)._scrollable() }; d.fn._scrollable = function() { return this.map(function() { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function(n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function() { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function(a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function() { a.call(this, n, b) }) } }).end() }; k.max = function(a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);

/*
* jQuery.LocalScroll - Animated scrolling navigation, using anchors.
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 3/11/2009
*/
; (function($) { var l = location.href.replace(/#.*/, ''); var g = $.localScroll = function(a) { $('body').localScroll(a) }; g.defaults = { duration: 1e3, axis: 'y', event: 'click', stop: true, target: window, reset: true }; g.hash = function(a) { if (location.hash) { a = $.extend({}, g.defaults, a); a.hash = false; if (a.reset) { var e = a.duration; delete a.duration; $(a.target).scrollTo(0, a); a.duration = e } i(0, location, a) } }; $.fn.localScroll = function(b) { b = $.extend({}, g.defaults, b); return b.lazy ? this.bind(b.event, function(a) { var e = $([a.target, a.target.parentNode]).filter(d)[0]; if (e) i(a, e, b) }) : this.find('a,area').filter(d).bind(b.event, function(a) { i(a, this, b) }).end().end(); function d() { return !!this.href && !!this.hash && this.href.replace(this.hash, '') == l && (!b.filter || $(this).is(b.filter)) } }; function i(a, e, b) { var d = e.hash.slice(1), f = document.getElementById(d) || document.getElementsByName(d)[0]; if (!f) return; if (a) a.preventDefault(); var h = $(b.target); if (b.lock && h.is(':animated') || b.onBefore && b.onBefore.call(b, a, f, h) === false) return; if (b.stop) h.stop(true); if (b.hash) { var j = f.id == d ? 'id' : 'name', k = $('<a> </a>').attr(j, d).css({ position: 'absolute', top: $(window).scrollTop(), left: $(window).scrollLeft() }); f[j] = ''; $('body').prepend(k); location = e.hash; k.remove(); f[j] = d } h.scrollTo(f, b).trigger('notify.serialScroll', [f]) } })(jQuery);

/*
* Elastic by Jan Jarfalk
* http://www.unwrongest.com
* MIT License - http://www.opensource.org/licenses/mit-license.php
*/
; (function(jQuery) { jQuery.fn.extend({ elastic: function() { var mimics = ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'fontSize', 'lineHeight', 'fontFamily', 'width', 'fontWeight']; return this.each(function() { if (this.type != 'textarea') { return false } var $textarea = jQuery(this), $twin = jQuery('<div />').css({ 'position': 'absolute', 'display': 'none', 'word-wrap': 'break-word' }), lineHeight = parseInt($textarea.css('line-height'), 10) || parseInt($textarea.css('font-size'), '10'), minheight = parseInt($textarea.css('height'), 10) || lineHeight * 3, maxheight = parseInt($textarea.css('max-height'), 10) || Number.MAX_VALUE, goalheight = 0, i = 0; if (maxheight < 0) { maxheight = Number.MAX_VALUE } $twin.appendTo($textarea.parent()); var i = mimics.length; while (i--) { $twin.css(mimics[i].toString(), $textarea.css(mimics[i].toString())) } function setHeightAndOverflow(height, overflow) { curratedHeight = Math.floor(parseInt(height, 10)); if ($textarea.height() != curratedHeight) { $textarea.css({ 'height': curratedHeight + 'px', 'overflow': overflow }) } } function update() { var textareaContent = $textarea.val().replace(/&/g, '&amp;').replace(/  /g, '&nbsp;').replace(/<|>/g, '&gt;').replace(/\n/g, '<br />'); var twinContent = $twin.html(); if (textareaContent + '&nbsp;' != twinContent) { $twin.html(textareaContent + '&nbsp;'); if (Math.abs($twin.height() + lineHeight - $textarea.height()) > 3) { var goalheight = $twin.height() + lineHeight; if (goalheight >= maxheight) { setHeightAndOverflow(maxheight, 'auto') } else if (goalheight <= minheight) { setHeightAndOverflow(minheight, 'hidden') } else { setHeightAndOverflow(goalheight, 'hidden') } } } } $textarea.css({ 'overflow': 'hidden' }); $textarea.keyup(function() { update() }).keydown(function() { update() }); $textarea.live('input paste', function(e) { setTimeout(update, 250) }); update() }) } }) })(jQuery);

/*
* Background-Position Animation Plugin v. 1.22
* Alexander Farkas
* Dual licensed under MIT and GPL.
*/
; (function($){if(!document.defaultView||!document.defaultView.getComputedStyle){var e=$.curCSS;$.curCSS=function(a,b,c){if(b==='background-position'){b='backgroundPosition'}if(b!=='backgroundPosition'||!a.currentStyle||a.currentStyle[b]){return e.apply(this,arguments)}var d=a.style;if(!c&&d&&d[b]){return d[b]}return e(a,'backgroundPositionX',c)+' '+e(a,'backgroundPositionY',c)}}var f=$.fn.animate;$.fn.animate=function(a){if('background-position'in a){a.backgroundPosition=a['background-position'];delete a['background-position']}if('backgroundPosition'in a){a.backgroundPosition='('+a.backgroundPosition}return f.apply(this,arguments)};function toArray(a){a=a.replace(/left|top/g,'0px');a=a.replace(/right|bottom/g,'100%');a=a.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var b=a.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(b[1],10),b[2],parseFloat(b[3],10),b[4]]}$.fx.step.backgroundPosition=function(a){if(!a.bgPosReady){var b=$.curCSS(a.elem,'backgroundPosition');if(!b){b='0px 0px'}b=toArray(b);a.start=[b[0],b[2]];var c=toArray(a.end);a.end=[c[0],c[2]];a.unit=[c[1],c[3]];a.bgPosReady=true}var d=[];d[0]=((a.end[0]-a.start[0])*a.pos)+a.start[0]+a.unit[0];d[1]=((a.end[1]-a.start[1])*a.pos)+a.start[1]+a.unit[1];a.elem.style.backgroundPosition=d[0]+' '+d[1]}})(jQuery);

/* 
* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*/
; (function(c) { var a = ["DOMMouseScroll", "mousewheel"]; c.event.special.mousewheel = { setup: function() { if (this.addEventListener) { for (var d = a.length; d; ) { this.addEventListener(a[--d], b, false) } } else { this.onmousewheel = b } }, teardown: function() { if (this.removeEventListener) { for (var d = a.length; d; ) { this.removeEventListener(a[--d], b, false) } } else { this.onmousewheel = null } } }; c.fn.extend({ mousewheel: function(d) { return d ? this.bind("mousewheel", d) : this.trigger("mousewheel") }, unmousewheel: function(d) { return this.unbind("mousewheel", d) } }); function b(f) { var d = [].slice.call(arguments, 1), g = 0, e = true; f = c.event.fix(f || window.event); f.type = "mousewheel"; if (f.wheelDelta) { g = f.wheelDelta / 120 } if (f.detail) { g = -f.detail / 3 } d.unshift(f, g); return c.event.handle.apply(this, d) } })(jQuery);

/*

Quicksand 1.2.2

Reorder and filter items with a nice shuffling animation.

Copyright (c) 2010 Jacek Galanciak (razorjack.net) and agilope.com
Big thanks for Piotr Petrus (riddle.pl) for deep code review and wonderful docs & demos.

Dual licensed under the MIT and GPL version 2 licenses.
http://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt
http://github.com/jquery/jquery/blob/master/GPL-LICENSE.txt

Project site: http://razorjack.net/quicksand
Github site: http://github.com/razorjack/quicksand

*/

(function ($) {
    $.fn.quicksand = function (collection, customOptions) {     
        var options = {
            duration: 750,
            easing: 'swing',
            attribute: 'data-id', // attribute to recognize same items within source and dest
            adjustHeight: 'auto', // 'dynamic' animates height during shuffling (slow), 'auto' adjusts it before or after the animation, false leaves height constant
            useScaling: true, // disable it if you're not using scaling effect or want to improve performance
            enhancement: function(c) {}, // Visual enhacement (eg. font replacement) function for cloned elements
            selector: '> *',
            dx: 0,
            dy: 0
        };
        $.extend(options, customOptions);
        
        if ($.browser.msie || (typeof($.fn.scale) == 'undefined')) {
            // Got IE and want scaling effect? Kiss my ass.
            options.useScaling = false;
        }
        
        var callbackFunction;
        if (typeof(arguments[1]) == 'function') {
            var callbackFunction = arguments[1];
        } else if (typeof(arguments[2] == 'function')) {
            var callbackFunction = arguments[2];
        }
    
        
        return this.each(function (i) {
            var val;
            var animationQueue = []; // used to store all the animation params before starting the animation; solves initial animation slowdowns
            var $collection = $(collection).clone(); // destination (target) collection
            var $sourceParent = $(this); // source, the visible container of source collection
            var sourceHeight = $(this).css('height'); // used to keep height and document flow during the animation
            
            var destHeight;
            var adjustHeightOnCallback = false;
            
            var offset = $($sourceParent).offset(); // offset of visible container, used in animation calculations
            var offsets = []; // coordinates of every source collection item            
            
            var $source = $(this).find(options.selector); // source collection items
            
            // Replace the collection and quit if IE6
            if ($.browser.msie && $.browser.version.substr(0,1)<7) {
                $sourceParent.html('').append($collection);
                return;
            }

            // Gets called when any animation is finished
            var postCallbackPerformed = 0; // prevents the function from being called more than one time
            var postCallback = function () {
                
                if (!postCallbackPerformed) {
                    postCallbackPerformed = 1;
                    
                    // hack: 
                    // used to be: $sourceParent.html($dest.html()); // put target HTML into visible source container
                    // but new webkit builds cause flickering when replacing the collections
                    $toDelete = $sourceParent.find('> *');
                    $sourceParent.prepend($dest.find('> *'));
                    $toDelete.remove();
                         
                    if (adjustHeightOnCallback) {
                        $sourceParent.css('height', destHeight);
                    }
                    options.enhancement($sourceParent); // Perform custom visual enhancements on a newly replaced collection
                    if (typeof callbackFunction == 'function') {
                        callbackFunction.call(this);
                    }                    
                }
            };
            
            // Position: relative situations
            var $correctionParent = $sourceParent.offsetParent();
            var correctionOffset = $correctionParent.offset();
            if ($correctionParent.css('position') == 'relative') {
                if ($correctionParent.get(0).nodeName.toLowerCase() == 'body') {

                } else {
                    correctionOffset.top += (parseFloat($correctionParent.css('border-top-width')) || 0);
                    correctionOffset.left +=( parseFloat($correctionParent.css('border-left-width')) || 0);
                }
            } else {
                correctionOffset.top -= (parseFloat($correctionParent.css('border-top-width')) || 0);
                correctionOffset.left -= (parseFloat($correctionParent.css('border-left-width')) || 0);
                correctionOffset.top -= (parseFloat($correctionParent.css('margin-top')) || 0);
                correctionOffset.left -= (parseFloat($correctionParent.css('margin-left')) || 0);
            }
            
            // perform custom corrections from options (use when Quicksand fails to detect proper correction)
            if (isNaN(correctionOffset.left)) {
                correctionOffset.left = 0;
            }
            if (isNaN(correctionOffset.top)) {
                correctionOffset.top = 0;
            }
            
            correctionOffset.left -= options.dx;
            correctionOffset.top -= options.dy;

            // keeps nodes after source container, holding their position
            $sourceParent.css('height', $(this).height());
            
            // get positions of source collections
            $source.each(function (i) {
                offsets[i] = $(this).offset();
            });
            
            // stops previous animations on source container
            $(this).stop();
            var dx = 0; var dy = 0;
            $source.each(function (i) {
                $(this).stop(); // stop animation of collection items
                var rawObj = $(this).get(0);
                if (rawObj.style.position == 'absolute') {
                    dx = -options.dx;
                    dy = -options.dy;
                } else {
                    dx = options.dx;
                    dy = options.dy;                    
                }

                rawObj.style.position = 'absolute';
                rawObj.style.margin = '0';

                rawObj.style.top = (offsets[i].top - parseFloat(rawObj.style.marginTop) - correctionOffset.top + dy) + 'px';
                rawObj.style.left = (offsets[i].left - parseFloat(rawObj.style.marginLeft) - correctionOffset.left + dx) + 'px';
            });
                    
            // create temporary container with destination collection
            var $dest = $($sourceParent).clone();
            var rawDest = $dest.get(0);
            rawDest.innerHTML = '';
            rawDest.setAttribute('id', '');
            rawDest.style.height = 'auto';
            rawDest.style.width = $sourceParent.width() + 'px';
            $dest.append($collection);      
            // insert node into HTML
            // Note that the node is under visible source container in the exactly same position
            // The browser render all the items without showing them (opacity: 0.0)
            // No offset calculations are needed, the browser just extracts position from underlayered destination items
            // and sets animation to destination positions.
            $dest.insertBefore($sourceParent);
            $dest.css('opacity', 0.0);
            rawDest.style.zIndex = -1;
            
            rawDest.style.margin = '0';
            rawDest.style.position = 'absolute';
            rawDest.style.top = offset.top - correctionOffset.top + 'px';
            rawDest.style.left = offset.left - correctionOffset.left + 'px';
            
            
    
            

            if (options.adjustHeight === 'dynamic') {
                // If destination container has different height than source container
                // the height can be animated, adjusting it to destination height
                $sourceParent.animate({height: $dest.height()}, options.duration, options.easing);
            } else if (options.adjustHeight === 'auto') {
                destHeight = $dest.height();
                if (parseFloat(sourceHeight) < parseFloat(destHeight)) {
                    // Adjust the height now so that the items don't move out of the container
                    $sourceParent.css('height', destHeight);
                } else {
                    //  Adjust later, on callback
                    adjustHeightOnCallback = true;
                }
            }
                
            // Now it's time to do shuffling animation
            // First of all, we need to identify same elements within source and destination collections    
            $source.each(function (i) {
                var destElement = [];
                if (typeof(options.attribute) == 'function') {
                    
                    val = options.attribute($(this));
                    $collection.each(function() {
                        if (options.attribute(this) == val) {
                            destElement = $(this);
                            return false;
                        }
                    });
                } else {
                    destElement = $collection.filter('[' + options.attribute + '=' + $(this).attr(options.attribute) + ']');
                }
                if (destElement.length) {
                    // The item is both in source and destination collections
                    // It it's under different position, let's move it
                    if (!options.useScaling) {
                        animationQueue.push(
                                            {
                                                element: $(this), 
                                                animation: 
                                                    {top: destElement.offset().top - correctionOffset.top, 
                                                     left: destElement.offset().left - correctionOffset.left, 
                                                     opacity: 1.0
                                                    }
                                            });

                    } else {
                        animationQueue.push({
                                            element: $(this), 
                                            animation: {top: destElement.offset().top - correctionOffset.top, 
                                                        left: destElement.offset().left - correctionOffset.left, 
                                                        opacity: 1.0, 
                                                        scale: '1.0'
                                                       }
                                            });

                    }
                } else {
                    // The item from source collection is not present in destination collections
                    // Let's remove it
                    if (!options.useScaling) {
                        animationQueue.push({element: $(this), 
                                             animation: {opacity: '0.0'}});
                    } else {
                        animationQueue.push({element: $(this), animation: {opacity: '0.0', 
                                         scale: '0.0'}});
                    }
                }
            });
            
            $collection.each(function (i) {
                // Grab all items from target collection not present in visible source collection
                
                var sourceElement = [];
                var destElement = [];
                if (typeof(options.attribute) == 'function') {
                    val = options.attribute($(this));
                    $source.each(function() {
                        if (options.attribute(this) == val) {
                            sourceElement = $(this);
                            return false;
                        }
                    });                 

                    $collection.each(function() {
                        if (options.attribute(this) == val) {
                            destElement = $(this);
                            return false;
                        }
                    });
                } else {
                    sourceElement = $source.filter('[' + options.attribute + '=' + $(this).attr(options.attribute) + ']');
                    destElement = $collection.filter('[' + options.attribute + '=' + $(this).attr(options.attribute) + ']');
                }
                
                var animationOptions;
                if (sourceElement.length === 0) {
                    // No such element in source collection...
                    if (!options.useScaling) {
                        animationOptions = {
                            opacity: '1.0'
                        };
                    } else {
                        animationOptions = {
                            opacity: '1.0',
                            scale: '1.0'
                        };
                    }
                    // Let's create it
                    d = destElement.clone();
                    var rawDestElement = d.get(0);
                    rawDestElement.style.position = 'absolute';
                    rawDestElement.style.margin = '0';
                    rawDestElement.style.top = destElement.offset().top - correctionOffset.top + 'px';
                    rawDestElement.style.left = destElement.offset().left - correctionOffset.left + 'px';
                    d.css('opacity', 0.0); // IE
                    if (options.useScaling) {
                        d.css('transform', 'scale(0.0)');
                    }
                    d.appendTo($sourceParent);
                    
                    animationQueue.push({element: $(d), 
                                         animation: animationOptions});
                }
            });
            
            $dest.remove();
            options.enhancement($sourceParent); // Perform custom visual enhancements during the animation
            for (i = 0; i < animationQueue.length; i++) {
                animationQueue[i].element.animate(animationQueue[i].animation, options.duration, options.easing, postCallback);
            }
        });
    };
})(jQuery);
