function PageResult() {

	this.table = $("#page").dataTable();
	this.intervalId = null;
	this.getPageResultFirstly = function(testPlanId, scripts, map) {
		for ( var i = 0; i < scripts.length; i++) {
			var url =  testPlanId + "/" + scripts[i].scriptId + "/page";
			this.getPagesResult(url, map, scripts[i].scriptName, this.table);
		}

	}

	this.loadPageResult = function(testPlanId, scripts) {
		var table = $("#page").dataTable();
		var map = new HashMap();
		var page = this;
		this.getPageResultFirstly(testPlanId, scripts, map);
		this.intervalId = setInterval(function() {

			for ( var i = 0; i < scripts.length; i++) {

				var url =  testPlanId + "/" + scripts[i].scriptId
						+ "/page";
				page.getPagesResult(url, map, scripts[i].scriptName, table);
			}

		}, 7000);

	}
	this.getPagesResult = function(url, map, scriptName, table) {

		var page = this;

		$.post(url, {}, function(data) {
			if (!data.success) {
				return;
			}
			data = data.pages;
			map.put(scriptName, data);
			page.insertDataToTable(table, map)
			if ($("#status").attr("status") == "Complete") {
				if (page.intervalId != null) {
					clearInterval(page.intervalId);
				}

			}
		}, "json");

	}

	this.insertDataToTable = function(table, map) {

		table.fnClearTable();
		for ( var k = 0; k < map.length(); k++) {
			var names = map.getKeys();
			for ( var j = 0; j < map.get(names[k]).scriptPageBriefModels.length; j++) {
				var data = map.get(names[k]).scriptPageBriefModels[j];
				var page = "Page" + j;
				table.fnAddData([ page, names[k], data.countFromBegin,
						data.minResponseTimeFromBegin,
						data.maxResponseTimeFromBegin,
						data.averageResponseTimeThisTime,
						data.latestResponseTime ]);

			}

		}
	}
}
