/*
 Uploader.js

 (c) Lateral Arts 2002 (http://www.larts.co.uk)

 Please edit this file for use at your site.

 You should do this by changing the values of the variables below:

*/

var HOST = "www.larts.co.uk";	/* The name of the FTP server */
var USER = "larts";		/* The user name on the FTP server */
var PASSWORD = "larts";		/* The password for that user on the FTP server */
var DIR = "/";	        /* The directory on the server that will be displayed */

var BGCOLOR = "FFFFFF";			/* This sets the background colour for the applet - in RGB Hex format */
var WIDTH = "98%";			/* This sets the width of the applet */
var HEIGHT = "80%";			/* This sets the height of the applet */

var ENABLE_UPLOAD = "TRUE";		/* This enables the Upload button */
var ENABLE_DOWNLOAD = "FALSE";		/* This enables the Download button */
var ENABLE_DELETE = "TRUE";		/* This enables the Delete button */

var PORT = "21";			/* The TCP/IP port to connect to on the server */
var PASSIVE = "TRUE";			/* Sets the FTP connection to be passive or normal */

var DEBUG = "TRUE";			/* Set to TRUE to show the replies from the FTP server in the Java console */

var NUM_EXCLUDED_FILES = "1";		/* Number of excluded files */

var EXCLUDED_FILES = "<param name='EXCLUDED_FILE1' value='testm1.jpg'>";
					/* this variable lists the filenames to be excluded from the view */
var EXCLUDED_FILES_NS = "EXCLUDED_FILE1='testm1.jpg'";
					/* this variable lists the filenames to be excluded from the view for 
					Mac Netscape which uses the EMBED tag instead of APPLET */
var ALLOW_DIRECTORIES="FALSE";
var ENABLE_MULTIPLE_UPLOAD = "TRUE"; 	/* This enables non-standard multiple upload file dialog */
/*
 The script below this point creates the correct HTML for the browser you are using
*/

var n;

var agt=navigator.userAgent.toLowerCase();

// detect browser version
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.

var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

// *** BROWSER TYPE ***
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
	       && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
	       && (agt.indexOf('webtv')==-1));
	       
var is_opera = (agt.indexOf('opera')!=-1);
	       
var is_nav4up = (is_nav && (is_major >= 4));
var is_ie   = (agt.indexOf("msie") != -1);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) );
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);

