/**
* $Id: uploader.js 134 2009-02-19 21:21:30Z grinch $
* $Date: 2009-02-19 16:21:30 -0500 (Thu, 19 Feb 2009) $
* $Rev: 134 $
*/

/**
* Stop an upload
*/
function stopUpload(r){

    // r is an object in the form
    // msg:msg|err:error|img:image name|r_w:real width|r_h:real height|d_w:display width|d_h:display height|asp:aspect ratio|siz:size|tim:date

    // hide the spinner and display the result message
    $('#form-container #tab-0 #uploadspinner').hide();
    $('#form-container #tab-0 #copymessage').fadeIn();
    $('#form-container #tab-0 #upmsg').html(r.msg).show();
    var msgclass = ( r.err ) ? 'uperror' : 'upcomplete';
    $('#upmsg').addClass(msgclass);

    if( !r.err ) {
        // update the picture location with the uploaded photo
        var src = $('#form-container #tab-0 #profile_url').val() + '/' + r.img;
        $('#form-container #tab-0 img#user-photo').attr("src", src).attr("height", r.d_h).attr("width", r.d_w);
        $('input#image_file_name').val(r.img);

        // clear the upload file name and copyright checkbox
        $('#not_copyrighted').attr('checked','');
        $('#image').val('');
        
        if( $('#tab-box').hasClass('add') ) {
        	$('div.buttonbox input#next-panel').attr('disabled', '').removeClass('disable');
        	$('div.buttonbox #emsg').fadeOut('slow', 
        		function() {
        			$(this).html('');
        		});
        }
    }
    return(true);
}

/**
* Start an upload
*/
function startUpload() {

    $('#form-container #tab-0 #copymessage').fadeOut('fast',
    function() {
        $('#form-container #tab-0 #uploadspinner').fadeIn();
    });
    $('#form-container #tab-0 #upmsg').hide().removeClass('uperror').removeClass('upcomplete');
    return(true);
}