function loadImages(src,returntype,currimage,fileroot)
{
	var targetframe = 'popupImages';
	var newhref = editmodenullpagelink+'layout=rt_spaced&main.ctrl=filemgr.list&main.view=fileroom.list&main.order=directory+desc,file_name&main.srcfield='+src.form.name+'.'+src.name+'&main.imagepicker=yes&top.bgcolor=white&top.function=Image+Picker&top.align=left&top.tdwith=10';
	if (currimage != null) newhref += '&main.currimage='+escape(currimage);
	if (fileroot == null) fileroot = 'images';
	if (newhref.indexOf('fileroot') == -1) newhref += '&main.fileroot_name='+fileroot;
	var relpath = getCookie(fileroot+"_savedpath");
	if (relpath != null) newhref += '&main.relative_path='+relpath;
	if (returntype != null) newhref += '&main.returntype='+returntype;
	var images = window.open(newhref,targetframe,getAllPopupWinSizeParams(380,550,'yes','no','yes'));
}

function swapImg(imgFld)
{
	imgField = imgFld;
	if(imgField && document.usr_img)
	{
		if (imgField.value.length > 0)
		{
			dummyImg = new Image(); // used to calculate actual size
			if (imgField.value.indexOf('http')==0)
				dummyImg.src = imgField.value;
			else
				dummyImg.src = imagepickercontextpath + imgField.value;
			document.usr_img.src = dummyImg.src;

			if(imgFld.form.x_imgsize.selectedIndex > 0)
				document.usr_img.width = imgFld.form.x_imgsize[imgFld.form.x_imgsize.selectedIndex].value;
			else if(dummyImg.width > 0 && document.usr_img.width != dummyImg.width)
				document.usr_img.width = dummyImg.width;

			// Do not touch divs because it may show/hide the image independent from the div itself
			//showDivs(new Array('ui_sp','ui_prev'));
		}
		else
		{
			document.usr_img.src = rtimagepath + "/icons/shim.gif";
			// Do not touch divs because it may show/hide the image independent from the div itself
			//hideDivs(new Array('ui_sp','ui_prev'));
		}
	}
}
swapImg();
togglePref('usr_image','uid0','uid1','ui_sp','ui_prev');
