/*
 * hacktest01.js, coded by Ian Ruotsala beginning
 * Apr. 6, 2010
 * This is a test program to hack/sketch out how a
 * more final version would work.
 * Specifically it represents the module that holds 
 * and interacts with the various event arrays.
 */

/*
 program outputs the following in Firefox:
stringobjectobjectundefined
undefined
undefined
0,result [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

0,result,0,kb_archivid
ivo://helio-informatics.org/AR_NOAASECObserver_20090904_153554_859
 */

function get_events(event_type){
	//send present url to query, update the stored JSON
	var httpQuery = new XMLHttpRequest();
	httpQuery.open("GET",event_type,false);
  	httpQuery.send(null);
	//this.jsonDoc = eval('(' + httpQuery.responceText + ')');
	//eval is generall considered bad practice, security risk
	//use parseJSON instead
	var returnString = httpQuery.responseText;
	document.write(typeof(returnString));
	
	var returnObj = YAHOO.lang.JSON.parse(returnString);
	
	document.write(typeof(returnObj));
	
	//this.jsonDoc = returnObj;
	
	//var jsonCode = (document.childNodes[0]);
	//document.write(jsonCode);
	//document.write(typeof((document.childNodes[1])));
	
	//this.jsonDoc = returnString.parseJSON();
	//document.write(typeof(returnString));
	//this.jsonDoc = this.parse(returnString);
	
	//return true if >= 200 events returned
	if (returnObj.result.length >= 200){
		return true;
	}
	
	return returnObj;
}

function test(){
	var events = new Array();
	events[0] = get_events("ar");
	//^^^ note it will query once per event type

	document.write(typeof(events[0]));
	document.write(typeof(events[0][0]))
	document.write("
"); document.write(events[0][0]); document.write("
"); document.write(typeof(events[0][2])); document.write("
0,result "); document.write(events[0].result); document.write("
"); document.write("
0,result,0,kb_archivid
"); document.write(events[0].result[0].kb_archivid); }