﻿/*
	VERSION:    Reveal jQuery Plugin 1.0  (08-27-2008)	
	AUTHOR:     Oren Goldfinger
	REQUIRES:   jquery.js (1.2.6 or later)
	SYNTAX:     $(selector).reveal(options);  
	OPTIONS:
		        speed   : integer (default = 500)
	EXAMPLE:
	            $("#myId").reveal();            
                $("#myId2").reveal({
                    speed: 200
                });
 */
(function($){
    $.fn.reveal = function(options) 
    {        
        var opts = $.extend({
                        speed: 500                        
                    }, options);        
                
        var obj = $(this);                
        
        // If we're in the processing of animating, ignore the click
        if(obj.data("isMoving") == "true") return;
        
        //var move = obj.height();
        
        // wrap it with a relative div (do this only once)
        if(obj.data("isOpen") == undefined)
        {
            // put it in a container once only
            var container = $("<div></div>");
            container.css({
                height:"1px",
                position:"relative"
            });                    
                               
            obj.wrap(container);        
            
            // IE fix
            obj.prepend("<div class='ierevealfix'><iframe src='about:blank' scrolling='no' frameborder='0'></iframe></div>");                                    
        }        
        
        // Determine if this is an open or close
        if(obj.data("isOpen") == "true")        
        {
            //move *= -1; // close it
            obj.data("isOpen", "false");   
        }
        else
        {
            obj.data("isOpen", "true");
        }
        
        obj.data("isMoving", "true");                
        obj.animate({
            height: "toggle"
        }, opts.speed, function(){
            obj.data("isMoving", "false");
        });                               
        
    };
})(jQuery);