/*
FILE TABLE OF CONTENTS:
	1.0 - jquery.ax.js
	2.0 - ax.utilities.js
	3.0 - jquery.utilities.js
	4.0 - jquery.sysmessage.js
	5.0 - jquery.forms.js
	6.0 - jquery.navcolumn.js
	7.0 - jquery.link_to_remote.js
	8.0 - jquery.contactinfopopup.js
	9.0 - jquery.tracking.js
	10.0 - jquery.featured_experts.js
	11.0 - jquery.ajaxLoadContent.js
	12.0 - jquert.carousel.js
	13.0 - shortenUrl
*/

var currentLocation = window.location;

/* BEGIN 1.0: jquery.ax.js */

(function($) {
	$.fn.ax = function(options){
		var opts = $.extend({}, $.fn.ax.defaults, options);
		
		return this.each(function() {
			$this = $(this);
		});
  };
	
	$.fn.ax.defaults = {		
	};
	
	$.fn.ax.link_to_remote = function (scope) {
		$this = scope;
		$("a.Remote", $this).link_to_remote({ method: 'get', update: '#ContentWell', after: null });
	};
	
	$.fn.ax.debug_links = function (scope) {
		$this = scope;
		$('a[href=OPEN_TEST]', $this).debug_links();
	};
})(jQuery);

/* END 1.0: jquery.ax.js */

/* BEGIN 2.0: ax.utilities.js */

var AX = AX || {};

// splitURLVars - takes GET variables from URL and returns key->value array
AX.splitURLVars = function(url) {
	var getData = new Array();
	
	var vars = url.split('?')[1];
	
	if (vars) 
	{
		vars = vars.substr(0);
		
		var pairs = vars.split("&");
		
		for (var i = 0; i < pairs.length; i++)
		{
			var formData = pairs[i].split("=");
			
			var name = formData[0];
			var value = formData[1];
			getData[name] = value;
		}
	}
	
	return getData;
};

AX.onFollowButtonMouseOver = function ($button) {
			var $tooltip = $button.siblings('.tt_wrap');

			if ($tooltip.length === 0) {
				var $ttBubble = $('<span/>', { 'class': 'tt_bubble', 'html': $button.attr('title') }),
					$ttPointer = $('<span/>', { 'class': 'tt_pointer' });
				$tooltip = $('<span/>', { 'class': 'tt_wrap' }).append($ttPointer, $ttBubble);
				$button.parent().append($tooltip);
				$tooltip.css('left', -(($tooltip.width() / 2) - ($button.width() / 2)));
			} else {
				$tooltip.show();
			}
		};

AX.onFollowButtonMouseOut = function ($button) {
			$tooltip = $button.siblings('.tt_wrap');
			$tooltip.hide();
		};

// Funciton to add even/odd classes to the child nodes of the parent element given
// i.e. $.ax.stripe('ul.topics');
$.fn.stripe = function (e) {
	$(e).children().removeClass('even');
	$(e).children().removeClass('odd');
	
	$(e).children(':even').addClass('odd');
	$(e).children(':odd').addClass('even');

};

function ajaxSuccess(content) {
	$content = $(content);
	if(typeof(content) == "string" && content == "") {
		$('body').sysmessage('We\'re sorry, your request could not be processed', {type: 'error'});
		return false;	
	} else if($content.hasClass('error')) {
		$('body').sysmessage($content.html(), {type: 'error'});
		return false;
	} else if($content.hasClass('redirect')) {
		var currentLocation = window.location.pathname;
		window.location.href = $(this).find('a:first').attr('href') + currentLocation;
	} else if($content.hasClass('success') || (typeof(content) == "string" && content != "") ) {
		return true;
	} else {
		$('body').sysmessage('We\'re sorry, your request could not be processed', {type: 'error'});
		return false;
	}
};

AX.setupAccordion = function () {

	//run top story code if not in takeover mode
	if ($('#top_story_takeover').length == 0) {
		$('#section_top_stories').find('h3 a').each(function () { this.href = '#'; });

		$('#accordion_top_stories').accordion({
			'clickElements': 'h3',
		'accordionContainer': 'ul',
		'tabContainer': 'li',
		'contentContainer': 'div',
			'hideClickElemOnActive': true,
		'accordionAnim': AX.accordionAnimation,
		'animationDisabledClasses': ['ie7']
	});
	}

	$('#accordion_most_popular').accordion({
		'clickElements': 'h4 a',
		'accordionContainer': 'ul',
		'tabContainer': 'li',
		'contentContainer': 'div',
		'ititialTab': 2,
		'accordionAnim': AX.accordionAnimation,
		'animationDisabledClasses': ['ie7']
	});

	$('#accordion_of_community').accordion({
		'clickElements': 'h4 a',
		'accordionContainer': 'ul',
		'tabContainer': 'li',
		'contentContainer': '.of_community_members_content',
		'ititialTab': 1,
		'accordionAnim': AX.accordionAnimation,
		'animationDisabledClasses': ['ie7']
	});


	// accordionChangeStart Binding.
	$(window).bind('accordionChangeStart', function (e, params) {
		if (params.id === 'accordion_top_stories') {
			AX.heroGalleryImageChange(params);
		}
		if (params.id.match(/accordion_most_popular|accordion_of_community/gi)) {
			if (typeof $.cookie === 'function') {
				$.cookie(params.id + '_state', params.vars.tabIndex.toString(), { path: '/' });
			}
		}
	});
};

AX.heroGalleryImageChange = function(params) {
	var $sourceImage = params.tab.parents('ul li').find('.accordion_image'),
		$sourceLink = $sourceImage.parent(),
		newLinkHref = $sourceLink.attr('href'),
		newClasses = $sourceLink.attr('class'),
		newLinkTitle = $sourceLink.attr('title'),
		newSrc = $sourceImage.attr('src'),
		newTitle = $sourceImage.attr('title'),
		newIsVideo = (newClasses.search('video') >= 0);
		
	var currentImage = params.tab.parents('#section_top_stories').find('#selected_image');
	var currentLink = currentImage.parent();
	var currentMediaButton = currentLink.find('span.media_button');
	
	var offStageImage = $('<img src="'+newSrc+'" title="'+newTitle+'" id="off_stage_image"/>');
	offStageImage.insertAfter(currentImage);
	currentLink.attr('href', newLinkHref)
		.attr('title', newLinkTitle)
	
	currentImage.fadeTo(500, 0, function(){
		$(this).remove();
		$('#section_top_stories').find('#off_stage_image').attr('id','selected_image');
	});
	
	if (newIsVideo) currentLink.attr('class', newClasses);
	currentMediaButton.fadeTo(500, (newIsVideo) ? 1 : 0, function(){
		if (!newIsVideo) currentLink.attr('class', newClasses);
	});
	
};


AX.accordionAnimation = function ($tab, config, transitionVars) {

	var toggleCloseCache = [],
		toggleOpenCache = [],
		toggleClickElemOpenCache = [];
	
	//Assign animating elements to respective caches.
	transitionVars.$allContentContainers.each(function () {
		if ($(this).is(':visible')) {
			toggleCloseCache.push(this);
		}
	});
	if (config.hideClickElemOnActive) {
		transitionVars.$allTabs.each(function () {
			if (!$(this).is(':visible')) {
				toggleClickElemOpenCache.push(this);
			}
		});
		toggleCloseCache.push($tab[0]);
	}
	toggleOpenCache.push(transitionVars.$contentContainer[0]);
	
	// BEGIN : ANIMATION SEQUENCE
	// **************************
	
	var openSpeed = 450, closeSpeed = 400;
	
	transitionVars.$accordionContainer.addClass('isAnimating');
	transitionVars.$accordionContainer.css('min-height', transitionVars.$accordionContainer.height());
	
	$(toggleClickElemOpenCache).animate({ height: 'toggle', opacity: 'toggle' }, closeSpeed);
	
	var openObjects = function () {
		$(toggleOpenCache).each(function (i) {
			if (i + 1 === toggleOpenCache.length) {
	
				$(this).animate({ height: 'toggle', opacity: 'toggle' }, openSpeed, function () {
	
					//Clear animation temp settings.
					transitionVars.$accordionContainer.css('min-height', '');
					transitionVars.$accordionContainer.removeClass('isAnimating');
	
					transitionVars.$accordionContainer.trigger('accordionChangeComplete', { focusOn: transitionVars.$tabContainer });
				});
			} else {
				$(this).animate({ height: 'toggle', opacity: 'toggle' }, openSpeed);
			}
		});
	};
	
	var closeObjects = function () {
	
		if (toggleCloseCache.length === 0) {
			openObjects();
		} else {
			$(toggleCloseCache).each(function (i) {
				if (i + 1 === toggleCloseCache.length) {
					$(this).animate({ height: 'toggle', opacity: 'toggle' }, closeSpeed, function () {
	
						transitionVars.$allTabContainers.removeClass(config.activeClass);
						transitionVars.$tabContainer.addClass(config.activeClass);
	
						openObjects();
					});
				} else {
					$(this).animate({ height: 'toggle', opacity: 'toggle' }, closeSpeed);
				}
			});
		}
	};
	
	//Start animation
	closeObjects();
	
	// ************************
	// END : ANIMATION SEQUENCE

}

// Open all links (external) to acceptpay.com with an interstitial message
function acceptpayInterstitial() {

		var acceptpayMessage = '<div id="acceptpay_interstitial"><h3>You\'re about to leave the OPEN Forum website.</h3><p id="body-copy">The AcceptPay<sup>SM</sup> site is powered by PaySimple<sup>&reg;</sup>. On this site you can learn more about and apply for AcceptPay e-invoicing, payment acceptance and receivables management on-line service.</p><p>In addition to our <a class="pay-simple" href="http://www.paysimple.com/legal.html">Terms of Service</a> and <a class="pay-simple" href="http://www.paysimple.com/privacy.html">Privacy Statement</a>, PaySimple\'s Terms of Service and Privacy Policy will apply to you after you click "continue" below.</p><p id="continue-btn"><a class="continue" href="http://www.acceptpay.com/">Continue</a></p></div>';
		
		function showMessage(ele, linkUrl) {
			
			$('body').sysmessage(acceptpayMessage, {
				type: 'confirmation', autoDismiss: false
			});
			
			var headwallEle = '<div id="sysmessage_headwall" style="position:absolute; left: -99999em;"></div>';
			
			$('body .sysmessage').prepend(headwallEle);
			
			$('body .sysmessage .sysmessage-message').css({
				'width' : '419px',
				'padding-top': '35px', 
				'padding-bottom': '1px'
			});
			
			$('.sysmessage a').attr('tabindex', '0');
			
			$('.sysmessage .sysmessage-close a').attr('title', 'close this popup');
			
			$('a[href^="http://www.paysimple.com"]').attr('target', '_blank');
			
			$('body .sysmessage').show();
			
			$('.sysmessage #sysmessage_headwall').attr('tabindex', '-1');
			$('.sysmessage #sysmessage_headwall').focus();
			
			$('#acceptpay_interstitial a.continue').attr({
				'href': linkUrl,
				'target': '_blank'
			});
			
			$('#continue-btn a').keypress(function(event) {
				if (event.keyCode == '9') {
					$('.sysmessage #sysmessage_headwall').focus();
				}
			});

			$('#acceptpay_interstitial a.continue, #ap_container .sysmessage-close a').click(function(){

				if ($.browser.version == "6.0") {
					$('.shim').remove();
				}
				if($(this).parent().hasClass('sysmessage-close')) {
					return false;
				}
			});
		}
		
		$('a[href^="http://www.acceptpay.com"]').click(function() {
			var linkUrl = $(this).attr('href');
			showMessage($(this), linkUrl);
			return false;
		});
}

function insuranceedgeInterstitial() {

		var sysmessageMessage = '<div id="insuranceedge_interstitial"><h3>You\'re about to leave the OPEN Forum website.</h3><p id="body-copy">The InsuranceEdgeSM site is operated by our partner, Bolt.  On this site you may learn more about and apply for InsuranceEdge insurance.</p><p id="continue-btn"><a class="continue" href="http://ad.doubleclick.net/clk;224729550;48522286;m">Continue</a></p></div>';
		
		function showMessage(linkUrl) {
			$('body').sysmessage(sysmessageMessage, {
				type: 'confirmation', autoDismiss: false
			});
			$('body .sysmessage .sysmessage-message').css({
				'width' : '419px',
				'padding-top': '35px', 
				'padding-bottom': '1px'
			});
			
			$('a[href^="http://ad.doubleclick.net/clk;224729550;48522286;m"]').attr('target', '_blank');
			
			$('#insuranceedge_interstitial a.continue').attr({
				'href': linkUrl,
				'target': '_blank'
			});
			$('#insuranceedge_interstitial a.continue').click(function(){
				$('body .sysmessage').remove();
				if ($.browser.version == "6.0") {
					$('.shim').remove();
				}
			});
		}
		
		$('a[href^="http://ad.doubleclick.net/clk;224729550;48522286;m"]').click(function() {
			var linkUrl = $(this).attr('href');
			showMessage(linkUrl);
			return false;
		});
}

/* END 2.0: ax.utilities.js */

/* BEGIN 3.0: jquery.utilities.js */

// BEGIN: Radio Button Select/Deselect Function
////////////////////////////////////////////////////
jQuery.fn.extend({
	check: function() {
		return this.each(function() { this.checked = true; });
	},
	uncheck: function() {
		return this.each(function() { this.checked = false; });
	}
});
////////////////////////////////////////////////////
// END: Radio Button Select/Deselect Function


// BEGIN: Help Links
////////////////////////////////////////////////////
$.fn.helpLinks = function() {
	$('a.help_link').bind('click',function(){
		window.open ($(this).attr('href'),"Help_Desk","status=0,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=1,height=600,width=831");
		
		return false;
	});
};
////////////////////////////////////////////////////
// END: Help Links

	
// BEGIN: Preload Images
////////////////////////////////////////////////////
$.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		$("<img>").attr("src", arguments[i]);
	}
};
////////////////////////////////////////////////////
// END: Preload Images


// BEGIN: UI Block
////////////////////////////////////////////////////
$.BlockUI = function() {
	$('<div id="UIBlock">').css({
		width: $('#Content').outerWidth() + 'px',
		height: ($('#PageWrapper').outerHeight() - $('#Footer').outerHeight() - $('#Header').outerHeight()) + 'px',
		top: $('#Header').outerHeight(),
		opacity: '0.0'
	}).appendTo('body').animate({
		opacity: '0.7'
	},100);
	
	if ($.browser.msie && ($.browser.version < 7)) { // Hide all visible select lists for IE6
		$('div#Content select').each(function() {
			$select = $(this);
			
			if ( $select.css('display') == 'inline' ) {
				$select.addClass('UIBlocked');
			}
		});
	}
	
};
$.unBlockUI = function() {
	$('#UIBlock').fadeOut(100,function() {
		$('select').removeClass('UIBlocked');
		$(this).remove();
	});
};
////////////////////////////////////////////////////
// END: UI Block


// BEGIN: Trim object at specified characters
////////////////////////////////////////////////////
jQuery.fn.charTrim = function(chars, suffix) {
	if($(this).text().length >= chars) {
		var tmp = $(this).text().split('',chars), str = '';
		for(i = 0; i < tmp.length; i++){
			str += tmp[i];
		}
		$(this).text(str+suffix);
	}
};
////////////////////////////////////////////////////
// END: Trim object at specified characters


// BEGIN: vertical positioning in the viewport
////////////////////////////////////////////////////
(function($){
	$.fn.vCenter = function() {
		return this.each(function(index) {
			var $this = $(this);
			$this.css({
				position: 'fixed',
				top: '50%',
				marginTop: '-' + ($this.outerHeight()/2) + 'px'
			});
			if ($.browser.msie && ($.browser.version < 7)) {
				$this.css({
					position: 'absolute',
					top: $(window).scrollTop() + ($(window).height()/2)
				});
			}
		});
	};
})(jQuery);
////////////////////////////////////////////////////
// END: vertical positioning in the viewport


// BEGIN: Equal heights
////////////////////////////////////////////////////
$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		// for ie6, set height since min-height isn't supported
		if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return this;
};
////////////////////////////////////////////////////
// END: Equal Heights


// BEGIN: One Shot Ajax
////////////////////////////////////////////////////
$.fn.oneShotAjax = function(options, callback) {

	var opts = $.extend({}, $.fn.oneShotAjax.defaults, options);

	return this.each(function() {
		$this = $(this);
		var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;
		
		if($this.is('a')) {
			$this.bind('click', function(event) {
				event.preventDefault();
				var self = this;
				$.ajax({
					type: "GET",
					url: $(this).attr('href'),
					data: o.component ? 'component=' + o.component : '',
					success: function(data) {
						if(ajaxSuccess(data)) {
							if(callback && typeof(callback) == 'function'){
								callback.apply(self);
							}	
						}
					}
				});
			});
		}

	});
};
////////////////////////////////////////////////////
// END: One Shot Ajax


// BEGIN: AJAX Popup Message Window
////////////////////////////////////////////////////

// Close buttons
$.fn.bindCloseMessageForm = function() {
	$('.form_well_close, .button_cancel').click(function() {
		tinyMCE.activeEditor.remove();
		
		$('#form_well').remove();
		$('div#search_container').remove();
	
		return false;
	});
};


// Load forms
$.fn.bindLoadMessageForm = function(o) {
	$(this).click(function() {
		
		if (o && o.preCallback && typeof(o.preCallback) == 'function') {
			o.preCallback();
		}
		
		$('body').append('<div id="form_well" class="create_new_message">');
		$.ajax({
			type: "GET",
			url: $(this).attr('href'),
			success: function(data) {
				if ( ajaxSuccess(data) ) {
					$('#form_well').html( data );
					
					$('#form_well p.formKit_submit input#submit').submitReplace({ cssClass: 'form_button button_save btn-blue' });
					$('#form_well p.formKit_submit input#Cancel').hide().after('<a href="#" class="form_button button_cancel btn-grey">Cancel</a>');
					$('input[name=addRecipient]').remove();
					
					$('#form_well input#subject').keydown(function(e) {
						if (e.which == 13) { return false; }
					});
					
					$('#form_well').append('<a href="#" class="form_well_close">X</a>').show();
					$.fn.bindCloseMessageForm();
					$.fn.bindProcessMessageForm();
					$.fn.bindPredictiveSearch();
					
					if (o && o.postCallback && typeof(o.postCallback) == 'function') {
						o.postCallback();
					}
					
					$('div#form_well .formKit_textarea textarea').css({
						padding: 0,
						border: 'none'
					}).textarea();
					$('div#form_well :text, #form_well textarea').formKit().defaultText();
					
					tinyMCE.init({
						mode: "exact",
						theme: "advanced",
						convert_urls: false,
						theme_advanced_layout_manager: "SimpleLayout",
						theme_advanced_toolbar_location: "external",
						element_format: "xhtml",
						elements: "message",
						setup: function(ed) {
							
							ed.onKeyUp.add(function(ed, e) {
								id = ed.id;
								strip = (tinyMCE.activeEditor.getContent()).replace(/(<([^>]+)>)/ig,"");
								count = ($('textarea[name=' + $(ed).attr('id') + ']').metadata().tinyMceCharLimit - tinyMCE.get('message').getContent().length);
								text = "<span>" + count + "</span>" + ((count == 1) ? " character" : " characters") + " left";
								
								// Create alert for when text gets close to limit
								if ( strip.length >= ($('textarea[name=' + $(ed).attr('id') + ']').metadata().tinyMceCharLimit - 25)) {
									$('.charLimit[rel=' + $(ed).attr('id') + ']').addClass('charLimit_warning');
								} else {
									$('.charLimit[rel=' + $(ed).attr('id') + ']').removeClass('charLimit_warning');
								}
								
								$('.charLimit[rel=' + $(ed).attr('id') + ']').html(text);
			
							});
						},
						init_instance_callback: function() {
							
							if ( $.browser.msie && ($.browser.version < 7) ) { // Add iframe shim
								$('div#form_well').append('<iframe id="form_well_shim" src="" frameborder="2" scrolling="no" height="1">');
								$('iframe#form_well_shim').css({
									background: 'transparent',
									height: $('div#form_well').height(),
									left: 0,
									position: 'absolute',
									top: 0,
									width: $('div#form_well').width(),
									zIndex: 1
								});
							} else {
								// Add Shadow
								$('div#form_well').append('<div class="form_well_shadow_r"></div><div class="form_well_shadow_br"></div><div class="form_well_shadow_b"></div>');
								$('div#form_well div.form_well_shadow_r').css({
									height: $('div#form_well').outerHeight() - 10
								});
								$('div#form_well div.form_well_shadow_b').css({
									width: $('div#form_well').outerWidth() - 10
								});								
							}
							
							$('div#form_well').vCenter();
						}
						
					});
					
					if (o && o.postCallback && typeof(o.postCallback) == 'function') {
						o.postCallback();
					}
					
				}
			}
		});
		
		return false;
		
	});
};


// Process form
$.fn.bindProcessMessageForm = function() {
	$('#form_well input#submit').click(function() {		
		if ( $('div#form_well input[name=to]').val() == '' ) {
			$('body').sysmessage('Please choose a recipient for this message.', {type: 'error'});
		} else if ( $('div#form_well input[name=subject]').val() == '' ) {
			$('body').sysmessage('Your message must have a subject.', {type: 'error'});
		} else if ( parseInt($('div#form_well span.charLimit span').text(),10) < 0 ) {
			
			$('body').sysmessage('Your message has exceeded the maximum allowed characters. Please limit your text to ' + $('div#form_well textarea').metadata().tinyMceCharLimit + ' characters.', {type: 'error'});
		} else {
			
			$('#form_well p.formKit_submit a.button_save').hide().after('<img src="/images/forms/btn.sending.gif" />');
			
			$.ajax({
				type: "POST",
				url: $(this).parent().parent('form').attr('action')+'?component=post-message',
				data: "return=" + encodeURIComponent($('div#form_well input[name=return]').val()) + "&to=" + encodeURIComponent($('div#form_well input[name=to]').val()) + "&subject=" + encodeURIComponent($('div#form_well input[name=subject]').val()) + "&message=" + escape(tinyMCE.get('message').getContent()) + "&tomsgid=" + encodeURIComponent($('div#form_well input[name=tomsgid]').val()) + "&submit=Send",
				success: function(data) {
					if ( ajaxSuccess(data) ) {
						tinyMCE.activeEditor.remove();

						//omniture tracking message sent
						$('#message_form').trigger('success.message_sent.ax');
						
						$('#form_well').fadeOut(100,function() {
							//$('html,body').animate({scrollTop: $('#Content').offset().top},'fast');
							$('body').sysmessage('Your message has been sent.', {type: 'confirmation'});
							
							/* sent message popup (jquery.forms.js > $.popupForm()) */
							/*TO DO: Add this popup once appropriate survey url is acquired
							$.ajax({
				                type: "GET",
				                url: '/message_center/forms/sent_message_popup.html',				                
				                success: function(data) {
				                    $('body').append('<div id="message_confirm_popup">');
				                    $('#message_confirm_popup').html(data).popUp();
				                    $('p.buttons a').click(function(e){
				                        e.preventDefault();
				                        $('#popUp').closePopUp();
				                        if ($(this).attr('id') == 'SurveyYes'){
				                            window.open($(this).attr('href'),'','status=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,height=550,width=650');
				                        }
				                    });
							    }
							});*/
							
							$('div#search_container').remove();
						});
//						var currentLocation = window.location.href;
//						var pos = currentLocation.indexOf("sent");
//						
//						if (pos > 0) {
//							window.location.reload();
//						}
					} else {
						$('#form_well p.formKit_submit img').remove();
						$('#form_well p.formKit_submit a.button_save').show();
					}
				}
			});
			
		}

		return false;
	});
	
};


