var attempts = 0;

function doAjaxLoginCheck(data)
			{
				attempts++;
				
				if (data.success)
				{
					var login = data.login;
					var fontSize = '10px';
					 
					if (login.length > 30)
					{
						fontSize = '9px';
						var temp = new Array();
						temp=login.split("@");
						if (temp.length > 1)
						{
							if (temp[1].length > 30)
							{
								temp[1] = temp[1].substr(0,27) + '...';
							}
							login = temp.join(" <br> ");
						}
					}
					$('#loginformcontent').html('<form action="/include/login.php" method="post" name="loginform" ><div id="loginhere"></div>Welcome <span style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:' + fontSize + '; color:#1E62A0; font-weight:bold">' + login + '</span> <br/> <br/>You are currently logged in!<br /><br /><table cellspacing="0" cellpadding="0" onclick="javascript: document.loginform.submit();" class="ButtonTable"><tr><td><input type="image" src="/skin1_ms/www_palmflex_com/images/but1_light_blue.gif" class="ButtonSide_light_blue" alt="" /></td><td class="Button_light_blue"><font class="Button_light_blue">Log out</font></td><td><img src="/skin1_ms/www_palmflex_com/images/but2_light_blue.gif" class="ButtonSide_light_blue" alt="" /></td></tr></table><input type="hidden" name="mode" value="logout" /><input type="hidden" name="redirect" value="customer" /></form><br/>');
					$('#recoverPass').hide();
					userZipcode = data.userinfo.s_zipcode;
					userState = data.userinfo.s_state;
					userAddress = data.userinfo.s_address;
					userCity = data.userinfo.s_city;
					
					disableAllMyBoxes();
					alert('Welcome ' + login + ' you are currently logged in!');
					return false;
				}
					alert(data.message);
					if (attempts == 3)
					{
						window.location = ('/help.php?section=Password_Recovery');
					}
					return false;
			}

function doAjaxLogin()
{
     
							info = new Object();
										   info.username = $('[name=username]').val();
										   info.password = $('[name=password]').val();
										   info.ajaxSubmit = true;
										   info.redirect = $('[name=redirect]').val();
										   info.usertype = $('[name=usertype]').val();
										   info.mode = $('[name=mode]').val();
						   var error = false;
						   if (info.username.length < 1) {alert('Please Enter your username'); error = true;}
						   if (info.username.length > 64) {alert('Username must be less than 64 characters'); error = true;}
						   if (info.password.length < 1) {alert('Please Enter your password');error = true;}
						   if (info.password.length > 64) {alert('Password must be less than 64 characters');error = true;}
							if (error) return false;
							var dataString = $.toJSON(info);
                    $.post(
						   '/include/login.php',{ajaxdata: dataString},
							function(data){ doAjaxLoginCheck($.evalJSON(data));}
						   );
				
               

}

