

//use this function to control thumb when the page may display more than 1 thumb at a time (e.g. search)
function updateThumb_singleThumb(DTAId,fullImageURL,thumbImageURL,cbId,numChildren,fileID)
			{			
				//update the  thumb hyperlink
				thumbLink = document.getElementById('thumbLink_'+DTAId);				
				thumbLink.href = fullImageURL;
				thumbLink.children[0].src = "../images/Downloading.gif";
				if(thumbImageURL.indexOf("getFileThumb_PDF.aspx")>=0)	
					RS.Execute(thumbImageURL, "buildPDFThumb", callback, errorCallback,thumbLink);					
				else				
					thumbLink.children[0].src=thumbImageURL;					
				
				//alert(thumbImageURL);
				//thumbhl.href = fullImageURL
				//thumbhl.children[0].src=thumbImageURL;
				//alert(thumbImageURL);
				
				// uncheck all files in this list
				//table = document.getElementById("lstFiles");	
				prefix="cbThumb_";
				
				for (i=0; i <= numChildren; i++)
				{
					id = "cbThumb_" + DTAId + "_" + i;
					//alert(' id ' +id);
					oldcb = document.getElementById(id);
					//alert('oldcb ' + oldcb);
					oldcb.children[0].src="../images/uncheck.gif";
				}					
				
				//update the new checked file
				newcb = document.getElementById(cbId);
				newcb.children[0].src="../images/check_R.gif";		
				
				hidFileID = document.getElementById("hiddenFileID_" + DTAId);
				hidFileID.value=fileID;			
			}
			
//implementation of RS.Execute callback
function callback(result,tLink)
	{		
		//alert(thumbLink);
		//thumbLink.children[0].src = result;	
		//thumbLink.children[0].height=100;
		//thumbLink.children[0].width=100;	
		
		//alert('callback');
		tLink.children[0].src = result;	
		tLink.children[0].height=100;
		tLink.children[0].width=100;		
		window.status="";		
	}

//implementation of RS.Execute errorCallback
function errorCallback(result)
	{
		alert("An error occurred while invoking the remote method: " + result);
		window.status="";
	}
//use this function to control thumb when the page only display 1 thumb at a time (e.g. submit)
function updateThumb_onGrid(linkID,fullImageURL, thumbImageURL, newcbImageID,numChildren)
			{									
				//update the  thumb hyperlink
				thumbLink = document.getElementById(linkID);
				
				thumbLink.href = fullImageURL;
				thumbLink.children[0].src = "../images/Downloading.gif";
				if(thumbImageURL.indexOf("getFileThumb_PDF.aspx")>=0)	
				{
					window.status="Downloading ...";			
					RS.Execute(thumbImageURL, "buildPDFThumb", callback, errorCallback,thumbLink);
				}
				else
					thumbLink.children[0].src = thumbImageURL;						
				
				// uncheck all files in this list
				newCbImg = document.getElementById(newcbImageID);				
				tableLevel = newCbImg.parentElement.parentElement.parentElement.parentElement;
				prefix = tableLevel.id;
				suffix = "_hlThumbBtn";				
				for( count=2 ; (count<=numChildren) ; count++ )
				{
					eId = prefix+'__ctl'+count+suffix;		
					e = document.getElementById(eId);	
					e.children[0].src = "../images/uncheck.gif";
				}
				
				//update the new checked file
				newCbImg.children[0].src = "../images/check_R.gif";				
			}
			

function loadThumb()
{
	for (var i=0; i < document.images.length; i++)
	{
		src = document.images[i].src;
		//alert(src);
		//alert(src.indexOf("images/noThumb.gif"));
		fileId = 0;
		if ((src.toLowerCase()).indexOf("downloading.gif") >=0 )
		{
			//alert(document.images[i].parentElement.fileId);
			fileId = document.images[i].parentElement.fileId;
			fileType = document.images[i].parentElement.fileType;
			if ((fileType.toLowerCase()).indexOf("application/pdf") >= 0)
			{
				tLink = document.getElementById(document.images[i].parentElement.id);				
				tImageURL = "../maplib/getFileThumb_PDF.aspx?fileId="+fileId;
				RS.Execute(tImageURL, "buildPDFThumb", callback, errorCallback, tLink);
			}
			else
			{
				document.images[i].src = "../maplib/getFileThumb.aspx?fileId="+fileId;
			}
			
		}
	}
}