$.fn.bindSubmitLinks = function() {
	
	$('a#mark_as_read, a#delete_marked').click(function() {
		$this = $(this);
		var id = $this.attr('id');
		
		var box = $('#TabNav li.active a').text();
		switch (box) {
			case 'Inbox':
				box = 'inbox';
				break;
			case 'Sent':
				box = 'sent';
				break;
		}
		
		$('input#'+ $this.attr('rel') +' ').attr("checked","checked");
		$('#message_form').trigger('submit');
		
		return false;
	});
	
	$('a#block_marked').click(function() {
		$('input#mark_block').attr('checked','checked');
		$('#message_form').trigger('submit');
		
		return false;
	});
	
	$('a#block_marked').confirmation({	message: 'Are you sure you want to block the marked user(s)? All of their representation/messages/comments will disappear. <br /><br /> All blocked users can be unblocked at any time by viewing your <a href="/home/preferences/privacy#unblock" target="_new">Visiblity Settings<a/>', 
										triggerClick: true,
										condition: "$('#message_form input:checkbox:checked').size() > 0",
										conditionFailMessage: 'No messages were selected.' });
										
	$('a#delete_marked').confirmation({	message: 'Are you sure you want to delete the marked message(s)?', 
										triggerClick: true, 
										condition: "$('#message_form input:checkbox:checked').size() > 0",
										conditionFailMessage: 'No messages were selected.' });
};

// Predictive search
$.fn.bindPredictiveSearch = function() {
	
	var current = -1;
	var currentName;
	var currentGUID;
	var numView = 7;
	var xhr;
	
	$('input.predictivesearch').removeAttr("disabled");
	
	$('span.site-search').wrap('<div id="predictivesearch">');
	$('div#predictivesearch').css('position','relative').append('<div id="search_container">');
	
	$('span.site-search').click(function() {
		$('input.predictivesearch').focus();
	});
	$('input.predictivesearch').wrap('<ul><li id="recipient-search"></li></ul>');
	
	$('input.predictivesearch').keyup(function(e) {
		
		$this = $(this);
		
		if ( $.browser.safari ) {
			var scrollTop = $('body').scrollTop();
		} else {
			var scrollTop = $('html').scrollTop();
		}
		
		if ($this.val().length >= 3) {
			
			if (e.which == 38 || e.which == 40) {
				
				height = $('div#search_container li').height() * numView;
				offset = $('div#search_container').scrollTop();
				
				if (e.which == 38) { // Up
					if ( (current - 1) < 0 ) {
						current = ($('div#search_container li').size() - 1);
					} else {
						current--;
					}
					
					if ( current == ($('div#search_container li').size() - 1) ) {
						$('div#search_container').scrollTop( $('div#search_container li').size() * $('div#search_container li').height() - height );
					} else if ( (current * $('#search_container li').height()) < offset ) {
						$('div#search_container').scrollTop( current * $('div#search_container li').height() );
					}
				} else if (e.which == 40) { // Down
					if ( (current+1) == $('div#search_container li').size()) {
						current = 0;
					} else {
						current++;
					}
					
					if ( current == 0 ) {
						$('div#search_container').scrollTop(0);
					} else if ( ((current * $('div#search_container li').height()) - offset) >= height ) {
						$('div#search_container').scrollTop( ((current+1) * $('div#search_container li').height()) - height );
					}
				}
				
				$('div#search_container li a').removeClass('hover');
				$('div#search_container li:eq(' + current + ') a').addClass('hover');
				
				currentName = $('div#search_container li:eq(' + current + ') a i').text();
				currentGUID = $('div#search_container li:eq(' + current + ') a').attr('rel');
				
			} else {
				current = -1;
				
				$('div#search_container').css({
					left: 0
				});
					
				if (xhr) {
					xhr.abort();
				}
					
				xhr = $.ajax({
					type: "GET",
					url: "/message-center/newmessage/?component=get-contacts&search=" + $this.val(),
					cache: false,
					complete: function() {
						$('#AjaxLoader').remove();
					},
					success: function(html) {
						
						$('div#search_container').html(html);

						$('div#search_container').css('max-height', ($('div#search_container li').height() * numView));
						if ($.browser.msie && $.browser.version < 7) {
							$('div#search_container').css('height', ($('div#search_container li').height() * numView));
						}
						
						$('div#search_container li a').click(function() {
							$this.val('').parent().before('<li class="recipient"><span class="recipient-name">' + $('i',this).text() + '</span><span class="recipient-delete">X</span></li>');
							
							if ( $('input[rel=' + $this.attr('name') + ']').val() == '' ) {
								updateRecipients = $(this).attr('rel');
							} else {
								updateRecipients = $('input[rel=' + $this.attr('name') + ']').val() + ',' + $(this).attr('rel');
							}
							$('input[rel=' + $this.attr('name') + ']').val( updateRecipients );
							
							$.fn.bindRemoveRecipient();
							
							$('div#form_well div.form_well_shadow_r').css({
								height: $('div#form_well').outerHeight() - 10
							});
							$('div#form_well div.form_well_shadow_b').css({
								width: $('div#form_well').outerWidth() - 10
							});
							
							$('div#search_container').html('').css('left',-9999);
							$this.focus();
						
							current = -1;
							
							return false;
						});
						$('body, html').click(function() { $('div#search_container').html('').css('left',-9999); });
						
						$('div#search_container li a').hover(
							function() {
								$('div#search_container li a').removeClass('hover');
								$(this).addClass('hover');
							},
							function() {
								$(this).removeClass('hover');
							}
						);
					},
					error: function() {}
				});
				
			}
			
		} else {
			$('div#search_container').html('').css('left',-9999);
		}
		
	});
	
	// Recipient actions
	$.fn.bindRemoveRecipient = function() {
		$('span.recipient-delete').click(function() {
			
			newString = '';
			recipientArray = $('input[rel=' + $this.attr('name') + ']').val().split(',');
			
			recipientArray.splice($(this).parent().prevAll().size(),1);
			$('input[rel=' + $this.attr('name') + ']').val(recipientArray.toString());
			
			$(this).parent().remove();
			
			$('div#form_well div.form_well_shadow_r').css({
				height: $('div#form_well').outerHeight() - 10
			});
			$('div#form_well div.form_well_shadow_b').css({
				width: $('div#form_well').outerWidth() - 10
			});
			
		});
	};
	
	// Close search box if tab or enter key is pressed
	$('input.predictivesearch').keydown(function(e) {
		if (e.which == 9) { // tab
			$('div#search_container').html('').css('left',-9999);
		} else if (e.which == 13) { // enter
			if($('input.predictivesearch').val() == '' || currentName == null) {
				return false;
			}
			$('div#search_container').html('').css('left',-9999);
			$('input.predictivesearch').val('').parent().before('<li class="recipient"><span class="recipient-name">' + currentName + '</span><span class="recipient-delete">X</span></li>');
			
			if ( $('input[rel=' + $('input.predictivesearch').attr('name') + ']').val() == '' ) {
				updateRecipients = currentGUID;
			} else {
				updateRecipients = $('input[rel=' + $('input.predictivesearch').attr('name') + ']').val() + ',' + currentGUID;
			}
			$('input[rel=' + $('input.predictivesearch').attr('name') + ']').val( updateRecipients );
			
			$.fn.bindRemoveRecipient();
			
			$('div#form_well div.form_well_shadow_r').css({
				height: $('div#form_well').outerHeight() - 10
			});
			$('div#form_well div.form_well_shadow_b').css({
				width: $('div#form_well').outerWidth() - 10
			});
		
			current = -1;
			
			return false;
		} else if (e.which == 27) { // esc key
			$('div#search_container').html('').css('left',-9999);
			$('input.predictivesearch').val('');
		}
	});

};
////////////////////////////////////////////////////
// END: AJAX Popup Message Window

// BEGIN: Cookie Plugin
////////////////////////////////////////////////////

jQuery.cookie = function(name, value, options) {
	if (typeof value != 'undefined') { // name and value given, set cookie
		options = options || {};
		if (value === null) {
			value = '';
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
		}
		// CAUTION: Needed to parenthesize options.path and options.domain
		// in the following expressions, otherwise they evaluate to undefined
		// in the packed version for some reason...
		var path = options.path ? '; path=' + (options.path) : '';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure' : '';
		document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
		} else { // only name given, get cookie
			var cookieValue = null;
			if (document.cookie && document.cookie != '') {
				var cookies = document.cookie.split(';');
				for (var i = 0; i < cookies.length; i++) {
					var cookie = jQuery.trim(cookies[i]);
					// Does this cookie string begin with the name we want?
					if (cookie.substring(0, name.length + 1) == (name + '=')) {
						cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
						break;
					}
				}
			}
			return cookieValue;
		}
};

////////////////////////////////////////////////////
// END: Cookie Plugin

// BEGIN: Omniture tracking values
////////////////////////////////////////////////////
// NOTE: $.fn.setOmnitureValuesSync is used for syncronous click tracking. i.e. any click that leaves the current page.
// NOTE: pass the clicked obj (element) along with tracking params
$.fn.setOmnitureValuesSync = function(obj, options) {
  if(window.console && window.console.log) {
    console.log( 'setOmnitureValuesSync' );
  }
};

// NOTE: $.fn.setOmnitureValues is used for asyncronous click tracking i.e. any click that remains on the current page
// NOTE: pass tracking params and/or callback
$.fn.setOmnitureValues = function(options) {
  if(window.console && window.console.log) {
    console.log( 'setOmnitureValues' );
  }
};

