String.prototype.trim = function ()
{ 
    return this.replace(/^\s+|\s+$/, ''); 
}


var IE_all_cache = new Object();

function IE_getElementById(id)
{
    if (IE_all_cache[id] == null)
    {
        IE_all_cache[id] = document.all[id];
    }

    return IE_all_cache[id];
}

if (document.all)
{
  if (!document.getElementById)
  {
    document.getElementById = IE_getElementById;
  }
}

function checkBeforeUpload(obj)
{
    if (document.getElementById("file").value.trim() == '')
    {
        alert('Please select a file for upload!');
        document.getElementById("file").focus();
        return false;
    }

    if (document.getElementById("txt_description").value.trim() == '')
    {
        alert('Please enter a meaningful file description!');
        try
        {
            document.getElementById("txt_description").focus();
        }
        catch (e)
        {
        }
        
        return false;
    }

    if (document.getElementById("chk_agree").checked == false)
    {
        alert('You MUST AGREE the Terms of Service!');
        try
        {
            document.getElementById("chk_agree").focus();
        }
        catch (e)
        {
        }
        
        return false;
    }

    return upuInit(obj);
}