// *** PLATFORM ***
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);
var is_sun   = (agt.indexOf("sunos")!=-1);
var is_irix  = (agt.indexOf("irix") !=-1);    
var is_hpux  = (agt.indexOf("hp-ux")!=-1);
var is_aix   = (agt.indexOf("aix") !=-1);     
var is_linux = (agt.indexOf("inux")!=-1);
var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
var is_unixware = (agt.indexOf("unix_system_v")!=-1);
var is_mpras    = (agt.indexOf("ncr")!=-1);
var is_reliant  = (agt.indexOf("reliantunix")!=-1);
var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
		(agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
		(agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
var is_sinix = (agt.indexOf("sinix")!=-1);
var is_freebsd = (agt.indexOf("freebsd")!=-1);
var is_bsd = (agt.indexOf("bsd")!=-1);
var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
		is_sco ||is_unixware || is_mpras || is_reliant ||
		is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

function appletWillRun() {
  if (is_ie4 || is_ie5up || (is_nav4up && is_minor >= 4.08))                     
    return true;           
  return false;
}
function mrj()  {
  for (var i = 0; i < navigator.plugins.length; i++) {
    if (navigator.plugins[i].name.indexOf("MRJ") > -1) return true;
  } 
  return false;
}

// The following script will detect weather MAC or PC version of the applet should be started 
// and set up the appropriate jar file

var jar = "lartsuploaderapplet.jar";
if (is_mac) {
  jar = "lartsuploaderapplet.jar";
}

var netmac=0;			
// netmac = 0 means it is either Mac/IE or non-Mac
if (is_mac && is_nav) {		
  if (mrj()) {
    netmac=1;	// netmac = 1 means this is Mac/Netscape so use <embed> tag
  }
  else { 
    netmac=2;	// this is Mac/Netscape w/o MRJ Plugin
  }	
}

if (netmac == 0) {
  if (appletWillRun()) {
    document.writeln("<APPLET name='Uploader' code='larts.uploader.Uploader.class' height='"+HEIGHT+"' width='"+WIDTH+"' archive='"+jar+"' MAYSCRIPT VIEWASTEXT>");
    document.writeln("<PARAM NAME='CABINETS' VALUE='Uploader.cab'>");
    document.writeln("<PARAM NAME='HOST' VALUE='"+HOST+"'>");
    document.writeln("<PARAM NAME='PORT' VALUE='"+PORT+"'>");
    document.writeln("<PARAM NAME='PASSIVE' VALUE='"+PASSIVE+"'>");
    document.writeln("<PARAM NAME='USER' VALUE='"+USER+"'>");
    document.writeln("<PARAM NAME='PASSWORD' VALUE='"+PASSWORD+"'>");
    document.writeln("<PARAM NAME='ENABLE_UPLOAD' VALUE='"+ENABLE_UPLOAD+"'>");
    document.writeln("<PARAM NAME='ENABLE_DOWNLOAD' VALUE='"+ENABLE_DOWNLOAD+"'>");
    document.writeln("<PARAM NAME='ENABLE_DELETE' VALUE='"+ENABLE_DELETE+"'>");
    document.writeln("<PARAM NAME='BGCOLOR' VALUE='"+BGCOLOR+"'>");
    document.writeln("<PARAM NAME='DEBUG' VALUE='"+DEBUG+"'>");
    document.writeln("<PARAM NAME='DIR' VALUE='"+DIR+"'>");
    document.writeln("<PARAM NAME='ENABLE_MULTIPLE_UPLOAD' VALUE='"+ENABLE_MULTIPLE_UPLOAD+"'>");
    document.writeln("<PARAM NAME='ALLOW_DIRECTORIES' VALUE='"+ALLOW_DIRECTORIES+"'>");
    document.writeln("<PARAM NAME='NUM_EXCLUDED_FILES' VALUE='"+NUM_EXCLUDED_FILES+"'>");
    document.writeln(EXCLUDED_FILES);
    document.writeln("<p>Please enable Java in your browser to run this applet");
    document.writeln("</APPLET>");	
  } 
}
else if (netmac==1){ 
// It's Netscape use the embed tag instead!
  document.writeln("<EMBED  TYPE = 'application/x-java-vm' name='Uploader' PLUGINSPAGE = 'http://www.mozilla.org/oji/' BORDER='0'");
  document.writeln("CODE='larts.uploader.Uploader.class' height='"+HEIGHT+" width='"+WIDTH+"'  archive='"+jar+"' "); 
  document.writeln("HOST='"+HOST+"'");
  document.writeln("PORT='"+PORT+"'");
  document.writeln("PASSIVE='"+PASSIVE+"'");
  document.writeln("USER='"+USER+"'");
  document.writeln("DIR='"+DIR+"'");
  document.writeln("PASSWORD='"+PASSWORD+"'");
  document.writeln("ENABLE_UPLOAD='"+ENABLE_UPLOAD+"'");
  document.writeln("ENABLE_DOWNLOAD='"+ENABLE_DOWNLOAD+"'");
  document.writeln("ENABLE_DELETE='"+ENABLE_DELETE+"'");
  document.writeln("BGCOLOR='"+BGCOLOR+"'");
  document.writeln("DEBUG='"+DEBUG+"'");
  document.writeln("ENABLE_MULTIPLE_UPLOAD='"+ENABLE_MULTIPLE_UPLOAD+"'");
  document.writeln("ALLOW_DIRECTORIES='"+ALLOW_DIRECTORIES+"'");
  document.writeln("NUM_EXCLUDED_FILES='"+NUM_EXCLUDED_FILES+"'");
  document.writeln(EXCLUDED_FILES_NS);
  document.writeln(">"); 
}



