// For AddtoAny
var a2a_prioritize=["linkedin"];
// Lines below opt out of 3rd-party tracking--but do they disable Google Analytics integration?
//var a2a_config = a2a_config || {};
//    a2a_config.no_3p = 1;
// Some global variables for openPopup() below
var WindowObjectReference = null; // global variable for openPopup()
var popupFeatures = 'scrollbars,resizable,location=0,statusbar=0,'
	+ 'menubar=0,';
var defaultWidth = 500;
var defaultHeight = 400;

// Equal height divs fix (from http://andreaslagerkvist.com/jquery/equal-height/)
// NOTE: Here as well as in independent file so it can be run separately
jQuery.fn.equalHeight = function () {
    var height        = 0;
    var maxHeight    = 0;
    // Store the tallest element's height
    this.each(function () {
        height        = jQuery(this).outerHeight();
        maxHeight    = (height > maxHeight) ? height : maxHeight;
    });
    // Set element's min-height to tallest element's height
    return this.each(function () {
        var t            = jQuery(this);
        var minHeight    = maxHeight - (t.outerHeight() - t.height());
        var property    = jQuery.browser.msie && jQuery.browser.version < 7 ? 'height' : 'min-height';
        t.css(property, minHeight + 'px');
    });
};

///////////// ADD COMMAS TO A NUMBER //////////////
function addCommas(n) {
	n = n.toString(); // Convert number to string
	var len = n.length;
	var fn='';
	if (len > 3) { // If over 3 digits, add commas
		for (i = len-3; i > 0; i -= 3) {
			fn = "," + n.substr(i,3) + fn;
		}
		return(n.substr(0, i+3) + fn);
	} else {
		return(n); // Otherwise, just return original number
	}
}

////////////////// WINDOW POPUPS ///////////////////////////////// 
// Return the parameters to center a popup window on the browser screen
function windowCenteringInfo(myWidth, myHeight) {
	var info = '';
	if (window.screen) {
		var x_pos = parseInt(screen.availWidth/2) - (myWidth/2);
		var y_pos = parseInt(screen.availHeight/2) - (myHeight/2);
		info += ",left=" + x_pos; // offset from left
		info += ",screenX=" + x_pos; 
		info += ",top=" + y_pos; // offset from top
		info += ",screenY=" + y_pos; 
	}
	return info;
}
// Window popup function and associated variables; adapted from developer.mozilla.org
// Usage: <a href="http://www.nceo.org/" target="aName" onclick="openPopup(this.href, this.target);">link text</a>
// Or with optional params: ...onclick="openPopup(this.href, this.target, 200, 300)...
// Don't use _blank as target because it will open a new tab (FF) or window (MSIE) as well as the popup
function openPopup(strUrl, strWindowName, width, height) {
	if ((typeof(width) == 'undefined') || (typeof(height) == 'undefined')) {
		width = defaultWidth; 
		height = defaultHeight;
	}
	// strWindowName = strWindowName ? strWindowName : '_blank';
	popupFeatures += 'width=' + width + ',height=' + height;
	popupFeatures += windowCenteringInfo(width, height);
	// Create window (for this popup only) if it doesn't exist; otherwise, just bring to front
	if (WindowObjectReference == null || WindowObjectReference.closed) {
		WindowObjectReference = window.open(strUrl, strWindowName, popupFeatures);
		WindowObjectReference.focus();
	}
	WindowObjectReference.focus();
	// Cancel link in calling window if popup was created
	return (WindowObjectReference) ? false : true;
}

// Rollover effects for form buttons
function buttonOver(theButton) { theButton.className = "submitover" }
function buttonDown(theButton) { theButton.className = "submitdown"; }
function buttonOut(theButton, restoreStyle) { theButton.className = restoreStyle; }

// Confirm form submission
function confirmSubmission(message) {
	// In case message is omitted
	if (!message) message = 'Do you want to submit the form?';
	var goAhead = confirm(message);
    return goAhead;
}
	
////////////////// DROP-DOWN MENUS /////////////////////////////////
// From http://www.htmldog.com/articles/suckerfish/dropdowns/ --works with CSS-formatted lists
sfHover = function() {
	if (document.getElementById("nav")) { // If on a menu page (if not, this avoids a JS error)
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



