window.onerror = function (err, file, line) {
alert('The following error occured: ' + err + '\n' + 'In file: ' + file + '\n' + 'At line: ' + line);
return true;
}

function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
            buildTopicList();
         } else {
            alert("There was a problem retrieving the XML data:\n" +
                req.statusText);
         }
    }
}


function viewImage(url){
var newWin = window.open(url ,"","titlebar=no,toolbar=no,location=no,menubar=no,location=no,resizable=yes,scrollbars=no,status=no,centerscreen=yes")
return false;
}


function buildTopicList(){
    var items  = req.responseXML.getElementsByTagName("thumb");
    var picloc = req.responseXML.getElementsByTagName("picloc");
    var content = '';
    var total_images = items.length ;
    content += 'Total Images: ' + total_images;
    
    content += '<table>';
    var z= 1;
    
    for (var i = 0; i < items.length; i++) {

    if (z==0) {
    content += '<tr>';
    }

	content += '<td>';
	content += '<img onmouseover="this.style.cursor=\'pointer\'" onclick="viewImage(\'' + picloc[i].firstChild.data + ' \')" border="1" src="' + items[i].firstChild.data  + '" ></td>';

				if (z==cols){
						content += '</tr>';
					z = 0 ;
				}
    z++;
    }

	 content += '</table>';
document.getElementById('pix').innerHTML = content ;
}

			if(new String(navigator.userAgent).search('MSIE') != -1){
			req = new ActiveXObject("Msxml2.XMLHTTP");
			}else {
			req = new XMLHttpRequest();
			}

 	        req.onreadystatechange = processReqChange;
			req.open ('GET', loginUrl, true);
			req.send(null);