// BEGIN: New Omniture Tracking Framework
////////////////////////////////////////////////////
AX.Analytics = (function (window, document) {

  /**
  @private
  @description
  Mapping object used to associate element ID's to analytics
  data such as click tracking names. Retrieve dynamic values from AX.TrackingData or set values statically
  @example
  'eventType': {
  'elementID': {
  'trackFunction': omnitureFunctionName,
  'params': ['var1', 'var2']
  }
  }
  */

  var _trackingMap = {
    'click': {
      'track_AddConnectodexByPerson': {
        'trackFunction': function () {
          omn_rmprofile('RequestConnection');
        }
      },
      'track_AddOrRemoveFromRadarByPerson': {
        'trackFunction': function () {
          omn_rmprofile('AddRadar');
        }
      },
      //share tools
      'share_tools_stumbleupon': {
        'trackFunction': function () {
          omn_rmshare('StumbleUpon', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'share_tools_digg': {
        'trackFunction': function () {
          omn_rmshare('Digg', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'share_tools_email': {
        'trackFunction': function () {
          omn_rmshare('Email', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'share_tools_reddit': {
        'trackFunction': function () {
          omn_rmshare('Reddit', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'share_tools_linkedin': {
        'trackFunction': function () {
          omn_rmshare('LinkedIn', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'share_tools_twitter': {
        'trackFunction': function () {
          omn_rmshare('Twitter', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'share_tools_facebook': {
        'trackFunction': function () {
          omn_rmshare('Facebook', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'share_tools_tumblr': {
        'trackFunction': function () {
          omn_rmshare('Tumblr', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'tumblr_social': {
        'trackFunction': function () {
          omn_rmshare('Tumblr', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'header_dropdown_facebook': {
        'trackFunction': function () {
          omn_rmshare('Facebook', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'header_dropdown_twitter': {
        'trackFunction': function () {
          omn_rmshare('Twitter', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'header_dropdown_stumbleupon': {
        'trackFunction': function () {
          omn_rmshare('StumbleUpon', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'header_dropdown_linkedin': {
        'trackFunction': function () {
          omn_rmshare('LinkedIn', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'header_dropdown_digg': {
        'trackFunction': function () {
          omn_rmshare('Digg', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'header_dropdown_reddit': {
        'trackFunction': function () {
          omn_rmshare('Reddit', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'header_dropdown_email': {
        'trackFunction': function () {
          omn_rmshare('Email', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'footer_dropdown_facebook': {
        'trackFunction': function () {
          omn_rmshare('Facebook', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'footer_dropdown_twitter': {
        'trackFunction': function () {
          omn_rmshare('Twitter', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'footer_dropdown_stumbleupon': {
        'trackFunction': function () {
          omn_rmshare('StumbleUpon', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'footer_dropdown_linkedin': {
        'trackFunction': function () {
          omn_rmshare('LinkedIn', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'footer_dropdown_digg': {
        'trackFunction': function () {
          omn_rmshare('Digg', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'footer_dropdown_reddit': {
        'trackFunction': function () {
          omn_rmshare('Reddit', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      'footer_dropdown_email': {
        'trackFunction': function () {
          omn_rmshare('Email', AX.TrackingData.pageTitle, AX.OmnitureScope.omn_author);
        }
      },
      //global follow us 
		'Global_Follow_Email': {
			'trackFunction': function () {
				omn_rmfollowstart('WeeklyNewsletter');
			}
		},
		'Global_Follow_Facebook': {
			'trackFunction': function () {
				omn_rmfollowstart('Facebook');
			}
		},
		'Global_Follow_Twitter': {
			'trackFunction': function () {
				omn_rmfollowstart('Twitter');
			}
		},
		'Global_Follow_Linkedin': {
			'trackFunction': function () {
				omn_rmfollowstart('LinkedIn');
			}
		},
		'Global_Follow_Youtube': {
			'trackFunction': function () {
				omn_rmfollowstart('YouTube');
			}
		},
		'Global_Follow_Tumblr': {
			'trackFunction': function () {
				omn_rmfollowstart('Tumblr');
			}
		},
		'Global_Follow_RSS': {
			'trackFunction': function () {
				omn_rmfollowstart('RSS');
			}
		},
		'Global_Follow_Mobile': {
			'trackFunction': function () {
				omn_rmfollowstart('Mobile');
			}
		},
      //footer share icons
      'footer_email': {
        'trackFunction': function () {
          omn_rmfollowstart('WeeklyNewsletter');
        }
      },
      'footer_facebook': {
        'trackFunction': function () {
          omn_rmfollowstart('Facebook');
        }
      },
      'footer_twitter': {
        'trackFunction': function () {
        	omn_rmfollowstart('Twitter');
        }
      },
      'footer_linkedin': {
        'trackFunction': function () {
        	omn_rmfollowstart('LinkedIn');
        }
      },
      'footer_youtube': {
				'trackFunction': function () {
       		omn_rmfollowstart('YouTube');
				}
      },
      'footer_tumblr': {
				'trackFunction': function () {
       		omn_rmfollowstart('Tumblr');
				}
      },
      'footer_rss': {
        'trackFunction': function () {
          omn_rmfollowstart('RSS');
        }
      },
      'footer_mobile': {
        'trackFunction': function () {
          omn_rmfollowstart('Mobile');
        }
      },
      //profile update tracking
      'SaveContinue': {
        'trackFunction': function () {
          if ($('#LayoutWrapper').hasClass('EditPreferences') || $('#LayoutWrapper').hasClass('EditProfile')) {
            omn_rmprofile('ProfileUpdated');
          }
        }
      },
      'Save': {
        'trackFunction': function () {
          if ($('#LayoutWrapper').hasClass('EditPreferences') || $('#LayoutWrapper').hasClass('EditProfile')) {
            omn_rmprofile('ProfileUpdated');
          }
        }
      },
			'account_delete_deactivate': {
				'trackFunction': function () {
					if ($('#LayoutWrapper').hasClass('ProfileStatus')) {
						omn_rmprofile('ProfileUpdated');
					}
				}
			},
      //profile and message center click items
      'track_Message_Center_NewMessage': {
        'trackFunction': function () {
          omn_rmprofile('MessageRead');
        }
      },
      //RSS popup topic links
      'RSS_All_Articles': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:AllArticles');
        }
      },
      'RSS_All_Events': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:AllEvents');
        }
      },
      'RSS_Everything': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:Everything');
        }
      },
      'RSS_Innovation': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:Innovation');
        }
      },
      'RSS_Lifestyle': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:Lifestyle');
        }
      },
      'RSS_Managing': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:Managing');
        }
      },
      'RSS_Marketing': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:Marketing');
        }
      },
      'RSS_Money': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:Money');
        }
      },
      'RSS_Technology': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:Technology');
        }
      },
      'RSS_TheWorld': {
        'trackFunction': function () {
          omn_rmfollowcomplete('RSS:TheWorld');
        }
      },
      //email signup success -- share tools
      'email_subscribed_fb': {
        'trackFunction': function () {
          omn_rmfollowstart('Facebook');
        }
      },
      'email_subscribed_tw': {
        'trackFunction': function () {
          omn_rmfollowstart('Twitter');
        }
      },
      'email_subscribed_mobile': {
        'trackFunction': function () {
          omn_rmfollowstart('Mobile');
        }
      }
    },
    'success': {
      //successful comment sent
      'form_comment': {
        'trackFunction': function () {
          var username = '';
          var urlSplit = String(window.location.href).split("/");
          var topic = urlSplit[urlSplit.length - 1];
          topic = String(topic).replace('#comments', '');
          urlSplit = null;

          if (AX.user_name != undefined && AX.user_name.length > 0) {
            username = String(AX.user_name).replace('-', ' ').toUpperCase();
          }

          omn_rmdiscuss('Comment', 'OF:' + topic, username);
        }
      },
      //successful discussion created
      'create_discussion': {
        'trackFunction': function () {
          var username,
						topic = $('#create_discussion p.formKit_text input').val();

          if (AX.user_name == undefined || AX.user_name == null || AX.user_name == '') {
            username = '';
          } else {
            username = AX.user_name.replace("-", " ").toUpperCase();
          }

          omn_rmdiscuss('StartDiscussion', 'OF:' + topic, username);
        }
      },
      //successful message sending (general, introduce, etc.)
      'message_form': {
        'trackFunction': function () {
          if ($('.create_new_message').length > 0) {
            switch ($('#message_form').find('#subject').attr('value')) {
              case 'Allow me to introduce myself.':
                omn_rmprofile('Introductions');
                break;
              default:
                omn_rmprofile('MessageSent');
                break;
            }
          }
        }
      },
      //add to radar
      'AddBookmarkLink': {
        'trackFunction': function () {
          omn_rmprofile('AddRadar');
        }
      },
      //request a connection
      'AddConnectodexLink': {
        'trackFunction': function () {
          omn_rmprofile('RequestConnection');
        }
      },
      //marked as read
      'mark_as_read': {
        'trackFunction': function () {
          omn_rmprofile('MessageRead');
        }
      },
      //subscribe weekly newsletter
      'modal_emailsubscribe': {
        'trackFunction': function () {
          omn_rmfollowcomplete('WeeklyNewsletter');
        }
      }
    },
    'failure': {
      //failed to subscribe to weekly newsletter
      'modal_emailsubscribe': {
        'trackFunction': function () {
          omn_rmaction('US:OpenForum:Follow', 'error>WeeklyNewsletter');
        }
      }
    },
       'blockExitLinks': ['share_tools_stumbleupon', 'share_tools_digg', 'share_tools_email', 'share_tools_reddit', 'share_tools_linkedin', 'share_tools_twitter', 'share_tools_facebook', 'share_tools_tumblr', 'tumblr_social', 'Global_Follow_Email', 'Global_Follow_Facebook', 'Global_Follow_Twitter', 'Global_Follow_Linkedin', 'Global_Follow_Youtube', 'Global_Follow_Tumblr', 'Global_Follow_RSS', 'Global_Follow_Mobile', 'footer_email', 'footer_facebook', 'footer_twitter', 'footer_linkedin', 'footer_youtube', 'footer_tumblr', 'footer_rss', 'footer_mobile', 'header_dropdown_facebook', 'header_dropdown_twitter', 'header_dropdown_stumbleupon', 'header_dropdown_linkedin', 'footer_dropdown_linkedin', 'header_dropdown_digg', 'header_dropdown_reddit', 'header_dropdown_email', 'footer_dropdown_facebook', 'footer_dropdown_twitter', 'footer_dropdown_stumbleupon', 'footer_dropdown_linkedin', 'footer_dropdown_digg', 'footer_dropdown_reddit', 'footer_dropdown_email']
  };

  var self = {
    /** 
    @name AX.Article.Analytics#init
    @function
    @description
    Initializes event listeners for click tracking
    and other analytics code.
    */
    'init': function () {
      self.pageLoad();
      self.blockExitLinks();
      self.bindEvents();
    },

    /** 
    @name AX.Global.Analytics#pageLoad
    @function
    @description
    Iterates through OmnitureScope vars and assigns their value based on AX.OmnitureScope{} set in view
    */
    'pageLoad': function () {
      for (var key in AX.OmnitureScope) {
        window[key] = AX.OmnitureScope[key];
      }
      s.t();
    },

    'dynamicPageLoad': function (data) {
      if (typeof data !== 'object') {
        return;
      }

      for (key in data) {
        window[key] = data[key];
      }
      s.t();
    },

    /** 
    @name AX.Global.Analytics#blockExitLinks
    @function
    @description
    Injects onclick to targeted exit links to force-fire custom link tracking, and prevent exit link tracking
    */
    'blockExitLinks': function () {
      $(_trackingMap['blockExitLinks']).each(function (i, item) {
        $('#' + item).attr('onclick', 'var a="s.tl("');
      });
    },

    /** 
    @name AX.Global.Analytics#bindEvents
    @function
    @description
    Creates a delegated event listener on the &lt;body&gt;
    and can listen to any type of event on any type of element.
    The event handler is responsible for determining if the event
    and element exist in a data dictionary (_trackingMap) and
    invokes the respective function (usually Omniture tracking).
    @param elementID Optional value passed in through a custom event
    */
    'bindEvents': function () {
      $(window).bind('success.ajax.ax', function (e, data) {
        if (!data) {
          return;
        }
        self.dynamicPageLoad(data);
      });

      $(document.body).delegate('div, span, p, a, form, input, select', 'click change customEvent success.form.ax success.discussion.ax success.message_sent.ax success.add_radar.ax success.request_connection.ax success.mark_as_read.ax success.modal_emailsubscribe failure.modal_emailsubscribe', function (e, elementID) {
        var event = e.type,
					link = e.currentTarget;
				
        var id = elementID || link.getAttribute('data-track') || link.id;
			
        if (typeof _trackingMap === 'undefined' || typeof _trackingMap[event] === 'undefined' || (typeof _trackingMap[event][id] === 'undefined')) {
          return;
        }

        //If an id exists, do not do a lookup using the list of classes
        if (typeof _trackingMap[event][id] === 'object') {
          var fn = _trackingMap[event][id].trackFunction;
          if (typeof fn === 'function') {
            switch (id) {
              default:
                fn.apply(window);
                break;
            }
          }
        }
      });
    }
  };
  return self;
})(this, this.document);

/* END 3.0: jquery.utilities.js */

/* BEGIN 4.0: jquery.sysmessage.js */

(function($) {
	function ___getPageSize() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
				
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	};

	$.fn.sysmessage = function(message, options, callback) {
		
		var opts = $.extend({}, $.fn.sysmessage.defaults, options);
		
		var sizes = ___getPageSize();
		
		return this.each(function() {
			$this = $(this);
			var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;
			
			var contentElm = $('<div>');
			contentElm.addClass(o.baseClass);
			if (o.type) contentElm.addClass(o.type);
			contentElm.css('z-index', 10020);
			
			//var backgroundElm = '<div class="' + o.baseClass + '_shadow_r"></div><div class="' + o.baseClass + '_shadow_br"></div><div class="' + o.baseClass + '_shadow_b"></div>';
			//$(backgroundElm).appendTo(contentElm);

			var killLightbox = function() { };
			var showLightbox = function() { };
			if (o.lightbox) {
				var lightboxDiv = $('<div class="lightbox-bg" style="background-color: #FFF; position: absolute; left: 0; top: 0; z-index: 10010;">');
				var targetOpacity = 0.8;
				
				lightboxDiv.width(sizes[0]);
				lightboxDiv.height($(document).height());
				
				$this.append(lightboxDiv);
				
				showLightbox = function() {
					if ($.browser.msie) {
						lightboxDiv.css('filter', 'alpha(opacity=' + targetOpacity * 100 + ')');
					} else {
						lightboxDiv.css({ opacity: 0.01 });
						lightboxDiv.animate({ opacity: targetOpacity }, 10);
					}

					lightboxDiv.click(function(){
						killLightbox();
						killSysmessage(contentElm, o.type, callback);
					});
				};
				
				killLightbox = function() {
					if ($.browser.msie) {
						lightboxDiv.remove();
					} else {
						lightboxDiv.animate({ opacity: 0 }, 0, function() {
							lightboxDiv.remove();
						});
					}
				};
			}
			
			if(o.appendClose) {
				var closeElm = $('<div>');
				closeElm.append('<a href="#">X</a>');
				closeElm.click(function() {
					killLightbox();
					killSysmessage(contentElm, o.type, callback);
					
					return false;
				});
				closeElm.addClass(o.baseClass+"-close").appendTo(contentElm);
			}
			
			if (o.closeElement) {
				o.closeElement.click(function() {
					killLightbox();
					killSysmessage(contentElm, o.type, callback);
				});
			}
			
			var messageElm = $('<div>');
			messageElm.append(message).addClass(o.baseClass+"-message").appendTo(contentElm);
			
			$this.append(contentElm);
			
			$(message).show();
			
			$('div.' + o.baseClass).vCenter();
			
			showLightbox();
			
			/* Size the Drop Shadows */
      /*
			if($('div.' + o.baseClass).outerWidth() != 0){
				//following is conditional for IE6 bug(s)
				if (!($.browser.msie && $.browser.version < 7)) {
					$('div.' + o.baseClass + '_shadow_r').css({
						'height': $('div.' + o.baseClass).outerHeight() - 10 + 'px'
					});
					$('div.' + o.baseClass + '_shadow_b').css({
						'width': $('div.' + o.baseClass).outerWidth() - 10 + 'px'
					});
				}
			}
      */
			if (!$.browser.msie) {
				contentElm.css({ opacity: 0.01 });
				contentElm.animate({ opacity: 1 },10);
			}
			
			if ($.browser.msie && $.browser.version < 7) {
				contentElm.after('<iframe class="shim">');
				contentElm.next('.shim').css({
					background: '#000',
					border: 0,
					height: messageElm.outerHeight(),
					left: messageElm.offset().left,
					position: 'absolute',
					top: messageElm.offset().top,
					width: messageElm.outerWidth(),
					zIndex: 10015
				});
				
				var mHeight = $('.sysmessage-message').height()
				if(typeof mHeight == 'number'){
					$('iframe.shim').css({
						height: mHeight+'px'
					});
				}
				
			}
			
			if(o.autoDismiss) {
				var timeout = setTimeout(function() { killLightbox(); killSysmessage(contentElm, o.type, callback); }, o.timeout);
			}
			
			contentElm.hover(function() {
				clearTimeout(timeout);
			}, function() {
				if(o.autoDismiss) {
					timeout = setTimeout(function() { killLightbox(); killSysmessage(contentElm, o.type, callback); }, o.timeout);
				}
			});
			
			$('body').triggerHandler("open.sysmessage", [o.type, $(contentElm)]);
			
	
		});

	};
	
	function killSysmessage($obj, type, callback) {
		if ($.browser.msie) {
			$obj.remove();
			$('body').triggerHandler("close.sysmessage", [type, $obj]);
			$('.shim').remove();

		} else {
			$obj.animate({
				opacity: 0
			}, 0, function() {
				$(this).remove();
				$('body').triggerHandler("close.sysmessage", [type, $obj]);
			});
		}
		
		if(callback && typeof(callback) == 'function') {
			callback();
		}
	};
	
	$.fn.sysmessage.defaults = {
		baseClass: "sysmessage",
		type: "",
		timeout: 3000,
		pauseOnHover: true,
		appendClose: true,
		autoDismiss: true,
		position: {
			top: "15px",
			right: "600px",
			bottom: "",
			left: ""
		},
		margin: -5,
		closeElement: null,
		lightbox: false
	};
	
	$.ax = $.ax || { };
	$.ax.sysmessageInline = function(selector) {
		$(selector).each(function() {
			$(this).hide();
			var opts = $.metadata ? $(this).metadata() : {};
			$("body").sysmessage($(this).html(),opts);
		});
	};
	$.ax.sysmessageListner = function() {
		$("body").bind('error.sysmessage', function(e, message) {
			e.target.sysmessage(message, {type: 'error'});
		});
		$("body").bind('warning.sysmessage', function(e, message) {
			e.target.sysmessage(message, {type: 'warning'});	
		});
		$("body").bind('confirmation.sysmessage', function(e, message) {
			e.target.sysmessage(message, {type: 'confirmation'});
		});	
	};

}) (jQuery);

/* END 4.0: jquery.sysmessage.js */

/* BEGIN 5.0: jquery.forms.js */

/*
PLUGIN DIRECTORY
--------------------------------------------------

1.0 - Even out form fields
2.0 - Default text in input:text and textarea
3.0 - Textarea
4.0 - <ul> List => select list
5.0 - Select List
6.0 - Checkbox/Radio Button
7.0 - File Input
8.0 - Submit Button
9.0 - Edit in Place
10.0 - Generic popup
11.0 - Confirmation dialog
*/

// Check for IE6
var ie6 = false;
if ($.browser.msie && $.browser.version < 7) { ie6 = true; }

// 1.0 - Even out form fields
// --------------------------------------------------
(function($) {
	
	$.fn.formKit = function(options) {
	
		// build main options before element iteration
		var opts = $.extend({}, $.fn.formKit.defaults, options);
	
		// iterate and reformat each matched element
		return this.each(function() {
			
			$this = $(this);
			var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;
			
			if (!$this.hasClass('formKit_adjusted') && !$this.hasClass('predictivesearch')) {
				$this.addClass('formKit_adjusted').css({
					width: parseInt($this.css('width'),10) - (parseInt($this.outerWidth(),10) - parseInt($this.css('width'),10)) + 'px'
				});
			};
			
		});
	};
	
	// plugin defaults
	$.fn.formKit.defaults = {};
	
})(jQuery);


// 2.0 - Default text in input:text and textarea
// --------------------------------------------------
(function($) {

	$.fn.defaultText = function(options) {
		
		return this.each(function() {
			
			var $this = $(this);
			if ($this.metadata().defaultvalue) {
				if ($(this).val() == "") {
					$this.val( $this.metadata().defaultvalue ).addClass('defaultVal defaultVal_default');
				} else if ($(this).val() == $this.metadata().defaultvalue) {
					$this.addClass('defaultVal defaultVal_default');
				} else {
					$this.addClass('defaultVal');
				}
			}
			
			$this.focus(function() {
				if ($this.hasClass('defaultVal_default')) {
					$this.val('').removeClass('defaultVal_default');
				}
			});
			
			$this.blur(function() {
				if ($this.val() == "") {
					if ($this.metadata().defaultvalue) {
						$this.val( $this.metadata().defaultvalue ).addClass('defaultVal_default');
					}
				}
			});

		});
		
	};

})(jQuery);


// 3.0 - Textarea
// --------------------------------------------------
(function($) {
	
	$.fn.textarea = function(options) {
		
		var opts = $.extend({}, $.fn.textarea.defaults, options);

		return this.each(function () {
			
			$this = $(this);
			var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;
			
			$this.css('height',o.height);
			
			if (o.charLimit) {
				
				$(this).addClass('limitMe').after('<br /><span class="formKit_help charLimit" rel="' + $(this).attr('name') + '"><span>' + ($(this).metadata().charLimit - $(this).val().length ) + '</span> ' + ((($(this).metadata().charLimit - $(this).val().length ) == 1) ? " character" : " characters") +'' + ' left</span>');
				
				// Create alert if text is close to limit
				if ( $(this).val().length >= ($(this).metadata().charLimit - 25)) {
					$('.charLimit[rel=' + $(this).attr('name') + ']').addClass('charLimit_warning');
				} else {
					$('.charLimit[rel=' + $(this).attr('name') + ']').removeClass('charLimit_warning');
				}
			
				$this.keypress(function(e) {
					
					if ( e.charCode >= 48 || e.charCode == 32 ) {
						if( ($(this).val().length+1) > $(this).metadata().charLimit ) {
							
							return false;
						} else {
				
							// Create alert for when text gets close to limit
							if ( $(this).val().length >= ($(this).metadata().charLimit - 25)) {
								$('.charLimit[rel=' + $(this).attr('name') + ']').addClass('charLimit_warning');
							} else {
								$('.charLimit[rel=' + $(this).attr('name') + ']').removeClass('charLimit_warning');
							}
							
						}
					} else if ( e.charCode == 0 ) {
						return true;
					}
				
				});
				$this.keyup(function(e) {
					if ($(this).val().length > $(this).metadata().charLimit)
					{
						var limit = $(this).metadata().charLimit == 0 ? 1000 : $(this).metadata().charLimit;
						var newVal = $(this).val().substring(0, limit);
						$(this).val(newVal);
						$('body').sysmessage('The text you have entered has exceeded the character limit and will be truncated.', {type: 'warning'});
					}
					$('.charLimit[rel=' + $(this).attr('name') + ']').html( '<span id=\"charsLeft\">' + ($(this).metadata().charLimit - $(this).val().length) + '</span>' + (($(this).metadata().charLimit - $(this).val().length == 1) ? " character" : " characters") + ' left');
					
					return true;
				});
				
			} else if (o.tinyMceCharLimit) {
				$(this).after('<span id=\"charsLeft\" class="formKit_help charLimit" rel="' + $(this).attr('name') + '"><span>' + ($(this).metadata().tinyMceCharLimit - $(this).val().replace(/(<([^>]+)>)/ig,"").length ) + '</span> ' + ((($(this).metadata().tinyMceCharLimit - $(this).val().replace(/(<([^>]+)>)/ig,"").length ) == 1) ? " character" : " characters") +'' + ' left</span>');
				
				// Create alert if text is close to limit
				if ( $(this).val().replace(/(<([^>]+)>)/ig,"").length >= ($(this).metadata().tinyMceCharLimit - 25)) {
					$('.charLimit[rel=' + $(this).attr('name') + ']').addClass('charLimit_warning');
				} else {
					$('.charLimit[rel=' + $(this).attr('name') + ']').removeClass('charLimit_warning');
				}

			}

		});
		
	};

	// Plugin defaults
	$.fn.textarea.defaults = {
		charLimit: 0,
		tinyMceCharLimit: 0,
		textareaHeight: 100
	};

})(jQuery);


// 4.0 - <ul> List => select list
// --------------------------------------------------
function scrollAdjust(dir,id,scroll) {
	var scrollSpeed = scroll * $('#' + id + ' ul li').size();
	var scrollOffset = $('#' + id + ' ul').height() - $('#' + id + ' div.customList-scrollarea').height();
	var currOffset = parseInt($('#' + id + ' ul').position().top,10);
	var percentScrolled = currOffset/scrollOffset * -1;

	var newSpeed = 0;
	if (dir == 'down') {
		newSpeed = scrollSpeed * (1-percentScrolled);
	} else {
		newSpeed = scrollSpeed * percentScrolled;
	}
	
	return newSpeed;
}

(function($) {
	
	// plugin definition
	$.fn.customList = function(options) {
		
		// build main options before element iteration
		var opts = $.extend({}, $.fn.customList.defaults, options);
		
		// iterate and reformat each matched element
		return this.each(function() {
			
			$this = $(this);
			
			// build element specific options
			var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;
			
			var thisID = 0;
			var IDHash = "#customList-" + $this.attr('id');
			
			$this.wrap('<ul class="customList" id="customList-' + $this.attr('id') + '"><li class="customList-items"><div class="customList-scrollarea">');
			$(IDHash + ' li.customList-items').before('<li class="customList-title"><div class="customList-left"></div><div class="customList-right"></div><span>' + $this.metadata().title + '</span></li>');
			
			// Drop Shadows
			$(IDHash + ' li.customList-items').append('<div class="shadow-top_l"></div><div class="shadow-top"></div><div class="shadow-top_r"></div><div class="shadow-r"></div><div class="shadow-btm_r"></div><div class="shadow-btm"></div><div class="shadow-btm_l"></div><div class="shadow-l"></div>');
			
			$(IDHash).css('width', o.width);
			$(IDHash + ' li.customList-items').css('width', o.width);
			$(IDHash + ' li.customList-items li').css('width', o.width - 12);
			$(IDHash + ' li.customList-items li a').css('width', o.width - 12);
			$(IDHash + ' div.customList-scrollarea').css('width', o.width);
			
			// Set up scrolling
			if ($('li',$this).size() > o.scrollThreshold) {
				
				$(IDHash + ' li.customList-items').css({
					height: o.scrollThreshold * $('li',$this).height() + 36,
					top: -18
				});
				$(IDHash + ' li.customList-items ul').css({
					position: 'absolute',
					top: 18
				});
				$(IDHash + ' div.customList-scrollarea').css({
					height: o.scrollThreshold * $('li',$this).height() + 36,
					left: 3,
					marginTop: 3,
					position: 'absolute',
					top: 0
				}).append('<a href="#" class="customList-up">Up</a><a href="#" class="customList-down">Down</a>');
				$(IDHash + ' .customList-up, ' + IDHash + ' .customList-down').css('width',o.width);
				
			} else if ($('li',$this).size() == 0) {
				$this.parent().parent().parent().addClass('customList-disabled').find('.customList-title').css('opacity', '0.3');
			};
			
			if ($('li',$this).size() > 0) {
				// Shadow containers
				$(IDHash + ' .shadow-top, ' + IDHash + ' .shadow-btm').css({
					width: parseInt(o.width,10) - 8
				});
				$(IDHash + ' .shadow-r, ' + IDHash + ' .shadow-l').css({
					height: parseInt( $(IDHash + ' .customList-items').height() ,10) - 8
				});
				$(IDHash + ' .shadow-btm, ' + IDHash + ' .shadow-btm_r, ' + IDHash + ' .shadow-btm_l').css({
					top: $(IDHash + ' .customList-items').height()
				});
			}
			
			// Actions for scrolling
			$('.customList-up').hover(
				function() {
					$(this).parent().find('ul').animate({
						top: 18
					},scrollAdjust('up', $(this).parent().parent().parent().attr('id'), o.scrollFactor),'linear');
				},
				function() { $('ul').stop(); }
			).click(function() { return false; });
			$(IDHash + ' .customList-down').hover(
				function() {
					$(this).parent().find('ul').animate({
						top: '-' + ($(this).parent().find('ul').height() - $(this).parent('div.customList-scrollarea').height() + 18) + 'px'
					},scrollAdjust('down', $(this).parent().parent().parent().attr('id'), o.scrollFactor),'linear');
				},
				function() { $('ul').stop(); }
			).click(function() { return false; });
			
			// Click and hover actions
			$('li.customList-title').click(function() {
				if ( $(this).parent().find('ul li').size() > 0 ) {
					var thisID = $(this).parent().find('ul').attr('id');
					
					// Reposition list to selected item
					if ( $('ul#' + thisID + ' a').hasClass('selected') ) {
						
						$('ul#' + thisID).css({
							top: ( $('ul#' + thisID + ' li').index( $('ul#' + thisID + ' a.selected').parent('li') ) * 17 - 18) * -1
						});
					}
					
					$(this).next('li.customList-items').css({
						left: -4,
						zIndex: 10000
					});
				}
			});
			$('li.customList-items').hover(
				function(){},
				function(){
					$(this).css({
						left: '-9999px',
						zIndex: 100
					});
				}
			);
			$(IDHash + ' li.customList-items li a').click(function() {
				thisID = $(this).parent().parent().attr('id');
				if(thisID.length > 0){
					$('ul#' + thisID).find('a').removeClass('selected');
				}
				
				$(this).addClass('selected');
				$(this).parent().parent().parent().parent().prev('li.customList-title').find('span').html( $(this).html() );
				$(this).parent().parent().parent().parent().css({ left: '-9999px' });
			});
			
			$this.animate({ opacity: 1 }, 1);
			
		});
	};
	
	// plugin defaults
	$.fn.customList.defaults = {
		width: 100,
		scrollThreshold: 7,
		scrollFactor: 30
	};
})(jQuery);

(function() {
  	$.fn.selectReplace = function(options) {
  		if (!($.browser.msie && $.browser.version < 7)) {
  			var opts = $.extend({}, $.fn.selectReplace.defaults, options);
  			return this.each(function() {
  				var $this = $(this);
  				var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

					var this_title = $this.children().first().text();	
					
  				$this
						.wrap('<span id="' + $this.attr('id') + '_wrapper" class="select_wrapper"></span>')
						.before('<span class="left_line"></span><span class="arrow"></span>')
						.css("opacity", 0)
						.change(function() {
							var this_option = $this.find('option:selected').text();
  						$this.parent().find('span.current_value').text(this_option);
  					})
						.parent().prepend('<span class="current_value">'+this_title+'</span>')
						.find('option[selected="selected"]').remove();
					
					$this.css('width','auto').parent().width($this.parent().find('.current_value').width() + 32);
					
					// Browser consistency
					if ($.browser.webkit) { $('span.select_wrapper > select').css('left','-6px'); }
					
  			});
  		}
  	};
  	$.fn.selectReplace.defaults = {
	    width: 'auto',			// Width of select list component (can be auto or fixed width)
	    cssOffset: 7,			// Left offest of popup layer
	    scrollFactor: 80,		// Speed in milliseconds to scroll the height of one item
	    scrollThreshold: 7,	// Number of items to display before scrolling
	    supportIE6: false
    };
})(jQuery);

// 5.0 - Select List
// --------------------------------------------------
(function($) {
	
	$.fn.customSelect = function(options) {
		
		var customSelectFocus = '';
		var opts = $.extend({}, $.fn.customSelect.defaults, options);
		
		// KEYBOARD: Function to check position of highlighted item against scrolling window
		$.fn.customSelect.kbAutoScroll = function(i) {
			if ( $('li div', i).is('.customSelect-scrollarea') ) { 
				var $containerPos = $('.customSelect-items-container ul',i).position();
				var $selectedPos = $('.customSelect-scrollarea li.customSelect-li-hover',i).position();
				var $scrollAreaPos = $('.customSelect-scrollarea ul',i).position();
				var $cursorPos = $selectedPos.top + $containerPos.top;
				
				if ( $cursorPos < 0 ) {
					$('.customSelect-scrollarea ul',i).css({ top: $scrollAreaPos.top + $('.customSelect-items li',i).height()}); // Scroll up
				} else if ( $cursorPos > ($('.customSelect-scrollarea',i).height() - $('.customSelect-items li',i).height()) ) {
					$('.customSelect-scrollarea ul',i).css({ top: $scrollAreaPos.top - $('.customSelect-items li',i).height()}); // Scroll down
				}
			}
		};
		
		// KEYBOARD/MOUSE: Function to reposition scrollable area after a selection is made
		$.fn.customSelect.repositionUL = function(i,j) {
			current = $('option', j).index( $('option:selected', j) );
			var newPos = ((current*parseInt($('.customSelect-items li',i).height(),10))*-1);
			$('.customSelect-scrollarea ul',i).css('top',newPos + 'px');
		};
		
		return this.each(function () {
			
			var $this = $(this);
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			
			// if width is <= 0, object isn't visible and we don't need to customize it
			if($this.width() > 0 && !opts.supportIE6 && !ie6) {
			
				var IDHash;
				var list = '';
				var size = $('option', $this).size();
				var focus = false;
				var current = 0;
			
				function init () {
					
					// ADD ID TO SELECT ITEM IF IT DOESN'T EXIST
					if (!$this.attr('id')) {
						$this.attr('id',$this.attr('name'));
					}
					IDHash = '#customSelect-' + $this.attr('id');
					
					// Neutralize border width
					$this.css({
						border: '1px solid #000',
						opacity: 0.01
					});
					
					// Check for an existing select list and destroy it
					if ( $this.next('ul').attr('id','customSelect-' + $this.attr('id')).hasClass('customSelect-list') ) {
						$(IDHash).remove();
						$this.css({ width: 'auto' });
					}
					
					// ADJUST SELECT LIST SIZE BEFORE REPLACING IT TO ACCOUNT FOR BROWSER VARIANCES
					if (opts.width == 'auto') {
						$this.css({ width: $this.width() });
					} else {
						$this.css({ width: opts.width });
					}
				
					// BUILD SELECT LIST
					$this.after('<ul class="customSelect-list" id="customSelect-' + $this.attr('id') + '" rel="' + $this.attr('id') + '"><li class="customSelect-title"><div class="customSelect-left"></div><div class="customSelect-right"></div><span></span></li><li class="customSelect-items"><div class="customSelect-items-container"><ul></ul></div><div class="shadow-top_l"></div><div class="shadow-top"></div><div class="shadow-top_r"></div><div class="shadow-r"></div><div class="shadow-btm_r"></div><div class="shadow-btm"></div><div class="shadow-btm_l"></div><div class="shadow-l"></div></li></ul>');
				
					// FIX DISPLAY BUG IN SAFARI
					if ($.browser.safari) {
						$(IDHash).css('display','inline');
					}
					
					// Check if element is set to disabled
					if ($this.attr('disabled') && $this.attr('disabled') == true) { $(IDHash).addClass('customSelect-disabled'); }
				
					// ADD SELECT ELEMENTS
					$('option',$this).each(function() {
						list += '<li rel="' + $(this).attr('value') + '">' + $(this).html() + '</li>';
					});
					$('.customSelect-items ul',IDHash).html(list);
				
					// SET THE INITIAL VALUE AND SELECTED STATE
					$('.customSelect-title span',IDHash).html( $('option:selected',$this).html() );
					if ( $this.val() ) {
						$('.customSelect-items li[rel=' + $this.val() + ']',IDHash).addClass('customSelect-selectedItem');
					}
				
					// FINE TUNE WIDTH FOR SOME BROWSERS
					if (opts.width == 'auto') {
						var $selectWidth = $this.width();
					} else {
						var $selectWidth = opts.width;
					}
				
					// GET POSITION OF REPLACED COMPONENT
					$selectPos = $this.position();
				
					// SET POSITION AND SIZE OF COMPONENT
					$(IDHash).css({
						left: $selectPos.left,
						position: 'absolute',
						top: $selectPos.top,
						width: $selectWidth,
						zIndex: 500
					});
				
					// SET POSITION AND SIZE OF SHIM TO PREVENT REPLACED COMPONENT FROM BEING CLICKED
					if ($.browser.msie && $.browser.version < 7) {
						$(IDHash).after('<iframe class="shim">');
					}
					$(IDHash).next('.shim').css({
						background: '#fff',
						border: 0,
						height: $('.customSelect-title',IDHash).height(),
						left: $selectPos.left,
						position: 'absolute',
						top: $selectPos.top,
						width: $selectWidth,
						zIndex: 50
					});
				
					// SET WIDTH OF POPUP LAYER AND LINKS
					borderLeft = parseInt($('.customSelect-items-container',IDHash).css('border-left-width'),10);
					if ( !borderLeft ) { borderLeft = 0; }
					borderRight = parseInt($('.customSelect-items-container',IDHash).css('border-right-width'),10);
					if ( !borderRight ) { borderRight = 0; }
				
					innerWidth = parseInt($selectWidth,10) + parseInt(opts.cssOffset,10) - borderLeft - borderRight;
					$('.customSelect-items',IDHash).css({
						width: (parseInt($selectWidth,10) + opts.cssOffset)
					});
					$('.customSelect-items li',IDHash).css({
						width: innerWidth - 12
					});
				
					// SET SCROLLING
					if ($('.customSelect-items ul li',IDHash).size() > opts.scrollThreshold) {
						$('.customSelect-items ul',IDHash).wrap('<div class="customSelect-scrollarea">');
						$('.customSelect-scrollarea',IDHash).height( opts.scrollThreshold * $('.customSelect-items li',IDHash).height() ).before('<div class="customSelect-up">Up</div>').after('<div class="customSelect-down">Down</div>');

						$('.customSelect-items',IDHash).css({
							top: (parseInt($('.customSelect-items',IDHash).css('top'),10) - parseInt($('.customSelect-up',IDHash).height(),10)) + 'px'
						});
					
						// PRE-POSITION LIST FOR SELECTED ITEM
						$.fn.customSelect.repositionUL(IDHash,$this);
					}
				
					// SET WIDTH AND HEIGHT OF SHADOW CONTAINERS
					$('.shadow-top, .shadow-btm',IDHash).css({
						width: (parseInt($('.customSelect-items',IDHash).width(),10) - 8)
					});
					$('.shadow-r, .shadow-l',IDHash).css({
						height: (parseInt($('.customSelect-items',IDHash).height(),10) - 8)
					});
					$('.shadow-btm_r, .shadow-btm, .shadow-btm_l',IDHash).css({
						top: $('.customSelect-items',IDHash).height()
					});
					$('.shadow-top_r, .shadow-r, .shadow-btm_r',IDHash).css({
						left: $('.customSelect-items',IDHash).width()
					});
				
					// ADD .customSelect-shim TO FIX HOVER PROBLEM IN IE (all versions)
					if ($.browser.msie) {
						$('<div class="customSelect-shim">').insertAfter(IDHash + ' .customSelect-items-container').css({
							background: '#fff',
							height: $('.customSelect-items',IDHash).height(),
							left: $('.customSelect-items',IDHash).css('padding-left'),
							position: 'absolute',
							top: $('.customSelect-items',IDHash).css('padding-top'),
							width: $('.customSelect-items',IDHash).width(),
							zIndex: 50
						});
					}
				
				}
				init();
			
				// FUNCTION TO ADJUST SCROLLING SPEED BASED ON POSITION IN LIST
				function scrollAdjust(e) {
					var scrollSpeed = opts.scrollFactor * parseInt($('.customSelect-scrollarea ul li',IDHash).size(),10);
					var scrollOffset = parseInt($('.customSelect-items ul',IDHash).height(),10) - parseInt($('.customSelect-scrollarea',IDHash).height(),10);
					var currOffset = parseInt($('.customSelect-scrollarea ul',IDHash).css('top'),10);
					var percentScrolled = (currOffset/scrollOffset) * -1;

					var newSpeed = 0;
					if (e == 'down') {
						newSpeed = scrollSpeed * (1-percentScrolled);
					} else {
						newSpeed = scrollSpeed * percentScrolled;
					}

					return newSpeed;
				}
			
			
			
				// ACTIONS FOR SCROLLING
				$('.customSelect-up',IDHash).hover(
					function() {
						$('.customSelect-scrollarea ul',IDHash).animate({
							top: '0'
						},scrollAdjust('up'),'linear');
					},
					function() { $('.customSelect-scrollarea ul',IDHash).stop(); }
				).click(function() { return false; });
				$('.customSelect-down',IDHash).hover(
					function() {
						$('.customSelect-scrollarea ul',IDHash).animate({
							top: '-' + (parseInt($('.customSelect-items ul',IDHash).height(),10) - parseInt($('.customSelect-scrollarea',IDHash).height(),10)) + 'px'
						},scrollAdjust('down'),'linear');
					},
					function() { $('.customSelect-scrollarea ul',IDHash).stop(); }
				).click(function() { return false; });
			
				// SELECT LIST TITLE HOVER ACTIONS
				$('.customSelect-title',IDHash).hover(
					function(){ if (!$(IDHash).hasClass('customSelect-disabled')) { $(this).addClass('customSelect-hover'); } },
					function(){ if (!$(IDHash).hasClass('customSelect-disabled')) { $(this).removeClass('customSelect-hover'); } }
				);
			
				// SELECT LIST TITLE CLICK ACTIONS
				$('.customSelect-title',IDHash).click(function() {
					if (!$(IDHash).hasClass('customSelect-disabled')) { 
						// Reposition UL
						$.fn.customSelect.repositionUL(IDHash,$this);
					
						$(IDHash).css({zIndex:'1000'});
						$(this).toggleClass('customSelect-click');
						$('.customSelect-items',IDHash).toggleClass('jitems-click');
					}
				});
			
				// SET HOVERING
				$('.customSelect-up').hover(
					function() { $(this).addClass('customSelect-up-hover'); },
					function() { $(this).removeClass('customSelect-up-hover'); }
				);
				$('.customSelect-down').hover(
					function() { $(this).addClass('customSelect-down-hover'); },
					function() { $(this).removeClass('customSelect-down-hover'); }
				);
				$('.customSelect-items li').hover(
					function() {
						$('.customSelect-items li').removeClass('customSelect-li-hover');
						$(this).addClass('customSelect-li-hover');
					},
					function() {}
				);
				$('.customSelect-items').hover(
					function() {},
					function() {
						$('.customSelect-title',IDHash).removeClass('customSelect-click');
						$('.customSelect-items',IDHash).removeClass('jitems-click');
						$(IDHash).css({zIndex:'100'});
					}
				);
			
				// SELECT LIST ITEM CLICK
				$('.customSelect-items li',IDHash).click(function() {

					$this.val( $(this).attr('rel') );
					$this.trigger('change');
				
					$('.customSelect-title span',IDHash).html( $(this).html() );
					$('.customSelect-title',IDHash).removeClass('customSelect-click');
					$('.customSelect-items',IDHash).removeClass('jitems-click');

					$('.customSelect-items li',IDHash).removeClass('customSelect-selectedItem');
					$(this).addClass('customSelect-selectedItem');
				
					focus = false;

					// Reposition UL
					$.fn.customSelect.repositionUL(IDHash,$this);

					return false;
				});
			
				/* Keyboard Accessibility */
				$this.focus(function() {
				
					current = $('option', $this).index( $('option:selected', $this) );
					customSelectFocus = $(this).attr('id');
				
					$('.customSelect-title',IDHash).addClass('customSelect-hover');
				
					// Reposition UL
					$.fn.customSelect.repositionUL(IDHash,$this);
				
				}).blur(function() {
					$('.customSelect-title',IDHash).removeClass('customSelect-hover');
					$('.customSelect-items li',IDHash).removeClass('customSelect-selectedItem');
					if ($this.val()) {
						$('.customSelect-items li[rel=' + $this.val() + ']',IDHash).addClass('customSelect-selectedItem');
					}
				
					if (!$.browser.safari) {
						$('.customSelect-items li').removeClass('customSelect-li-hover');
						$('.customSelect-title',IDHash).removeClass('customSelect-click');
						$('.customSelect-items',IDHash).removeClass('jitems-click');
						$(IDHash).css({zIndex:'100'});
					
						focus = false;
					}
				}).change(function() {
					$('.customSelect-title span',IDHash).html( $('option:selected',$this).html() );
				
					if ( $.browser.msie ) {
						if (focus == false) {
							$('#customSelect-' + customSelectFocus).css({zIndex:'1000'});
							$('#customSelect-' + customSelectFocus + ' .customSelect-title').addClass('customSelect-click');
							$('#customSelect-' + customSelectFocus + ' .customSelect-items').addClass('jitems-click');
						
							focus = true;
						}
					
						$('.customSelect-items li',IDHash).removeClass('customSelect-li-hover');
						$('.customSelect-items li[rel=' + $('option:selected',$this).attr('value') + ']',IDHash).addClass('customSelect-li-hover');
					
						$.fn.customSelect.kbAutoScroll(IDHash);
					} else {
						$('.customSelect-title',IDHash).removeClass('customSelect-click');
						$('.customSelect-items',IDHash).removeClass('jitems-click');
	
						$('.customSelect-items li a',IDHash).removeClass('customSelect-selectedItem');
						$('.customSelect-items li a[rel=' + $this.val() + ']',IDHash).addClass('customSelect-selectedItem');
	
						// Reposition UL
						$.fn.customSelect.repositionUL(IDHash,$this);
					}
				});
			
				$(window).keydown(function(e) {
				
					if ( !$.browser.safari && !$.browser.msie ) { // IE doesn't need this part and Safari doesn't support it
					
						if (e.which == 38 || e.which == 40 && focus == false) {
						
							$('#customSelect-' + customSelectFocus).css({zIndex:'1000'});
							$('#customSelect-' + customSelectFocus + ' .customSelect-title').addClass('customSelect-click');
							$('#customSelect-' + customSelectFocus + ' .customSelect-items').addClass('jitems-click');
						
							focus = true;
						}
					
						if (focus) {
						
							if (e.which == 38) { // Up
								if ( (current-1) >= 0) {
									current--;
								} else if ( current == 0) {
									current = 0;
								}
							} else if (e.which == 40) { // Down
								if ( (current+1) <= (size-1)) {
									current++;
								} else if ( current == (size-1)) {
									current = (size-1);
								}
							}
				
							$('.customSelect-items li',IDHash).removeClass('customSelect-li-hover');
							$('.customSelect-items li:eq(' + current + ')',IDHash).addClass('customSelect-li-hover');
						
							$.fn.customSelect.kbAutoScroll(IDHash);
						
						}
					}
				});
			}
		});
	};
	
	// Plugin defaults
	$.fn.customSelect.defaults = {
		width: 'auto',			// Width of select list component (can be auto or fixed width)
		cssOffset: 7,			// Left offest of popup layer
		scrollFactor: 80,		// Speed in milliseconds to scroll the height of one item
		scrollThreshold: 7,	// Number of items to display before scrolling
		supportIE6: false
	};
	
})(jQuery);

// 6.0 - Checkbox/Radio Button
// --------------------------------------------------
(function($) {
	
	var $i = 0;

	$.fn.checkboxRadioInput = function(options) {
		
		var opts = $.extend({}, $.fn.checkboxRadioInput.defaults, options);

		return this.each(function () {

			$this = $(this);
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			
			if(!opts.supportIE6 && !ie6) {
			
				// Add DIV
				$this.attr('rel','cr_input-' + $i).after('<div class="' + opts.elementClass + '" id="cr_input-' + $i + '"></div>');
				
				// Set checked elements
				if ( $this.attr('checked') ) { $('#' + $this.attr('rel')).addClass(opts.checkedClass); }
				
				// Set disabled elements
				if ( $this.attr('disabled') && opts.disabledClass ) { $('#' + $this.attr('rel')).addClass(opts.disabledClass); }
				
				// Add rel to label
				$('label[for='+$this.attr('id')+']').attr('rel','cr_input-' + $i);
				
				// Get position of replaced component
				checkboxPos = $this.position();
				
				// Adjust position of component
				checkboxHeight = $this.outerHeight();
				checkboxWidth = $this.outerWidth();
				replacementHeight = $('.' + opts.elementClass + '').css('height');
				replacementWidth = $('.' + opts.elementClass + '').css('width');
				
				// Adjust for margin
				if ( parseInt($this.css('margin-top'),10) ) {
					marginTop = parseInt($this.css('margin-top'),10);
				} else {
					marginTop = 0;
				}
				if ( parseInt($this.css('margin-left'),10) ) {
					marginLeft = parseInt($this.css('margin-left'),10);
				} else {
					marginLeft = 0;
				}
				
				// Do the math
				adjustedTop = Math.round(checkboxPos.top + ((parseInt(checkboxHeight,10) - parseInt(replacementHeight,10))/2) + marginTop );
				adjustedLeft = Math.round(checkboxPos.left + ((parseInt(checkboxWidth,10) - parseInt(replacementWidth,10))/2) + marginLeft );
				
				// Set CSS of component
				$('#cr_input-'+$i).css({
					top: adjustedTop+'px',
					left: adjustedLeft+'px',
					opacity: 1
				});
				
				// Allow default checkbox to take up space on page but hide below replacement. 0.01 fixes bug in IE
				$this.css('opacity',0.01);
				
				// Hover actions			
				$('.' + opts.elementClass).hover(
					function() { if (opts.hoverClass) { $(this).addClass(opts.hoverClass); } },
					function() { if (opts.hoverClass) { $(this).removeClass(opts.hoverClass); } }
				);
				$('label[rel=cr_input-' + $i + ']').hover(
					function() { if (opts.hoverClass) { $('#' + $(this).attr('rel')).addClass(opts.hoverClass); } },
					function() { if (opts.hoverClass) { $('#' + $(this).attr('rel')).removeClass(opts.hoverClass); } }
				);
	
				// Click action on label or element
				$this.click(function() {
					if ($(this).attr('type') == 'checkbox') {
						if ( $(this).attr('checked') ) {
							if ( $('#' + $(this).attr('rel')).is('.' + opts.focusUncheckedClass) ) {
								$('#' + $(this).attr('rel')).attr('class', opts.elementClass +  ' ' + opts.focusCheckedClass);
							} else {
								$('#' + $(this).attr('rel')).addClass(opts.checkedClass);
							}
						} else {
							if ( $('#' + $(this).attr('rel')).is('.' + opts.focusCheckedClass) ) {
								$('#' + $(this).attr('rel')).attr('class', opts.elementClass +  ' ' + opts.focusUncheckedClass);
							} else {
								$('#' + $(this).attr('rel')).removeClass(opts.checkedClass);
							}
						}
					} else {
						if ( $('#' + $(this).attr('rel')).is('.' + opts.focusUncheckedClass) || $('#' + $(this).attr('rel')).is('.' + opts.focusCheckedClass) ) {
							checkboxFocused = true;
						} else {
							checkboxFocused = false;
						}
						
						$(':radio[name=' + $(this).attr('name') + ']').each(function() {
							$('#' + $(this).attr('rel')).attr('class', opts.elementClass);
						});
						
						if (checkboxFocused) {
							$('#' + $(this).attr('rel')).addClass(opts.focusCheckedClass);
						} else {
							$('#' + $(this).attr('rel')).addClass(opts.checkedClass);
						}
					}
				});
	
				// Click action on fake element
				$('#cr_input-' + $i).click(function() {
					if ($('input[rel='+$(this).attr('id')+']').attr('type') == 'checkbox' && !$('input[rel='+$(this).attr('id')+']').attr('disabled')) {
						$(this).toggleClass(opts.checkedClass);
						
						if ( $('input[rel='+$(this).attr('id')+']').attr('checked') ) {
							$('input[rel='+$(this).attr('id')+']').removeAttr('checked');
						} else {
							$('input[rel='+$(this).attr('id')+']').attr('checked','checked');
						}
						$('input[rel='+$(this).attr('id')+']').trigger('change');
					} else if ($('input[rel='+$(this).attr('id')+']').attr('type') == 'radio' && !$('input[rel='+$(this).attr('id')+']').attr('disabled')) {
						var thisName = $('input:radio[rel=' + $(this).attr('id') + ']').attr('name');
						$(':radio[name=' + thisName + ']').each(function() {
							$('#' + $(this).attr('rel')).removeClass(opts.checkedClass);
							$('input[rel='+$(this).attr('rel')+']').removeAttr('checked');
						});
					
						$(this).addClass(opts.checkedClass);
						$('input[rel='+$(this).attr('id')+']').attr('checked','checked');
					}
				});
				
				// Keyboard control
				$this.focus(function() {
					if ( $(this).attr('checked') ) {
						if ( opts.focusCheckedClass ) { $('#' + $(this).attr('rel')).attr('class', opts.elementClass +  ' ' + opts.focusCheckedClass); }
					} else {
						if ( opts.focusUncheckedClass ) { $('#' + $(this).attr('rel')).attr('class', opts.elementClass +  ' ' + opts.focusUncheckedClass); }
					}
				}).blur(function() {
					if ( $(this).attr('checked') ) {
						if ( opts.focusCheckedClass ) { $('#' + $(this).attr('rel')).attr('class', opts.elementClass +  ' ' + opts.checkedClass); }
					} else {
						if ( opts.focusUncheckedClass ) { $('#' + $(this).attr('rel')).attr('class', opts.elementClass); }
					}
				});
				
				// Increment counter
				$i++;
			
			}

		});

	};

	// Plugin defaults
	$.fn.checkboxRadioInput.defaults = {
		elementClass: 'cr_inputReplace',				// Class applied to input checkbox replacement
		hoverClass: null,									// Class to be applied on hover (optional)
		checkedClass: 'cr_inputReplace_checked',	// Class applied to checked element
		focusCheckedClass: null,						// Class applied to focused element
		focusUncheckedClass: null,						// Class applied to focused element
		disabledClass: null,								// Class applied to disabled element
		supportIE6: false
	};

})(jQuery);


// 7.0 - File Input
// --------------------------------------------------
(function($) {
	
	$.fn.fileInput = function(options) {
		
		var opts = $.extend(defaults, options);
		
		return this.each(function () {
			
			var $this = $(this);
			
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			
			if(!opts.supportIE6 && !ie6) {
				
				// Add ID to item if it doesn't exist
				if (!$this.attr('id')) {
					$this.attr('id',$this.attr('name'));
				}
				
				// Wrap input in <div> and set styles
				$this.wrap('<div class="'+defaults.windowClass+'">');
				$this.parent('div').before('<div class="'+defaults.fileClass+'">');
				$this.parent('div').css({
					height:defaults.height+'px',
					overflow:'hidden',
					position:'relative',
					outline:'none',
					width:defaults.width+'px'
				});
				
				// Set initial position of file input
				var itemPos = $this.parent('div').position();
				var offset = $this.parent('div').offset();
	
				$this.css({
					left:'-'+($this.width()-defaults.width)+'px',
					opacity:'0.0',
					position:'absolute',
					top:'0px'
				});
				
				// File input actions
				$this.parent('div').hover(
					function() { if (defaults.windowHover) $(this).addClass(defaults.windowHover); },
					function() { if (defaults.windowHover) $(this).removeClass(defaults.windowHover); }
				).mousedown(
					function() { if (defaults.windowClick) $(this).addClass(defaults.windowClick); }
				).mouseup(
					function() { if (defaults.windowClick) $(this).removeClass(defaults.windowClick); }
				).mousemove(function(e) {
					var x = e.pageX - offset.left;
					var y = e.pageY - offset.top;
					
					$this.css({
						top:(y - $this.height())+'px',
						left:(x - ($this.width()-40))+'px'
					});
				});
				
				// Display file name in window
				$.fn.fileInput.reBind($this);
			
			}
			
		});
		
	};
	
	// Public function to bind change event to file input
	$.fn.fileInput.reBind = function(myItem) {
		$(myItem).bind('change',function() {
			var myString = $(myItem).val();
			if ($.browser.safari) {
				var myArray = myString.split('/');
			} else if (myString.indexOf('\\')) { // Detect for Windows file pattern
				var myArray = myString.split('\\');
			} else {
				var myArray = myString.split('/');
			}

			var myFile = myArray[myArray.length-1];
			$(myItem).parent('div').prev('.'+defaults.fileClass).html(myFile);
		});
	};
	
	// Plugin defaults
	var defaults = {
		width: 75,						// Width of button
		height: 30,						// Height of button
		windowClass: 'myWindow',	// Class applied to input field wrapper
		windowHover: null,			// Class to be applied on hover (optional)
		windowClick: null,			// Class to be applied on mousedown/mouseup (optional)
		fileClass: 'myFileText',	// Class applied to returned filename text
		supportIE6: false
	};
	
})(jQuery);


// 8.0 - Submit Button
////////////////////////////////////////////////////
(function($) {
	
	// plugin definition
	$.fn.submitReplace = function(options) {
	
		// build main options before element iteration
		var opts = $.extend({}, $.fn.submitReplace.defaults, options);

		// iterate and reformat each matched element
		return this.each(function() {
			var $this = $(this);
			
			// build element specific options
			var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;
			
			var label = $this.val();
			if (o.label) { label = o.label; }
			
			var replacementLink = $('<a href="#" title="' + o.title + '">' + label + '</a>');

			$this.css({
				left: -9999,
				position: 'absolute',
				top: 0,
				width: 1
			}).after(replacementLink);
			
			if (o.cssClass) { replacementLink.addClass(o.cssClass); }
			$('#entire_connectodex_form').attr('name', 'entire_connectodex_form')
			//replacement link trigger
			if (o.enable) {
				replacementLink.click(function(e) {
					e.preventDefault();
					$(this).prev().trigger('click');
				});
			}
		});
	};
	
	// plugin defaults
	$.fn.submitReplace.defaults = {
		cssClass: null,
		label: null,
		title: '',
		enable: true
	};
})(jQuery);


// 9.0 - Edit in Place
// --------------------------------------------------

/* REMOVED */

// 10.0 - Generic popup
// --------------------------------------------------
(function($) {

	$.fn.popUp = function(options) {
		
		var opts = $.extend({}, $.fn.popUp.defaults, options);
	
		return this.each(function() {
			$this = $(this);
			
			var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;
			
			$this.appendTo('body').wrap('<div id="popUp"><div id="popUp_content"></div><div id="popUp_shadow_r"></div><div id="popUp_shadow_br"></div><div id="popUp_shadow_b"></div></div>');
			
			$('div#popUp_content').css({
				width: $this.outerWidth()
			});
			
			if (o.cssClass) { $('div#popUp_content').addClass(o.cssClass); }
			if (o.openCallback) { o.openCallback(); }
			
			if (o.close) {
				$('div#popUp').append('<a href="#" class="popUp_close">Close</a>');
				
				$('a.popUp_close').click(function() {
					$.fn.closePopUp(o.closeCallback);
					return false;
				});
			}
			
			/* Drop Shadow */
			$('div#popUp div#popUp_shadow_r').css({
				height: $('div#popUp').outerHeight() - 10
			});
			$('div#popUp div#popUp_shadow_b').css({
				width: $('div#popUp').outerWidth() - 10
			});
			
			if (o.hCenter) {
				$('div#popUp').css({
					left: ($('div#MainContent').outerWidth() - $('div#popUp').outerWidth())/2 + $('div#NavColumn').outerWidth()
				});
			}
			if (o.vCenter) {
				$('div#popUp').css({
					top: '50%',
					position: 'fixed',
					marginTop: '-' + ($('div#popUp').outerHeight()/2) + 'px'
				});
				if ($.browser.msie && ($.browser.version < 7)) { $('div#popUp').css('position','absolute'); }
			}
			
		});
	};
	
	$.fn.closePopUp = function(closeCallback) {
		$('div#popUp').remove();
			
		if (closeCallback) { closeCallback(); }
	};

	// plugin defaults
	$.fn.popUp.defaults = {
		hCenter: true,
		vCenter: true,
		close: false,
		openCallback: null,
		closeCallback: null,
		cssClass: null
	};
})(jQuery);


// 11.0 - Confirmation dialog
// --------------------------------------------------
var isConfirmation = false;

(function($) {
	
	// plugin definition
	$.fn.confirmation = function(options) {
		
		// build main options before element iteration
		var relCounter = 0;
		var label;
		var controlType;
		var opts = $.extend({}, $.fn.confirmation.defaults, options);
		
		// iterate and reformat each matched element
		return this.each(function() {
			
			$this = $(this);
			currRel = relCounter++;
			
			// build element specific options
			var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;

			if (o.label != '') {
				label = o.label;
			} else {
				if ($this.is('a')) {
					label = $this.text();
				} else {
					label = $this.attr('value');
				}
			}
			
			if ($this.is('a')) {
				controlType = 'a';
			} else {
				controlType = 'input';
			}
			
			$this.addClass('confirmTarget').css({
				left: -9999,
				position: 'absolute',
				top: -9999
			});
			
			confirmationLink = $('<a href="#" class="confirmLink confirmLink-' + controlType + '" rel="' + $this.attr('rel') + '">' + label + '</a>').insertAfter($this);
			
			var condition = '';
			if (o.condition)
			{
				condition = o.condition;
			}
			
			var conditionFailMessage = 'Error processing request.';
			if (o.conditionFailMessage)
			{
				conditionFailMessage = o.conditionFailMessage;
			}
				$.fn.confirmation.action(o.baseClass,confirmationLink,o.message,o.buttonOK,o.buttonCancel,currRel,o.triggerClick,o.trackID,condition,conditionFailMessage);
			
		});
	};
	
	// external function
	$.fn.confirmation.action = function(baseClass,i,message,buttonOK,buttonCancel,rel,triggerClick,trackID,condition,conditionFailMessage) {
	
		$(i).click(function() {
			
			if (condition != '' && !eval(condition)) {
				$('body').sysmessage(conditionFailMessage, {type: 'error'});
				return false;
			}
			
			if (isConfirmation == false) {
				isConfirmation = true;
				
				// Insert confirmation dialog
				confirmation = $('<div class="' + baseClass + ' confirmation"><div class="' + baseClass + '-message">' + message + '<p class="' + baseClass + '_links"><a href="#" class="confirmation-false">' + buttonCancel + '</a> <a id="'+ trackID +'" href="#" class="confirmation-true">' + buttonOK + '</a></p></div></div>').appendTo('body');
				$(confirmation).css({
					position: 'fixed',
					top: '50%',
					marginTop: '-' + ($(confirmation).outerHeight()/2) + 'px'
				});
				
				if ($.browser.msie && ($.browser.version < 7)) {
					$(confirmation).css({
						position: 'absolute',
						top: $(window).scrollTop() + ($(window).height()/2)
					});
				}
				
				// Drop shadow or iFrame shim
				if ($.browser.msie && $.browser.version < 7) {
					$(confirmation).after('<iframe class="shim" frameborder="0">');
					$(confirmation).next('.shim').css({
						background: '#000',
						border: 0,
						height: $('div.' + baseClass + '-message', confirmation).outerHeight(),
						left: $(confirmation).offset().left,
						position: 'absolute',
						top: $(confirmation).offset().top,
						width: $('div.' + baseClass + '-message', confirmation).outerWidth(),
						zIndex: 50
					});
				} // else {
				 // 					$(confirmation).append('<div class="' + baseClass + '_shadow_r"></div><div class="' + baseClass + '_shadow_br"></div><div class="' + baseClass + '_shadow_b"></div>');
				 // 					$('div.' + baseClass + ' div.' + baseClass + '_shadow_r').css({
				 // 						height: $('div.' + baseClass).outerHeight() - 10
				 // 					});
				 // 					$('div.' + baseClass + ' div.' + baseClass + '_shadow_b').css({
				 // 						width: $('div.' + baseClass).outerWidth() - 10
				 // 					});	
				 // 				}
				
				// Click actions
				$('a.confirmation-false').click(function() {
					$( $(this).parent().parent().parent('div.sysmessage') ).remove();
					if ($.browser.msie && $.browser.version < 7) {
						$('iframe.shim').remove();
					}
					isConfirmation = false;
					
					return false;
				});
				$('a.confirmation-true').live('click',function(e) {
					setTimeout(function(){
						$( $(this).parent().parent().parent('div.sysmessage') ).remove();
						if ($(i).hasClass('confirmLink-a')) {
							if (triggerClick == true) {
								$('a.confirmTarget[rel=' + $(i).attr('rel') + ']').trigger('click');
							} else {
								window.location = $('a.confirmTarget[rel=' + $(i).attr('rel') + ']').attr('href');
							}
						} else {
							$('input.confirmTarget[rel=' + $(i).attr('rel') + ']').trigger('click');
						}
						isConfirmation = false;
					}, 500);
					e.preventDefault();
				});
			}
			return false;
			
		});
	};
	
	// plugin defaults
	$.fn.confirmation.defaults = {
		baseClass: 'sysmessage',
		buttonOK: 'OK',
		buttonCancel: 'Cancel',
		label: '',
		message: 'Are you sure?',
		triggerClick: false,
		trackID: ''
	};
})(jQuery);


// PLUGIN - popupForm
////////////////////////////////////////////////////
(function($) {
	
	$.fn.popupForm = function(options) {

		var opts = $.extend({}, $.fn.popupForm.defaults, options);
		
		return this.each(function() {
			$this = $(this);
			var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;
			
			formURL = $this.attr('href') ? $this.attr('href') : o.url;
			if(formURL) {	
				$this.bind(o.bindEvent, function(event) {
					if(o.preventDefault)
						event.preventDefault();
					$.ajax({
						type: 'GET',
						dataType: 'html',
						url: formURL,
						beforeSend: function() {
							$.BlockUI();
						},
						success: function(html) {
							if ( ajaxSuccess(html) ) {
								// Create popup form container
								$content = $(html).find('form');
								formName = $content.attr('name');
								$popupForm = $('<div class="popupForm"></div>');
							
								// Insert popup into content
								$(html).appendTo($popupForm);
								$popupForm.appendTo($(o.scope));
							
								// Setup drop shadow
								$('.popupForm form h4, .popupFormBtns input').before('<a href="#" class="popupFormClose">Cancel</a>');
								$('.popupForm form').after('<div class="popupForm_shadow-top_l"></div><div class="popupForm_shadow-top"></div><div class="popupForm_shadow-top_r"></div><div class="popupForm_shadow-r"></div><div class="popupForm_shadow-btm_r"></div><div class="popupForm_shadow-btm"></div><div class="popupForm_shadow-btm_l"></div><div class="popupForm_shadow-l"></div>');

								// Set width and height of shadow containers
								$('.popupForm_shadow-top, .popupForm_shadow-btm').css({
									width: $('.popupForm form').width() + parseInt($('.popupForm form').css('padding-left'),10) + parseInt($('.popupForm form').css('padding-right'),10) + parseInt($('.popupForm form').css('border-left-width'),10) + parseInt($('.popupForm form').css('border-right-width'),10) - 16 + 'px'
								});
								$('.popupForm_shadow-top_r, .popupForm_shadow-r, .popupForm_shadow-btm_r').css({
									left: $('.popupForm form').width() + parseInt($('.popupForm form').css('padding-left'),10) + parseInt($('.popupForm form').css('padding-right'),10) + parseInt($('.popupForm form').css('border-left-width'),10) + parseInt($('.popupForm form').css('border-right-width'),10) + 'px'
								});
								$('.popupForm_shadow-r, .popupForm_shadow-l').css({
									height: $('.popupForm form').height() + parseInt($('.popupForm form').css('padding-top'),10) + parseInt($('.popupForm form').css('padding-bottom'),10) + parseInt($('.popupForm form').css('border-top-width'),10) + parseInt($('.popupForm form').css('border-bottom-width'),10) - 16 + 'px'
								});
								$('.popupForm_shadow-btm_r, .popupForm_shadow-btm, .popupForm_shadow-btm_l').css({
									top: $('.popupForm form').height() + parseInt($('.popupForm form').css('padding-top'),10) + parseInt($('.popupForm form').css('padding-bottom'),10) + parseInt($('.popupForm form').css('border-top-width'),10) + parseInt($('.popupForm form').css('border-bottom-width'),10) + 'px'
								});

								// Custom file input
								$('.popupFormFile label').css({
									left: $('.popupFormFile').width() - $('.popupFormFile label').innerWidth() - 1 + 'px'
								});
								$('.popupFormFile input').fileInput({
									height:21,
									width:$('.popupFormFile label').width()
								});
								$('.popupFormFile .myFileText').css({
									width: $('.popupFormFile').width() - $('.popupFormFile label').width() + 'px'
								});
								$('.popupFormFile .myWindow').hover(
									function() { $('.popupFormFile label strong').css({color:'#c00'}); },
									function() { $('.popupFormFile label strong').css({color:'#193569'}); }
								);

								// Submit button rollovers
								$('.popupFormBtns input[type="image"]').submitRollover();
			
								// Show Popup
								$('.popupForm').css({ visibility: 'visible', opacity: '0.0'}).animate({ opacity: '1.0' });
								//$('.popupForm h4').sifr({font_color:'#464646'});
								//$('.popupForm').css({ visibility: 'visible' });
							
								// Bind dismissal event
								$this.bind('popupForm.dismiss',function() { 
									$popupForm.fadeOut('fast', function() { $(this).remove(); });
									//$popupForm.remove();
									$.unBlockUI();	
								});
							
								// Post cancel/close action
								$('.popupFormClose, .popupFormBtns .popupFormClose').click(function() {
									$this.trigger('popupForm.dismiss');
									return false;
								});
							
								$('.popupForm_shadow-top_l, .popupForm_shadow-top, .popupForm_shadow-top_r, .popupForm_shadow-r, .popupForm_shadow-btm_r, .popupForm_shadow-btm, .popupForm_shadow-btm_l,	.popupForm_shadow-l').ifixpng();
							
								//Remove form defaults on click, restore on blur if not set 
								$('input, textarea', $('.popupForm')).each(function() {
									$(this).focus(function() {
										if($(this).val() == this.defaultValue)
											$(this).val("");
									});
									$(this).blur(function() {
										if($(this).val() == "")
											$(this).val(this.defaultValue);
									});
								});
							
								// Custom Callback
								if (o.onPopup && typeof(o.onPopup) == 'function') {
									o.onPopup();
								}
							}
						}
					});
				});
			}

		});
	};
	
	$.fn.popupForm.defaults = {
		bindEvent: 'click',
		preventDefault: true,
		onPopup: function(){ return false; },
		url: null,
		scope: '#Content'
	};
}) (jQuery);

/* END 5.0: jquery.forms.js */

/* BEGIN 6.0: jquery.navcolumn.js */

// Main NavColumn function
////////////////////////////////////////////////////

$.ax.NavColumn = function () {

	// Initiate Plugins
	////////////////////////////////////////////////////

	$('.Filters select').customSelect({
		cssOffset: 3,
		width: 165,
		scrollFactor: 230
	});

	$('#SiteSearch select').customSelect({
		cssOffset: 3,
		width: 112
	});

	$('#SiteSearch').submit(function() {
		if( $('#site_search_keyword').val().length <= 2) {
			$('body').sysmessage('Please enter 3 or more characters to perform a search', {type: 'error'});
			return false;
		}
	});

	$('#site_search_submit').click(function (e) {
		$(this).closest('form').submit();
	});

	$('#SiteSearch').submit(function (e) {
		var $searchForm = $(this),
				txtFieldVal = $searchForm.find('#site_search_keyword').val();
	
		$searchForm.find('#site_search_keyword').val(AX.stringSanitize(txtFieldVal));
	
		if (txtFieldVal != 'Search OPEN Forum') {
			return true;
		} else {
			return false;
		}
	});

	//START: Site Authentication menu
	$('#Global_Auth').removeClass('visible');

	/*$('#Global_Auth p, #Global_Auth ul').hover(
	function () {
	$(this).parent().addClass('visible');
	},
	function () {
	$(this).parent().removeClass('visible');
	}
	);*/

	$('#Global_Auth ul li a').focus(function () {
		$('#Global_Auth').addClass('visible');
	}).blur(function () {
		$('#Global_Auth').removeClass('visible');
	});

	//START: Share link hover states
	$(document.body).delegate('#Global_Follow .share_tools a', 'mouseover mouseout focusin focusout click', function (e) {
		var $this = $(this);
		switch (e.type) {
			case 'mouseover':
			case 'focusin':
				AX.onFollowButtonMouseOver($this);
				break;
			case 'click':
				AX.onFollowButtonMouseOut($this);
				$this.blur();
				break;
			case 'mouseout':
			case 'focusout':
			default:
				AX.onFollowButtonMouseOut($this);
				break;
		}
	});
	
	//END: Share link hover states

	$('.NavDrawer .DrawerSubNav, .NavDrawer .DrawerSubNavA').wrapInner('<span></span>');

	$('#paw').click(function () {
		var mainSection = $('#PageWrapper').attr('class');
		var subSection = $('#LayoutWrapper').attr('class').split(' ').join(':');

		var d = {
			'pagename': mainSection + ':' + subsection + ':3rd_party_ad',
			'prop6': 'passive',
			'evar6': 'passive',
			'prop7': 'click on ad',
			'evar7': 'click on ad',
			'prop10': 'both',
			'evar10': 'both'
		};


	});

	// IE 6 
	if ($.browser.msie == true && $.browser.version == "6.0" && (location.href.indexOf('special') >= 0 || location.href.indexOf('com/women') >= 0)) {
		$('#content').css('position', 'relative');
		$('#NavColumn').css('position', 'absolute').css('top', '0px').css('left', '0px').css('z-index', '3000');
		if ($('#MainContent').height() <= $('#NavColumn').height()) {
			$('#MainContent').height($('#NavColumn').height() + 20);
		}
	}

	$('#bc_facebook, #bc_twitter').click(function () {
		window.open($(this).attr('href'));
		return false;
	});


	$('.global_rss_subscribe').click(function (event) {
		if($('#AjaxLoader').size() > 0){
			return false;
		}
		if ($('#modal_emailsubscribe').size() != 0) {
			$('#modal_emailsubscribe').remove();
		}
		event.preventDefault();
		if ($('#modal_rssfeed').size() == 0) {
			$('<div id="AjaxLoader">Loading...</div>').appendTo('#PageWrapper');
			$.ajax({
				type: "GET",
				url: $(this).attr('href'),
				dataType: 'html',
				success: function (html) {
					if (ajaxSuccess(html)) {

						$('#AjaxLoader').remove();
						var rssContent = $(html).find('#rss_content');

//						//omniture tracking dynamic pageload
//						$(window).trigger('success.ajax.ax', {
//							'omn_language': 'en',
//							'omn_hierarchy': 'US|OPENForum|Subscribe',
//							'omn_pagename': 'RSS',
//							'omn_loginstatus': AX.user_state
//						});

						$('body').sysmessage(rssContent, {
							type: 'confirmation',
							lightbox: true,
							autoDismiss: false
						});

						$('body .sysmessage').attr('id', 'modal_rssfeed');

						var $rssModal = $('#modal_rssfeed');
						$rssModal.css('margin-top', '-' + String($rssModal.outerHeight() / 2) + 'px');

						$('.sysmessage_shadow_r, .sysmessage_shadow_b, .sysmessage_shadow_br').remove();

					} // if ajaxSuccess
				},  //END: success
				error: function () {
					$('#AjaxLoader').remove();
				}
			}); //END: ajax

		} // END: if #rssfeed_pop size == 0

	}); //END: click

	$('.global_email_subscribe').click(function (event) {
		if($('#AjaxLoader').size() > 0){
			return false;
		}
		if ($('#modal_rssfeed').size() != 0) {
			$('#modal_rssfeed').remove();
		}
		event.preventDefault();

		if ($('#modal_emailsubscribe').size() == 0) {
			$('<div id="AjaxLoader">Loading...</div>').appendTo('#PageWrapper');
			$.ajax({
				type: "GET",
				url: $(this).attr('href'),
				dataType: 'html',
				success: function (html) {
					if (ajaxSuccess(html)) {

						$('#AjaxLoader').remove();
						var rssContent = $(html).find('#ContentWell');

						$('body').sysmessage(rssContent, {
							type: 'confirmation',
							lightbox: true,
							autoDismiss: false
						});

						$('body .sysmessage').attr('id', 'modal_emailsubscribe');

						var $emailModal = $('#modal_emailsubscribe');
						$emailModal.css('margin-top', '-' + String($emailModal.outerHeight() / 2) + 'px');

						$('p.privacy a', '#modal_emailsubscribe').click(function (event) {
							event.preventDefault();
							var thisHref = $(this).attr('href');
							window.open(thisHref);
						});

						$('.sysmessage_shadow_r, .sysmessage_shadow_b, .sysmessage_shadow_br').remove();
						$('.sysmessage-close').find('a').attr('title', 'close this popup');
						emailSubscribe();
						cancelEmailForm();
						//validateEmailForm();

					} // if ajaxSuccess
				}, //END: success
				error: function () {
					$('#AjaxLoader').remove();
				}
			}); //END: ajax

		} // END: if #emailsubscribe_pop size == 0

	}); //END: click
	
	getUrlVars = function () {
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for (var i = 0; i < hashes.length; i++) {
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
	}

	getUrlVar = function (name) {
		return getUrlVars()[name];
	}

	function emailSubscribe() {

		$("#email_subscribe").submit(function (event) {
			event.preventDefault();
			//disable the submit button after clicked
			$("#newsletter_submit").attr('disabled', 'disabled');

			//clear error styles and messaging
			if ($('p.error', this).length > 0) {
				$('p.error', this).remove();
			}
			$('input, label', this).removeClass('error');
			$('#modal_emailsubscribe').find('.error_message').hide().empty();

			if (validateEmailForm($(this)) == true) {
				var formData = 'first_name=' + encodeURIComponent($('#newsletter_first_name').val()) + '&last_name=' + encodeURIComponent($('#newsletter_last_name').val()) + '&email=' + encodeURIComponent($('#newsletter_email').val()) + '&confirm_email=' + encodeURIComponent($('#newsletter_confirm_email').val()) + '&zip_code=' + encodeURIComponent($('#newsletter_zip_code').val()) + '&continue=' + $('#newsletter_continue').val() + '&submit=submit';
				$.ajax({
					type: "POST",
					data: formData,
					url: "/weeklynewslettersubscription?component=subscription",
					dataType: 'html',
					success: function (html) {
						$('#newsletter_submit').trigger('success.modal_emailsubscribe');
						if (html == "<div class='error validation'>You are already a member. Do you still want to activate e-mail subscriptions?</div>") {

							if ($('#newsletter_continue', '#email_subscribe').val() == '1') {
								emailSentMessage('', $('#newsletter_email', '#email_subscribe').val());
							} else {
								emailSentMessage('member', $('#newsletter_email', '#email_subscribe').val());
							}
						}
						else {
							emailSentMessage('', $('#newsletter_email', '#email_subscribe').val());
						}
						$('#newsletter_submit').removeAttr('disabled');
					},
					error: function(){
						$('#newsletter_submit').removeAttr('disabled');
					}
				});

			} else { //END: if validateEmailForm == true

				$('#newsletter_submit').trigger('failure.modal_emailsubscribe');
				emailErrorHandling($(this));
				$('#newsletter_submit').removeAttr('disabled');
			} //END: if validateEmailForm == false (error)

		}); //END: submit

	}

	emailSentMessage = function (status, emailAddress) {
		
		$('#email_subscribe').children().remove();
		$('#modal_emailsubscribe').find('.formKit_form').addClass('email_subscribe_success');
		$('#modal_emailsubscribe').find('.description').remove();

		var messageHtml = [];
		messageHtml[0] = "<div class=\"message\"><p><strong>The e-mail address you entered is registered to an existing OPEN Forum member.</strong></p><p>OPEN Forum members can subscribe to their own e-mail update in their settings <a href=\"/home/preferences/notifications\" id=\"link_notifictations\">Here</a>.</p><p><a class=\"button_link\" id=\"mess_cancel\" href=\"#\"><img src=\"/images/special_feature/email_subscription/btn.cancel.png\" alt=\"cancel\" /></a>&nbsp;<a class=\"button_link\" id=\"mess_continue\" href=\"#\"><img src=\"/images/special_feature/email_subscription/btn.continue.png\" alt=\"continue anyway\" /></a></p></div>";
		messageHtml[1] = "<div class=\"message\"><p class='thank_you'>Thank you for signing up for email updates from OPEN Forum.</p><p>A confirmation e-mail has been sent to " + emailAddress + "</p><div class=\"dotted_divider\"></div><p class='follow_openforum'>Other ways to follow OPEN Forum:</p><ul><li id=\"Email_Follow_Facebook\"><a href=\"http://www.facebook.com/Open\" title=\"find us on Facebook\" rel=\"external\" id=\"email_subscribed_fb\">Find us on Facebook</a></li><li id=\"Email_Follow_Twitter\"><a href=\"http://twitter.com/openforum\" title=\"follow us on Twitter\" rel=\"external\" id=\"email_subscribed_tw\">Follow us on Twitter</a></li><li id=\"Email_Follow_Mobile\"><a href=\"/mobile\" title=\"mobile\" id=\"email_subscribed_mobile\">Mobile</a></li><li id=\"Email_Follow_RSS\"><a href=\"/rssfeeds\" title=\"subscribe\">RSS Subscribe</a></li></ul></div>";
		
		if (status == 'member') {
			message_Html = messageHtml[0];

		} else {
			message_Html = messageHtml[1];
		}
		
		$('#email_subscribe').append(message_Html);

		$('#mess_cancel', '#email_subscribe').click(function (event) {
			event.preventDefault();
			$('.message', '#email_subscribe').remove();
			$('#email_subscribe').children().show();
		});

		$('#mess_continue', '#email_subscribe').click(function (event) {
			event.preventDefault();
			$('#newsletter_continue', '#email_subscribe').val('1');
			$('#email_subscribe').submit();
			$('.message', '#email_subscribe').html(messageHtml[1]);

		});

		$('#mess_close', '#email_subscribe').click(function (event) {
			event.preventDefault();
			if ($.browser.msie) {
				$('.lightbox-bg, #modal_emailsubscribe', 'body').remove();
			} else {
				$('.lightbox-bg, #modal_emailsubscribe', 'body').animate({ opacity: 0 }, function () {
					$('.lightbox-bg, #modal_emailsubscribe', 'body').remove();
				});
			}
		});
		
		$('#Email_Follow_RSS').click(function(e){
			e.preventDefault();
			$('#modal_emailsubscribe').remove();
			$('.lightbox-bg').remove();
			$('#Global_Follow_RSS').click();
		})

	}
	
	function emailErrorHandling(theForm) {
		errorArray = new Array();
		errorArray = validateEmailForm(theForm);
		for (i = 0; i < errorArray.length; i++) {
			$('#' + errorArray[i], theForm).addClass('error').prev().addClass('error');

			if (errorArray[i] == "email_match") {
				$('#newsletter_email, #confirm_email', theForm).addClass('error').prev().addClass('error');
			}

			if (errorArray[i] == "email_regex") {
				$('#newsletter_email, #confirm_email', theForm).addClass('error').prev().addClass('error');
			}

			if (errorArray[i] == "zip_regex") {
				$('#newsletter_zip_code', theForm).addClass('error').prev().addClass('error');
			}
		}
		$('#modal_emailsubscribe').find('.error_message').show().text('Some information above appears to be incorrect or missing. Please try again.');
	}

	validateEmailForm = function (theForm) {

		var first_name = $('#newsletter_first_name', theForm).val();
		var last_name = $('#newsletter_last_name', theForm).val();
		var email = $('#newsletter_email', theForm).val();
		var confirm_email = $('#newsletter_confirm_email', theForm).val();
		var zip_code = $('#newsletter_zip_code', theForm).val();

		var emailRegex = /^([A-Za-z0-9_\+\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var zipRegex = /(^[ABCEGHJKLMNPRSTVXYabceghjklmnprstvxy]\d[ABCEGHJKLMNPRSTVWXYZabceghjklmnprstvxy]( )?\d[ABCEGHJKLMNPRSTVWXYZabceghjklmnprstvxy]\d$)|(^\d{5}(-\d{4})?$)/;

		var error = new Array();
		var i = 0;
		if (first_name == '') { error[i] = "newsletter_first_name"; i++; }
		if (last_name == '') { error[i] = "newsletter_last_name"; i++; }
		if (email == '') { error[i] = "newsletter_email"; i++; }
		if (confirm_email == '') { error[i] = "newsletter_confirm_email"; i++; }
		if (zip_code == '') { error[i] = "newsletter_zip_code"; i++ }

		if (email != confirm_email) { error[i] = "email_match"; i++; }

		if (!(emailRegex.test(email))) { error[i] = "email_regex"; i++; }
		if (!(zipRegex.test(zip_code))) { error[i] = "zip_regex"; i++; }

		if (error.length < 1) {
			return true;
		} else {
			return error;
		}
	}

	function cancelEmailForm() {
		$('#newsletter_cancel', '#email_subscribe').click(function (event) {
			event.preventDefault();
			$('input:text', '#email_subscribe').val('');
			$('.sysmessage-close a').trigger('click');
		});
	}

};

/* END 6.0: jquery.navcolumn.js */

/* BEGIN 7.0: jquery.link_to_remote.js */

/* REMOVED */

/* END 7.0: jquery.link_to_remote.js */

/* BEGIN 8.0: personacard.js */

(function() {

	$.fn.personaCard = function(options) {
		
		//retrieve location for persona popup metrics

		var pageName = 'persona_popup';
		if ($('#LayoutWrapper').hasClass('MemberSearch')) pageName = 'find_a_business:persona_popup';
		
		///////////	

		
		var opts = $.extend({}, $.fn.personaCard.defaults, options);
		var infoRequest;
		return this.each(function() {
			var $this = $(this);
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
			
			var allowPopup, popupTimeout, hoverIntent, hoverInterval, position, defaultXPos, defaultYPos, xPos, yPos, deltaY;
			var maxPosX = 980;
			
			if($this.hasClass('PersonOnly')) {
				return;
			}
			
			$this.click(function() {
				$.fn.personaCard.killPopups(infoRequest);
				if(infoRequest) {
					infoRequest.abort();
					//alert('aborted');
				}
				var loc = $('a[href^=/connectodex]:first', $this).attr('href');
				if(loc != '') {
					window.location.href = loc;
				}
			});
			
			$this.hover(function() {			
				
				clearTimeout(popupTimeout);
				hoverIntent = setTimeout(function() {
					$.fn.personaCard.killPopups(infoRequest);
					
					if($('#PersonaCard_' + $this.attr('rel')).size() == 0) {
						var $personaCardWrapper;
						var personaCardWrapper = document.createElement('div');
						personaCardWrapper.innerHTML =  $.fn.personaCard.template;
						$personaCardWrapper = $(personaCardWrapper);
						$personaCardWrapper.addClass('PersonaCardWrapper');
						
						var $personaCard = $('.PersonaCard', $personaCardWrapper);
						var personaKey = new Date();
						$this.attr('rel', personaKey.getTime());
						$personaCard.attr('id', 'PersonaCard_' + $this.attr('rel'));
						$personaCardWrapper.appendTo('body');
						if($.browser.msie && $.browser.version < 7) {
  						var $personaShim = $('<iframe class="PersonaShim"></iframe>');
  						$personaShim.appendTo('body');
						}

						
						$personaCardWrapper.hover(function() {
							clearTimeout(popupTimeout);
						}, function() {
							popupTimeout = setTimeout(function() {
								$.fn.personaCard.killPopups(infoRequest);
							}, 1);
						});

						position = $this.offset();
						xPos = position.left + o.offsetX;
						yPos = position.top + o.offsetY - o.loadingHeight;
						var shiftCardUpwards = true;
						
						if(xPos + o.loadingWidth > maxPosX) {
							xPos = xPos - o.loadingWidth + o.offsetX;
						}
						
						if(yPos - o.loadingBufferHeight < $(window).scrollTop()) {
							yPos = position.top + o.offsetY;
							shiftCardUpwards = false;
						}
						
						$personaCardWrapper.css({
							left: xPos,
							top: yPos
						});
						
						if($.browser.msie && $.browser.version < 7) {
  						$personaShim.css({
  						  left: xPos,
  						  top: yPos
  						});
					  }
						
						var jsonStream;
						if($this.attr('href')) {
							jsonStream = $this.attr('href');
						} else if($('p.Avatar a', $this).attr('href')) {
							jsonStream = $('p.Avatar a', $this).attr('href');
						} else {
							jsonStream = $('a[href^=/connectodex]:first', $this).attr('href');
						}
						
						if(jsonStream != '') {
							infoRequest = $.ajax({
								url: jsonStream,
								type: 'get',
								dataType: 'json',
								data: 'component=business-card',
								global: false,
								cache: false,
								success: function(data) {
									if (data == null) {return false;}
									var business = data.business;
									var loggedIn = data.user_state && data.user_state == 'LoggedInMember' ? true : false;

									$('.PersonaInfo .BusinessAvatar img', $personaCard).attr({
										src: business.profile_img_url,
										alt: business.name
									});
									$('.BusinessInfo h5 a', $personaCard).html(business.name).attr('href', business.profile_url);
									$('.BusinessLocation', $personaCard).html(business.location);
									$('.BusinessInfo p:eq(2)', $personaCard).html(business.profile_blurb);
									if(loggedIn && business.share_msg != '') {
											$('.BusinessInfo .ShareMessage a', $personaCard).html(business.share_msg).attr('href', business.profile_url);
									} else {
										$('.BusinessInfo .ShareMessage', $personaCard).remove();
									}

									$('.BusinessInfo p a', $personaCard).attr('href', business.profile_url);

									if(business.expert) {
										$personaCard.addClass('ExpertCard');
									}

									if(business.members && business.members.length > 0) {
										// set up full nav popup
										$('.BusinessSeeksAndProvides', $personaCard).remove();
										$('.PersonaNavigation .BusinessAvatar img', $personaCard).attr({
											src: business.avatar_img_url,
											alt: business.name
										});
								
										for(var i in business.members) {
											var $personaNavCard = $('.PersonaNavigation .MemberAvatar:first', $personaCard).clone();
											$personaNavCard.removeClass('Template');
											$('.Avatar img', $personaNavCard).attr({
												src: business.members[i].avatar_img_url,
												alt: business.members[i].name
											});


											var $personaInfoCard = $('.MemberInfo:first', $personaCard).clone();
											$personaInfoCard.removeClass('Template');
											$('h5 a', $personaInfoCard).append(business.members[i].name).attr('href', business.members[i].profile_url + '#' + business.members[i].GUID);
											$('.MemberTitle', $personaInfoCard).html(business.members[i].title);
											$('p:eq(1)', $personaInfoCard).html(business.members[i].profile_blurb);
											if(loggedIn && !business.members[i].is_me) {
												if(business.members[i].share_msg && business.members[i].share_msg != "") {
													$('.ShareMessage a', $personaInfoCard).html(business.members[i].share_msg).attr('href', business.members[i].profile_url + '#' + business.members[i].GUID);
												} else {
													$('.ShareMessage', $personaInfoCard).remove();
												}

												$('.MemberActions li:first a', $personaInfoCard).attr('href', business.members[i].profile_url + '#' + business.members[i].GUID);
												$('a.add_bookmark', $personaInfoCard).attr('href', '/tools/RelationshipAddRemove.aspx?userguid='+business.members[i].GUID+'&performaction=bookmark');
												
												var action = '';
												if(business.members[i].is_my_contact) {
													$('a.remove_bookmark', $personaInfoCard).html('remove connection').attr('rel','connection');
													action = 'remove';
												} else {
													$('a.remove_bookmark', $personaInfoCard).attr('rel','radar');
													action = 'removebookmark';
												}
												
												$('a.remove_bookmark', $personaInfoCard).attr('href', '/tools/RelationshipAddRemove.aspx?userguid='+business.members[i].GUID+'&performaction=' + action);
												
												$('a.add_connection', $personaInfoCard).attr('href', '/tools/RelationshipAddRemove.aspx?userguid='+business.members[i].GUID+'&performaction=add');
												$('a.message', $personaInfoCard).attr('href', '/message-center/newmessage?userid='+business.members[i].GUID);
												if(business.members[i].is_my_bookmark || business.members[i].is_my_contact) {
													$('.MemberActions li a.add_bookmark', $personaInfoCard).remove();
												} else {
													$('.MemberActions li a.remove_bookmark', $personaInfoCard).remove();
												}
												if(business.members[i].is_my_contact) {
													$('.MemberActions li a.add_connection', $personaInfoCard).remove();
												}
											} else if(!loggedIn || business.members[i].is_me) {
												$('.ShareMessage, .MemberActions', $personaInfoCard).remove();
											}

											if(business.members[i].ID == business.default_state) {
												$personaNavCard.insertAfter($('.MemberAvatar:first', $personaCard));
												$personaNavCard.addClass('Active').siblings('.Active').removeClass('Active');
												$personaInfoCard.insertAfter($('.MemberInfo:first', $personaCard));
												$personaInfoCard.addClass('Active').siblings('.Active').removeClass('Active');
											} else {
												$personaNavCard.appendTo($('.PersonaNavigation', $personaCard));
												$personaInfoCard.appendTo($('.PersonaInfo', $personaCard));	
											}
										}

										$('.Template', $personaCard).remove();
										if(business.members.length < o.navCarouselThreshold) {
											for(var i = 1; i <= o.navCarouselThreshold - business.members.length; i++) {
												$('<li class="Filler"></li>').appendTo($('.PersonaNavigation', $personaCard));
											}
											$('.PersonaNavigation', $personaCard).prependTo($personaCard);
											$('.PersonaNavigationWrapper', $personaCard).remove();
										}
									} else {
										// set up business only popup 
										$personaCard.addClass('BusinessOnly');
										for( var i in business.seeks) {
											$('<li>'+business.seeks[i]+'</li>').appendTo($('.BusinessSeeks ul', $personaCard));
										}
										for( var i in business.provides) {
											$('<li>'+business.provides[i]+'</li>').appendTo($('.BusinessProvides ul', $personaCard));
										}
										$('.BusinessSeeks p a, .BusinessProvides p a', $personaCard).attr('href', business.profile_url);
										$('.PersonaNavigationWrapper, .ShareMessage', $personaCard).remove();
									}

									$('.PersonaInfo, .PersonaNavigation, .PersonaNavigationPrev a, .PersonaNavigationNext a', $personaCard).show();
									
									$.fn.personaCard.nav.init($personaCard, o);

									deltaY = business.members && business.members.length > 0 ? $('.PersonaInfo', $personaCard).height() - 37 : $('.BusinessInfo', $personaCard).height() - 126;
									if(yPos - deltaY < $(window).scrollTop()) {
										shiftCardUpwards = false;
									}
									
									if(shiftCardUpwards)  {
										$personaCardWrapper.animate({ top: '-='+(deltaY - 90)+'px' }, 100);
										}
									
							
									//attach user action events
									$('a.add_bookmark', $personaCardWrapper).oneShotAjax({}, function() {
										//omniture tracking add to radar trigger
										$('#AddBookmarkLink').trigger('success.add_radar.ax');
										$.fn.personaCard.killPopups(infoRequest);
										$('body').sysmessage('This person has been added to Your Radar.  They won\'t be notified, but you can keep up with their activity on the homepage and find them in <a href="https://www.openforum.com/connectodex/contacts">Your Contacts</a>.', {type: 'confirmation'});
									});
									
									$('a.add_connection', $personaCardWrapper).oneShotAjax({}, function() {
										//omniture tracking request a connection trigger
										$('#AddConnectodexLink').trigger('success.request_connection.ax');
										$.fn.personaCard.killPopups(infoRequest);
										$('body').sysmessage('Contact request sent', {type: 'confirmation'});
									});
									
									
									$('a.remove_bookmark', $personaCardWrapper).click(function() {
										var relationship = $(this).attr('rel');
										if(relationship == 'radar') {
											$('body').sysmessage('This person has been removed from Your Radar', {type: 'confirmation'});
										} else if(relationship == 'connection') {
											$('body').sysmessage('This person has been removed from Your Contacts', {type: 'confirmation'});
										}
											
									});

									$('a.remove_bookmark', $personaCardWrapper).oneShotAjax({}, function() {
										$.fn.personaCard.killPopups(infoRequest);
										if($('#LayoutWrapper').hasClass('YourContacts')) {
											$this.fadeOut('fast', function() {
												$(this).remove();
											});
										}
									});

									$('a.message', $personaCardWrapper).bindLoadMessageForm();
									$('a.message', $personaCardWrapper).click(function(){
										$.fn.personaCard.killPopups(infoRequest);
									});

									$('.preload_overlay', $personaCard).fadeOut(100);
								},
								error: function() { return; }
							});
						}
					}
				}, 750);
			}, function() {
				clearTimeout(hoverIntent);
				popupTimeout = setTimeout(function() {
					$.fn.personaCard.killPopups(infoRequest);
				}, 150);
			});
			
		});
	};

	$.fn.personaCard.nav = {
		init: function($personaCard, o) {
			var $personaNavWrapper = $('.PersonaNavigationWrapper', $personaCard).size() > 0 ? $('.PersonaNavigationWrapper', $personaCard) : null;
			var $personaNav = $('.PersonaNavigation', $personaCard);
			$('.overlay', $personaNav).animate({ opacity : 0.75 }, 1);			
			
			//activate default card view
			$.fn.personaCard.nav.activate($personaNav, $('li.Active', $personaNav), $personaNavWrapper);
			
			// enable switching between cards on click
			$('li', $personaNav).not('.Filler').click(function() {
				if(!$(this).hasClass('Active')) {
					var $personaNavCard = $(this);
					$.fn.personaCard.nav.activate($personaNav, $personaNavCard, $personaNavWrapper);
				}
			});
			
			// enable pagination if card count is over threshold
			if($personaNavWrapper && $personaNavWrapper.find('li').not('.Filler').size() >= o.navCarouselThreshold) {
				$personaNav.css('width', ($personaNavWrapper.find('li').outerWidth(true) + 10) * $personaNavWrapper.find('li').size());
				$('.PersonaNavigationNext', $personaNavWrapper).click(function() {
					if(!$('a', this).hasClass('Disabled')) {
						$.fn.personaCard.nav.next($personaNav, $personaNavWrapper);
					}
					return false;
				});
				$('.PersonaNavigationPrev', $personaNavWrapper).click(function() {
					if(!$('a', this).hasClass('Disabled')) {
						$.fn.personaCard.nav.prev($personaNav, $personaNavWrapper);
					}
					return false;
				});
			}
		},
		next: function($personaNav, $personaNavWrapper) {
			var $next = $('li.Active', $personaNav).next();
			if($next.size() > 0) {
				$.fn.personaCard.nav.activate($personaNav, $next, $personaNavWrapper);
			}
		},
		prev: function($personaNav, $personaNavWrapper) {
			var $prev = $('li.Active', $personaNav).prev();
			if($prev.size() > 0) {
				$.fn.personaCard.nav.activate($personaNav, $prev, $personaNavWrapper);
			}
		},
		transition: function($personaNav, direction) {
			$personaNav.animate({
				left: direction == 'left' ? '+=125px' : '-=125px'
			}, 100);
		},
		activate: function($personaNav, $personaNavCard, $personaNavWrapper) {
			$personaCard = $personaNavWrapper ? $personaNavWrapper.parent() : $personaNav.parent();
			$personaNavCard.addClass('Active').siblings('.Active').removeClass('Active');
			var activateIndex = $personaNavCard.prevAll().size();
			var $activatedCard;
			$activatedCard = activateIndex - 1 >= 0 ? $('.MemberInfo:eq('+(activateIndex-1)+')',$personaCard) : $('.BusinessInfo', $personaCard);
			$activatedCard.addClass('Active').siblings('.Active').removeClass('Active');
			
			if($personaNavWrapper) {
				if($personaNavCard.position().left  + $personaNav.position().left <= 0) {
					$.fn.personaCard.nav.transition($personaNav, 'left');
				} else if($personaNavCard.position().left + $personaNavCard.outerWidth() + $personaNav.position().left >= 337) {
				 	$.fn.personaCard.nav.transition($personaNav, 'right');
				}
				
				if($personaNavCard.prevAll().size() == 0) {
					$('.PersonaNavigationPrev a', $personaNavWrapper).addClass('Disabled');
				} else {
					$('.PersonaNavigationPrev a', $personaNavWrapper).removeClass('Disabled');
				}
				if($personaNavCard.nextAll().size() <= 0) {
					$('.PersonaNavigationNext a', $personaNavWrapper).addClass('Disabled');
				} else {
					$('.PersonaNavigationNext a', $personaNavWrapper).removeClass('Disabled');
				}
			}
		}
	};

	$.fn.personaCard.killPopups = function(infoRequest) {
		if(infoRequest) {
			infoRequest.abort();
		}
		if(!$.fn.personaCard.debug) {
			if($.browser.msie) {
				$('.PersonaCardWrapper').stop().remove();
				if($.browser.msie && $.browser.version < 7) {
					$('iframe.PersonaShim').stop().remove();
				}
			} else {
				$('.PersonaCardWrapper').stop().fadeOut('fast', function() {
					$(this).remove();
				});
				
			}
			
		}
	};
	
	$.fn.personaCard.debug = false;
	
	$.fn.personaCard.defaults = {
		navCarouselThreshold: 2,
		offsetX : 27,
		offsetY : 24,
		loadingWidth: 364,
		loadingHeight: 178,
		loadingBufferHeight: 122
	};	
	
$.fn.personaCard.template = '<div class="PersonaCard"><div class="preload_overlay"></div><div class="PersonaNavigationWrapper"><p class="PersonaNavigationPrev"><a href="#">Prev</a></p><p class="PersonaNavigationNext"><a href="#">Next</a></p><ul class="PersonaNavigation"><li class="BusinessAvatar Active"><div class="overlay"></div><p class="Avatar"><img src="a" height="64"  alt="" /></p></li><li class="MemberAvatar Template"><div class="overlay"></div><p class="Avatar"><img src="a" height="64" alt="Member Name" /></p></li></ul></div><ul class="PersonaInfo"><li class="BusinessInfo Active"><div class="AtAGlance"><p class="BusinessAvatar"><img src="a" width="111" height="73" alt="" /></p><h5><a href=""></a></h5><p class="BusinessLocation"></p><p></p><p><a href="">launch profile</a></p></div><p class="ShareMessage"><a href=""></a></p><div class="BusinessSeeksAndProvides"><div class="BusinessSeeks"><h6>They Seek</h6><ul></ul><p><a href="/connectodex/business_short_name#seeks">view more</a></p></div><div class="BusinessProvides"><h6>They Provide</h6><ul></ul><p><a href="/connectodex/business_short_name#provides">view more</a></p></div></div></li><li class="MemberInfo Template"><h5><a href=""></a></h5><p class="MemberTitle"></p><p></p><ul class="MemberActions"><li><a>Launch Profile</a></li><li><a href="/tools/RelationshipAddRemove.aspx?userguid=GUID&performaction=add" class="add_connection" id="AddConnectodexLink" title="Ask to add this person as a contact">Request a Connection</a></li><li><a href="/message-center/newmessage?userid=GUID" class="message">Send a Message</a></li><li><a href="/tools/RelationshipAddRemove.aspx?userguid=GUID&performaction=bookmark" class="add_bookmark" id="AddBookmarkLink" title="Follow without adding as a contact">Put On Your Radar</a></li><li><a href="/tools/RelationshipAddRemove.aspx?userguid=GUID&performaction=removebookmark" class="remove_bookmark">Remove from Radar</a></li></ul><p class="ShareMessage"><a href=""></a></p></li></ul></div>';

})(jQuery);


/* END 8.0:personacard.js */

/* BEGIN 9.0: jquery.tracking.js */

var parseTitle = function(type) { 
    var pageMeta = $('#LayoutWrapper').attr('class').split(' '); //returns ["Topic"], [MediaType], [TopicName] 
    if (type=='topic'){
        if (pageMeta.length == 3) return pageMeta[2].toLowerCase(); 
        else if (pageMeta.length == 2) return pageMeta[1].toLowerCase(); 
        else return pageMeta[0].toLowerCase();
    }
    else if (type=='media') return pageMeta[1].toLowerCase();       
};

var isPlaying = false;
function setVideoMetrics(video, action) {
	
	if($('#LayoutWrapper').hasClass('Topic') ||
		$('#LayoutWrapper').hasClass('Insuranceedge') ||
		$('#LayoutWrapper').hasClass('SearchManager')){
			
		var topicName = parseTitle('topic');
		var vidName = $('#ContentWell h5').text();
		var $PageWrapper = $('#PageWrapper');
		var $LayoutWrapper = $('#LayoutWrapper');
		

		if(action == 'onStart'){
			isPlaying = true;
			//Video play tracking here
			if (!$PageWrapper.hasClass('Rebrand') && !$LayoutWrapper.hasClass('msnbc')) {
				omn_rmvidstart(AX.TrackingData.pageTitle, AX.TrackingData.author);
			}
						
			if ($LayoutWrapper.hasClass('msnbc')){
				omn_rmvidstart('OF:' + $('#article_content h5 a').attr('href').split('/video/')[1], AX.TrackingData.author);
			}
						
		} else if (action == 'onComplete' && isPlaying){
			//Video end tracking here
			if (!$PageWrapper.hasClass('Rebrand') && !$LayoutWrapper.hasClass('msnbc')) {
				omn_rmvidcomplete(AX.TrackingData.pageTitle, AX.TrackingData.author);
			}

			if ($LayoutWrapper.hasClass('msnbc')){
				omn_rmvidcomplete('OF:' + $('#article_content h5 a').attr('href').split('/video/')[1], AX.TrackingData.author);
			}
			isPlaying = false;
		} 
	}
}

/* END 9.0: jquery.tracking.js */

/* BEGIN 10.0: jquery.featured_experts.js */
(function($) {
	
	// featured_experts plugin - operates on the 'ul' in a featured experts section
	$.fn.featured_experts_pager = function(options) {
	
		var opts = $.extend({}, $.fn.featured_experts_pager.defaults, options); // create options
		var trackClick = false;
		
		// primary plugin function
		return this.each(function() {
		
			$ul = $(this); // for later convenience
			
			//determine experts and sizes
			var experts = $('li', $(this)); // all expert items
			var pageCount = Math.ceil(experts.size() / opts.pageSize);
			
			// clean & create boxes
			var box = $('p.box:first', $(this).siblings('div.pager'));
			$(box).nextAll('p.box').remove(); //remove extras
			
			for(var i = 2; i <= pageCount; i++) {
				$(box).after(box.clone());
			}
			
			var boxes = $('p.box', $(this).siblings('div.pager')); // save boxes
			
			//show/hide numbers, show/hide pager
			
			if(pageCount <= 1) {
				$(this).siblings('div.pager').hide();
				$(this).siblings('div.numbers').hide();
			} else {
				$(this).siblings('div.pager').show();
				$(this).siblings('div.numbers').show();
			}
				
			// set maximum size text
			$('span#count', $(this).siblings('div.numbers')).text(experts.size());
			
			// Click handler for 'box' images
			$(boxes).click(function() {
			
				var myIndex = $(boxes).index($(this));
				
				// make clicked box the only 'active' box
				$(boxes).removeClass('active');
				$(this).addClass('active');
			
				// figure out the expert indices we should display
				var bottom = 1 + (myIndex * opts.pageSize); 
				var top = bottom + (opts.pageSize -1);
			
				if(top > experts.size()) { top = experts.size(); }
				if(experts.size() == 0) { bottom = 0; }
				
				// show only correct li elements
				experts.hide().slice(bottom - 1, top).show();
			
				//set correct text on readout labels
				$('span.bold', $ul.siblings('div.numbers')).text(bottom + " - " + top);
				
				if (!trackClick) {
					trackClick = true;
					return false;
				}
				
				var containingDiv = $(this).parents('div.pod_content');
				var name = containingDiv.prev().find('a.active').text().toLowerCase();
				var type = '';
				
				if (name == 'newest' || name == 'nearest') {
					type = 'connections';
				} else if (name == 'experts') {
					type = 'experts';
				}
				
				return false;
			});
				
			// Click handler for 'next' arrow
			$('p.next', $ul.siblings('div.pager')).unbind();
			$('p.next', $ul.siblings('div.pager')).click(function() {
				var nextBox = $(boxes).filter('p.box.active').next('.box');
				if(nextBox.length == 1) {
					nextBox.click();
				} 
				else {
					$(boxes).filter(':first').click();
				}
				return false;
			});
				
			// Click handler for 'prev' arrow
			$('p.prev', $ul.siblings('div.pager')).unbind();
			$('p.prev', $ul.siblings('div.pager')).click(function() {
				var prevBox = $(boxes).filter('.box.active').prev('.box');
				if(prevBox.length == 1) {
					prevBox.click();
				} 
				else {
					$(boxes).filter(':last').click();
				}
				return false;
			});
				
			// go to first page by default
			$(boxes).filter(':first').click();
			
			$ul.show();
			
		}); // end return for each
		
	};	// end init			

	// Default settings
	$.fn.featured_experts_pager.defaults = {
		pageSize: 6
	};

}) (jQuery);

/* End 10.0: jquery.featured_experts.js */

/* BEGIN 11.0: jquery.ajaxLoadContent.js */

/* jQuery filterList plugin
--------------------------------------------------*/

(function($) {

	$.fn.ajaxLoadContent = function(options) {

		// build main options before element iteration
		var opts = $.extend({}, $.fn.ajaxLoadContent.defaults, options);

		// iterate and reformat each matched element
		return this.each(function() {
			
			$this = $(this);
			
			// build element specific options
			var o = $.metadata ? $.extend({}, opts, $this.metadata()) : opts;
			
			if (o.trigger) {
				processAjaxLoad( o.trigger, o.component, o.content, o.container, o.preCallback, o.callback  );
			} else {
				$this.bind('click',function() {
					processAjaxLoad( $(this).attr('href'), o.component, o.content, o.container, o.preCallback, o.callback  );
					
					return false;
				});
			}

		});
		
	};
	
	function processAjaxLoad(ajaxLoadURL, component, content, container, preCallback, callback) {
		if (component) {
			ajaxLoadURL += '&component=' + component;
		}
		
		$.ajax({
			type: 'GET',
			url: ajaxLoadURL,
			dataType: 'html',
			cache: $.browser.msie ? false : true,
			success: function(html) {
				if ( ajaxSuccess(html) ) {
					// Pre callback
					if (preCallback && typeof(preCallback) == 'function') { preCallback(); }
					
					// Insert returned content into DOM
					if (component && !content) {
						$(container).html( html );
					} else if (content) {
						$(container).html( $(html).find(content).html() );
					}
				
					// Main callback
					if (callback && typeof(callback) == 'function') { callback(); }
				}
				
			}
		});
	}

	// plugin defaults
	$.fn.ajaxLoadContent.defaults = {
		trigger: null, // default is click
		component: null,
		content: null,
		container: null,
		preCallback: null,
		callback: null
	};
})(jQuery);


/* END 11.0: jquery.ajaxLoadContent.js */

/* BEGIN 12.0: jquery.carousel.js */

(function($) {

	$.fn.contactcarousel = function(options, beforeSend, callback) {
	
		var opts = $.extend({}, $.fn.contactcarousel.defaults, options);
		
		return this.each(function() {
			$this = $(this);
			$('ul', $this).wrap('<div class="carousel_wrapper"></div>');
			
			var liCount = $('li',$this).size();
			
			if(liCount > 0) {
				
				var div = $('.carousel_wrapper', $this);
				var o = $.metadata ? $.extend({}, opts, div.metadata()) : opts;

				if(!o.visible) {
					o.visible = 6;
				} 
				
				o.scroll = o.visible;
				
				if(liCount < o.circularThreshold && liCount % o.visible != 0 && liCount > o.visible) {
					var i = o.visible - liCount % o.visible;
					while(i-- > 0) {
						$('ul', $this).append('<li>&nbsp;</li>');
					}
				}
				
				var running = false, animCss = "left", sizeCss= "width";
				var ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;
				
				if(liCount > o.visible) {
					$this.prepend($('<p class="carousel_prev"><a href="#">prev</a></p><p class="carousel_next"><a href="#">next</a></p>'));
					
					if(o.circular) {
						ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());
						o.start += v;
					}
				} else {
					div.parent().addClass('single_pane');
				}

				var li = $("li", ul), itemLength = li.size(), curr = o.start;
				div.css("visibility", "visible");

				li.css({overflow: "hidden", 'float': "left", display: "block"});
				ul.css({margin: "0", padding: "0", position: "relative", listStyleType: "none", zIndex: 1, display: "block"});
				div.css({overflow: "hidden", position: "relative", zIndex: 2, left: "0px", display: "block"});
				
				if(liCount < o.visible) {
					div.css({left: "8px"});
				}
				var liSize = width(li);   
				var ulSize = liSize * itemLength;
				var divSize = liSize * v;
				
				li.css({width: li.width(), height: li.height()});
				ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));
				div.css(sizeCss, divSize+"px");
				
				if (o.boxPagination) {
					var pageCount = Math.ceil(liCount / o.pageSize);
					
					// clean & create boxes
					var box = $('p.box:first', $('div#boxPager'));
					$(box).nextAll('p.box').remove(); //remove extras
					
					for(var i = 2; i <= pageCount; i++) {
						$(box).after(box.clone());
					}
					
					var boxes = $('p.box', $('div#boxPager'));
					
					//show/hide numbers, show/hide pager
					if(pageCount <= 1) {
						$('div#boxPager').hide();
						$('div#boxNumbers').hide();
					} else {
						$('div#boxPager').show();
						$('div#boxNumbers').show();
					}
						
					// set maximum size text
					$('span#viewed_count', $('div#boxNumbers')).text(liCount);
					
					// Click handler for 'box' images
					$(boxes).click(function() {
						var currIndex = $(boxes).index($(boxes).filter('.box.active'));
						setActivePagerBox(this, o.pageSize);
						var newIndex = $(boxes).index($(boxes).filter('.box.active'));						
						
						if (currIndex > newIndex) {
							go(curr - (o.scroll * (currIndex - newIndex)), beforeSend, callback);
						} else {
							go(curr + (o.scroll * (newIndex - currIndex)), beforeSend, callback);
						}
						
						return false;
					});
					
					$('.carousel_prev', $this).click(function(e) {
						if (!running) {
							var prevBox = $(boxes).filter('.box.active').prev('.box');
							if(prevBox.length == 1) {
								setActivePagerBox(prevBox, o.pageSize);
							} 
							else {
								setActivePagerBox($(boxes).filter(':last'), o.pageSize);
							}
							
							return true;
						}
						return false;
					});

					$('.carousel_next', $this).click(function(e) {
						if (!running) {
							var nextBox = $(boxes).filter('p.box.active').next('.box');
							if(nextBox.length == 1) {
								setActivePagerBox(nextBox, o.pageSize);
							} 
							else {
								setActivePagerBox($(boxes).filter(':first'), o.pageSize);
							}
							
							return true;
						}
						return false;
					});

					setActivePagerBox($(boxes).filter(':first'), o.pageSize);
				}

				$('.carousel_prev', $this).click(function(e) {
					go(curr-o.scroll, beforeSend, callback);
					return false;
				});

				$('.carousel_next', $this).click(function(e) {
					go(curr+o.scroll, beforeSend, callback);
					return false;
				});
				
				function vis() {
					return li.slice(curr).slice(0,v);
				};

				function go(to, beforeSend, callback) {
					if(callback && typeof(callback) == 'function')
						beforeSend();

					if(!running) {

						if(o.beforeStart)
							o.beforeStart.call(this, vis());

						if(o.circular) {
							if(to<=o.start-v-1) {
								ul.css(animCss, -((itemLength-(v*2))*liSize)+"px");
								curr = to==o.start-v-1 ? itemLength-(v*2)-1 : itemLength-(v*2)-o.scroll;
							} else if(to>=itemLength-v+1) { 
								ul.css(animCss, -( (v) * liSize ) + "px" );
								curr = to==itemLength-v+1 ? v+1 : v+o.scroll;
							} else curr = to;
						} else {                    
							if(to<0 || to>itemLength-v) return;
							else curr = to;
						}                           
						running = true;

						ul.animate(
							animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
							function() {
								if(o.afterEnd)
									o.afterEnd.call(this, vis());
									running = false;
							}
						);

						if(!o.circular) {
							$(o.btnPrev + "," + o.btnNext).removeClass("disabled");
							$( (curr-o.scroll<0 && o.btnPrev) || (curr+o.scroll > itemLength-v && o.btnNext) || []).addClass("disabled");
						}
					}

					if(callback && typeof(callback) == 'function')
						callback();

					return false;
				};
				
			} else {
				$this.find('.carousel_wrapper').addClass('inactive_carousel');
			}
			
		$this.hide(1, function() { $(this).show(); });
	
		});

	};
	
	function css(el, prop) {
		return parseInt($.css(el[0], prop), 10) || 0;
	};
	function width(el) {
		return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
	};
	function height(el) {
		return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
	};
	
	function setActivePagerBox(box, pageSize) {
		// make clicked box the only 'active' box
		$('p.box', $('div#boxPager')).removeClass('active');
		$(box).addClass('active');
		
		//set correct text on readout labels
		var bottom = getBottomIndex(box, pageSize);
		var top = getTopIndex(box, pageSize, bottom);
		
		$('span.bold', $('div#boxNumbers')).text(bottom + " - " + top); 
	};

	function getBottomIndex(box, pageSize) {
		var myIndex = $('p.box', $('div#boxPager')).index($(box));
		
		var bottom = 1 + (myIndex * pageSize);
		if($('div#viewed ul li').size() == 0) { bottom = 0; }
		
		return bottom;
	};

	function getTopIndex(box, pageSize, bottom) {
		var myIndex = $('p.box', $('div#boxPager')).index($(box));
		
		var upperLimit = parseInt($('span#viewed_count', $('div#boxNumbers')).text());
		
		var top = bottom + (pageSize - 1);
		if(top > upperLimit) { top = upperLimit; }
		
		return top;
	};
	
	$.fn.contactcarousel.defaults = {
		btnPrev: null,
		btnNext: null,
		btnGo: null,
		mouseWheel: false,
		auto: null,
		speed: 500,
		easing: null,
		vertical: false,
		circular: true,
		visible: null,
		start: 0,
		scroll: null,
		beforeStart: null,
		afterEnd: null,
		circularThreshold: 60,
		boxPagination: false,
		pageSize: 4
	};


}) (jQuery);

/* END 12.0: jquery.carousel.js */

/* BEGIN 13.0: shortenUrl */

(function() {

	$.fn.shortenUrl = function(options) {
		var opts = $.extend({}, $.fn.shortenUrl.defaults, options);
		return this.each(function() {
			var 
				$this = $(this),
				o = $.meta ? $.extend({}, opts, $this.data()) : opts,
				baseUrl = $this.attr('href'),
				targetUrl;
				
				typeof opts.target == "undefined" ? targetUrl = window.location.href : targetUrl = opts.target;

			if (window.location.protocol == 'http:') {
				// Only shorten if we're in http since bit.ly generates http:// requests and if we're
				// in https we'll get mix security warnings
				$.fn.shortenUrl.shorten(targetUrl, function(data) {
					$this.attr('href', baseUrl + data['results'][targetUrl]['shortUrl']);
				}, o);
			} else {
				$this.attr('href', baseUrl + targetUrl);
			}
		});
	};
	
	$.fn.shortenUrl.shorten = function(url, callback, options) {
		var opts = $.extend({}, $.fn.shortenUrl.defaults, options);
		$.ajax({
			url: opts.url,
			type: 'get',
			dataType: 'jsonp',
			data: {
				longUrl: url,
				version: opts.version,
				login: opts.login,
				apiKey: opts.apiKey
			},
			success: function(data) {
				callback(data);
			}
		});
	};
	
	$.fn.shortenUrl.defaults = {
		url: 'http://api.bit.ly/shorten',
		apiKey: 'R_80e4ab6bded5efc219610968a07c7270',
		login: 'openforum',
		version: '2.0.1'
	};

})(jQuery);



/* END 13.0: shortenUrl */

/* BEGIN: tout tooltips */
$(document).ready(function () {

	if (typeof $().accordion === 'function') {
		AX.setupAccordion();
	}
	/*
	if ($('.loginLinks')) {
		var registerText = $('.loginLinks li.register a').attr('title');
		var loginText = $('.loginLinks li.login a').attr('title');
		var tteleReg = "<span class=\"tooltip\">" + registerText + "</span>";
		var tteleLog = "<span class=\"tooltip\">" + loginText + "</span>";
		var dumb = 'stupid';
		$('.loginLinks li.register a').append(tteleReg);
		$('.loginLinks li.login a').append(tteleLog);
		$('.loginLinks li.register a').removeAttr('title');
		$('.loginLinks li.login a').removeAttr('title');
		$('.loginLinks li.register a,.loginLinks li.login a').hover(
			function () {
				$(this).addClass('Hover');
			},
			function () {
				$(this).removeClass('Hover');
			}
		);
	}
	*/
	//External Link Catches
	$(document.body).delegate('a[rel]', 'click', function (e) {
		if ($(this).attr('rel') == 'external') {
			e.preventDefault();
			window.open($(this).attr('href'));
		}
	});

	//Functionality controls ToutWelcome.ascx
	AX.welcomeBanner = function () {
		var $banner = $('#welcome_banner');
		var track = function () {
			var source = $('#LayoutWrapper');
			switch (true) {
				case source.hasClass('Articles'):
					source = 'article';
					break;
				case source.hasClass('Videos'):
					source = 'video';
					break;
				default:
					source = 'home';
					break;
			}
			$('li a', $banner).click(function () {
				var rel = $(this).attr('rel');
				var source = $('#LayoutWrapper');
				switch (true) {
					case source.hasClass('Articles'):
						source = 'article';
						break;
					case source.hasClass('Videos'):
						source = 'video';
						break;
					default:
						source = 'home';
						break;
				}
			});
		};
		var bindClose = function () {
			$('.close a', $banner).click(function (e) {
				$banner.fadeOut(400);
				return false;
			});
		};
		var setCookie = function () {
			var expiry = new Date();
			expiry.setTime(expiry.getTime() + (1000 * 60 * 60 * 24 * 30));
			expiry.toGMTString();
			$.cookie('hasVisited', 'true', { path: '/', expires: expiry });
		};
		var init = function () {
			if (!$.cookie('hasVisited') && $banner.size() > 0) {
				$banner.show();
				track();
				bindClose();
			}
			//refresh cookie each visit (set 30days from current)
			setCookie();
		};
		return {
			init: init
		}
	} ();
	AX.welcomeBanner.init();

	//shareLinkClickBehavior();

});
/* END: tout tooltips */

(function($) {
    var buildAnimations = function(markup) {
        // For each li.response we find in the given jQuery object
        // we build a function that will animate the progress bar to
        // a calculated width
        //
        // We then return a function that will iterate and call each
        // individual animate function
		
        var animations = [];
        markup.each(function() {
			var pollResultMarkup = $(this);
			var responses_list = pollResultMarkup.find('ul.poll_responses');
			var responses = responses_list.find('.response');

			var animation_time = responses_list.parents('.poll_small').length >= 1 ? 750 : 1500;

			responses.each(function() {
				var li = $(this);

				var bar = li.find('div.bar');
				var shadow = $('<div class="shadow">');
				var percent = bar.metadata()['percent'];

				bar.append(shadow);

				bar.css('width', 0);

				animations.push(function(width) {
					var target = percent * width + 'px';
					bar.animate({ width: target }, animation_time, function() {
						if (percent > 0 && percent < 1) {
							shadow.css('left', target);
							shadow.fadeIn(1000);
						}
					});
				});
			});
        });

        return function(width) {
            for (var i in animations) {
                animations[i](width);
            }
        };
    };

    var transition = function(toHide, toShow, afterFadeOut) {
        // Given toHide, and toShow, fadeOut toHide call 'afterFadeOut' which *must* take a function
        // and call it at the end.  That anon func will do further animation finally calling afterFadeIn
        // provided to it.
        //
        // This is so we can progress from 'take the poll' to results, and use the same tranistion effects for
        // 'take this poll' link on the discussion list to go back to 'take the poll'

        var inlineReplace = toHide.attr('class') == toShow.attr('class');
        var hideElement = toHide;

        if (!inlineReplace) {
            toShow.hide(); // Make sure it's not showing before we try and fade it in

            // What we want to hide might be wrapped in a animation wrapper; if it is then we'll use
            // the wrapper for the fadeOut call instead of the toHide element
            var toHideAnimationWrapper = toHide.parents('.poll_animation_wrapper');
            hideElement = toHideAnimationWrapper.length >= 1 ? toHideAnimationWrapper : toHide;
        }

        // We wrap the toShow div in a animation wrapper.  This wrapper has its height set to the fadeOutDiv
        // and then is animated to the toShow height
        var toShowAnimationWrapper = toShow.parents('.poll_animation_wrapper');
        if (toShowAnimationWrapper.length < 1) {
            toShow.wrap('<div class="poll_animation_wrapper">');
            toShowAnimationWrapper = toShow.parents('.poll_animation_wrapper');
        }

        var toHideHeight = hideElement.height();

		var fadeTime = 500;
        hideElement.fadeOut(fadeTime, function() {
			// Set our wrapper to the height of the div we just faded out, so that the page doesn't (visibily) reflow
			toShowAnimationWrapper.height(toHideHeight);
			toShowAnimationWrapper.show();

			if (!inlineReplace) {
				// This is hidden now, so reset its height so that if this ever becomes the div we're going to
				// show (and therefore animate its height) the page doesn't jump around funny
				toHideAnimationWrapper.height(0);
			}

			var animateAndFadeIn = function(afterFadeIn) {
				toShowAnimationWrapper.animate({ height: toShow.height() }, function() {
					toShowAnimationWrapper.height('auto');
					toShow.fadeIn(fadeTime, afterFadeIn);
				});
			};

			if ($.isFunction(afterFadeOut)) {
				afterFadeOut(animateAndFadeIn);
			} else {
				animateAndFadeIn();
			}
        });
    };

	var findClass = function(elements, clsName) {
		for (var i = 0; i < elements.length; i++) {
			var e = $(elements[i]);
			if (e.hasClass(clsName)) {
				return e;
			}
		}
		
		return undefined;
	};

    var renderPollResults = function(toHide, toShow, fetchMarkup) {
        // Transition between toHide to toShow
        // first we fetch the markup, and build our animations
        // then we fadeOut, set the html on toShow, fadeIn and animate
		
		fetchMarkup(function(html) {
			//var pollResults = $(html).find('div.poll_results');
			
			var pollResults = findClass($(html), 'poll_results_target');
			
			if (pollResults == undefined || pollResults.find('div.poll_results').length <= 0) {
				$('body').sysmessage('Unable to process the poll results, please try again later.');
				return;
			}
			
			var markup = $(pollResults.html());
			var animateProgressBars = buildAnimations(markup);

			transition(toHide, toShow, function(animateAndFadeIn) {
				toShow.html(markup);
		        
				bindResultsViewClicks();
				bindTakeThisPollClick();

				animateAndFadeIn(function() {
					animateProgressBars(toShow.find('div.progress:first').width());
				});
			});
		});
    };
    
    var track = function(element, poll_wrapper, type) {
		var pageName = $('#PageWrapper').attr('class') == 'FrontDesk' ? 'home' : 'discussion_detail';
		var topicName = parseTitle('topic');
		
		var pollName = $.trim(poll_wrapper.find('.poll_question').text());
		
		if (pollName == '') {
			pollName = $.trim($('.topic_details .topic_title').text());
		}
		
		if(pollName.length > 45) {
			pollName = pollName.substring(0, 45) + '...';
		}
		
		var e = 'poll:'+pageName+':'+topicName+':'+pollName+':'+type;
		
	};
    
    var bindTakeThisPollClick = function() {
        $('p.take_this_poll a').click(function() {
			var link = $(this);
            var toHide = $(this).parents('div.poll_results_target');
            var toShow = $('div.poll_target');

			$.get(link.attr('href'), function(html) {
				var pollTarget = findClass($(html), 'poll_target');
				
				if (pollTarget == undefined || pollTarget.find('div.poll').length <= 0) {
					$('body').sysmessage('Unable to retrieve the poll options, please try again later.');
					return;
				}
				
				transition(toHide, toShow, function(animateAndFadeIn) {
					toShow.html(pollTarget.html());
					
					bindPollClick();
					
					animateAndFadeIn();
				});	
			});

            return false;
        });
    };

    var bindResultsViewClicks = function() {
        $('div.poll_share_header a').click(function() {
            $(this).parents('div.poll_share').find('div.poll_share_links').toggle();
            $(this).toggleClass('hidden');
            
            $(this).parents('div.poll_share').find('div.poll_share_links p.share a').attr("target", "_blank");

            return false;
        });
        
        $('.poll_results .view_comments a').click(function() {
			track(this, $(this).parents('div.poll_results_target'), 'join_conversation');
        });
        
        $('.poll_share p.share a').click(function() {
			var type = $(this).attr('class');
			
			track(this, $('div.poll_results'), 'share_' + type);
        });
    };

    var bindPollClick = function() {
        
        var process = function(element, trackType, fetch) {
			// This function assumes that there will only ever be
			// one results target.  If we ever want to do ajax
			// voting / result viewing in discussion list this will
			// have to be changed
			
			var toHide = element.parents('div.poll_target');
            var toShow = $('div.poll_results_target');
            
            var pollForm = element.parents('form.poll_vote_form');
            var url = pollForm.attr('action');
            
            track(element, toHide, trackType);
            
            var fetchMarkup = fetch(url, pollForm);
            
            if ($.isFunction(fetchMarkup)) {
				renderPollResults(toHide, toShow, fetchMarkup);
            }
        };
        
        var validateVoteOptions = function(pollForm) {
			var numberChecked = $('input[type=radio]:checked', pollForm).length;
				
			if (numberChecked <= 0) {
				var messageString = "Please click your poll choice. Did you mean to view the <span>results</span>?";
				$("body").sysmessage(messageString);
			}
			
			return numberChecked;
        };
        
        $('a.view_poll_results').click(function() {
            process($(this), 'view_results', function(url, pollForm) {
				return function(callback) {
					var e = {
						pollGuid : pollForm.find("[name=pollGuid]").val(),
						viewOptions : pollForm.find("[name=resultsViewOptions]").val()
					};
					
					if (e.pollGuid == undefined ||
						e.viewOptions == undefined) {
						
						$('body').sysmessage('Unable to retrieve the poll results right now, please try again later.');
						return;
					}
				
					$.get(url, e, callback);
				};
            });
            return false;
        });

        $('a.btn_poll_vote').click(function() {
            process($(this), 'vote', function(url, pollForm) {
				if (validateVoteOptions(pollForm) <= 0) {
					return false;
				}
				
				return function(callback) {
					var e = {
						pollGuid : pollForm.find("input[name='pollGuid']").val(),
						viewOptions : pollForm.find("input[name='viewOptions']").val(),
						resultsViewOptions : pollForm.find("input[name='resultsViewOptions']").val(),
						optionGuid : pollForm.find("input[name='optionGuid']:checked").val()
					};
					
					if (e.pollGuid == undefined ||
						e.viewOptions == undefined ||
						e.resultsViewOptions == undefined ||
						e.optionGuid == undefined) {
						
						$('body').sysmessage('Unable to submit your vote right now, please try again later.');
						return;
					}
					
					$.post(url, e, callback);
				};
            });

            return false;
        });
    };

    $.fn.thisWeeksPoll = function() {
        bindPollClick();
        bindResultsViewClicks();
        bindTakeThisPollClick();

        var animateProgressBars = buildAnimations($('div.poll_results'));
        animateProgressBars($('div.poll_results div.progress:first').width());
    };
})(jQuery);

// Process message list utilities 
$.fn.bindMessageUtilityForm = function() {
	var messageCount = parseInt($('li#NavMessageCenter a.DrawerSubNavA em span').text());
	
	$('#message_form').submit(function() {
		
		if ( $('#message_form input:checkbox:checked').size() == 0 ) {
			$('body').sysmessage('No messages were selected.', {type: 'error'});
		} else {
			var inputs = "select_actions=" + $('input[name=select_actions]:checked').val() + "&guids=";
			$('#message_form input:checkbox:checked').each(function() {
				inputs += $(this).val() + ',';
			});
			
			$.ajax({
				type: "POST",
				url: $(this).attr('action') + "?component=message-action",
				data: inputs.substr(0,(inputs.length - 1)),
				success: function(data) {
					if ( ajaxSuccess(data) ) {
						
						var radioValue = $('input[name=select_actions]:checked').val();
						
						// mark as read
						if ( radioValue == "mark as read" ) {
							$(':checkbox:checked').each(function() {
								if ( $(this).parent().parent().find('p').hasClass('message_new') ) {
									messageCount = messageCount - 1;
								}
							});

							//omniture tracking marked as read
							$('#mark_as_read').trigger('success.mark_as_read.ax');
							
							$(':checkbox:checked').attr('checked','').parent().parent().find('p.message_new, div.ContactIcon').fadeOut('fast');
						};
	
						// delete message
						if ( radioValue == "delete marked" || radioValue == "block marked users" ) {
							
							//retrieve num of messages on current page; store num messages deleted
							var messageNum = $('ul#messages li').length;
							var numDeleted = 0;
							
							//retrieve current page num; retrieve current page view; retrieve next page val
							var pageNum = parseInt($('.pagination ul li a.active').text(), 10);
							var pageView = $('#TabNav li.active a').text();
							var nextPage = $('.pagination a.active').parent().next('li').find('a');
							
							$(':checkbox:checked').each(function() {
								numDeleted++;
								
								if ( $(this).parent().parent().find('p').hasClass('message_new') ) {
									messageCount = messageCount - 1;
								}
							});
							
							$(':checkbox:checked').attr('checked','').parent().parent().fadeOut('fast',function() {
								$(this).remove();

								// Re-stripe rows
								$.fn.stripe('ul#messages');
								
							});
							
							// determine page behavior depending on current and next page
							if (pageNum > 1){
								if(nextPage.hasClass('disabled')) pageNum = pageNum-1;
							} else pageNum = 1; 
							
							var currentSort = $('#message_tools #customList-message_filter .customList-title span').text().toLowerCase();
							var sortType = currentSort.substring(0,2) == 'by' ?  currentSort.substring(3) : 'pendingConnections';
							
							//retrieve view specific message list -- clean up 
							if (pageView == 'Sent'){
								$.ajax({
									type: 'GET',
									url: '/message-center/sent?component=message_list&pagenumber='+pageNum+'&sorttype='+sortType,
									dataType: 'html',
									cache: $.browser.msie ? false : true,
									success: function(html) {
										if ( ajaxSuccess(html) ) {
											$('#message_list_content').html( html );
											$.fn.markNewMessages();
											$.fn.messagePagination();
											$.fn.bindLoadMessageUtilityActions();
											$.fn.bindSubmitLinks();
											$('ul#messages .ContactIcon').personaCard();
										}
									}
								});  
							} else{
								$.ajax({
									type: 'GET',
									url: '/message-center/?component=message_list&pagenumber='+pageNum+'&sorttype='+sortType,
									dataType: 'html',
									cache: $.browser.msie ? false : true,
									success: function(html) {									
										if ( ajaxSuccess(html) ) {
											$('#message_list_content').html( html );
											$.fn.markNewMessages();
											$.fn.messagePagination();
											$.fn.bindLoadMessageUtilityActions();
											$.fn.bindSubmitLinks();
											$('ul#messages .ContactIcon').personaCard();
										}
									}
								});  
							}					  
						};
						
						if (messageCount <= 0) {
							$('li#NavMessageCenter a.DrawerSubNavA em').remove();
						} else {
							$('li#NavMessageCenter a.DrawerSubNavA em span').text(messageCount);
						}
						
					}
				}
				
			});
		
		}
		
		return false;
	});
};

/*
$.fn.setPaginationWidth = function() {
	
	if ($('div.pagination').length > 0) {
		// IE fix to reduce gap between previous and 1st page buttons
		$('div.pagination li a.disabled').parent().css("margin", "0px");
		
		// Determine the size of the pagination ul so we can center it
		var width = 0;
		$('div.pagination li').each(function() {
			width += $(this).width() + 9;
		});
		
		$('div.pagination ul').css('width', width - 5);		
	}
}*/










var _c = _c || {};
var AX = AX || {};

AX.Utilities = (function (window, document) {
	var _emailRegex = /^([A-Za-z0-9_\+\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	var _zipRegex = /(^\d{5}(-\d{4})?$)|(^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$)/;

	var testElem = document.createElement('test');
	var testStyle = testElem.style;

	var self = {
		testFor : {

			ie7 : function(){
				return $('html').hasClass('ie7');
			},

			csstransitions : function() {
				return self.testFor.test_props_all( 'transitionProperty' );
			},
			
			test_props_all : function ( prop ) {
				var uc_prop = prop.charAt(0).toUpperCase() + prop.substr(1),
				props = [
					prop,
					'Webkit' + uc_prop,
					'Moz' + uc_prop,
					'O' + uc_prop,
					'ms' + uc_prop,
					'Khtml' + uc_prop
				];
				return !!self.testFor.test_props( props );
			},
			
			test_props : function ( props ) {
				for ( var i in props ) {
					if ( testStyle[ props[i] ] !== undefined ) {
						return true;
					}
				}
			}
		}
	};
	return self;
})(this, this.document);

AX.openContentOverlay = function () {

	var speed = _c.ie7 ? 0 : 250;
			
	if ( $('#site_overlay').length === 0 ) {
		var $siteOverlay = $('<div id="site_overlay" />');
		$('#Top_Menu').parent().append($siteOverlay);
		$('#site_overlay').bind('click', function(){
			if ( _c.$headerGlobal.$search.hasClass('active') || $search.hasClass('opened') ) {
				_c.$headerGlobal.$search.children('a').trigger('click');
			}
		});
	};

	clearTimeout(_c.headerInteractionTimeout);	
	_c.headerInteractionTimeout = setTimeout(function(){
		$('#site_overlay').show().stop().fadeTo(speed, 0.6);
	}, speed);

};

AX.closeContentOverlay = function () {
	
	var speed = _c.ie7 ? 0 : 250;

	clearTimeout(_c.headerInteractionTimeout);	
	_c.headerInteractionTimeout = setTimeout(function(){
		$('#site_overlay').stop().fadeTo(speed, 0, function() {
			$(this).hide();
		});
	}, speed);
};

AX.repositionHeader = {
	
	Test: function(){
		if (_c.topMenuVerticalOffset <= $(window).scrollTop()) {
			_c.$topMenu.addClass('page_scrolled');
		} else {
			_c.$topMenu.removeClass('page_scrolled');
		}
	}
};  

AX.openSeeMoreDropdown = function(){
	AX.closeSearchDropdown();
	AX.openContentOverlay();
	if ( _c.cssTransitions || _c.ie7 ) {
		_c.$headerGlobal.$seeMore.addClass('active');
	} else {
		_c.$headerGlobal.$searchField.blur();
		_c.$headerGlobal.$seeMore.addClass('active').find('#see_more_dropdown').delay(250).stop().animate({'top':'90px'}, 400);
	}
};

AX.closeSeeMoreDropdown = function(){
	AX.closeContentOverlay();
	if ( _c.cssTransitions || _c.ie7 ) {
		_c.$headerGlobal.$seeMore.removeClass('active');
	} else {
		_c.$headerGlobal.$seeMore.find('#see_more_dropdown').delay(250).stop()
			.animate({'top':'-255px'}, 400, function(){
				_c.$headerGlobal.$seeMore.removeClass('active');
			});
	}
};

AX.openSearchDropdown = function(){
	AX.openContentOverlay();
	if ( !_c.$headerGlobal.$search.hasClass('active') && !_c.$headerGlobal.$search.hasClass('opened') ) {
		if ( _c.cssTransitions || _c.ie7 ) {
			_c.$headerGlobal.$search.addClass('active');
			_c.$headerGlobal.$searchField.focus().val('');	
		} else {
			_c.$headerGlobal.$searchField.val('');
			_c.$headerGlobal.$search.addClass('active').addClass('opened').find('.small_dropdown').show().delay(250).stop()
				.animate({'top':'90px'}, 400, function(){
					_c.$headerGlobal.$searchField.focus();
				});
		}
	}
};

AX.closeSearchDropdown = function(){
	if ( _c.$headerGlobal.$search.hasClass('active') || _c.$headerGlobal.$search.hasClass('opened') ) {
		AX.closeContentOverlay();
		if ( _c.cssTransitions || _c.ie7 ) {
			_c.$headerGlobal.$search.removeClass('active');
			if ( _c.$headerGlobal.$searchField.attr('id') === document.activeElement.id ) {
				_c.$headerGlobal.$searchField.blur();	
			}
		} else {
			_c.$headerGlobal.$search.removeClass('opened').find('.small_dropdown').show().delay(250).stop()
				.animate({'top':'-70px'}, 400, function(){
					_c.$headerGlobal.$search.removeClass('active');
					if ( _c.$headerGlobal.$searchField.attr('id') === document.activeElement.id ) {
						_c.$headerGlobal.$searchField.blur();	
					}
				});
		}
	}	
};

AX.headerGlobalSetup = function(){

	$(window).bind('scroll', function () {
		AX.repositionHeader.Test();
	});
	AX.repositionHeader.Test();

	_c.cssTransitions = AX.Utilities.testFor.csstransitions();
	_c.ie7 = AX.Utilities.testFor.ie7();

	_c.$headerGlobal = _c.$headerGlobal || {};

	_c.$headerGlobal.$menu = $('#Header_Global_Menu');
	_c.$headerGlobal.$featuredFocus = _c.$headerGlobal.$menu.find('.featured:last > a');
	_c.$headerGlobal.$search = _c.$headerGlobal.$menu.find('.search');
	_c.$headerGlobal.$searchDropdown = _c.$headerGlobal.$search.find('.small_dropdown');
	_c.$headerGlobal.$searchClick = _c.$headerGlobal.$menu.find('.search > a');
	_c.$headerGlobal.$searchField = _c.$headerGlobal.$search.find('#site_search_keyword');
	_c.$headerGlobal.$searchSubmit = _c.$headerGlobal.$search.find('#site_search_submit');
	_c.$headerGlobal.$seeMore = _c.$headerGlobal.$menu.find('.see_more');
	_c.$headerGlobal.$seeMoreClick = _c.$headerGlobal.$menu.find('.see_more > a');
	_c.$headerGlobal.$seeMoreFocus = _c.$headerGlobal.$seeMore.find('a:first, a:last');

	var _d = _c.$headerGlobal;

	if ( !_c.cssTransitions && !_c.ie7 ) {
		_d.$seeMore.find('#see_more_dropdown').css('top','-255px');
		_d.$search.addClass('opened').find('.small_dropdown').css('top','-70px');
	}

	_d.$featuredFocus.bind('focus', function(){
		AX.closeSeeMoreDropdown();
	});

	_d.$seeMoreClick.bind('click',function(e){
		e.preventDefault();		
	});

	_d.$seeMore.hover( 
		function(e){ AX.openSeeMoreDropdown(); },
		function(e){ AX.closeSeeMoreDropdown(); }
	);

	_d.$seeMoreFocus.bind('focus', function(e){
		AX.openSeeMoreDropdown();
	});

	_d.$searchClick.bind('click', function(e){
		e.preventDefault();
		if ( _d.$search.hasClass('opened') || _d.$search.hasClass('active') ) {
			AX.closeSearchDropdown();
		} else {
			AX.openSearchDropdown();
		}
	});

	_d.$searchDropdown.bind('mouseover', function (e) {
		AX.openSearchDropdown();
	});

	_d.$searchField.bind('focus', function(e){
		AX.closeSeeMoreDropdown();
		AX.openSearchDropdown();
	});

	_d.$searchSubmit.bind('blur', function(e){
		AX.closeSearchDropdown();
	});

};

AX.setupCustomSelect = function () {
	$('.input_select.custom').each(function () {
		var $this = $(this),
					polyfill = '<span class="selected" /><span class="cap_left" /><span class="cap_right" />';
		$this.find('select').wrap('<span />').before(polyfill).bind('change', function () {
			$this.find('.selected').text($.text($this.find(':selected')));
		});
		$this.find('.selected').text($.text($this.find(':selected')));
	});
};

AX.bindGlobalSearch = function () {
  $('#text_form_search_footer').focus(function () {
    if ($(this).val() == this.defaultValue) $(this).val('');
  }).blur(function () {
    if ($(this).val() === '') $(this).val(this.defaultValue);
  });
  $('#Global_Search,#form_search_footer').submit(function (e) {
    var $searchForm = $(this),
	txtField = $searchForm.find('input[type~="text"]');
    return txtField.val() != 'Search OPEN Forum' && txtField.val() != '';
  });
}

AX.safariFiveMac = function(){
	return (
		navigator.appVersion.split('5.')[0].length == 0 &&
		typeof navigator.appVersion.split('5.')[1] == 'string' &&
		typeof navigator.vendor !== 'undefined' &&
		navigator.vendor.search('Apple') > -1 &&
		navigator.platform.search('Mac') > -1
	);
};

$(document).ready(function () {
	_c.$topMenu = $('#Top_Menu');
	if ( _c.$topMenu.length > 0 ) _c.topMenuVerticalOffset = _c.$topMenu.offset().top;
	_c.headerInteractionTimeout;
	AX.headerGlobalSetup();
	AX.bindGlobalSearch();
	if (AX.safariFiveMac()) $('html').addClass('safariFiveMac');
});

