﻿
//This function will check if the first input type file
// in the document has a file or not
function CheckHasFile()
{

    var mforms = document.forms[0].elements;
    
    for(i = 0; i < mforms.length; i++)
    {
    
        if (mforms[i].type == 'file')
        {
            if (mforms[i].value == '')
            {
                return false
            }
            else
            {
                return true
            }
        }
    
    }
    
    return false

}



function CheckUploadedPicture(sender, args)
{

    //We need to check if the user has uploaded a file,
    //if not we shall warn him before submiting the form
    
    if (CheckHasFile() == false)
    {
    
        var x = confirm("לא הוספת תמונה וחבל... האם בכל זאת להמשיך?");
        if (x == false)
        {
            StopAnimation()//Stop the ajax animation
        }
        
        args.IsValid = x;
        return;
    
    }
    else
    {
        args.IsValid = true;
    }

}
