/**
 * Author => Company       : Prodo Ltd
 *        => Website       : http://www.prodo.com
 * Code   => Last Modified : 22 January 2010
 */

$(function() {
	
	/*
	 * Make external links open in a new window
	 */
	$('a[rel=external]').click(function(e) {
		open(this.href);
		e.preventDefault();
	}).attr('title', 'Opens in a new window');
	
	/*
	 * Font Size
	 */
	var originalFontSize = '13.0167px';
	
	$(".font-size .reset").click(function(e) {
		$('#content .primary').css({fontSize : originalFontSize});
		e.preventDefault();
	});
	
	$(".font-size .increase").click(function(e) {
		var newFontSize = parseFloat($('#content .primary').css('font-size'), 10) * 1.1;
		
		if(newFontSize < 16) {
			$('#content .primary').css({fontSize : newFontSize});
		}
		
		e.preventDefault();
	});
	
	$(".font-size .decrease").click(function(e) {
		var newFontSize = parseFloat($('#content .primary').css('font-size'), 10) * .9;
		
		if(newFontSize > 10) {
			$('#content .primary').css({fontSize : newFontSize});
		}
		
		e.preventDefault();
	});
	
	$(".font-size").show();
	
	/*
	 * Sitefinity's default form errors are wrapped in a tag
	 * with a class of *error*, but this isn't removed if no
	 * error exists... and sometime it drops empty span tags
	 * into the error message for no apparent reason.
	 */
	$('p.error').each(function() {
		if($.trim($('p.error').html()).length == 0) {
			$(this).remove();
		}
		else if($.trim($('p.error span').html()).length == 0) {
			$(this).remove();
		}
	});
	
});
