// updated @AK 3-01-2004
function getWWWPath(localpath){
var start = localpath.indexOf("prange");
start = start -1;
var end = localpath.length;
if(start < end )
  return localpath.substring(start,end);
}

function getThumbNail(collection,imagepath){
return imagepath.replace(collection,collection+"/thumbnails");
}

function setThumbInfo(count){
var name;
if(count == 0){
name = "/entry/image/image_thumb";
  }else{
	count++;
name = "/entry/image["+count+"]/image_thumb";
  }
//alert('name is:'+ name);
window.opener.document.getElementById(name).value = getWWWPath(document.getElementById("path").value);
}

function setLargeInfo(count){
var name;
if(count == 0){
name = "/entry/image/image_large";
  }else{
	count++;
name = "/entry/image["+count+"]/image_large";
  }
//alert('name is:'+ name);
window.opener.document.getElementById(name).value = getWWWPath(document.getElementById("path").value);
}








function setInfo(count){
var name,path,size,type,id;
if(count == null)
count=0;
if(count == 0){
name = "/entry/image/image_name";
path = "/entry/image/image_path";
size = "/entry/image/image_size";
type = "/entry/image/@type";
  }else{
	count++;
name = "/entry/image["+count+"]/image_name";
path = "/entry/image["+count+"]/image_path";
size = "/entry/image["+count+"]/image_size";
type = "/entry/image["+count+"]/@type";
  }	

id = "/entry/@id";

//alert(window.opener.document.getElementById(id));
window.opener.document.getElementById(id).value = document.getElementById("name").value;
window.opener.document.getElementById(name).value = document.getElementById("name").value;
window.opener.document.getElementById(path).value = getWWWPath(document.getElementById("path").value);
window.opener.document.getElementById(type).value = document.getElementById("type").value;
window.opener.document.getElementById(size).value = document.getElementById("size").value; 
var entry = "/entry/item/rights/owner/.";
var entry_type = "/entry/item/rights/owner/@type";
var entry_ownership = "/entry/item/rights/owner/@ownership";
var entry_clearance = "/entry/item/rights/owner/@clearance";
window.opener.document.getElementById(entry).value = "University of Maryland"; 
window.opener.document.getElementById(entry_type).value = "library"; 
window.opener.document.getElementById(entry_ownership).value = "physical"; 
window.opener.document.getElementById(entry_clearance).value = "no"; 
}

function deleteImages(name){

  var popUpRef = window.open("","", "width=700, height=700, status=yes, resizeable=yes" );
  /* if(popUpRef.opener == null ){
	popUpRef.opener = self;
   }
*/

   popUpRef.window.document.writeln("<HTML>\n");

   popUpRef.window.document.writeln("<head> <title>Servlet File Delete</title> <head>\n");

   popUpRef.window.document.writeln("<body> <script  language=\"javascript\" src=\"common/imageinfo.js\"></script>");
   popUpRef.window.document.writeln("<p>Image Upload Servlet</p>\n");

  popUpRef.window.document.writeln("<FORM ACTION=\"requestdelete");
  popUpRef.window.document.writeln("?file="); 
  popUpRef.window.document.writeln(name); 
  popUpRef.window.document.writeln("\" METHOD=POST>\n");
  popUpRef.window.document.writeln("<br>Delete file:"+name+"\n"); 
  popUpRef.window.document.writeln("<BR> <INPUT TYPE=SUBMIT value=delete> </FORM> \n</body> \n </HTML>");
  popUpRef.window.document.close();

}


function getImageEntry(count){
  if(count == 0){
return "/entry/image/image_name";
  }else{
 return "/entry/image["+count+"]/image_name";
  }	
}


function getImageInfo(count){
//alert("javascript:Test I");
var popUpRef = window.open("","","width=500 height=500 status=yes resizable=yes" );

if ( popUpRef.opener == null ){
  	alert("openner is null");
		popUpRef.opener = self;
	}

//alert("javascript:Test II");
popUpRef.window.document.writeln("<HTML>\n");

popUpRef.window.document.writeln("<head> <title>Java Servlet File Upload</title> <head>");

   popUpRef.window.document.writeln("<body> <script  language=\"Javascript\" src=\"common/imageinfo.js\"></script>");
   popUpRef.window.document.writeln("<p>Image Upload Servlet</p>");

  popUpRef.window.document.writeln(" <FORM ACTION=\"requestupload");
  popUpRef.window.document.writeln("?count="); 
  popUpRef.window.document.writeln(count); 
  popUpRef.window.document.writeln("&thumbnail=false"); 
  popUpRef.window.document.writeln("\" METHOD=POST ENCTYPE=\"multipart/form-data\">");
  popUpRef.window.document.writeln(" \n Which file to upload?  <INPUT TYPE=FILE NAME=file1> \n <BR> \n <INPUT TYPE=SUBMIT> \n </FORM> \n </body> \n </HTML>");
  popUpRef.window.document.close();
}

function getImageThumbnailInfo(count){
//alert("javascript:Test 3");

var popUpRef1 = window.open("","","width=500 height=500 status=yes resizable=yes" );

if ( popUpRef1.opener == null ){
		popUpRef1.opener = self;
	}

//alert("javascript:Test 4");

popUpRef1.window.document.writeln("<HTML>\n");

popUpRef1.window.document.writeln("<head> <title>Java Servlet File Upload</title> <head>");

   popUpRef1.window.document.writeln("<body> <script  language=\"Javascript\" src=\"common/imageinfo.js\"></script>");
   popUpRef1.window.document.writeln("<p>Image Thumbnail Upload Servlet</p>");

  popUpRef1.window.document.writeln(" <FORM ACTION=\"requestuploadthumb");
  popUpRef1.window.document.writeln("?count="); 
  popUpRef1.window.document.writeln(count); 
  popUpRef1.window.document.writeln("&thumbnail=true"); 
  popUpRef1.window.document.writeln("\" METHOD=POST ENCTYPE=\"multipart/form-data\">");
  popUpRef1.window.document.writeln(" \n Which file to upload?  <INPUT TYPE=FILE NAME=file1> \n <BR> \n <INPUT TYPE=SUBMIT> \n </FORM> \n </body> \n </HTML>");
  popUpRef1.window.document.close();
}



function setID(n,p,s,t)
{
	name_id = n;
	path_id = p;
	size_id = s;
	type_id = t;
}


