<script type="text/javascript">
 		var ri = 0;
 		
 		 var modopts = {
			position: ["40%",],
			dataId: 'loader',
			close: false
		};
		
		var erroropts = {
			overlayId: 'overlay',
			position: ["30%",],
			modalId: 'wontwork',
			opacity: 75,
			close: false
		};
		
		var forgotopts = {
			overlayId: 'overlay',
			position: ["30%",],
			dataId: 'forgotModal',
			containerId: 'forgotModalContainer',
			opacity: 75,
			close: true
		};
 		
 		$(window).resize(function(){
 			if(ri == 0){
				size();
				ri=1;
				setTimeout(function(){ri=0;},100);
			}
 		});
 		
 		$(document).ready(function(){
 			size();
 			
 			$('.login').delay(200).fadeIn(800, 'easeInOutQuad');
 			
 			
 			setTimeout(function(){
 				$('.loginbox').each(function(){
					if($(this).val().length > 0){
						//$(this).css({'background-color':'#fff'});
						$(this).next().hide();
						
					}   
				});
 			},200);
 			
 			setInterval(function(){
 				$('.loginbox','.login').each(function(){
					if($(this).val().length > 0){
						//$(this).css({'background-color':'#fff'});
						$(this).next().hide();
						
					}   
				});
 			},500);
 			
 			$('.loginbox').keyup(function(e){
 				if($(this).val().length > 0){
 					$(this).next().hide(100);	
 				}
 				
				var code = e.charCode || e.keyCode;
				if(code == 13){
					login.validate();
				}
			});
			
			$('.loginbox').focus(function(e){
				$(this).parent().addClass('activeInputContainer');
			});
			
			$('.loginbox').blur(function(){
				var val = $(this).val();
				if(val == ''){
					$(this).next().show(100);
				}
				
				$(this).parent().removeClass('activeInputContainer');
			});
			
			$('.loginCaption').click(function(){
				$(this).prev().focus();
			});
			
			$('#login-submit').click(function(){
				login.validate();
			});
			
			$('#forgotpassword').click(function(){
				forgot.get();
			});
			
			
 			
 			
 		});
 		
 		function size(){
 			width = $(window).width();
 			height = $(window).height();

 			var content = $('.login').css('min-height');
 			content = parseInt(content);
			margin = parseInt((height - content)*0.4);
			
			if(margin < 95){margin = 95;}
			
			$('.login').css({marginTop:margin});
			
			
			
			
 		}
 		
 		//jQuery(function($){
			var login = {
				init: function(){
					
				},
				validate: function(){
					var x = 0;
					if($('#user').val() == 'please enter your user id'){
						alert('Please enter a valid user id');
						x = 1;
						$('#user').focus();
					}
					else
					  {
						if($('#pw').val() == 'please enter your user pw')
						{
							alert('Please enter a valid user password');
							x = 1;
							$('#pw').focus();
						}
					  }
					
					if(x == 0){
						login.submit();
					}
				},
				submit: function(){
					$('#loginform').submit();
					$('#login-submit').addClass('post');
				}
				
			};
			//login.init();
			
		//});
		var Url = 'mail.php';
		
		var forgot = {
			get: function(){
				$('<div>Loading</div>').modal(forgotopts);
				
				var forgotGetUrl = Url+'forgotpassword';
				$.get(
					forgotGetUrl,
					function(RT){
						$('#forgotModal').html(RT);
						$('#forgotEmail').keyup(function(e){
							var code = e.charCode || e.keyCode;
							if(code == 13){
								forgot.post($('#forgotEmail').val());
							}
						});
						
						$('.forgotSubmit','#forgotModal').click(function(){
							forgot.post($('#forgotEmail').val());
						});
					
					},
					"html"
				);
			},
			
			post: function(email){
				$('#forgotModal').html('Processing...');
				var forgotPostUrl = Url+'forgotpassword';
				$.post(
					forgotPostUrl,
					{email:email},
					function(RT){
						if(RT == "OK"){
							$('#forgotModal').html('<p class="forgotmatter">We have sent you an email containing a password reset link. This link will expire in the next 24 hours.</p>')
							setTimeout(function(){$.modal.close();},2000);
						}else{
							$('#forgotModal').html('<p class="forgotmatter">'+RT+'</p>');
							setTimeout(function(){$.modal.close();},2000);
						}
					},
					"html"
				);
			}
		};
		
		
		function wontwork(){
			$('#wontwork').modal(erroropts);
		}
		
		</script>