
/* Uploader clutters up the global namespace with hide().
   Currently, hide is built in to the applet, so there is no way around
   using it.
   
   All methods are class methods.  We don't need more than one instance.
*/

// Constructor
var Uploader = new Object;

Uploader.showUploader = function (section, date, slug) {

	var width  = 730;
	var height = 290;
  var allowedExtensions = "jpg,jpeg,bmp,gif,tiff,png";
  var destination = Conf.Path.fullAppRoot 
                    + '/timelinebuilder/imageuploader/'
                    + section +'/'
                    + date +'/'
                    + slug +'/';
                    
  var jarfile = Conf.Path.appRoot + "/lib/cnnFileUploader.jar";

	var applet;
    if (window.ActiveXObject) {
      applet = '<object id="uploadApplet" '
               +'classid="clsid:CAFEEFAC-0015-0000-0000-ABCDEFFEDCBA" '
               +'width=' + width + ' ' 
               +'height=' + height + '> '
               +'<param name="archive" '
               +'value="' + jarfile + '"/>'
		           +'<param name="destination" VALUE="' + destination + '"/>'
               +'<param name="code" value="CnnFileUploader"/>'
//               +'<param name="frameId" value="' + frameId + '"/>'
		           +'<param name="extensions" value="'+allowedExtensions+'">'
               +'</object>';
    }
    else {
      applet = '<embed name="uploadApplet" destination="' + destination + '" '
               +'extensions="' + allowedExtensions + '" '
//               +'frameId="' + frameId + '" '
               +'id="uploadApplet" '
               +'type="application/x-java-applet;version=1.5" '
               +'width=' + width + ' ' 
               +'height=' + height + ' '
               +'archive="' + jarfile + '" '
               +'code="CnnFileUploader"></embed>';
    }
    document.getElementById('uploaderframe').innerHTML = applet;
    document.getElementById('uploaderapplet').style.display = 'inline';
};

Uploader.hide = function () { hide(); };

