/**
 * How it works JavaScript.
 * Grey out effect is extracted from LightBox.
 * This JavaScript code is a simplified version of the Idea-lizer and
 * therefore is not under version control.
 *
 * @author Brad Chen <brad.chen@70mainstreet.com>
 */

// global variables and initialization
var howitworks;
jQuery(document).ready(function() {
  howitworks = new Howitworks();
});

/**
 * Howitworks Constructor.
 *
 * Properties:
 * container	- outmost div
 * overlay		- overlay for grey out effect
 * content		- div for the actual content
 */
function Howitworks() {
	this.container  = null;
	this.overlay    = null;
	this.content    = jQuery('#howitworks');
}

/**
 * Display the window.
 */
Howitworks.prototype.show = function() {
	// happy lazy initialization!
	if (!this.container) {
		this.initialize();
	}
	this.content.fadeIn(500);
	this.container.fadeIn(500);
};

/**
 * Hide the window.
 */
Howitworks.prototype.hide = function() {
	this.content.fadeOut(500);
	this.container.fadeOut(500);
};

/**
 * Initialize idealizer and create overlays.
 */
Howitworks.prototype.initialize = function() {
	this.container = jQuery('<div id="howitworks-container"></div>');
	this.overlay = jQuery('<div id="howitworks-overlay"></div>');
	this.overlay.appendTo(this.container);
	this.container.appendTo(jQuery('BODY'));

	// set up overlay
	if (!document.body.style.maxHeight) {
		// that's IE 6 we are talking here
		jQuery('body', 'html').css({height: '100%', width: '100%'});
		jQuery('html').css({overflow: 'hidden'});
		this.overlay.css({position: 'absolute'});
	}
	// macFirefox() function is defined by Idealizer
	if (macFirefox()) {
		this.overlay.addClass('howitworks-overlay-mac-ff');
	} else {
		this.overlay.addClass('howitworks-overlay-bg');
	}
	this.overlay.click(function() {
		howitworks.hide();
	});
};

