;(function($) {

$.fn.contact= function(options) {
	
	var $button = $(options.button);
	var $form = $(this);
var $expanded = false;
_initButton();
	
var $navbutton = $(options.navbutton);

	$navbutton.bind('click',function(){
		if($expanded){
			$expanded = false;
		$form.slideUp('fast', function() {
		    // Animation complete.
_initButton();
$navbutton.removeClass('active')
	});
		} else {
			$button.unbind('mouseover');
				$button.unbind('mouseout')
				$expanded = true;
				$button.addClass('active')
					//$button.text('Close contact form')
					//$button.css({backgroundColor: '#afd5dc'});
					$(this).addClass('active')
			$form.slideDown('fast', function() {
				$('#name',$form).focus();
			    // Animation complete.
			  });
		}
	return false;
	})
	
	
	
	$button.bind('click',function(){
		if($expanded){
			$expanded = false;
		$form.slideUp('fast', function() {
		    // Animation complete.
_initButton();
	});
		} else {
			$(this).unbind('mouseover');
			$(this).unbind('mouseout')
				$expanded = true;
				$button.addClass('active')
					$button.text('Close contact form')
					//$button.css({backgroundColor: '#afd5dc'});
			$form.slideDown('fast', function() {
				$('#name',$form).focus();
			    // Animation complete.
			  });
		}
	return false;
	})
	
	function _initButton(){
		$button.text('Click here to contact us')
		$button.removeClass('active')
		$button.bind('mouseover',function(){
			$(this).text(' and start saving today!')
		})
		$button.bind('mouseout',function(){
			$(this).text('Click here to contact us')
		})
		
		
	}
//
	
}

})(jQuery);






