function onHistoryChanged(newLocation, historyData) {
	updateList(historyData);
};
function onCategoryListWindowLoad() {    
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(onHistoryChanged);
	var criteria = dhtmlHistory.getCurrentLocation();
	if(criteria != null && criteria !== "") {
	    if(historyStorage.hasKey(criteria))
	        updateList(historyStorage.get(criteria));
        else {
            var args = criteria.split(",");
            movePage(_category, parseInt(args[1]) || 1, parseInt(args[2]) || 10, parseInt(args[3]) || 5);
        }
	} else 
	    movePage(_category, 1, 10, 5);
};
function movePage(category, start, count, rowsize) {    
	var key = category.sdbmHash() + "," + start + "," + count + "," + rowsize;	
    if(historyStorage.hasKey(key)) {
        updateList(historyStorage.get(key));     
        return;
    }    
    var onSuccessCallback = function(transport) {        
        if(transport.responseText) {            
            updateList(transport.responseText);            
            dhtmlHistory.add(key, transport.responseText);
        } else {
            updateList("no response text");
        }    
    }	
	new Ajax.Request(g_db_url + "/webCategoryList?OpenAgent&category=" + category + "&start=" + start + "&count=" + count + "&rowsize=" + rowsize, {
			method:'get',
			onSuccess: onSuccessCallback,
            onFailure: function(){ alert("Something went wrong...") }
  	});
};
function updateList(s) {
    $("list").innerHTML = s;
};
function showLightBox(obj) {
	window.location.href = "/lightbox";
}
