
// Homepage:  Even up the 3box area
jQuery(document).ready(function($){
	if ($('#home_boxes').size() < 1) { return; }
	$('#home_boxes div.box h2').equalHeight();
	$('#home_boxes div.box .format_text').equalHeight();
	
});

// Turf Area Calculator Widget
jQuery(document).ready(function($){
	// Prepare & set Default values
	defWidthVal = 'width(m)';
	defLengthVal = 'length(m)';
	$('#tcwidth').val(defWidthVal);
	$('#tclength').val(defLengthVal);
	// Handle Focus & Blur events
	$("#tcwidth").focus(function() {	if ($("#tcwidth").val()==defWidthVal)	{ $("#tcwidth").val(''); 			}	});
	$("#tcwidth").blur(function() {		if ($("#tcwidth").val()=='') 			{ $("#tcwidth").val(defWidthVal);	}	});
	$("#tclength").focus(function() {	if ($("#tclength").val()==defLengthVal)	{ $("#tclength").val(''); 			}	});
	$("#tclength").blur(function() {	if ($("#tclength").val()=='') 			{ $("#tclength").val(defLengthVal);	}	});
	// Handle Submit event
	$("#tcsubmit").click(function() {
		$("#tcSwitch").fadeOut(function() { 
			result = 'You need ' + turfCalc() + 'm&sup2; of turf for your project!';
			$("#tcSwitch").html(result).fadeIn();
		});
		
	});
});
function turfCalc() {
	width = document.getElementById('tcwidth').value;
	length = document.getElementById('tclength').value;
	return width * length;
}


// Newsletter Widget
jQuery(document).ready(function($){
	defNewsText = 'Email Address...';
	$('#newsletter_email').val(defNewsText);
	$("#newsletter_email").focus(function() {	if ($("#newsletter_email").val()==defNewsText)	{ $("#newsletter_email").val(''); 			}	});
	$("#newsletter_email").blur(function() {	if ($("#newsletter_email").val()=='') 			{ $("#newsletter_email").val(defNewsText);	}	});
	
});







// Plugin from:	http://andreaslagerkvist.com/jquery/equal-height/
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 innerHeight    = t.innerHeight();
        var outerHeight    = t.outerHeight();
        var notHeight    = outerHeight - innerHeight;
        var minHeight    = maxHeight - notHeight;
        var property    = jQuery.browser.msie && jQuery.browser.version < 7 ? 'height' : 'min-height';

        t.css(property, minHeight + 'px');
    });
};