var cslrGlobal = {
	initStack : {
		stack: new Array("initHeader","initNav","initFooter"),
		addTo: function(mN) {
			if(jQuery.inArray(mN, this.stack) == -1) {
				this.stack[this.stack.length] = mN;
			}
		},
		execute: function() {
			jQuery.each(this.stack, function(i,val) {
				cslrGlobal[val]();
			})
		}
	},
	init: function() {
		this.initStack.execute();
	},
	initToolTips: function() {
		$('.tooltipWrap').each(function(i, tipWrap) {
			var trigger = $(tipWrap).closest('tr');
			$(trigger).mouseenter(function() {
				$(tipWrap).fadeIn('fast');
			});
			$(trigger).mouseleave(function() {
				$(tipWrap).hide();
			});
		});
	},
	initNav: function() {
		var conf = {
			autoArrows: false,
			dropShadows: false,
			delay: 400
		}
		if($.browser.msie && $.browser.version > 6) {
			conf['speed'] = 1;
			conf['animation'] = {height: 'show'};
		} else {
			jQuery.each(jQuery.browser, function(i, val) {
			  if(i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.8")
				$('ul#primaryNav').css('opacity', 0.9999);	// fix for opacity bug in mac FF		
			});
			conf['speed'] = 'fast';
		}
	    $('#primary')/*.supersubs({
	    	minWidth: 15,
	    	maxWidth: 15,
	    	extraWidth: .5
	    })*/.superfish(conf);
	},
	initHeader: function() {
		$('#gSearch .field label').click(function() {
			$(this).hide();
		});
		$('#gSearch input.text').blur(function() {
			$(this).siblings('label').show();
		});
	},
	initFooter: function() {
		$('#newsletter input.text')
		.click(function() {
			$(this).siblings('label').hide();
		})
		.focus(function() {
			$(this).siblings('label').hide();
		})
		.blur(function() {
			if(!$(this).val()) $(this).siblings('label').show();
		});
	},
	initNewsLanding: function() {
		$('#newsletterInner input.text')
		.click(function() {
			$(this).siblings('label').hide();
		})
		.focus(function() {
			$(this).siblings('label').hide();
		})
		.blur(function() {
			if(!$(this).val()) $(this).siblings('label').show();
		});
	},
	initBlinds: function() {
		$('.hides').each(function(i, hides) {
			if(!$(hides).hasClass('hid')) {
				$(hides).hide();
			}
			var handle = $('#' + $(hides).attr('id') + '-handle');
			handle.click(function() {
				cslrGlobal.toggleBlind(hides);
			})
		})
	},
	toggleBlind: function(hidesEl) {
		var hidesEl = $(hidesEl);
		var handle = $('#' + hidesEl.attr('id') + '-handle');
		if(hidesEl.is(':hidden')) {
			// show
			handle.addClass('active');
			hidesEl.fadeIn('normal');
		} else {
			// hide
			handle.removeClass('active');
			hidesEl.hide();
		}
	},
	initDropdowns: function() {
		$('select.replaceDrop').selectbox({
			inputClass: 'hidInput',
			hoverClass: 'cur',
			selectedClass: 'active',
			valueBoxClass: 'vDisplay'
		});
	}
}

$(document).ready(function(){
	cslrGlobal.init();
});

var initStack = new Array();