
// Modify these vars to suit your needs

var cssPath = "easyflashuploader.css"; // the page where the files will be posted
var formPostURL = "upload.php"; // the page where the files will be posted
var afterCompletionPage = "quote-confirmation.php"; // leave empty if you dont want to redirect
var onCancelPage = "cancelled.php"; // 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 flashFormID = "UploadForm"; // the form which has the flash uploader embeded
var maxUploadSize = 2097152; // maximum allowed upload size in bytes
var minUploadSize = 3072; // minimum allowed upload size bin bytes
var maxFiles = 12; // allow a maximum of 5 files to be uploaded at a time
var allowedFileTypes = '*.pdf;*.tiff;*.tif;*.jpeg;*.jpg;*.png;*.bmp;*.doc;*.rtf;*.docx'; // allowed file types; add or delete extensions in the given format
var showFlashAlert = false; // will show javascript based alert by default; set true to show flash alert for validation
var showNoAlert = false; // will not show any alert if set to true - set to true when you want to surpress any error message


// Called by flash; modify if you want to validate html form
function efuValidateForm()
{
   name = document.getElementById("Name").value;
   email = document.getElementById("Email").value;
   address = document.getElementById("Address").value;
   postcode = document.getElementById("Postcode").value;
   propaddress = document.getElementById("PropAddress").value;
   proppostcode = document.getElementById("PropPostcode").value;
   proptype = document.getElementById("PropType").value;
   propsize = document.getElementById("PropSize").value;
	
   if(name == "Name: " || name == "Name:" || name == "") { alert("Please enter your Name!"); return false; }
   if(email == "Email: " || email == "Email:" || email == "") { alert("Please enter your Email Address!"); return false; }
   if (email != "") { var emailpattern = /^.+@.+\..{2,3}$/; if(!emailpattern.test(email)) {  alert("Please enter a valid Email Address!"); return false; } }
   if(address == "Address: " || address == "Address:" || address == "") { alert("Please enter your Address!"); return false; }
   if(postcode == "Postcode: " || postcode == "Postcode:" || postcode == "") { alert("Please enter your Postcode!"); return false; }
   if(propaddress == "Address: " || propaddress == "Address:" || propaddress == "") { alert("Please enter the Property Address!"); return false; }
   if(proppostcode == "Postcode: " || proppostcode == "Postcode:" || proppostcode == "") { alert("Please enter the Property Postcode!"); return f}
   if(proptype == "Property Type e.g. retail unit, warehouse, etc" || proptype == "") { alert("Please enter the Property Type!"); return false; }
   if(propsize == "Size of Premises: " || propsize == "Size of Premises:" || propsize == "") { alert("Please enter the Property Size!"); return false; }

 return true;
}

// --- DO NOT MODIFY BEYOND THIS POINT; UNLESS YOU KNOW WHAT YOU ARE DOING ---
var formValues = ""; // leave it empty
// Called by flash
function efuGetAfterCompletionPage()
{
	return afterCompletionPage;
}

// Called by flash; no modification needed
function efuGetFormPostURL()
{
	return formPostURL;
}

// Called by flash; no modification needed
function efuGetFormValues()
{
	return formValues;
}

function efuGetCssPath()
{
	return cssPath;
}

function efuGetMaxUploadSize()
{
	return maxUploadSize;
}

function efuGetMinUploadSize()
{
	return minUploadSize;
}

function efuGetAllowedFileTypes()
{
	return allowedFileTypes;
}

function efuGetShowFlashAlert()
{
	return showFlashAlert;
}

function efuGetShowNoAlert()
{
	return showNoAlert;
}

function efuGetMaxFiles()
{
	return maxFiles;
}

// called by html form; no modification needed
function efuGetFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

// called by html form; no modification needed
function efuDoSubmit()
{
	if(efuValidateForm())
	{
		formValues = '';
		var flash = efuGetFlashMovieObject(flashMovieObjectEmbedID);
		var formObj = document.getElementById(flashFormID);		
		for (var i = 0; i < formObj.elements.length; i++) 
		{
			formValues += escape(formObj.elements[i].name) + '=' + encodeURI(formObj.elements[i].value) + ((i != (formObj.elements.length - 1)) ? '&':'');
		}
		flash.startUpload();
	}
}

// cancel the upload
function efuCancelUpload()
{
	var flash = efuGetFlashMovieObject(flashMovieObjectEmbedID);
	flash.cancelUpload();
	if(onCancelPage!='')
	{
		location.href = onCancelPage;
	}
}
