$(document).ready(function(){
$.fn.nextUntil = function(expr) {
	var match = [];
	
	// We need to figure out which elements to push onto the array
	this.each(function(){
	// Traverse through the sibling nodes
	for( var i = this.nextSibling; i; i = i.nextSibling ) {
	// Make sure that we're only dealing with elements
	if ( i.nodeType != 1 ) continue;
	
	// If we find a match then we need to stop
	if ( jQuery.filter( expr, [i] ).r.length ) break;
	
	// Otherwise, add it on to the stack
	match.push( i );
	}
	});
	
	return this.pushStack( match, arguments );
};
	
	$('#dtPartner')
	.nextUntil('dt')
	.wrapInner('<div style="height:270px">')
	.addClass('gold');

	
	var dtLeadershipDD = $('#dtLeadership').nextUntil('dt');
	var s = dtLeadershipDD.size();
	var t = (169 * (s % 3));

	if(t != 0 && !(jQuery.browser.msie && jQuery.browser.version < 7))
		dtLeadershipDD.slice(-3,1).css({marginLeft:((514-t)/2)});
	else
		dtLeadershipDD.slice(-3,1).before('<dd class="gold" style="background:transparent;width:'+((490-t)/2)+'px"></dd>');
	
	dtLeadershipDD
	.wrapInner('<div style="height:270px">')
	.addClass('green');
	
	var dtFounderDD = $('#dtFounder').nextUntil('dt');
	
	
	var s = dtFounderDD.size();
	var t = (169 * (s % 3));

	if(t != 0 && !(jQuery.browser.msie && jQuery.browser.version < 7))
		dtFounderDD.slice(-3,1).css({marginLeft:((514-t)/2)});
	else
		dtFounderDD.slice(-3,1).before('<dd class="green" style="background:transparent;width:'+((490-t)/2)+'px"></dd>');

	dtFounderDD
	.wrapInner('<div style="height:270px">')
	.addClass('blue');

	$('#dtClientServices')
	.nextUntil('dt')
	.wrapAll('<dd class="tan">')
	.wrapAll('<dl>');
	
	$('#meettheTeam dt')
	.click(function(){
		$(this)
		.nextUntil('dt')
		.slideToggle();
	})
	.siblings('dd').hide();
	
	 $('a.newWin')
	.click(function(){
		var href = $(this).attr('href');
			window.open(href,'mywindow','width=760,height=864,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes');
		return false;
	});
	
	$('a.doExternal')
	.click(function(){
		var href = $(this).attr('href');
		if( $.cookie('CMSCOOKIE') ){
			document.location = href;
		}
		else{
			$.cookie('CMSCOOKIE', 'Ran Once');
			window.open("/wp-content/themes/cms/email.php?fileName="+href,'mywindow','width=450,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes');
		}
		return false;
	});
});