/* LEFT NAV SIGN IN FUNCTIONS */
function left_nav_sign_in() {
	// create rollovers for input boxes
	$('.login_field_left').focus(function() {
		$(this).css({'border':'1px solid #886A2E'})
	})
	$('.login_field_left').blur(function() {
		$(this).css({'border':'1px solid #4F473C'})
	})
	
	$('.login_text_links').hover(
		function() {
			$(this).css({'background':'#231E16'})
		},
		function() {
			$(this).css({'background':'none'})
		}
	)
	// create dropdown for submit bar
	$('#sign_in_header').toggle(
		function() {
			$('#sign_in_box_text_only').hide()
			$('#sign_in_box_containter').slideDown('slow', function() {
				
			 });
			$('#sign_in_header_button').css({'background-position':'1px -26px'})
		},
		function() {
			$('#sign_in_box_containter').slideUp('slow', function() {
					$('#sign_in_box_text_only').show()
			 });
			$('#sign_in_header_button').css({'background-position':'1px 0px'})
		}
	)
	$('#submit_button').click(function() {
		username = $('#Username').val()
		password = $('#Password').val()
		has_error = 0
		if (username == "") {
			$('#user_name_text').css({'float':'right'})
			$('#user_name_error').css({'display':'block', 'width':'14px'})
			$('#side_email_empty').css({'display':'block'})
			$('#Username').css({'border':'1px solid #C40300'})
			has_error = 1
		} else {
			$('#side_email_empty').css({'display':'none'})
			$('#user_name_text').css({'float':'left'})
			$('#user_name_error').css({'display':'none', 'width':'0px'})
			$('#Username').css({'border':'1px solid #4F473C'})
		}
		if (password == "") {
			$('#password_text').css({'float':'right'})
			$('#password_error').css({'display':'block', 'width':'14px'})
			$('#Password').css({'border':'1px solid #C40300'})
			$('#password_empty').css({'display':'block'})
			has_error = 1
		} else {
			$('#password_text').css({'float':'left'})
			$('#side_password_empty').css({'display':'none'})
			$('#password_error').css({'display':'none', 'width':'0px'})
			$('#Password').css({'border':'1px solid #4F473C'})
		}
		if (has_error) {
			$('#error_row').css({'display':'block'})
		} else {
			
				if (this.timer) clearTimeout(this.timer);
				this.timer = setTimeout(function () {
						$.post("/my_account/login_data.php?login_from_side=1", $("#login_side").serialize() ,function(data){
						// alert(data)
							returned_data = $.trim(data);
							// returned_data options will be 
							//	$ErrorCode = 1; // 'Expired';
							//	$ErrorCode = 2; // 'PassWord No Good ';
							//	$ErrorCode = 3; // 'Login No Good ';
							//	$ErrorCode = 0; // 'EVERYING OKEY DOKEY
							
							if (returned_data == '0') {
								this_location = document.location
								document.location = this_location		
							} else {
								$('#ErrorCode').val(returned_data);
								go_to_login_page(returned_data)
								/*
								// remove sign in box 
								$('#sign_in_header').hide()
								$('#sign_in_box_containter').hide()
								$('#sign_in_box_text_only').hide()
								
								// show my account 
								$('#my_account_container').show()
								$('#my_account_container_footer').show()
								*/

							}
						})
				})
		}
	})
	$('#logout').click(function() {
			$.post("/my_account/login_data.php?logout=1", { logout: "1"}  ,function(data){
								this_location = document.location
								document.location = this_location
								/*
								// remove sign in box 
								$('#sign_in_header').show()
								$('#login_box_container').show()
								
								$('#sign_in_box_containter').show()
								// show my account 
								$('#my_account_container').hide()
								$('#my_account_container_footer').hide()
								*/

			
			})
	})
 
	$(document).keydown(function(event) {
	  if (event.keyCode == '13') {
			if ( $('#sign_in_box_containter').css('display') != 'none' ) {
				$('#submit_button').trigger('click')
  		   event.preventDefault();
			}
	  }
	});	
	
} // end sign_in_functions
