Index: /gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in
===================================================================
--- /gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in	(revision 26750)
+++ /gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in	(revision 26751)
@@ -161,5 +161,5 @@
 										if(href.match(clRE)){
 											if(!visitedURLs[href]){
-												console.log("found a new CL line: " + href);
+												//console.log("found a new CL line: " + href);
 												outstandingURLs.push(href);
 												visitedURLs[href] = 1;
@@ -171,5 +171,5 @@
 												var docOID = docMatch[1];
 												
-												console.log("found a new doc line: " + docOID);
+												//console.log("found a new doc line: " + docOID);
 												visitedURLs[href] = 1;
 												docOIDs.push(docOID);
@@ -201,4 +201,6 @@
 					}
 					
+					
+					
 										
 					function pageLoaded(){
@@ -212,5 +214,106 @@
 							}
 							
-							var iframeDoc;
+							var iframeDoc = getIframeDoc(iframe);
+												
+						
+							/*Check url - if it's a doc Url, call "writeDocument", otherwise call "writeClPage"*/
+							var clRE = new RegExp("(\\\\/)browse\\\\/" + cl + "(\\\\/\\\\d+)+(\$)");
+							
+							
+							if(iframe.src.match(clRE)){
+								writeClPage(iframe,iframeDoc);
+							}else{
+								writeDocument(iframe,iframeDoc);
+							}
+						}
+					}
+					
+					function writeDocument(iframe){
+						
+						console.log("now processing document: " + iframe.src + " ***");
+						var xmlUrl = iframe.src + "&o=xml";
+						
+						var iter = (numDocOIDs - docOIDs.length);
+						var progressPercent = iter/numDocOIDs * 100;
+						
+						var frameNum = getMetadata(xmlUrl,'frameID');
+						
+						if(frameNum == null){
+							frameNum = iter;
+						}
+						
+						var iframeDoc = getIframeDoc(iframe);
+						
+						
+						\$(function(){
+							\$('#progressbar').progressbar({ value: progressPercent });
+						});
+						
+						var gsContent = iframeDoc.getElementById("gs_content");
+						
+						var assocElem = iframeDoc.getElementById("assocfilepath");
+						
+						var assocElem = iframeDoc.getElementById('assocfilepath');
+						var assoc = null;
+						
+						if(assocElem === undefined || assocElem === null){
+							assoc = getMetadata(xmlUrl,'assocfilepath');
+						}
+						
+						var expFrameTree = htmlToExpeditee(gsContent,compute_font,compute_width);
+						
+						var expFrame = JSON.stringify(expFrameTree);
+						//console.log(expFrame);
+						
+						var url = "cgi-bin/html-to-expeditee.pl";
+						var params = "c=" + collect;
+						
+						if(site.match(/\\w/)){
+							params += "&site=" + site;
+						}
+						
+						params += "&a=generate-frame&fn=" + frameNum;
+						params += "&json=" + escape(expFrame);
+						
+						//Add an assocfilepath but only if it is defined
+						if(assoc !== null){
+							params += "&assoc=" + assoc;
+						}
+						
+						params += "&compute-font=" + compute_font;
+												
+						params += "&page-type=" + "document";
+											
+						
+						var clHtml = urlPostSync(url,params);
+						
+						if(!clHtml.match(/html-to-expeditee saved frame/)){
+							alert("ERROR PROCESSING URL: " + url);
+						}
+						
+						if(docOIDs.length > 0){
+							var docOID = docOIDs.shift();
+							
+							//Add docOID and matching frame number to an associative array for later use.
+							hashMapDocFrames[docOID] = frameNum;
+							
+							
+							iframe.src = getDocumentUrl(docOID);
+							
+						}else{
+							
+							//start writing CL pages.
+							if(generate_browsing){
+								iframe.src = clPages.shift();
+							}else{
+								//We are finished
+								finish(iframe);
+							}
+						}	
+					}
+					
+					function getIframeDoc(){
+						
+						var iframeDoc = null;
 							
 							if(iframe.contentDocument){ /* FF and Chrome */
@@ -220,95 +323,6 @@
 							}
 						
-							/*Check url - if it's a doc Url, call "writeDocument", otherwise call "writeClPage"*/
-							var clRE = new RegExp("(\\\\/)browse\\\\/" + cl + "(\\\\/\\\\d+)+(\$)");
-							
-							
-							if(iframe.src.match(clRE)){
-								writeClPage(iframe,iframeDoc);
-							}else{
-								writeDocument(iframe,iframeDoc);
-							}
-						}
-					}
-					
-					function writeDocument(iframe,iframeDoc){
-						
-						var xmlUrl = iframe.src + "&o=xml";
-						
-						var iter = (numDocOIDs - docOIDs.length);
-						var progressPercent = iter/numDocOIDs * 100;
-						
-						var frameNum = getMetadata(xmlUrl,'frameID');
-						
-						if(frameNum == null){
-							frameNum = iter;
-						}
-						
-						//Add docOID and matching frame number to an associative array for later use.
-						hashMapDocFrames[docOID] = frameNum;
-						
-						\$(function(){
-							\$('#progressbar').progressbar({ value: progressPercent });
-						});
-						
-						var gsContent = iframeDoc.getElementById("gs_content");
-						
-						var assocElem = iframeDoc.getElementById("assocfilepath");
-						
-						var assocElem = iframeDoc.getElementById('assocfilepath');
-						var assoc = null;
-						
-						if(assocElem === undefined || assocElem === null){
-							assoc = getMetadata(xmlUrl,'assocfilepath');
-						}
-						
-						var expFrameTree = htmlToExpeditee(gsContent,compute_font,compute_width);
-						
-						var expFrame = JSON.stringify(expFrameTree);
-						//console.log(expFrame);
-						
-						var url = "cgi-bin/html-to-expeditee.pl";
-						var params = "c=" + collect;
-						
-						if(site.match(/\\w/)){
-							params += "&site=" + site;
-						}
-						
-						params += "&a=generate-frame&fn=" + frameNum;
-						params += "&json=" + escape(expFrame);
-						
-						//Add an assocfilepath but only if it is defined
-						if(assoc !== null){
-							params += "&assoc=" + assoc;
-						}
-						
-						params += "&compute-font=" + compute_font;
-												
-						params += "&page-type=" + "document";
-											
-						
-						var clHtml = urlPostSync(url,params);
-						
-						if(!clHtml.match(/html-to-expeditee saved frame/)){
-							alert("ERROR PROCESSING URL: " + url);
-						}
-						
-						if(docOIDs.length > 0){
-							var docOID = docOIDs.shift();
-							iframe.src = getDocumentUrl(docOID);
-							
-						}else{
-							//start writing CL pages.
-							if(generate_browsing){
-								numClPages = clPages.length;
-							
-								var url = clPages.shift();
-								iframe.src = url;
-								writeClPage(iframe,iframeDoc);
-							}else{
-								//We are finished
-								finish(iframe);
-							}
-						}	
+						
+						return iframeDoc;
 					}
 					
