$(function(){
	$('input#userEmployer').attr('checked', 'checked');
	$('#passwordFormContainer').hide();
	
	
    $('#userEmployer').click(function() {
        $('#loginFormContainer form').attr('ACTION', 'https://server.marlevo.com/docs/customer.php');
    });

    $('#userEmployee').click(function() {
        $('#loginFormContainer form').attr('ACTION', 'https://server.marlevo.com/docs/employee.php');
    });
    $('#loginSubmit').click(function() {
    	document.loginForm.submit()
    	return false;
    });
    
    $('#lost-pwd').click(function() {
    	$('#loginFormContainer').slideUp("200");
    	$('#passwordFormContainer').slideDown("200");
    	$('#passwordSent').remove();
    	return false;
    });
    $('#pwd-cancel').click(function() {
    	$('#passwordFormContainer').slideUp("200");
    	$('#loginFormContainer').slideDown("200");
    	return false;
    });
   
   $('#passwordSubmit').click(function() {
   		var dataString  = $("#email").val();
		var cc = jQuery.url.segment(0);
		
		function writeText() {
			if(cc == 'en') {
				$('#loginFormContainer').prepend("<h5 id='passwordSent'>Password has been sent to your email address</h5>");
			} else if (cc == 'fi') {
				$('#loginFormContainer').prepend("<h5 id='passwordSent'>Salasanasi on l&auml;hetetty s&auml;hk&ouml;postiisi</h5>");
			} else {
				$('#loginFormContainer').prepend("<h5 id='passwordSent'>L&ouml;senordet har skickats till din e-postadress</h5>");
			}
		}
		//alert (dataString);return false;
		
		$.ajax({
      	type: "POST",
      	url: "https://server.marlevo.com/docs/employee.php",
      	data:"email="+ dataString + "&action=password_remind_send&MEZZALINE_COMPANY=2565",
      	success: function() {
      		$('#passwordFormContainer').slideUp("200");
    		$('#loginFormContainer').slideDown("200");
    		writeText();
    	},
      	error: function() {
      		$('#passwordFormContainer').prepend("<h5>E-postadressen hittades ej</h5>");
       	}
     	});
   		return false;
   });
   
   
   
   
});

