function setDimensions() {
	var windowHeight = $(window).height();
	var windowWidth = $(window).width();
	var bodyHeight = $('body').height();
	var containerHeight = $('#container').innerHeight();
	var containerTop = Math.floor((windowHeight - containerHeight) / 2);
	var newImageHeight = Math.round(windowWidth * .666);
	
	if(windowHeight > bodyHeight) {
		$('#wrapper').height(windowHeight);
	}
	
	$('#container').css('top',containerTop);
	if(windowHeight > newImageHeight) {
		$('#imageContainer').height(windowHeight);
	} else {
		$('#imageContainer').height(newImageHeight);
	}
}

(function($) {
	jQuery.fn.validateForm = function() {
		$(this).submit(function() {
			$this = $(this);
			$($this).find('.error').remove();
			var hasError = false;
			$($this).find('.required').each(function() {
				var labelText = $(this).children('label').text();
				var $elems = $(this).children('input, textarea');
				var elVal = jQuery.trim($elems.val());
				var titleAttr = $elems.attr('title');
	
				if(elVal === '' || elVal === titleAttr) {
					$(this).append('<span class="error">Please enter your '+labelText+'</span>');
					hasError = true;
				} else if($(this).hasClass('email')) {
					var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
					if(!emailReg.test(elVal)) {
						$(this).append('<span class="error">You entered an invalid '+labelText+'</span>');
						hasError = true;
					}
				}
			});
			if(hasError) {
				return false;
			}
		});
	};
})(jQuery);

$(document).ready(function() {
	//Add/Remove Input Values
	$('input[title]').each(function() {
		if($(this).val() == '') {
			$(this).val($(this).attr('title'));	
		}
		
		$(this).focus(function() {
			if($(this).val() == $(this).attr('title')) {
				$(this).val('');	
			}
		});
		$(this).blur(function() {
			if($(this).val() == '') {
				$(this).val($(this).attr('title'));	
			}
		});
	});
	//End Add/Remove Input Values	
	
	//Window & container sizing
	setDimensions();
	$(window).resize(function() {
		setDimensions();				  
	});
	//End window & container sizing
	
	//Validate form
	$('#signUpForm').validateForm();
	//End validate form
});