$.fn.extend({
	//gets the sum of the widths (inc. padding/margin) of an element's children
	'childWidths': function() {
		var width = 0;
		$(this).children().each(function() {
			width += $(this).outerWidth(true);
		});
		return width;
	},
	//sets all elements matching the given selector to the same (max) height
	'setToEqualHeight': function() {
		this.css({ minHeight:0 });
		var maxHeight = 0;
		this.each(function() {
			maxHeight = Math.max(maxHeight, $(this).height());
		});
		return this.css({ minHeight: maxHeight + 'px' });
	},
	makeLargeClickArea : function() {
		$(this).each(function() {
			if( ($('a', this).length > 0) 
			|| ($("input", this).attr("type") == "submit") 
			|| ($("input", this).attr("type") == "button") ) {
				$(this).css("cursor","pointer");
			}
		});
		$(this).click(function() {
			var isLink = false;
			if($('a', this).length > 0) {
				if($('a', this).attr('href') != null) {
					document.location = $('a', this).attr('href');
				}
			} else {
				if($("input", this).attr("type") == "submit") {
					$("form:first").submit();
				} else if($("input", this).attr("type") == "button")  {
					$("input", this).click();
				}
			}
			if(isLink) {
				$(this).css("cursor","pointer");
			}
			return false;
		});
	},	// center orizontally 
	centerElement : function() {
		$(this).each(function() {
			var _center = ( $(this).parent().outerWidth() - $(this).width() ) / 2;
			$(this).css("left", _center);		
		});

	},
	setClasses : function(tab) {
		$(this).each(function(i) {
			$(this).addClass(tab[i]);
		});
	}
});
$(document).ready(function(){
	//FontSize
	var actualSize = 0;
	function setSize(newSize) {
		$('div,h1,h2,h3,h4,h5,p,a,em,strong,label,input[type=text]', $("#flashContainer,#flashContainerBody,.rightColumn,.rightContent,.whatsNew,.middleContent,#nutrizoom,.features")).each(function() {
			var size = parseInt($(this).css("font-size")) - actualSize + newSize;
			$(this).css("font-size",size+"px");
		});
		actualSize = newSize;
	}
	$(".textsize a").setClasses(new Array("first","second","third"));	
	$(".textsize a.first").click(function() {
		setSize(0);
	});
	$(".textsize a.second").click(function() {
		setSize(2);
	});
	$(".textsize a.third").click(function() {
		setSize(4);
	});
});
