

/**** VARIABLES - Configure these to fit your needs ****/ 

var languageFile = "efu-js/language.en.js"; // The language file - this MUST exist in the same folder as this file

var formPostURL = "efu-backend/upload.php"; // the page where the files will be posted

var cssPath = "efu-css/style.css"; // the path to the EFU CSS file

var afterCompletionPage = "thankyou.html"; // leave empty if you dont want to redirect

var onCancelPage = "canceled.html"; // page where you want to take the user if they cancel upload

var flashMovieObjectEmbedID = "FileUploader"; // the html tag "id" for the flash <object> and <embed> tags

var maxUploadSize = 314572800; // maximum allowed upload size in bytes; also see useTotalsForCalc 314572800 = 300MB

var minUploadSize = 0; // minimum allowed upload size bin bytes; also see useTotalsForCalc

var useTotalsForCalc = false; // use the total of all the file(s) size instead of individual file size to compare against maxUploadSize or minUploadSize

var maxFiles = 10; // allow a maximum of 5 files to be uploaded at a time

var allowedFileTypes = ''; // allowed file types; add or delete extensions in the given format; leave it as '' if you want to allow all files

var showAlert = true; // will not show any alert if set to false - set to false when you want to surpress any error message

var showFlashAlert = true; // will show javascript based alert by default; set true to show flash alert for validation

var gridRowHeight =  23; // height of each grid row in pixels

var gridRowCount = 6; // number of rows in the grid; you will need to manually adjust the height of the swf embed tag in the html for this to work without scrollbars



/**** Callbacks/Events - modify these if needed ****/

// Modify if you want to validate html form - called before the form is submitted

function efuValidateForm()

{

	// Put javascript form validation code here if you want

	// This function must return true for the Flash to work

	// If there is a validation issue, show js alert box and return false.

	var x=document.forms["UploadForm"]["name"].value;

	if (x==null || x=="")

	{

		alert("Name must be filled out");

		return false;

	}



	var x=document.forms["UploadForm"]["email_address"].value;

	var atpos=x.indexOf("@");

	var dotpos=x.lastIndexOf(".");

	if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)

	{

		alert("Not a valid e-mail address");

		return false;

	}











return true;	

}



function efuOnUploadError(fileName,errorString)

{

	// Put javascript here if you would like to do something when error occurs

	// Not really necessary in most basic cases

	// You can even put a code for redirection if you want

	

	if(showAlert)

	{

		alert(errorString);

	}

		

	return;	

}



// This function is called when uploads are done

// This function is not called incase of an upload error

function efuOnUploadsFinished(statusCode)

{

	// Put your code here if required

	

	//alert("Called: efuOnUploadsFinished with status code " + statusCode)

	

	//if(afterCompletionPage != '')

	//{

		window.location.href = afterCompletionPage;

	//}

		

	return;

}



// This function is called when upload is canceled

function efuOnCanceled()

{

	if(onCancelPage!='')

	{

		location.href = onCancelPage;

	}

}



/**** DO NOT MODIFY BEYOND THIS POINT - UNLESS YOU KNOW WHAT YOU ARE DOING ****/

var formValues = '';

// Submit form and upload files - Called by HTML form

function efuDoSubmit(objCaller)

{

	var flash;

	if (window.document[flashMovieObjectEmbedID]) 

	{

		flash = window.document[flashMovieObjectEmbedID];

	}

	if (navigator.appName.indexOf("Microsoft Internet")==-1)

	{

		if (document.embeds && document.embeds[flashMovieObjectEmbedID])

			flash = document.embeds[flashMovieObjectEmbedID]; 

	}

	else

	{

		flash = document.getElementById(flashMovieObjectEmbedID);

	}	

	

	if(efuValidateForm())

	{

		formValues = '';

		var formObj = objCaller.form;



		var serial = [], i, j, first;

		var add = function (name, value) {

			serial.push(encodeURIComponent(name) + '=' + encodeURIComponent(value));	

		}

			

		var elems = formObj.elements;

		for (i = 0; i < elems.length; i += 1, first = false) {

		  if (elems[i].name.length > 0) { 

		    switch (elems[i].type) {

		      case 'select-one': first = true;

		      case 'select-multiple':

		        for (j = 0; j < elems[i].options.length; j += 1)

		          if (elems[i].options[j].selected) {

		            add(elems[i].name, elems[i].options[j].value);

		            if (first) break; 

		          }

		        break;

		      case 'checkbox':

		      case 'radio': if (!elems[i].checked) break;

		      default: add(elems[i].name, elems[i].value); break;

		    }

		  }

		}

		

		formValues = serial.join('&');	

		flash.startUpload();

	}

}



// Cancel the upload - called by HTML form

function efuCancelUpload(objCaller)

{

	var flash;

	if (window.document[flashMovieObjectEmbedID]) 

	{

		flash = window.document[flashMovieObjectEmbedID];

	}

	if (navigator.appName.indexOf("Microsoft Internet")==-1)

	{

		if (document.embeds && document.embeds[flashMovieObjectEmbedID])

			flash = document.embeds[flashMovieObjectEmbedID]; 

	}

	else

	{

		flash = document.getElementById(flashMovieObjectEmbedID);

	}



	flash.cancelUpload();

	efuOnCanceled();

}



// Get the language string - called by Flash

function getLanguageString(ident)

{

	return LANG[ident];

}



// Include the language file

document.write("<script language=\"javascript\" src=\"" + languageFile + "\"></script>");
