﻿function afterUploadRecipeImage() 
{
   if (!validateFile())
   {
       return false;
   }
   AIM.submit(document.forms["fileForm"], { 'onStart': startCallback, 'onComplete': afterUploadRecipeImageCallback });
}

function afterUploadRecipeImageCallback(response) 
{
    clearImageUploadError()
    var index = response.indexOf('spanImageErrors');
    if(index >= 0)
    {
        displayImageUploadError(response);
    }
    else
    {
        var imgVars = response.split('|');
        var imgurl = imgVars[0];
        var thumburl = imgVars[1];
        images.push(imgurl);
        thumbnails.push(thumburl);
    }
    position = 0;
    showRecipeImage("previous");
    myLightWindow.deactivate();
}

function displayImageUploadError(response)
{
    var index = response.indexOf('<input id="gwProxy" type="hidden">');
    var error = response.substring(0, index);
    $('divErrors').update(error);
}

function clearImageUploadError()
{
    $('divErrors').update('');
}
