function initialize() {
	// quit if this was called already
	if (arguments.callee.wasCalledAlready) {
		return;
	}
	arguments.callee.wasCalledAlready = true; // on the first call, the 'was called already' flag is set to true

	if (typeof(nonW3CFixes_initialize) != 'undefined') {
		nonW3CFixes_initialize();
	}

	oShowLoginControlsDiv = document.getElementById('show-login-controls');
	if (oShowLoginControlsDiv) {
		oShowLoginControlsDiv.onclick = function () {
			this.parentNode.style.display = 'none';
			document.getElementById('login-controls').style.display = 'block';
			return false;
		}
	}

	var oaPasswordInputs = document.getElementsByClassName('password_input');
	for (var i = 0; i < oaPasswordInputs.length; i++) {
		oaPasswordInputs[i].onfocus = function () {
			try {
				this.type = 'password';
			} catch (e) {
				var oaInputs = this.parentNode.getElementsByTagName('input');
				oaInputs[0].style.display = 'none';
				oaInputs[1].style.display = 'inline';
				oaInputs[1].focus();
			}

			var sPasswordValue = this.className.match(/ default_value_(.+)$/);
			if (sPasswordValue.length == 2) {
				sPasswordValue = sPasswordValue[1];
				if (this.value == sPasswordValue.replace(/_/g, ' ')) {
					this.value = '';
				}
			}
		}

		oaPasswordInputs[i].onblur = function () {
			var sPasswordValue = this.className.match(/ default_value_(.+)$/);
			if (sPasswordValue.length == 2) {
				sPasswordValue = sPasswordValue[1];
				if (this.value.trim() == '') {
					this.value = sPasswordValue.replace(/_/g, ' ');
					try {
						this.type = 'text';
					} catch (e) { ; }
				}
			}
		}
	}


	var oaPasswordInputs = document.getElementsByClassName('toggle_input_type_ie');
	for (var i = 0; i < oaPasswordInputs.length; i++) {
		oaPasswordInputs[i].onblur = function() {
			if (this.value.trim() == '') {
				var oaInputs = this.parentNode.getElementsByTagName('input');
				oaInputs[0].style.display = 'inline';
				oaInputs[1].style.display = 'none';
			}
		}
	}

	if (document.getElementById('menu')) {
		menuSlider.init('menu','slide');
	}

	if (window.instructions && window.instructions.init) {
		window.instructions.init();
	}

	if (window.componentEmbeds && window.componentEmbeds.init) {
		window.componentEmbeds.init();
	}

	if (window.licenses && window.licenses.init) {
		window.licenses.init();
	}

	if (window.codeHighlighter && window.codeHighlighter.highlight) {
		window.codeHighlighter.highlight();
	}

	if (typeof(comments_init) != 'undefined') {
		window.comments_init();
	}

	if (window.cart && window.cart.init) {
		window.cart.init();
	}

	if (window.orders && window.orders.init) {
		window.orders.init();
	}

	if (window.ourTeam && window.ourTeam.init) {
		window.ourTeam.init();
	}

	if (window.faqHighlighter && window.faqHighlighter.init) {
		window.faqHighlighter.init();
	}

	if (window.faqsMenu && window.faqsMenu.init) {
		window.faqsMenu.init();
	}

	if (window.membership && window.membership.init) {
		window.membership.init();
	}

	if (window.twitterContest && window.twitterContest.init) {
		window.twitterContest.init();
	}


	if (window.checkout && window.checkout.init) {
		window.checkout.init();
	}

	var oForceLoginLink = document.getElementById('force_login');
	if (oForceLoginLink) {
		jQuery.noConflict();
		jQuery('#force_login').fancybox({
			titlePosition : 'inside',
			transitionIn : 'none',
			transitionOut : 'none',
			width: 900,
			height: 512,
			onStart: function(triggerLink) {
				if (jQuery.browser.msie || jQuery.browser.webkit) {
					jQuery('param').each(function(i, oParam) {
						if (oParam.name == 'wmode' && oParam.value != 'transparent') {
								jQuery(oParam).parent().attr('style', 'visibility: hidden;');
						}
					});
				}
			},
			onClosed: function() {
				if (jQuery.browser.msie || jQuery.browser.webkit) {
					jQuery('param').each(function(i, oParam) {
						if (oParam.name == 'wmode' && oParam.value != 'transparent') {
							jQuery(oParam).parent().attr('style', 'visibility: visible;');
						}
					});
				}
			}
		});
	}

	if (window.licensesQuiz && window.licensesQuiz.init) {
		window.licensesQuiz.init();
	}

	if (window.Custom && window.Custom.init) {
		window.Custom.init();
	}

	if (window.payment && window.payment.init) {
		window.payment.init();
	}

	if (window.chat && window.chat.init) {
		window.chat.init();
		window.chatTrigger = null;
	}

	if (window.chatTrigger && window.chatTrigger.init) {
		window.chatTrigger.init();
	}

	if (window.homeHeaderFeaturedProducts && window.homeHeaderFeaturedProducts.init) {
		window.homeHeaderFeaturedProducts.init();
	}

	if (window.myComponents && window.myComponents.init) {
		window.myComponents.init();
	}

	var oSearchInput = document.getElementById('search');
	if (oSearchInput && window.jQuery) {
		jQuery.noConflict();
		jQuery.get('/search_get_suggestions/', function (jsonData) {
			window.oComponents = jsonData;
			var saComponentNames = [];

			for (var sComponentName in window.oComponents) {
				saComponentNames.push(sComponentName);
			}

			jQuery('#header_search_input').autocomplete({
				appendTo: '#header .hm_right',
				source: saComponentNames,
				select: function (event, ui) {
					window.location.href = window.oComponents[ui.item.label];
				}
			}).focus(function() {
				var joSearchInput = jQuery(this);
				if (joSearchInput.val() == joSearchInput.attr('class').substring(0, joSearchInput.attr('class').indexOf(' ')).replace(/_/g, ' ')) {
					joSearchInput.val('');
				}
			}).blur(function() {
				var joSearchInput = jQuery(this);
				if (joSearchInput.val() == '') {
					joSearchInput.val(joSearchInput.attr('class').substring(0, joSearchInput.attr('class').indexOf(' ')).replace(/_/g, ' '));
				}
			});
		}, 'json');
	}

	if (window.customWorkRibbon && window.customWorkRibbon.init) {
		window.customWorkRibbon.init();
	}
}

// DOMContentLoaded event handler for browsers that support it
if (window.addEventListener) {
	window.addEventListener('DOMContentLoaded', initialize, false);
}

// DOMContentLoaded event handler for browsers that DON'T support it: Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)
document.write('<script id=__ie_onload defer src=javascript:void(0)><\/script>');
var script = document.getElementById('__ie_onload');
script.onreadystatechange = function() {
  if (this.readyState == 'complete') {
  	// IE6 needs a small timeout to completely load the DOM
  	if (!window.XMLHttpRequest) {
  		window.setTimeout(window.initialize, 30);
  	} else {
  		window.initialize();
  	}
  }
};
/*@end @*/

window.onload = function() {
	if (window.desaturate) {
		if (typeof(nonW3CFixes_initialize) != 'undefined') {
			nonW3CFixes_initialize();
		}

		window.desaturate.init();
	}
}
