/*
jQuery.fn.extend({
	adjustColumns: function () {
		// if secondary content doesn't exist, widen main column to include right column space
		if ($("#secondary").length == 0 || $("#secondary").height() == 0 || $("#secondary").text().length == 0) $("#primary").css("padding-right", "0px");
		
		// if secondary content does exist, equalize the primary and secondary columns
		if ($("#secondary").length > 0) {
			var targetHeight = Math.max($("#primary").height(), $("#secondary").height());
			$("#primary, #secondary").height(targetHeight);
		}
	}
});
*/
function adjustColumns () {
	// if secondary content doesn't exist, widen main column to include right column space
	if ($("#secondary").length == 0 || $("#secondary").height() == 0 || $("#secondary").text().length == 0) $("#primary").css("padding-right", "0px");
	
	// if secondary content does exist, equalize the primary and secondary columns
	if ($("#secondary").length > 0) {
		var targetHeight = Math.max($("#primary").height(), $("#secondary").height());
		$("#primary, #secondary").height(targetHeight);
	}
}



$(document).ready(function() {
						
	var docroot = "/";
	addBreadCrumb();
//	$().adjustColumns();
	adjustColumns();
	
	
				
	function addBreadCrumb () {				
//		if (location.href.indexOf("/welty-0.1/") >= 0) docroot = "/welty-0.1/";
		$("#breadcrumb").append('<ul></ul>').find('ul').appendBreadCrumbList(docroot, {
			delimAfter: " &raquo; "
			, docRootLabel: "Think Welty"
			, labels: {
				"about": "About Welty"
				, "industries": "Industries We Serve"
				, "projects": "Current Projects"
				, "successes": "Success Stories"
				, "wfsg": "Welty Facility Services Group"
			}
//			, urlFilters: [ [/\/current-projects\/.+$/, '/current-projects/'], [/\/news2\/.+\/.+$/, '/current-projects/'] ]
		});
		$("#mainMenu li, #subnav li").indicateCurrentPage("sel");

		// breadcrumb override for Current Projects pages
		$('body.currentprojects #breadcrumb > ul > li > ul').empty().append('<li><a href="/current-projects/test2">Current Projects</a> &raquo; </li>');

		// replace hard-coded docroots with server-appropriate urls
		var badDocroots = ['http://thinkwelty.com/', 'http://www.thinkwelty.com/'];
		if (location.href.indexOf("/welty-0.1/") >= 0) docroot = "/welty-0.1/";
		$("a[href^='http://thinkwelty.com/']").each(function(){
			var jqLink = $(this);
			$.each(badDocroots, function(i,el){
				var url = jqLink.attr('href').replace(el, docroot)
				jqLink.attr('href', url);
			});
		});
	}

});