@@ -329,8 +343,10 @@
 					}
 					
-					function writeClPage(iframe,iframeDoc){
+					function writeClPage(iframe){
 						
 						var frameNum = numClPages - clPages.length;
 						var progressPercent = frameNum / numClPages * 100;
+						var iframeDoc = getIframeDoc(iframe);
+						console.log("Processing cl page: " + iframe.src + " ****");
 						
 						\$(function(){
@@ -343,8 +359,9 @@
 						var docRE    = new RegExp("(?:\\\\/)document\\\\/(.*?)(?:\$)");
 						
-						//get rid of rectangles around nodes.
+						
 						for(var i = 0; i < gsContentChildren.length; i++){
 							var child = gsContentChildren[i];
 							
+							//get rid of rectangles around nodes.
 							if(child.tagName !== "IMG"){
 								child.setAttribute('rect','norect');
@@ -367,5 +384,5 @@
 										var frameName = collect + fn;
 										
-										//aElemChild.setAttribute("link",frameName);
+										aElemChild.setAttribute("link",frameName);
 									}
 									
@@ -376,7 +393,5 @@
 							}
 						}
-						
-						//add link attribute to children nodes of <a> elements.
-						
+	
 						
 						//TODO: Need to change htmlToExpeditee code to account for links
@@ -406,6 +421,5 @@
 						
 						if(clPages.length > 0){
-							var clPage = clPages.shift();
-							iframe.src = clPage;
+							iframe.src = clPages.shift();
 						}else{
 							finish(iframe);
