/**
 * @title: JQuery Client Portal Dropdown
 * @author: Michael Aguiar
 * @description: Changes the height of an element with an animation effect.
 */

$(document).ready(function() {
    $('#loginShow').click(function(e){
    	e.preventDefault();
        $('div#login').animate({
	        height: '100px'
        }, 'fast');
        
        $('.toggleLogin').toggle();
    });
    
    $("#loginHide").click(function(e){
    	e.preventDefault();
        $('div#login').animate({
	        height: '0px'
        }, 'fast');

        $('.toggleLogin').toggle()
    });
    
    $('#loginScript').submit(function(e) {
    	e.preventDefault();
		var str = $(this).serialize();
	
		$.ajax({
			type: 'POST',
			url: 'loginScript.php',
			data: str,
			success: function(msg) {
				$('#note').ajaxComplete(function(event, request, settings) {
					if(msg == 'Logged in as Admin.') {
						$(this).html('');
						$('#welcome').html('Admin');
						$('#loginShow, #loginHide').html('Links');
						$('#loginScript').hide();
						$('#adminLinks').show();
					} else {
						$(this).html(msg);
					}
				});
			}
		});
		return false;	
	});
});