jQuery(function() {

	

	jQuery('#gas_card').click(function() {

		showQuoteForm();

	});



});



function showQuoteForm() {

	jQuery.ajax({url: 'popupquoteform.php', success: function(str) {

		jQuery("body").prepend('<div id="overlay"></div>');

		var $overlay = jQuery("#overlay");

		$overlay.hide().click(function(e) {hideQuoteForm(e, false);});

		$overlay.fadeIn(500, function() {

			$overlay.append('<div id="modal"></div>');

			var $modal = jQuery("#modal");

			$modal.hide();

			$modal.html(str);

			$modal.slideDown(500);

			$modal.find('.close').click(function(e) {

				hideQuoteForm(e, true);

			});

		});

	}, error: function() {

		alert('An error occurred while retrieving our form. Please try again.');

	}});

}



function hideQuoteForm(e, ignore) {

	if (jQuery(e.target).is("#overlay") || ignore) {

		var $overlay = jQuery("#overlay");

		var $modal = jQuery("#modal");

		$modal.slideUp(500, function() {

			$modal.remove();

			$overlay.fadeOut(500, function() {

				$overlay.remove();

			});

		});

	}

}
	

(function(jQuery){
	jQuery.fn.headline_rotate = function(options) {
	
		var _this = this;
		var jQuerythis = jQuery(this);
		
		var settings = {
		  'timeout' : 3000
		};
		jQuery.extend( settings, options );

		jQuery(this).children('.headline').css('top',(jQuery(this).height()+10));
		jQuery(this).children('.headline').eq(0).css('top','5px').addClass('active');
		
		setInterval(function() {
		
			jQueryactive = jQuerythis.children(".headline.active");
		
			if (jQueryactive.next().length == 0) {jQuerynext = jQuerythis.children('.headline').eq(0);}
			else {jQuerynext = jQueryactive.next('.headline');}
			
			jQueryactive.animate({top: -(jQuerythis.height()+10)}, 750, function() {
				jQuery(this).css('top',(jQuerythis.height()+10)+'px').removeClass('active');
			});
			jQuerynext.addClass('active').show().animate({top: 5}, 750, function() {
				//jQuery(this).effect("bounce", { times: 2 , distance: 10 }, 300);
			});
		
		},settings.timeout);
		
		return _this;
	};
	
})(jQuery);
 
