/**
 * Slide Box : a jQuery Plug-in
 * Samuel Garneau <samgarneau@gmail.com>
 * http://samuelgarneau.com
 * 
 * Released under no license, just use it where you want and when you want.
 */

(function($){
	
	$.fn.slideBox = function(params){
	
		var content = $(this).html();
		var defaults = {
			width: "100%",
			height: "100%",
			position: "bottom"			// Possible values : "top", "bottom"
		}
		
		// extending the fuction
		if(params) $.extend(defaults, params);
		
		var divPanel = $("<div class='slide-panel'>");
		var divContent = $("<div class='content'>");
	
		$(divContent).html(content);
		$(divPanel).addClass(defaults.position);
		$(divPanel).css("width", defaults.width);
		
		// centering the slide panel
		$(divPanel).css("left", (100 - parseInt(defaults.width))/2 + "%");
	
		// if position is top we're adding 
		if(defaults.position == "top")
			$(divPanel).append($(divContent));
		
		// adding buttons
		$(divPanel).append("<div style='display: none; with:74px; height:26px; background: url(images/btn_close.png) no-repeat; ' id='close-button' class='slide-button'></div>");
		
		if(defaults.position == "bottom")
			$(divPanel).append($(divContent));
		
		$(this).replaceWith($(divPanel));
		
		// Buttons action
		$("#btn_contact").click(showContact);
		
		$(".logo_mid").click(showContact);
		
		function showContact(){
			if($(this).attr("id") == "close-button")
				$(divContent).animate({height: "0px"}, 250);
			else
			$(divContent).animate({height: defaults.height}, 250);
			$(".slide-button").show();
			$(".slide-button").click(function(){
				$(divContent).animate({height: "0px"}, 250);
				$(".slide-button").css({"display": "none"});
			})
		}
	};
	
})(jQuery);
