// <![CDATA[
/**
 * dependency of this plugin:
 *
 * //@var global string http_root
 * //@var global string rp_image_global
 * //@var global string image_loader
 * //@var global string rp_cms
 *
 * //@function close_popup()
 *
*/

// You need an anonymous function to wrap around your function to avoid conflict
(function($){
 
    // Attach this new method to jQuery
    $.fn.extend({ 
         
        // This is where you write your plugin's name
        reveal_tile_image: function(options) {
		
			// Set the default values, use comma to separate the settings, example:
            var defaults = {
				objectParent: '.tile-item' // The object parent.
            }
                 
            var options = $.extend(defaults, options);
			
			var $cm = this.each(function(){
				
				var o = options;
				var object = $(this);
				
				// Set the object parent.
				var parent_object = object.parent(o.objectParent);
				
				if(object.length > 0)
				{
					//On hover...	
					object.find('img').hover(function() { 
						
						//Fade the image container to 0.
						$(this).parent().fadeTo('normal', 0);
						
						//Fade the image to 0.
						$(this).fadeTo('normal', 0 , function() {
							//$(this).hide() //Hide the image after fade
						});
						
						//Set the overflow to visible to display the tile description.
						//parent.css({overflow:'visible'});
						
						$('div', parent_object).slideToggle('fast');
						//$(this).unbind('mouseenter mouseleave');
						
						//Change the button's position to the new position.
						$('a',parent_object).css({backgroundPosition: '0px -11px'});
						
						//On hover out...
					}, function() { 
						
						//$(this).bind('mouseenter mouseleave');
						
						//Fade the image container to 1.
						$(this).parent().fadeTo('normal', 1);
						
						//Fade the image to 1 
						$(this).fadeTo('normal', 0.4).show();
						
						//Set the overflow to visible to display the tile description.
						//parent.css({overflow:'hidden'});
						
						$('div', parent_object).slideToggle('fast');
						
						//Change the button's position back.
						$('a',parent_object).css({backgroundPosition: '0px 0px'});
					});
				}

			});

        }
    });
     
//pass jQuery to the function, 
//So that we will able to use any valid Javascript variable name 
//to replace "$" SIGN. But, we'll stick to $ (I like dollar sign: ) )       
})(jQuery);

// ]]>
