function ajaxFileUpload()
{
    $('#loading').show();
    $('#fileToUpload').hide();
    $('#image').hide();
    
    $.ajaxFileUpload(
    {
        url:'/uploader.php?action=upload',
        secureuri:false,
        fileElementId:'fileToUpload',
        dataType: 'json',
        success: function (data, status)
        {
            if(typeof(data.error) != 'undefined')
            {
                if(data.error != '')
                {
                    alert(data.error);
                }
                else
                {
                    showImage(data.imageSrc);
                }
            }
            
            $('#loading').hide();
            $('#fileToUpload').show();
        },
        error: function (data, status, e)
        {
            alert(e);
        }
    });
		
    return false;
}

function ajaxGetImageByMail()
{
    $('#loading').show();
    $('#fileToUpload').hide();
    $('#image').hide();
      
    $.getJSON('/uploader.php?action=getImageByMail', 
    {'mail': $('#mail').val()},
    function(data)
    {	
        if(data.error != '')
        {
            // obrazek nenalezen
        }        	  	
        else
        {   
            showImage(data.imageSrc);
        }
        
        $('#loading').hide();
        $('#fileToUpload').show();
    });
}

function showImage(src)
{
    $('#image').attr('src', src);
    $('#image').show();
}