function adjustColumns () {
	// if secondary content doesn't exist, widen main column to include right column space
	if (jQuery("#pageBodyContent > .secondary").length == 0 || jQuery("#pageBodyContent > .secondary").height() == 0 || jQuery("#pageBodyContent > .secondary").text().length == 0) jQuery("#pageBodyContent > .primary").css("padding-right", "0px");
	
	// if secondary content does exist, equalize the primary and secondary columns
	if (jQuery("#pageBodyContent > .secondary").length > 0) {
//		var targetHeight = Math.max(jQuery("#pageBodyContent > .primary").height(), jQuery("#pageBodyContent > .secondary").height());
//		jQuery("#pageBodyContent > .primary, #pageBodyContent > .secondary").height(targetHeight);\
		jQuery('#pageBodyContent > .primary, #pageBodyContent > .secondary').setEqualHeight();
	}
	
	// stretch subnav column
//	jQuery('#subnav').height(jQuery('#pageBodyContent').height());
	jQuery('#subnav, #pageBodyContent').setEqualHeight();
}


var emailSignup_inited = false;
function emailSignup_init () {
	if (!emailSignup_inited) {
		// hide form hints
		jQuery('.emailSignup .new').val("").removeClass('new');
		jQuery('.emailSignup .zip').focus(function(){
			jQuery('.emailSignup div.captcha').show();
		});
		// hook into Contact Form 7 script when AJAX response is received/processed
		jQuery('div.wpcf7 > form').ajaxForm({
			beforeSubmit: wpcf7BeforeSubmit,
			dataType: 'json',
			success: function(data){
				wpcf7ProcessJson(data);
				if (1 == data.mailSent) {
					jQuery('.emailSignup > p').hide();
				}
			}
		});		
		emailSignup_inited = true;
	}
}
function emailSignup_update () {
	jQuery('.emailSignup > p').hide();
}

(function($){
	$.fn.deorphanize = function(){
		var MIN_WIDTH = 225;
		var ALLOWED = 'b|i|em|strong';
		var reALLOWED_TAGS = new RegExp('<(\/?)(' + ALLOWED + ')>', 'g');
		var reALLOWED_TAGS_TEMP = new RegExp('\{\{\{(\/?)(' + ALLOWED + ')\}\}\}', 'g');
		var reLAST_TWO_WORDS = new RegExp('([^ ^<^>]+) ([^ ^<^>]+)$');
		return this.each(function(){
			var jqObj = $(this);
			// don't worry about orphans if less than min width
			var jqWidthSensor = $('<hr />');
			jqObj.append(jqWidthSensor);
			var textWidth = jqWidthSensor.width();
			jqWidthSensor.remove();
			if (textWidth < MIN_WIDTH) return;
			
			var oldStr = jqObj.html();
			var newStr = oldStr.replace(reALLOWED_TAGS, '{{{$1$2}}}');
			newStr = newStr.replace(reLAST_TWO_WORDS, '$1&nbsp;$2');
			newStr = newStr.replace(reALLOWED_TAGS_TEMP, '<$1$2>');
			jqObj.html(newStr);
		});
	};
})(jQuery);

(function($){
	// from http://www.webringideas.com/web-development/divs-of-equal-height-using-jquery-script.html
	jQuery.fn.setEqualHeight=function(o) {
		var maxHeight=0;
		var maxElement=null;
		jQuery(this).each(function(i) {
			if ((jQuery(this).height() + parseInt(jQuery(this).css("padding-bottom")) + parseInt(jQuery(this).css("padding-top"))) > maxHeight) {
				maxHeight = jQuery(this).height() + parseInt(jQuery(this).css("padding-top")) + parseInt(jQuery(this).css("padding-bottom"));
				maxElement = this;
			}
		});
		jQuery(this).not($(maxElement)).each(function(){
			$(this).height(maxHeight - parseInt(jQuery(this).css("padding-top")) - parseInt(jQuery(this).css("padding-bottom")))
		});
	};
})(jQuery);


jQuery(document).ready(function($) {
						   
	// hide captcha until user starts to input zip
	jQuery('.emailSignup div.captcha').hide();
						   /*
	$(".emailSignup input:text.new").focus(function(){
		$(this).val("").removeClass("new").focus(null);
	});
	*/
	
	
	/*
	addBreadCrumb();
	adjustColumns();
	$('#pageBodyContent > .primary').find('h1, h2, h3, h4, p, li').deorphanize();
	
	
	function addBreadCrumb () {				
		$("#nav .mainMenu ul li, #subnav h3, #subnav ul li").indicateCurrentPage("sel", {
			overrides: { "p=productview": "/site/portfolio/view-by-product.shtml", "p=applicationview": "/site/portfolio/view-by-application.shtml" }
		});
	}
	*/

});

