// JavaScript Document
$(document).ready
(
	function()
	{				
		//-- Homepage Animations --\\
		$("#closedChatBubbleA").click
		(
			function () 
			{
				$("#closedChatBubbleA").fadeOut("fast");
				$("#expandedChatBubbleA").fadeIn("fast");
			}
		);
		$("#expandedChatBubbleA").click
		(
			function () 
			{
				$("#closedChatBubbleA").fadeIn("fast");
				$("#expandedChatBubbleA").fadeOut("fast");
			}
		);  
		$("#closedChatBubbleB").click
		(
			function () 
			{
				$("#closedChatBubbleB").fadeOut("fast");
				$("#expandedChatBubbleB").fadeIn("fast");
			}
		);
		$("#expandedChatBubbleB").click
		(
			function () 
			{
				$("#closedChatBubbleB").fadeIn("fast");
				$("#expandedChatBubbleB").fadeOut("fast");
			}
		);  
		$("#closedChatBubbleC").click
		(
			function () 
			{
				$("#closedChatBubbleC").fadeOut("fast");
				$("#expandedChatBubbleC").fadeIn("fast");
			}
		);
		$("#expandedChatBubbleC").click
		(
			function () 
			{
				$("#closedChatBubbleC").fadeIn("fast");
				$("#expandedChatBubbleC").fadeOut("fast");
			}
		);
		//-0-0 0-0-\\
		$('#aspnetForm').submit
		(
			function()
			{
				var requiredFailed = false;
				var required = $('.required');
				for( i=0; i < required.length; i++ )
				{
					var current = required[i].value;
					if(current == "")
					{
						requiredFailed = true;
					}
				}
				var emailFailed = false;
				var email = $('.email');
				for( i=0; i < email.length; i++ )
				{
					var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
					var current = email[i].value;
					if(reg.test(current) == false && current != "")
					{
						emailFailed = true;
					}
				}
				var errormsg = $('#errormsg');
				if(requiredFailed && emailFailed)
				{
					errormsg.text('Required Field(s), and please enter a valid e-mail address');
					return false;
				}
				if(emailFailed)
				{
					errormsg.text('Please enter a valid e-mail address');
					return false;
				}
				if(requiredFailed)
				{
					errormsg.text('Required Field(s)');
					return false;
				}
				errormsg.text(' ');
				return true;
			}
		);
		$('#loginValidate').submit
		(
			function()
			{
				var requiredFailed = false;
				var required = $('#loginValidate > ul > li > .required');
				for( i=0; i < required.length; i++ )
				{
					var current = required[i].value;
					if(current == "")
					{
						requiredFailed = true;
					}
				}
				var errormsg = $('#errormsg2');
				if(requiredFailed)
				{
					errormsg.text('Required Field(s)');
					//$('#loginValidate > ul > li > username')
					return false;
				}
				errormsg.text(' ');
				return true;
			}
		);
	}
);