$.fn.clearQueue = $.fn.unpause = function(type) {
	return this.each(function(){
		type = type || "fx";
		if(this.queue && this.queue[type]) {
			this.queue[type].length = 0;
		}
	});
};

jQuery.fn.extend({
	toggle: function( fn, fn2 ){
		var args = arguments;
		return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
			this._toggle( fn, fn2 ) :
			this.each(function(){
				jQuery(this)[ jQuery(this).is(":hidden") ? "fadeIn" : "fadeOut" ]
					.apply( jQuery(this), args );
			});
	}
});
var crossFader = function(el1, el2, el3, el4) {
	if($(el2).css("background-image") != 'none' && $(el4).css('background-image') != 'none') {
		var intId = setInterval(function(){
			$(el1).toggle("slow");
			$(el2).toggle("slow", function(){new crossFader(el3, el4, el1, el2)});
			clearInterval(intId);
			intId=null;
		}, 5000);
	} else { clearInterval(intId); }
};
$(function(){
	$("ul.external-links a").each(function(){$(this).click(function(){window.open($(this).attr("href"),'_blank');return false;})});
	$("#page-content-scroll").jScrollPane({scrollbarMargin:10});
	TextResizeDetector.TARGET_ELEMENT_ID = 'page-content';	//id of element to check for and insert control
	TextResizeDetector.USER_INIT_FUNC = function(){
		var iBase = TextResizeDetector.addEventListener(function(){
			$("#page-content-scroll").jScrollPane({scrollbarMargin:10});
			$("#top").unpause();
			$("#top").css("margin-bottom",-(parseInt($("#container").css("height"))/2));
		},this);
		// $("#top").css("margin-bottom", -(parseInt($("#container").css("height"))));
	};
	new crossFader('#art1','#art3','#art2','#art4');
});