/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 

jQuery.noConflict();

// starting the script on page load
jQuery(document).ready(function(){
	
	    /*jQuery('a' ).attr("target", "_blank");
	    jQuery('a[href^="http://www.finchsquarterly"]' ).attr("target", "_self");
	    */

	imagePreviewJQ();
	
 
});

function loadLogContent(elementSelector, sourceUrl) {
	//alert(elementSelector);
	//jQuery(""+elementSelector+"").html('kk');
//jQuery(""+elementSelector+"").load('proxy.php?url='+sourceUrl+'');
jQuery(""+elementSelector+"").load('/wp-admin/profile.php');
//jQuery(""+elementSelector+"").load(""+sourceURL+"");
}

this.imagePreviewJQ = function(){	
	/* CONFIG */
		
		xOffset = 100;
		yOffset = 30;
		
		midscreen=document.documentElement.clientHeight/2;
		
	/* END CONFIG */
	

	/* Add to standard wordpress gallery a shadowbox */
	
	jQuery(".gallery-icon").hover(function(e){
		
		/* replace default thumb image */
		//getimage = jQuery('a img.attachment-thumbnail',this).attr("src");
		//jQuery('a',this).attr("href",getimage.replace(/-150x150/gi, '' ));
	
		/* set up as a sb gallery */
		//imgdcontent = jQuery(this).html();
		//alert(imgdcontent.replace(/<a/gi, '<a rel="shadowbox[1]"' ));
		}); 
	
	jQuery('.gallery-icon').each(function(index) {				
		/* replace default thumb image */
		getimage = jQuery('a img.attachment-thumbnail',this).attr("src");
		jQuery('a',this).attr("href",getimage.replace('-150x150', '' ));
	
		/* set up as a sb gallery */
		imgcontent = jQuery(this).html();
		
		jQuery(this).html(imgcontent.replace(/<a/gi, '<a rel="shadowbox[1]"' ));	
	});
	

	
	jQuery("a.fapreview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		jQuery("body").append("<div id='fapreview'><img src='"+ this.href +"' alt='Image preview' width='350px' />"+ c +"</div>");								 
		jQuery("#fapreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.slideDown("normal");						
    },
	function(){
		this.title = this.t;		
		jQuery("#fapreview").remove();
    });	
	jQuery("a.fapreview").mousemove(function(e){
		jQuery("#fapreview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



