// JavaScript Document
var Upload = new Class({
	initializeControl: function(spanId) {
		var control = null;
		switch (spanId) {
			case 'spnEntryImage':
				control = new SWFUpload({
					upload_url : "lib/server/upload.php",
					flash_url : "swf/swfupload.swf",
					file_size_limit : "20480",
					file_queued_handler : fileQueued, 
					file_dialog_complete_handler : fileDialogComplete,
					upload_progress_handler : uploadProgress,
					upload_success_handler : uploadSuccess,
					upload_complete_handler : uploadComplete,
					debug : false,
					
					button_image_url : "images/bt-browse-sprite.gif",	// Relative to the SWF file
					button_placeholder_id : "spnEntryImageUploadButton",
					button_width : 91,
					button_height : 33,
					button_action : SWFUpload.BUTTON_ACTION.SELECT_FILE,
					button_cursor : SWFUpload.CURSOR.HAND,
					
					custom_settings : {
						elemProgress : $('divProgress'),
						imgId : $$('#spnEntryImage .imgId')[0].get('html'),
						blankImage : $$('#spnEntryImage .blankImage')[0].get('html'),
						savePath : $$('#spnEntryImage .savePath')[0].get('html'),
						fileType : $$('#spnEntryImage .fileType')[0].get('html'),
						srcPath : $$('#spnEntryImage .srcPath')[0].get('html'),
						elemHidFileId : $($$('#spnEntryImage .elemHidFileId')[0].get('html')),
						elemFileName : $($$('#spnEntryImage .elemFileName')[0].get('html')),
						defaultFileSuffix : $$('#spnEntryImage .defaultFileSuffix')[0].get('html')
					}
				});
				break;
		}
		if (control != null) $(spanId).store('uploadControl', control);
	},
	destroyControl: function(spanId) {
		var control = $(spanId).retrieve('uploadControl');
		if ($type(control) == 'object') control.destroy();
	}
});
