$.extend( $.Isotope.prototype, {
	insertAbove : function( $content, target, callback, inlineId ) {
		var clickedY = 0;
		if(target) {
			clickedY = $(target).data('isotope-item-position').y;
		}
		
  		var above = null;
  		
  		for(var i = 0; i < this.$allAtoms.length; i++) {
  			var atomY = $(this.$allAtoms[i]).data('isotope-item-position').y;
  			var isContact = $(this.$allAtoms[i]).hasClass("contact");
  			
  			if(!isContact) {
	  			if(atomY >= clickedY) {
	  				break;
	  			} else {
	  				above = this.$allAtoms[i];
	  			}
  			}
  		}
  		
		if(above) {
			$(above).after( $content );
		} else {
			this.element.prepend( $content );
		}
		
		var instance = this;
		this.addItems( $content, function( $newAtoms ) {
		var $filteredAtoms = instance._filter( $newAtoms );
			instance.$filteredAtoms = instance.$filteredAtoms.add( $filteredAtoms );
		});
		
		this.options.sortBy = 'original-order';
		
		this.reloadItems();
		this._sort();
		
		if(callback) {
			this.reLayout( function() { callback(inlineId); } );
		} else {
			this.reLayout();
		}
	},
	
	insertBefore : function( $content, target, callback ) {
		if(target) {
			$(target).after( $content );
		} else {
			this.element.prepend( $content );
		}
		
		var instance = this;
		this.addItems( $content, function( $newAtoms ) {
		var $filteredAtoms = instance._filter( $newAtoms );
			instance.$filteredAtoms = instance.$filteredAtoms.add( $filteredAtoms );
		});
		
		this.options.sortBy = 'original-order';
		
		this.reloadItems();
		this._sort();
		
		if(callback) {
			this.reLayout( function() { callback(); } );
		} else {
			this.reLayout();
		}
	}
});
