sk =
{
	init		:	function()
	{
		sk.fixcss();
		$('form').bind('submit', sk.validate);
		// Set tooltip
		$(".sk_tooltip").Tooltip({
			track: true,
			delay: 0,
			showURL: false,
			opacity: 1,
			fixPNG: true,
			showBody: " - ",
			extraClass: "pretty fancy",
			top: -15,
			left: 5
		});
	},
	/*
	 * Fix any css on page.  run when page is loaded.
	 */
	fixcss		:	function()
	{
		if(!$.browser.msie)
		{
			if($('#sk_page').height() < $(window).height())
			{
				$('html').height('100%');
			}
			else
			{
				$('html').height('');
			}
			window.onresize = sk.fixcss;
		}
	},
	/*
	 * form validation
	 */
	validate	:	function()
	{
		var form = this;
		var valid = true
		$('input:visible:not(:submit)').each(
			function()
			{
				var type = $(this).attr('name');
				switch(type)
				{
					case 'email' :
						var input = $(this).val();
						input = input.replace(/^\s+/, "");
						input = input.replace(/\s+$/, "");
						var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
						if(!input.match(pattern))
						{
							valid = false;
							$(this).siblings('span.sk_error').show();
						}
						else
						{
							$(this).siblings('span.sk_error').hide();
						}
						break;
					case 'phone'	:
						var input = $(this).val();
						pattern = /[0-9]+$/;
						if(!input.match(pattern))
						{
							valid = false;
							$(this).siblings('span.sk_error').show();
						}
						else
						{
							$(this).siblings('span.sk_error').hide();
						}
						break;
					default		:
						if($(this).is('.sk_field_required') && $(this).val().length < 1)
						{
							valid = false;
							$(this).siblings('span.sk_error').show();
						}
						else
						{
							$(this).siblings('span.sk_error').hide();
						}
				}
			}
		);
		if(!valid)
		{
			return false;
		}
	}
}
$(document).ready(sk.init);
