jQuery.noConflict();
jQuery( function() {

	/*
	 * Automatically bind FancyBox to image previews.
	 */
	jQuery( ".preview" ).bind( "click", function() {
		jQuery.fancybox( {
			"imageScale": true,
			"padding": 10,
			"zoomOpacity": true,
			"zoomSpeedIn": 1250,
			"zoomSpeedOut": 1250,
			"zoomSpeedChange": 1000,
			"overlayShow": true,
			"overlayColor": "#000",
			"overlayOpacity": 0.8,
			"enableEscapeButton": true,
			'titleShow': true,
			"showCloseButton": true,
			"hideOnOverlayClick": true,
			"hideOnContentClick": false,
			"callbackOnStart": null,
			"callbackOnShow": null,
			"callbackOnClose": null,
			"centerOnScroll": true,
			"easingIn": "easeOutBack",
			"easingOut": "easeInBack",
			"transitionIn": "elastic",
			"transitionOut": "elastic",
			"easingChange": "easeInOutBack",
			"href": jQuery( this ).attr( "src" ).replace( ".preview", "" )
	} );	} );
	
	/*
	 * Change pointer for preview images that may not be linked to themselves.
	 */
	jQuery( ".preview" ).hover( function() {
		jQuery(this).css( { cursor: "pointer" } );
	}, function() {
		jQuery(this).css( { cursor: "auto" } );
	} );
	
	/*
	 * Automatically catch links to outsite websites and open them in Fancybox.
	 */
	//	$('a[href^="http"][href!="http://crowleyfurniture.blogspot.com/?ch=1"]').each( function() {
	jQuery( "a[href]:not( [href^='/'], [href^='#'], [href*='fb.me'], [href*='bit.ly'], [href*='pd.'], [href*='pickledish.com'], [href*='pickledishstore.com'] )" ).each( function() {
		jQuery( this ).addClass( "iframe" );
	});
	
	/*
	 * Open links marked as iframe in a fancybox
	 */
	jQuery( ".iframe" ).fancybox( {
		'imageScale': true,
		'padding': 10,
		'zoomOpacity': true,
		'zoomSpeedIn': 1250,
		'zoomSpeedOut': 1250,
		'zoomSpeedChange': 1000,
		'overlayShow': true,
		'overlayColor': "#000",
		'overlayOpacity': 0.8,
		'enableEscapeButton': true,
		'showCloseButton': true,
		'hideOnOverlayClick': true,
		'hideOnContentClick': false,
		'titleShow': true,
		'width': '90%',
		'height': '90%',
		'type': 'iframe',
		'callbackOnStart': null,
		'callbackOnShow': null,
		'callbackOnClose': null,
		'centerOnScroll': true,
		'transitionIn': 'fade',
		'transitionOut': 'fade'
	} );
	
	
	/*
	 * Default Fancybox Setup
	 */
	 jQuery.fn.getTitle = function() {
		var arr = jQuery("a.fancybox");
		jQuery.each(arr, function() {
			var title = jQuery(this).children("img").attr("title");
			jQuery(this).attr('title',title);
	})	}
	
	// Supported file extensions
	var thumbnails = 'a:has(img)[href$=".bmp"],a:has(img)[href$=".gif"],a:has(img)[href$=".jpg"],a:has(img)[href$=".jpeg"],a:has(img)[href$=".png"],a:has(img)[href$=".BMP"],a:has(img)[href$=".GIF"],a:has(img)[href$=".JPG"],a:has(img)[href$=".JPEG"],a:has(img)[href$=".PNG"]';

	jQuery(thumbnails).addClass("fancybox").attr("rel","fancybox").getTitle();

	jQuery("a.fancybox").fancybox({
		'imageScale': true,
		'padding': 10,
		'zoomOpacity': true,
		'zoomSpeedIn': 1250,
		'zoomSpeedOut': 1250,
		'zoomSpeedChange': 1000,
		'overlayShow': true,
		'overlayColor': "#000",
		'overlayOpacity': 0.8,
		'enableEscapeButton': true,
		'showCloseButton': true,
		'hideOnOverlayClick': true,
		'hideOnContentClick': false,
		'callbackOnStart': null,
		'callbackOnShow': null,
		'callbackOnClose': null,
		'centerOnScroll': true,
		'easingIn': 'easeOutBack',
		'easingOut': 'easeInBack',
		'transitionIn': 'elastic',
		'transitionOut': 'elastic',
		'easingChange': 'easeInOutBack'
	});

} );

/*
 * Disable target="_blank"
 */
function launch_popup( e, a, b, c ) { return true; }

