
		var rowcount = 0;
		var resultTable=[];
		var all_results=[];
		var resultCSV = "";
		
		// store domains, types, properties to use as filters
		var f = {"top":{},"more":{},"other":{}};

		var updateCache = true;
		var filter_property=$(document).getUrlParam("property") != null ?decodeURIComponent($(document).getUrlParam("property")) : "";
		var filter_types=$(document).getUrlParam("types") != null ?decodeURIComponent($(document).getUrlParam("types")) : "";
		var filter_day=Boolean($(document).getUrlParam("filter_day")) != null ?Number(decodeURIComponent($(document).getUrlParam("filter_day"))) : 0;
		var query_type=$(document).getUrlParam("query_type") != null ?decodeURIComponent($(document).getUrlParam("query_type")) : "Show All Topics";
		var domain=$(document).getUrlParam("domain") != null ?decodeURIComponent($(document).getUrlParam("domain")) : "";
		var day=$(document).getUrlParam("day") != null?decodeURIComponent($(document).getUrlParam("day")) : "";
		var to_year=$(document).getUrlParam("to_year") != null ?decodeURIComponent($(document).getUrlParam("to_year")) : "";
		var from_year=$(document).getUrlParam("from_year") != null ?decodeURIComponent($(document).getUrlParam("from_year")) : "";
		var nyears=$(document).getUrlParam("nyears") != null ?Number(decodeURIComponent($(document).getUrlParam("nyears"))) : 10; 
		var pagesize=$(document).getUrlParam("pagesize") != null ?Number(decodeURIComponent($(document).getUrlParam("pagesize"))) : 25;
		var qcount = 0; // count number of queries to determine when all callbacks are returned.	

		var total_rows=0;
		var year=0;
		var mql_cursor=true;

 		
 		var time_last = (new Date()).getTime(); 
 		var time_current = (new Date()).getTime(); 
 		var time_diff = 0;
 		var time_cum = 0;
			
		var qc = 0;
		var rwrap = {
				"code":"/api/status/ok",
				"q1": {
					"result":[]
				}
			};		


		function filter_section (fdomainId, ftypeId, fpropertyId){

			// top domains display whether or not the results include specific attributes		
			switch (fdomainId) {
				case '/aviation':
				case '/broadcast':
				case '/film':
				case '/tv':
				case '/music':
				case '/people':
				case '/sports':
					if (fpropertyId == null) {
						return "more";
					}				
					return "top";
					break;	
				default:
					break;
			}

			if (fdomainId != undefined) {
				if (fdomainId.substring(0,5) == "/user") {					
					return "other";
				}
			}

			if (propertyId == null) {
				return "other";
			}
			
			return "more";

		} // end function
		

		function setFilters(DomainId, DomainName, TypeId, TypeName, propertyId, propertyName){
//$(debug_div_id).append("<br>D:id:n::"+DomainId+ DomainName);
//$(debug_div_id).append("<br>T:id:n::"+TypeId, TypeName);
//$(debug_div_id).append("<br>P:id:n::"+propertyId, propertyName);

			var fid = (""+DomainName+DomainId).toLowerCase();
			var section = filter_section(DomainId, TypeId, propertyId);

//$(debug_div_id).append("<br>other: "+DomainId+"::"+TypeId);
// domain isn't in list then add it, otherwise use it later.
// if type isn't in list add it, otherwise use it later
// if there is a prop and prop isn't in list add it

// add to top only if prop
// add top to more
			if (section == "top" && propertyId == null) {
				section == "more"
			}

			if (f[section][fid] == undefined) {
				f[section][fid] = {"id":DomainId, "name":DomainName  , "type":{}}
			}
			if(f[section][fid].type[TypeId] == undefined){
				f[section][fid].type[TypeId] = {"name": TypeName  , "property":{}};
			}
			if ((propertyId != null) && (f[section][fid].type[TypeId].property[propertyId] == undefined)) {
				f[section][fid].type[TypeId].property[propertyId] = {"name": propertyName};
//$(debug_div_id).append("<br>p"+formattedJSON(f[section][fid].type[TypeId].property[propertyId]));
			}
	
		} // END setFilters



		function showfilters(){

			var domain_filter = "";
			var type_filter = "";
			var property_filter = "";
			var fdomain_id_list = "";
			var fdomain_name_list = "";
			var lkfront = "<a href=\"javascript:\{inputbox_div_id.";
			var lkend = "inputbox_div_id.showall.click();\}\">";
			var fclear = "";			
			var section = ""; // use for in [top, more, other]
			var section_div_id;
			var domain_name_id;

//			document.getElementById('status').innerHTML = ""; // clear the searching status message
			$(status_div_id).html(""); // clear the searching status message

			if(inputbox_div_id.domain.value == "" &&
				inputbox_div_id.types.value == "" &&
				inputbox_div_id.property.value == ""						
			){
				domain_filter ="<span class='domain_name'>All Topics</span>";
			}

			fclear = "inputbox_div_id.domain.value = '';inputbox_div_id.property.value = '';";
			section_div_id = document.getElementById('top_filters');
			$(section_div_id).append("<div id='topalltopics' class='domain_name'>"+lkfront+"types.value='';"+fclear+lkend+"All Topics</a></div>");


// use namespace to get official types. Need to update query to inclue this value 
// var official_types = {"type" : [{"domain" : {"key" : {"namespace" : "/"}}}]};




			for (s in f) {
				section = s;
				section_div_id = document.getElementById(''+s+'_filters');
					var fdomainlist = []; // store domain names, then sort, then index f[s] to display
					for (d in f[s]) {
						fdomainlist[fdomainlist.length] = d;					
					}
					
					fdomainlist.sort();
					var domain_types =""; 
					for (i = 0; i < fdomainlist.length; i++){
						var x = fdomainlist[i];
						// id is prefixed with 'dp' to ensure it is unique' 
//						$(section_div_id).append("<div id='dp"+f[s][x].name+"'> </div>");					
						fclear = "inputbox_div_id.types.value = '';inputbox_div_id.property.value = '';";
						$(section_div_id).append("<div id='"+s+x+"' class='domain_name'>"+lkfront+"domain.value='"+f[s][x].id+"';"+fclear+lkend+f[s][x].name+"</a></div>");

						domain_name_id = document.getElementById(''+s+x);
						if(inputbox_div_id.domain.value == f[s][x].id){
							domain_filter = ""+f[s][x].name;
						}
	
						domain_types =""; 
						for (y in f[s][x].type){
							fclear = "inputbox_div_id.domain.value = '';inputbox_div_id.property.value = '';";						
							domain_types += "&nbsp; - &nbsp;"+lkfront+"types.value='"+y+"';"+fclear+lkend+f[s][x].type[y].name+"</a>";
							if(inputbox_div_id.types.value == y){
								type_filter = ""+ f[s][x].type[y].name;
							}
	
							for (z in f[s][x].type[y].property){
								fclear = "inputbox_div_id.domain.value = '';inputbox_div_id.types.value = '';";
								domain_types += "<span style='font-size:12px;'>&nbsp;("+lkfront+"property.value='"+z+"';"+fclear+lkend+f[s][x].type[y].property[z].name+"</a>)</span>";
								if(inputbox_div_id.property.value == z){
									type_filter = " "+ f[s][x].type[y].name;
									property_filter = " ("+ f[s][x].type[y].property[z].name+")";
								}
							}
						}
						$(domain_name_id).append("<span style='font-weight:normal;'>"+domain_types+"</span>");	
	
					} // for each domain

					
			} // end for each section

			section_div_id = document.getElementById('active_filter');
			if (domain_filter != "") {
				$(section_div_id).append("<span  style='font-weight:bold;'>"+ domain_filter + "</span>");
			}
			if (type_filter != "") {
				$(section_div_id).append("<span>"+ type_filter + "</span>");				
			}
			if (property_filter != "") {
				$(section_div_id).append("<span style='font-size:14px;'>"+ property_filter + "</span>" );				
			}
								
			$(section_div_id).append("<span style='margin-left:12px;'> ("+total_rows+")</span>");
			
		} //END showfilters

		
		 
		function mqlread_cb(response) {
			qcount--;
//$(debug_div_id).append("<br>"+qcount);


		    if (response.code != '/api/status/ok') { 
//$(debug_div_id).append("<br> status not okay");
				if (qcount == 0){showfilters();}
//				alert('Freebase error: mqlread failed'); 
				return; 
				}
		    if (!response.q1.result ) { 
//$(debug_div_id).append("<br> not result");
				if (qcount == 0){showfilters();}
//				alert('empty result set');
				return;
				}
			if(response.q1.result.length == 0){
//$(debug_div_id).append("<br> result length 0");
				if (qcount == 0){showfilters();}
				return;
				}
//		    if (response.q1.result[0] == undefined) { return; }

//$(debug_div_id).append("<br>value::"+response.q1.result[0]['/type/reflect/any_value'][0].value);
//$(debug_div_id).append("<br>name::"+response.q1.result[0]['/type/reflect/any_value'][0].link.master_property.name);
//$(debug_div_id).append("<br>topic::"+response.q1.result[0].name);


			rowcount = 0;
			var 	topic = {};

			resultTable=[];
			for (var i=0; i < response.q1.result.length; i++) {
				topic = response.q1.result[i];

				if (topic.name != null){
					tableArray("newRow",rowcount);
					showTopicInYear(topic);
					rowcount++;
				}
			}

//			all_results = all_results.concat(resultTable);
			if(rowcount > 0){
				var added_rows = [];
				myDataTable.addRows(resultTable);

//$(debug_div_id).append(""+myDataTable.getLength());
//myDataTable.render();
				for (var x=0; x< resultTable.length; x++) {
					var b_id = resultTable[x]['Blurbid'];
					if ((b_id != undefined) && (b_id != "")) {

//YOU ARE HERE
						get_mw_blurb_with_guid(b_id,"blurb"+b_id, total_rows);						
					}
					total_rows++;

				}
						
			}

// FILTERS PANEL

			if (qcount == 0){
				showfilters();
			}
					
		} // END mqlread_cb
		
		
		function mqlread(query) {

//$(debug_div_id).append("<br>mqlread");
	
		$.ajax({
		    url: 'http://www.freebase.com/api/service/mqlread',
		    dataType: "jsonp",
		    cache: true, 
		    success: mqlread_cb,
		    data: { queries: query }
		});
	}
						
		//<!-- FUNCTION: tableArray -->
		function tableArray(action, row, column, v){

			if (action == 'newRow'){				
				resultTable[row]= new Array();
			}

			if (action == 'setColumn'){				
				  resultTable[row][column] = v;		
//$(debug_div_id).append("<br>"+resultTable[row][column]);
//$(debug_div_id).append("<br>ts:"+resultTable[row].toString());


					if(column==0 && row !=0){
						resultCSV += "/n";
					}					
					resultCSV += v;
				
				  
			}

			if (action == 'getColumn'){				
					return resultTable[row][column];

			}
//$(debug_div_id).append("<br>rc:"+resultTable[row][column]);
							
		} //<!-- end function tableArray-->
		

		function get_mw_blurb_with_guid(id, div_id_name, dt_row){

			if (id == undefined) {return;}
			var blurbservice = "http://api.freebase.com/api/trans/blurb/";
			var blurburl = "" + blurbservice + '%23' + id.replace(/#/, "");
			var blurb_div_id = document.getElementById(div_id_name);
			
//$(debug_div_id).append("<br>id::d_id: "+id+" :: "+div_id_name);			
			if (id != "") {
				$.ajax({
					url: blurburl,
					dataType: "jsonp",
					cache: true,
					success: function(response){
							if ((response.result != undefined)) {
//$(debug_div_id).append("<br>d_id"+" :: "+div_id_name+" :response: "+response.result.body);
//$(debug_div_id).append("<br>record"+myDataTable.getRecord(dt_row)._oData.Blurbid);
//myDataTable.getRecord(dt_row)._oData.Blurb = response.result.body;

// COMMENT OUT FOR DEBUGGING
var d = myDataTable.getRecordSet;
var rinstance = myDataTable.getRecord(dt_row);
// $(debug_div_id).append(" :"+dt_row);
//$(debug_div_id).append("<br>dt_row:"+);
myDataTable.updateCell(myDataTable.getRecord(dt_row),"Blurb", response.result.body);

//$(debug_div_id).append("<br>dt_row:"+dt_row);
//myDataTable.getRecord(dt_row)._oData.Blurb = "YO YO";
//$(debug_div_id).append("<br>record"+myDataTable.updateRecordValue(dt_row,"Blurb", response.result.body));
//								$(document.getElementById(div_id_name)).html(response.result.body);
							}
					},
					data: {maxlength: 300}
				});
			}
//$(debug_div_id).append("<br>topic::"+);
//						$(blurb_div_id).append(" ...");
//  REMOVED the following from if clause above to fix IE7: && (blurb_div_id.innerHTML == "")
//$(debug_div_id).append("<br><br>"+div_id_name+"::"+id+"::"+ blurb_div_id.innerHTML);
//$(debug_div_id).append("<br>"+div_id_name+"::"+id+"::"+response.result.body);
								
		} // end function


		//<!-- FUNCTION: showTopicBlurb -->
		function showTopicBlurb(t){
			var id = null;     
			var blurburl = null;					
			var blurbservice="http://api.freebase.com/api/trans/blurb/";
			var blurbs = t['/common/topic/article'];
//$(debug_div_id).append("<br>blurbs::"+formattedJSON(blurbs));
			if ((blurbs != null) && (0 < blurbs.length)){
//				for (var i=0; i < blurbs.length; i++){
					
					id = ""+ blurbs[0].guid; // use the first blurb
					id = id.replace(/#/, "");
//					blurburl = "<div id='blurb"+ id+"' class='blurb'></div>";
					tableArray("setColumn",rowcount,"Blurb",blurburl);						
					tableArray("setColumn",rowcount,"Blurbid",id);						

//don't need for loop				}
                
			}
		
		} //<!-- END FUNCTION: showTopicBlurb -->


		//<!-- FUNCTION: showTopicImage -->
		function showTopicImage(t){
			var images = t['/common/topic/image'];
			if (images != null){
				for (var i=0; i < images.length; i++){
					var id = images[i].id;     

					var imageurl="";
//http://www.freebase.com/api/trans/image_thumb//guid/9202a8c04000641f8000000004c775b2					
// http://www.freebase.com/api/trans/image_thumb/wikipedia/images/en_id/16870358	
//$(debug_div_id).append("<br>topic::"+formattedJSON(images));
				
					imageurl=""+'<'+'img alt='+'"'+t.name+'"'+' src='+'"'+
							"http://api.freebase.com/api/trans/image_thumb"+id+'"'+'>';
					tableArray("setColumn",rowcount,"Image",imageurl);
					
				}
			}

		} //<!-- END FUNCTION: showTopicImage -->




		//<!-- FUNCTION: Display dated topic -->
		function showTopicInYear(topic){
		
//			var propertyNameHeader = "";	
			var propertyName = "";	
			var	propertyLink = "";
			var	propertyTypeName = "";
			var propertyDomainName = "";
			var propertyNameId = "";
			var propertyTypeId = "";
			var propertyDomainId = "";
			var	typeList = "";
			var	typeCounter = 0;
			var formfield = "";
			var p = {};
			var t = {};
			var topic_link ="";
			var topic_date = new Date();
			var current_year;

							
			formfield = "showall";
//$(debug_div_id).append("<br>topic::"+formattedJSON(topic));

			
			for (var x=0; x<topic['/type/reflect/any_value'].length; x++){
				p = topic['/type/reflect/any_value'][x];
					propertyName = p.link.master_property.name;
					tableArray("setColumn",rowcount,"Attribute", propertyName);
					tableArray("setColumn",rowcount,"Type_of_Attribute", p.link.master_property.schema.name);						

//				if (propertyNameHeader != p.link.master_property.name + p.link.master_property.schema.name) 
				if(propertyName != null){
//					propertyNameHeader = p.link.master_property.name + p.link.master_property.schema.name;
					propertyTypeName   = p.link.master_property.schema.name;
					propertyDomainName   = p.link.master_property.schema.domain.name;

					propertyId = p.link.master_property.id;
					propertyTypeId = p.link.master_property.schema.id;
					propertyDomainId = p.link.master_property.schema.domain.id;
					
					current_year = Date.parseString(p.value).getFullYear();

// TRYING TO WORKAROUND IE7 NOT SHOWING TEXT - innerHTML did not work either
//					if (status_div_id.hasChildNodes()) {
//						status_div_id.removeChild(status_div_id.lastChild);						
//					}
//					$(status_div_id).append("<span>Getting data for "+ current_year+"</span>");
					$(status_div_id).html("Getting data for "+ current_year);
//$(debug_div_id).html("Getting data for "+ current_year);

					
//$(debug_div_id).append("<br>"+":"+propertyDomainName  +"::"+propertyTypeName  +"::"+propertyName);
//$(debug_div_id).append("<br>"+":"+propertyDomainId+"::"+propertyTypeId+"::"+propertyId);

					setFilters(propertyDomainId, propertyDomainName, propertyTypeId, propertyTypeName, propertyId, propertyName);
					
				} // end if
					
			
			} //<!-- end for p in topic -->

			<!-- get additional types for each topic -->						
			typeCounter = 0;
			typeList = "";
			
			// REPLACED ['n:type']
			for (var n=0; n<topic['type'].length; n++){
				t = topic['type'][n]; 
			
				if (t.name != 'Topic'){
					if (t.name != propertyTypeName){
						 if (typeCounter != 0){
						 		typeList = typeList + ", ";
						 }
						typeList = typeList + t.name;
						typeCounter++;
						setFilters(t.domain.id, t.domain.name, t.id, t.name, null, null);
					} //<!-- end if t is not the same as the primary property type-->
				}
			}	// end for t
							
			showTopicImage(topic);
			showTopicBlurb(topic);	
// 						card_content +=   "<div id='blurb"+ card_count+"' class='card_blurb'></div>";
// 						get_mw_blurb(topic,"blurb"+card_count); // send freebase request, put result in the blurb div
						

			//<!-- add other property values to array -->
			if (typeList != ''){													
					propertyTypeName   = propertyTypeName   + ', ';			
			}

 			topic_link =""+ '<' + 'a ' + 'href='+ '"' + 
 				'http://www.freebase.com/view?id=' +
 				encodeURIComponent(topic.id)+ '"' + '>' +topic.name + '<' + '/a' + '>';														
 			tableArray("setColumn",rowcount,"Year",current_year);
			tableArray("setColumn",rowcount,"Topic",topic_link);
//$(debug_div_id).append("<br>showTopicYear:rtable[0][topic]::"+resultTable[0]["Topic"]);


			typeList=propertyTypeName  +typeList;
			tableArray("setColumn",rowcount,"Topic_Types",typeList);
			tableArray("setColumn",rowcount,"Category",propertyDomainName  );
				
//$(debug_div_id).append("<br>"+formattedJSON(resultTable));
//	  write_it(day+".txt", resultTable[rowcount].toString());


	}  //<!-- end showTopicInYear -->



	//<!-- FUNCTION queryYear -->
	function queryYear(year, day, mql_cursor){


//this query gets official freebase types
// TO DO - ADD key namespace to query so official types can be easily found for displauy
 var official_types = [{
   "id" : "/en/robert_cook",
   "type" : [
     {
       "domain" : {
         "key" : {
           "namespace" : "/"
         },
         "limit" : 0
       },
       "id" : null
     }
   ]
 }
];


		if (mql_cursor == true){

					var domain_value = "";
					var full_date = ""+year+"-"+day; 
					var qwrap = {
						"q1": {
							"query": []
						}
					};					
					var tq = {
					"limit":200,
    				"/type/reflect/any_value":[{
	      				"link":{
	        				"master_property":{
		          				"schema":{
		          					"name":null,
		          					"id":null,
		            				"domain":{
			              				"id":null,
			              				"name":null
		            				}
	          				},
	          				"id":null,
	          				"name":null
	        				}
	      				},
	      				"type":"/type/datetime",
	      				"value":full_date
    				}],
    				"id":null,
    				"name":null,
    				"/common/topic/image":[{ "id":null,"optional":true, "limit":1 }],
    				"/common/topic/article":[{ "guid":null,"optional":true, "limit":1 }],
    				"type":[{
						"domain":{"name":null,"id":null},
						"name":null,
						"id":null
						}],
    				"n:type":[{ 
						"domain":{"name":null,"id":null},
						"name":null, 
						"id":null 					
					}]
  					};
	
	  			//<!-- restrict query to a single domain -->
	
		  			if (domain != ''){
	//	  					domain_value=domain;
							tq["n:type"][0].domain.id = domain;
	//	  					tq["/type/reflect/any_value"][0]["link"].master_property.schema.domain = 
	//	  							{"id":domain_value, "name":null};
		  			}
	
					if (filter_property != '') {
						tq["/type/reflect/any_value"][0]["link"].master_property["id|="] = new Object();
						tq["/type/reflect/any_value"][0]["link"].master_property["id|="] = [filter_property];
					}						
	
	
					if (filter_types != ''){					
						tq["type"][0].id = filter_types;
	//					tq["type|="] = new Object();
	//					tq["type|="] = [filter_types];
					}
	
	
	
					tq["sort"] = new Array();
					tq["sort"][0] = "/type/reflect/any_value.link.master_property.name";
					tq["sort"][1] = "/type/reflect/any_value.link.master_property.schema.name";
				
	
	
	// TEMPORARILY COMMENT OUT CURSOR CODE
	//					var mql_cursor_obj;
	//					mql_cursor_obj = {cursor:mql_cursor};					
	
	
	// query using tq		
				qwrap.q1.query[0] = tq;
	//$(debug_div_id).append(JSON.stringify(qwrap));
	//$(debug_div_id).append("<br>"+formattedJSON(qwrap));
				mqlread(JSON.stringify(qwrap));
	


			} //<!-- end mql_cursor == true -->



		} //<!-- end queryYear -->

		function getBlurb(id, row_id){

          
			if (id == undefined) {return;}
			var blurbservice = "http://api.freebase.com/api/trans/blurb/";
			var blurburl = "" + blurbservice + '%23' + id.replace(/#/, "");
			
			if (id != "") {
				$.ajax({
					url: blurburl,
					dataType: "jsonp",
					cache: true,
					success: function(response){
							if ((response.result != undefined)) {
//     myDataTable.unsubscribe("postRenderEvent", getDataToDisplay);                                
                                myDataTable.updateCell(row_id,"Blurb", response.result.body);
//$(debug_div_id).append(" :gotBlurb:"+id+":<br>");                                
//     myDataTable.subscribe("postRenderEvent", getDataToDisplay);
							}
					},
					data: {maxlength: 300}
				});
			}
								
		} // end function		
        
function getDataToDisplay () {
var tr, rindex, rinstance;
var b_id;
var blurb = "";

//$(debug_div_id).append(" :post: ");
            
     tr = myDataTable.getFirstTrEl();
     while (tr != null) {
// rindex = myDataTable.getRecordIndex(tr);
         rinstance = myDataTable.getRecord(tr);
         b_id = rinstance.getData("Blurbid");
         blurb = rinstance.getData("Blurb");
         if ((b_id != null) && (blurb == null)) {
//$(debug_div_id).append(" :: "+b_id+":"+blurb+": ");

//rinstance.setData("Blurb", b_id);             

        	getBlurb(b_id, rinstance)
         }

         tr = myDataTable.getNextTrEl(tr);
               
     }
//$(debug_div_id).append(" :: postevent"+rinstance.getData("Topic"));

// rindex = myDataTable.getRecordIndex(tr);
// rindex = myConfigs.paginator.getStartIndex();
    
}


		
function start_queries(){

//<!-- begin main section -->
//<!-- set variables with specified parameters -->
//$(debug_div_id).append("<br>SET DAY");



			//<!-- if no parameters are specified then initialize with something interesting -->
			if ((day == '') &&
				(filter_property == '') &&
				(filter_types == '') &&
				(from_year == '') &&
				(to_year == '')) 
				{
		
//				day='03-16';
//				filter_property= "/people/person/date_of_birth";
//				filter_types = "/film/actor";

				to_year ="1930";
				from_year = "1980";				
//				to_year =""+ today.getFullYear();
//				to_year ="1980";
//				from_year = "1950";				

			}
			
			//<!-- use today's date if none specified by user -->
			var the_date =   (day == '') ? new Date() : new Date.parseString(day);;

			day="";
			if (the_date.getMonth()< 9){
				day=day+"0";
			}
			day=day+(the_date.getMonth()+1)+"-";
			if (the_date.getDate()< 10){
				day=day+"0";
			}
			day=day+the_date.getDate();				
			
			if (to_year == '' && from_year ==''){
				//<!-- if no years specified use this year -->	
					to_year=""+ today.getFullYear();
					from_year=""+ ((to_year - nyears)+1);
			}
			//<!-- make years the same if only one is specified-->
			else if (to_year == ''){
					to_year = from_year;
			}
			else if (from_year == ''){
					from_year = to_year;
			}

			if (from_year > to_year){
					year=from_year; 
					from_year=to_year;
					to_year=year; 
			}
		
			year = to_year;
			nyears = (to_year-from_year) + 1;
			qcount = nyears; // use in mqlread_cb
			
	//<!-- end set variables -->

	//<!-- begin query and display -->

		year = year - nyears;

// INSTANTIATE DATATABLE ONCE
//			var myDataTable = new YAHOO.widget.DataTable("history_table", myColumnHeaders, myDataSource, myConfigs);

// THIS STOPPED IE7
//			myDataTable.getMsgTbodyEl().innerHTML="<div class='table_message'>.... still looking for something</div>";
// THIS DIDN'T STOP IE7 BUT IT DIDN'T WORK


			var table_status_msg_id = myDataTable.getMsgTbodyEl();
			var table_status_text = "<div class='table_message'>.... still looking for something</div>";
			$(table_status_msg_id).html(table_status_text);

//            myDataTable.subscribe("postRenderEvent", getDataToDisplay);
//            myDataTable.subscribe("rowAddEvent", getBlurb);

			to_year_div_id.value = to_year;
			from_year_div_id.value = from_year;
			day_div_id.value = day;
			domain_div_id.value = domain;
			types_div_id.value = filter_types;
			property_div_id.value = filter_property;			



//	$(debug_div_id).append("<br>NEED TO TEST ON IE, and try onload - wrap main in function start_queries");
	for (; nyears > 1; nyears--) {
		year++;
//$(debug_div_id).append("<br>"+ year);
		
		queryYear(year, day, true);
	}
	
	if (nyears > 0) {
		year++;
		queryYear(year, day, true);
	}
} // end start_queries