/* Version 3. BIG change to the Image upload section. John Porra - 13 Feb 2003. */ // Predefined match values. var ImageThumb = "/_TH_/gi.test(newfilename) && (/.gif$/gi.test(newfilename) || /.jpg$/gi.test(newfilename))"; var ImageNotThumb = "(!/_TH_/gi.test(newfilename)) && (/.gif$/gi.test(newfilename) || /.jpg$/gi.test(newfilename))"; var PDFonly = "(/.PDF/gi.test(newfilename))"; var ImageGifJpg = "(/.gif$/gi.test(newfilename) || /.jpg$/gi.test(newfilename))"; /**************************************************FUNCTION getUpload(control as document.forms[?].control , field as string , match as RegExpression, ImgRef as string, width as integer, height as integer, name as string ) ***************************************************/ function getupload(control, field, match, ImgRef, width, height, name) { /* This function looks at the values placed into a file upload control, and marks for deletion the files that have already been uploaded, ONLY if the file isnt used or is being replaced. The arguments: control : The file upload control that is being used field : The name of the field that stores the filename of the last object to be uploaded match : An optional string that is evaluated to perform tests on the file that is being uploaded. * Note, you can use the variable 'oldname' for reference to the old file name, and 'newfilename' for a reference of the new file name. * Contruct the match expression to check for conditions that you wish to hapen. ImgRef : Name of the image on the form to replace when blured. If left off, it's not used. If ImgRef is not set, then the width and height values are ignored. width : the number of pixels for an image. if left out, then it is not used. height : the number of pixels for an image. if left out, then it is not used. */ var form = document.forms[0]; var newname = control.value; // filename from upload control if (newname=="") return; var oldname = form[field].value; // old filename var thisarray = newname.split('\\'); // split on backslash var newfilename = thisarray[thisarray.length-1]; // get bit after last backslash var sizeError = ""; if (match != null) { if( eval(match) == false) { alert("This file is not valid. Please choose another file"); return; }else { if (ImgRef != null) { // try to load the file selected in the upload into the image of that name. Asumes that the image object is in document.forms[0] if (! is_nav) { NewImage = new Image() NewImage.src = "file:///"+control.value; eval("document.forms[0]."+ImgRef+".src = NewImage.src"); addToImgSizeList(control, NewImage, height, width, name, field) ; } } } if (oldname!="") { // look at deleting the image var deleteimage = false; // should we delete the old image? var olditemcount = 0; // count of the items that have the old image if (oldname==newfilename) deleteimage = true; for ( i=0; i