/*
 * getView() Makes an AJAX call to a url that responds with a dW view page
 */
function getView(query) {    
 	var req = newXMLHttpRequest(); 
	if (req) {
   req.onreadystatechange = getReadyStateHandler(req, processViewResults);
   req.open("GET", query, true);
   req.send("");
 	}
}


/*
 * processViewResult() Interrogates the result page for "No results found" and changes the content if true.
 *                     var: notFoundText, is defined on the calling page.
 */
function processViewResults(result) {
   var viewContents = document.getElementById("view-contents"); 
   var pattern = /No search results found./;
   if (result != null && viewContents != null) {
   	if (pattern.test(result)) {
    	viewContents.innerHTML = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\"><td colspan=\"2\"><img src=\"//www.ibm.com/i/c.gif\" border=\"0\" height=\"12\" width=\"12\" alt=\"\"/></td></tr><tr valign=\"top\"><td gcolor=\"#f6f6f6\" ><b>"+notFoundText+"</b></td><td bgcolor=\"#f6f6f6\" width=\"3\"><img src=\"//www.ibm.com/i/c.gif\" height=\"1\" width=\"3\" border=\"0\" alt=\"\" /></td></tr></table>";
   	}
   }
}
