var Chart = Class.create({
  
  initialize: function(ColomnCount, RowCount, Parent, Id, InsertCount) {
  	this.hcParamArray = new Array();
	this.hcParamTypeArray = new Array();
	this.hcParamElementArray = new Array();
    this.hcInsertCount = InsertCount;
	this.hcInsertCounter = 1;
	this.hcColomnCount  = ColomnCount;
    this.hcRowCount = RowCount;
	this.hcParent = Parent ;
	this.hcId = Id;
	this.chVariableArray = new Array();
	this.chVariableLabelArray = new Array();
	this.chVariableClassArray = new Array();
	this.chVariableTypeArray = new Array();
	this.chVariableUpperArray = new Array();
	this.chVariableCombineArray = new Array();
	this.hcElement = null;
	this.chartdata = null;
	this.inprogress = false;
	this.ajaxobg = null;
	this.animI = 0;
	this.animJ = 0;
	this.animM = 0;
	this.hcStaticValue = new Array();
	this.hcJsonUrl = "json_static.php";
	this.CountMinArray = null;
	this.CountMaxArray = null;
	this.minValuesArray = Array();
	this.maxValuesArray = Array();
	
	this.useNoData = false;
	this.chartColored = false;
	this.primaryVariable = 'value';
	this.displayVariable = 'name';
	this.CountryCounter = 0;
	this.selColomnEl = "sel";
	this.hRowPopMale = null;
	this.hRowPopFemale = null;
	this.hRowPopBoth = null;
	this.isFirst = true;
	this.fillNext = true;
	this.Quie = false;
	this.TitleText = "";
	this.selColorArray = new Array('#FF0000', '#00FF00', '#9933FF');
	this.selectedColor = 0;
	this.animateselect =  true;
	this.updatePops = false;
	this.ColorBlack="#000000";
	this.ColorWhite="#ffffff";
	this.ColorGray="#333333";
  },
  
  setTitleText : function (TitleText)
  {
	  this.TitleText = TitleText;
  },
  
  setSelColomn : function (selColomnEl)
  {
	  	this.selColomnEl = selColomnEl;
  },
  setJsonUrl : function (Url){
	  this.hcJsonUrl = Url;
  },
  addVariable : function ( Variable, VariableLabel, VariableClass, VariableType, VariableUpper, VariableCombine) {
	this.chVariableArray.push(Variable);
	this.chVariableLabelArray.push(VariableLabel);  
	this.chVariableClassArray.push(VariableClass);  
	this.chVariableTypeArray.push(VariableType);  
	this.chVariableUpperArray.push(VariableUpper); 
	this.chVariableCombineArray.push(VariableCombine); 
	
  },
  createPane : function() {
	  
	  var headcounter = 0;
    var tbl = document.createElement('table');
	tbl.id = 'hc_table';
	tbl.border = 0;
	tbl.cellSpacing =0;
	tbl.borderColor = "Black";
	$(this.hcParent).appendChild(tbl);
	
	
	
	var tblbody = document.createElement('TBODY');
	//tblbody.id = this.Id;
	tbl.appendChild (tblbody);
	this.hcElement = tblbody;
	
	
	var tblhead = document.createElement('THEAD');
	tbl.appendChild (tblhead);
	
	//var hrowt = tblhead.insertRow(headcounter);
	//headcounter++;
	//var colt1 = hrowt.insertCell(0);
	//coll1.colSpan = 2;
	//colt1.innerHTML  = this.TitleText;
	//colt1.className = 'header_cause_top_';
	//colt1.colSpan = 3;

	//var colt = hrowt.insertCell(0);
	//colt.innerHTML  = this.TitleText;
	//colt.className = 'header_cause_top_';
	//colt.colSpan = 120;
	var hrow001 = tblhead.insertRow(headcounter);
	headcounter++
	
	var col001 = hrow001.insertCell(0);
	//col001.innerHTML  = "&nbsp";
	//col001.id  = "time_pane";
	col001.style.width = 173;
	col001.className = 'hc_header_instructions';
	col001.colSpan = 2;
	//col001.innerHTML  = "<a href='javascript:open_instructions()' style='color:#000;'>INSTRUCTIONS</a>";
	col001.innerHTML  = "INSTRUCTIONS";
	col001.onclick = function () {showinstruction();}
	//col001.innerHTML  = "INSTRUCTIONS";
	//col001.onClick = function ()
	//{
	//	window.open('usa_data_grid_instructions.php', 'instructions', 'scrollbars=no');
	//}
	var col002 = hrow001.insertCell(1);
	col002.colSpan = 18;
	col002.innerHTML  = "USA DATA GRID";
	col002.className = 'hc_header_title';	
	
	
	
	var hrow0 = tblhead.insertRow(headcounter);
	headcounter++
	//var col01asdasd = hrow0.insertCell(0);
	var col01 = hrow0.insertCell(0);
	//coll1.colSpan = 2;
	
	
	col01.innerHTML  = "&nbsp";
	col01.id  = "time_pane";
	col01.style.width = 173;
	col01.className = 'header_cause_top';
	col01.colSpan = 2;
	var col02 = hrow0.insertCell(1);
	col02.colSpan = 18;
	col02.innerHTML  = "<div class='pop_instructions_left'>Select Gender-Sort By Age</div><div class='pop_instructions_right'>Select Gender-Sort By Age</div>POPULATION BY AGE AND GENDER";
	col02.className = 'header_cause_top_right';
	
	
	
	var hiden = tblhead.insertRow(headcounter);
	headcounter++;	
	var gag =  hiden.insertCell(0);
	gag.rowSpan = 4;
	gag.innerHTML = 'SELECT GENDER';
	gag.className = 'ch_gender';
	gag.id = 'flash';
	var hrowMale = tblhead.insertRow(headcounter);
	hrowMale.className = 'hc_head_sex';

	this.hRowPopMale = hrowMale;
	headcounter++;	
	hrowMale.insertCell(0);
	
	for (var i = 1;i< 10;i++)
	{
		var hrowMale_ = hrowMale.insertCell(i);
		hrowMale_.colSpan = 2;
	}
	
	var hrowFemale = tblhead.insertRow(headcounter);
	hrowFemale.className = 'hc_head_sex';
	this.hRowPopFemale = hrowFemale;
	headcounter++;	
	hrowFemale.insertCell(0);

	for (var i = 1;i< 10;i++)
	{
		var hrowMale_ = hrowFemale.insertCell(i);
		hrowMale_.colSpan = 2;
	}
	
	
	var hrowBoth = tblhead.insertRow(headcounter);
	hrowBoth.className = 'hc_head_sex';
	this.hRowPopBoth = hrowBoth;
	headcounter++;	
	hrowBoth.insertCell(0);
	for (var i = 1;i< 10;i++)
	{
		var hrowMale_ = hrowBoth.insertCell(i);
		hrowMale_.colSpan = 2;
	}
	
	
	var hrow1 = tblhead.insertRow(headcounter);
	headcounter++;
	var coll1 = hrow1.insertCell(0);
	coll1.rowSpan = 2;
	coll1.colSpan = 2;
	coll1.innerHTML  = "CAUSE OF DEATH RANKING";
	coll1.style.color = '#00FF00';
	coll1.className = 'header_cause';
	
	var collr_d = hrow1.insertCell(1);
	collr_d.innerHTML = "<a href=\"javascript:updateChartData('d')\">All Ages</a>";
	collr_d.colSpan = 2;
	collr_d.className = "header_ages";
	
	var collr_d_0_14 = hrow1.insertCell(2);
	collr_d_0_14.innerHTML = "<a href=\"javascript:updateChartData('d_0_14')\">0 - 14</a>";
	collr_d_0_14.colSpan = 2;
	collr_d_0_14.className = "header_ages";
	
	var collr_d_15_24 = hrow1.insertCell(3);
	collr_d_15_24.innerHTML = "<a href=\"javascript:updateChartData('d_15_24')\">15 - 24</a>";
	collr_d_15_24.colSpan = 2;
	collr_d_15_24.className = "header_ages";
	
	var collr_d_25_34 = hrow1.insertCell(4);
	collr_d_25_34.innerHTML = "<a href=\"javascript:updateChartData('d_25_34')\">25 - 34</a>";
	collr_d_25_34.colSpan = 2;
	collr_d_25_34.className = "header_ages";	
	
	var collr_d_35_44 = hrow1.insertCell(5);
	collr_d_35_44.innerHTML = "<a href=\"javascript:updateChartData('d_35_44')\">35 - 44</a>";
	collr_d_35_44.colSpan = 2;
	collr_d_35_44.className = "header_ages";	
	
	var collr_d_45_54 = hrow1.insertCell(6);
	collr_d_45_54.innerHTML = "<a href=\"javascript:updateChartData('d_45_54')\">45 - 54</a>";
	collr_d_45_54.colSpan = 2;
	collr_d_45_54.className = "header_ages";	
	
	var collr_d_55_64 = hrow1.insertCell(7);
	collr_d_55_64.innerHTML = "<a href=\"javascript:updateChartData('d_55_64')\">55 - 64</a>";
	collr_d_55_64.colSpan = 2;
	collr_d_55_64.className = "header_ages";	
	
	var collr_d_65_74 = hrow1.insertCell(8);
	collr_d_65_74.innerHTML = "<a href=\"javascript:updateChartData('d_65_74')\">65 - 74</a>";
	collr_d_65_74.colSpan = 2;
	collr_d_65_74.className = "header_ages";	
	
	var collr_d_75 = hrow1.insertCell(9);
	collr_d_75.innerHTML = "<a href=\"javascript:updateChartData('d_75')\">75 +</a>";
	collr_d_75.colSpan = 2;
	collr_d_75.className = "header_ages";	
	
	

	
	
	var hrow = tblhead.insertRow(headcounter);
	headcounter++
	var counter = 0;
	
	for (var m =0;m< this.hcColomnCount;m++)
	{
		for (var l=0;l<this.chVariableArray.length;l++)
		{
			if (l == 0 && m == 0)
			{
			}
			else
			{
				//col = hrow.insertCell(m*this.chVariableArray.length+l);
				
				if (!this.chVariableCombineArray[l-1])
				{
					
					col = hrow.insertCell(counter);
					col.className = 'hc_header';
					if (this.chVariableLabelArray[l] != '')
					{
						col.innerHTML = this.chVariableLabelArray[l];	
					}
					else
					{
						col.innerHTML = "";
					}
					
					if (this.chVariableCombineArray[l] )
					{
						
						col.colSpan = 2;
					}
					counter ++ ;
					
					
				}
				
			}
		}
	}

	
	
	var row = null;
	var col = null;
	for (var i = 0; i< this.hcRowCount;i++)
	{
		
		row = tblbody.insertRow(i);
		for (var j =0;j< this.hcColomnCount;j++)
		{
			
			for (var k=0;k<this.chVariableArray.length;k++)
			{
				col = row.insertCell(j*this.chVariableArray.length+k);
				col.className = this.chVariableClassArray[k];
				if (k == 0 && j == 0)
				{
					col.className += " , hc_first_hor";
				}
				if (k == 0)
				{
					col.colSpan = 2;
				}
				
					//col.className += " , hc_col_"+j+"_"+k;
				
				//col.innerHTML = k;
				col = null;
			}
		}
		row = null;
	}
	
	
  },
  
  clear : function ()
  {
  	for (var i = 0; i< this.hcRowCount;i++)
	{
		
		for (var j =0;j< this.hcColomnCount;j++)
		{
			for (k =0;k<this.chVariableArray.length;k++)
			{
			
				this.hcElement.rows[i].cells[j*this.chVariableArray.length+k].innerHTML = "&nbsp";
				//if (this.chVariableArray[k] == this.displayVariable )
				//{
					this.hcElement.rows[i].cells[j*this.chVariableArray.length+k].style.backgroundColor = this.ColorBlack;
				//}
				this.hcElement.rows[i].cells[j*this.chVariableArray.length+k].className = this.chVariableClassArray[k]; 
				//this.hcElement.rows[i].cells[j].style.backgroundColor = this.ColorBlack;
				
				this.hcElement.rows[i].cells[j*this.chVariableArray.length+k].style.borderColor = this.ColorGray;
				if (k>0)
				{
					this.hcElement.rows[i].cells[j*this.chVariableArray.length+k].style.color = this.ColorWhite;	
					this.hcElement.rows[i].cells[j*this.chVariableArray.length+k].style.fontWeight = 'normal';
				}
				
				
			}
		}	
	}
  },
  
  addParam : function (Param, ParamType, ParamElement){
	this.hcParamArray.push(Param);
	this.hcParamTypeArray.push(ParamType);
	this.hcParamElementArray.push(ParamElement);
  },
  
  updateData : function ()
  {
	
  	if (!this.inprogress)
	{
		
		this.clear();
		this.inprogress = true;
		var tmp_params = "";
		 
		
		for (var i=0;i<this.hcParamArray.length;i++)
		{
			
			if (this.hcParamTypeArray[i] == 'combo')
			{
				tmp_params += this.hcParamArray[i]+"="+$(this.hcParamElementArray[i]).options[$(this.hcParamElementArray[i]).selectedIndex].value+"&";
				//tmp_params[this.hcParamArray[i].toString()] = $(this.hcParamElementArray[i]).options[$(this.hcParamElementArray[i]).selectedIndex].value;
				this.hcStaticValue[this.hcParamArray[i]] = $(this.hcParamElementArray[i]).options[$(this.hcParamElementArray[i]).selectedIndex].value;
			}
			if (this.hcParamTypeArray[i] == 'text')
			{
				
				tmp_params += this.hcParamArray[i]+"="+$(this.hcParamElementArray[i]).value+"&";
				//tmp_params[this.hcParamArray[i].toString()] = $(this.hcParamElementArray[i]).options[$(this.hcParamElementArray[i]).selectedIndex].value;
				this.hcStaticValue[this.hcParamArray[i]] = $(this.hcParamElementArray[i]).value;
			}
		}

		this.ajaxobg = new Ajax.Request(this.hcJsonUrl, {
			 method:'get',
			 parameters: tmp_params,
			 onSuccess: function(transport){
				 var json = transport.responseText.evalJSON();
				 this.chartdata = json;
				
				 //alert(this.chartdata.chart.countries.countryitem.length);
				 this.dataLoadCompleate();
				 //updatechart();
				 //alert(json.chart.countries.countryitem.length);
			}.bind(this),
			onException: function(transport,e){
					alert(e.message+ e.name);
			}
   
	   }); 
	}
	else
	{
		this.Quie = true;
		//alert("Wait Data Loading ...");
	}
  },
  
  dataLoadCompleate : function (){
	  
  	this.drawPane();
  },
  drawPane : function (){
	 
  	this.animI = 0;
	this.animJ = 0;
	this.animM = 0;
	//if(!this.animator)
     //   this.animator = new PeriodicalExecuter(function(pe) {   
      //      this.drawItem();
       // }.bind(this), .001);
	this.CountryCounter = 0;
	if (this.isFirst)
	{
		this.addPops();
		this.isFirst = false;
	}
	if (this.updatePops)
	{
		this.addPops();
		this.updatePops = false;
	}
	
	this.drawItem();
	//setTimeout(this.drawItem.bind(this, null), 100);
  },
  addPops : function ()
  {
	  var pops = this.chartdata.chart.pops.popitem[0];
	  this.hRowPopMale.id = 'hc_head_sex';
	  this.hRowPopMale.className = 'hc_head_sex';
	  this.hRowPopMale.cells[0].innerHTML = pops.name;
	  
	  
	  this.hRowPopMale.cells[0].onclick = function ()
	  {
		  mychartobj.selectedColor = 1;
		  
		  $('sex').value = 'male';
		  //mychartobj.hRowPopMale.className = 'hc_head_sex_sel';
		  //mychartobj.hRowPopFemale.className = 'hc_head_sex';
		  //mychartobj.hRowPopBoth.className = 'hc_head_sex';
		  
		  this.style.backgroundColor = mychartobj.selColorArray[mychartobj.selectedColor];
		  mychartobj.hRowPopMale.style.backgroundColor = mychartobj.selColorArray[mychartobj.selectedColor];
		  mychartobj.hRowPopMale.style.color  =  mychartobj.ColorBlack;
		  mychartobj.hRowPopMale.style.fontWeight  =  'bold';
		  
		   mychartobj.hRowPopFemale.style.backgroundColor = mychartobj.ColorBlack;
		  mychartobj.hRowPopFemale.style.color  =  mychartobj.ColorWhite;
		  mychartobj.hRowPopFemale.style.fontWeight  =  'normal';
		  
		  mychartobj.hRowPopBoth.style.backgroundColor = mychartobj.ColorBlack;
		  mychartobj.hRowPopBoth.style.color  =  mychartobj.ColorWhite;
		  mychartobj.hRowPopBoth.style.fontWeight  =  'normal';
		  
		  mychartobj.animateselect = false;

		  
		  //mychartobj.hRowPopFemale.className = 'hc_head_sex';
		  //mychartobj.hRowPopBoth.className = 'hc_head_sex';

		  
		  mychartobj.updateData();
	  }
	  this.hRowPopMale.cells[0].className = 'gray_bg';
	  this.hRowPopMale.cells[0].style.backgroundColor = this.selColorArray[1];
	  
	  this.hRowPopMale.cells[1].innerHTML = pops.p; 
	  this.hRowPopMale.cells[2].innerHTML = pops.p_0_14;
	  this.hRowPopMale.cells[3].innerHTML = pops.p_15_24;
	  this.hRowPopMale.cells[4].innerHTML = pops.p_25_34;
	  this.hRowPopMale.cells[5].innerHTML = pops.p_35_44;
	  this.hRowPopMale.cells[6].innerHTML = pops.p_45_54;
	  this.hRowPopMale.cells[7].innerHTML = pops.p_55_64;
	  this.hRowPopMale.cells[8].innerHTML = pops.p_65_74;
	  this.hRowPopMale.cells[9].innerHTML = pops.p_75;
	  pops = this.chartdata.chart.pops.popitem[1];
	  this.hRowPopFemale.id = 'hc_head_sex';
	  this.hRowPopFemale.className = 'hc_head_sex';
	  this.hRowPopFemale.cells[0].innerHTML = pops.name; 
	    
	  this.hRowPopFemale.cells[0].onclick = function ()
	  {
		  mychartobj.selectedColor = 2;
		 
		  $('sex').value = 'female';
		  this.style.backgroundColor = mychartobj.selColorArray[mychartobj.selectedColor];
		  mychartobj.hRowPopFemale.style.backgroundColor = mychartobj.selColorArray[mychartobj.selectedColor];
		  mychartobj.hRowPopFemale.style.color  =  mychartobj.ColorBlack;
		  mychartobj.hRowPopFemale.style.fontWeight  =  'bold';
		  
		   mychartobj.hRowPopMale.style.backgroundColor = mychartobj.ColorBlack;
		  mychartobj.hRowPopMale.style.color  =  mychartobj.ColorWhite;
		   mychartobj.hRowPopMale.style.fontWeight  =  'normal';
		  
		  
		  mychartobj.hRowPopBoth.style.backgroundColor = mychartobj.ColorBlack;
		  mychartobj.hRowPopBoth.style.color  =  mychartobj.ColorWhite;
		  mychartobj.hRowPopBoth.style.fontWeight  =  'normal';
		  
		  mychartobj.animateselect = false;
		  
			mychartobj.updateData();
	  }
	  this.hRowPopFemale.cells[0].className = 'gray_bg';
	  this.hRowPopFemale.cells[0].style.backgroundColor = this.selColorArray[2];
	  
	  this.hRowPopFemale.cells[1].innerHTML = pops.p; 
	  this.hRowPopFemale.cells[2].innerHTML = pops.p_0_14;
	  this.hRowPopFemale.cells[3].innerHTML = pops.p_15_24;
	  this.hRowPopFemale.cells[4].innerHTML = pops.p_25_34;
	  this.hRowPopFemale.cells[5].innerHTML = pops.p_35_44;
	  this.hRowPopFemale.cells[6].innerHTML = pops.p_45_54;
	  this.hRowPopFemale.cells[7].innerHTML = pops.p_55_64;
	  this.hRowPopFemale.cells[8].innerHTML = pops.p_65_74;
	  this.hRowPopFemale.cells[9].innerHTML = pops.p_75;
	  pops = this.chartdata.chart.pops.popitem[2];
	  this.hRowPopBoth.id = 'hc_head_sex_sel';
	  this.hRowPopBoth.className = 'hc_head_sex_sel';
	  this.hRowPopBoth.cells[0].innerHTML = pops.name; 
	    
	  this.hRowPopBoth.cells[0].onclick = function ()
	  {
		  mychartobj.selectedColor = 0;
		 
		  $('sex').value = 'both';
		  this.style.backgroundColor = mychartobj.selColorArray[mychartobj.selectedColor];
		  mychartobj.hRowPopBoth.style.backgroundColor = mychartobj.selColorArray[mychartobj.selectedColor];
		  mychartobj.hRowPopBoth.style.color  =  mychartobj.ColorBlack;
		  mychartobj.hRowPopBoth.style.fontWeight  =  'bold';
		  
		  
		   mychartobj.hRowPopMale.style.backgroundColor = mychartobj.ColorBlack;
		  mychartobj.hRowPopMale.style.color  =  mychartobj.ColorWhite;
		  mychartobj.hRowPopMale.style.fontWeight  =  'normal';
		  
		  
		  mychartobj.hRowPopFemale.style.backgroundColor = mychartobj.ColorBlack;
		  mychartobj.hRowPopFemale.style.color  =  mychartobj.ColorWhite;
		  mychartobj.hRowPopFemale.style.fontWeight  =  'normal';
		  
		  mychartobj.animateselect = false;
		  
		  mychartobj.updateData();
	  }
	  this.hRowPopBoth.cells[0].className = 'gray_bg';
	  this.hRowPopBoth.cells[0].style.backgroundColor = this.selColorArray[0];
	  if (this.isFirst)
	  {
	  this.hRowPopBoth.style.backgroundColor = this.selColorArray[this.selectedColor];
	  this.hRowPopBoth.style.color  =  this.ColorBlack;
	  this.hRowPopBoth.style.fontWeight  =  'bold';
		  
	  }
	  
	  this.hRowPopBoth.cells[1].innerHTML = pops.p; 
	  this.hRowPopBoth.cells[2].innerHTML = pops.p_0_14;
	  this.hRowPopBoth.cells[3].innerHTML = pops.p_15_24;
	  this.hRowPopBoth.cells[4].innerHTML = pops.p_25_34;
	  this.hRowPopBoth.cells[5].innerHTML = pops.p_35_44;
	  this.hRowPopBoth.cells[6].innerHTML = pops.p_45_54;
	  this.hRowPopBoth.cells[7].innerHTML = pops.p_55_64;
	  this.hRowPopBoth.cells[8].innerHTML = pops.p_65_74;
	  this.hRowPopBoth.cells[9].innerHTML = pops.p_75;
	  
	  
	  
  },
  drawItem : function (){
  	var country_item = this.chartdata.chart.countries.countryitem[this.animI];
	var img = null;
	
	
	var counterr = this.chVariableArray.length;
	var i = 1;
	
	if (!this.fillNext)
	{
		counterr = 1;
		i = 0;
	}
	//alert(this.fillNext);
	for (i; i<counterr;i++)
	{
		
		//col.className += " , hc_col_"+j+"_"+k;
		//this.hcElement.rows[this.animM].cells[this.animJ+i].className += " , hc_col_"+(this.animJ+i).toString();

		if (this.chVariableArray[i] == $(this.selColomnEl).value )
		{
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.backgroundColor = this.ColorGray;
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.borderColor = this.ColorBlack;
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.fontWeight = 'bold';
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.color  = this.ColorWhite;
			//this.hcElement.rows[this.animM].cells[this.animJ+i].style.border = 'solid 1px #000000';
		}
		if (this.chVariableArray[i] == "r_"+$(this.selColomnEl).value)
		{
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.backgroundColor = this.selColorArray[this.selectedColor];
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.borderColor = this.ColorBlack;
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.color = this.ColorBlack;
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.fontWeight = 'bold';
			//this.hcElement.rows[this.animM].cells[this.animJ+i].style.border = 'solid 1px #000000';
		}
		
		if (i ==0)
		{
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.borderColor = this.ColorGray;
			//this.hcElement.rows[this.animM].cells[this.animJ+i].style.backgroundColor = this.selColorArray[this.selectedColor];
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.backgroundColor = this.ColorBlack;
			this.hcElement.rows[this.animM].cells[this.animJ+i].style.color = this.ColorWhite;
		}
		
		if (this.chVariableTypeArray[i] == 'img')
		{
			this.hcElement.rows[this.animM].cells[this.animJ+i].innerHTML = "<img src='images/flags/"+country_item[this.chVariableArray[i]]+".png' width='16px' heigth='16px' >";
		}
		else if (this.chVariableTypeArray[i] == 'text')
		{
			if (country_item[this.chVariableArray[i]])
			{
				if (this.chVariableUpperArray[i])
				{
					//this.hcElement.rows[this.animM].cells[this.animJ+i].appendChild(document.createTextNode(country_item[this.chVariableArray[i]].toUpperCase()));
					this.hcElement.rows[this.animM].cells[this.animJ+i].innerHTML = country_item[this.chVariableArray[i]].toUpperCase();
				}
				else
				{
					//this.hcElement.rows[this.animM].cells[this.animJ+i].appendChild(document.createTextNode(country_item[this.chVariableArray[i]]));
					this.hcElement.rows[this.animM].cells[this.animJ+i].innerHTML = country_item[this.chVariableArray[i]];
				}
			}
			
		}
		else if (this.chVariableTypeArray[i] == 'static')
		{
			//this.hcElement.rows[this.animM].cells[this.animJ+i].appendChild(document.createTextNode(this.hcStaticValue[this.chVariableArray[i]]));
			this.hcElement.rows[this.animM].cells[this.animJ+i].innerHTML  = this.hcStaticValue[this.chVariableArray[i]];
		}
	}
	
		if (this.animM == this.hcRowCount-1)
		{
			this.animM = 0;
			this.animJ = this.animJ+this.chVariableArray.length;
		}
		else
		{
			this.animM++;
		}
		this.animI ++;
		
		this.CountryCounter ++;
		this.checkLatest();
  },
  
  
  checkLatest : function (){
	  
	 		if (this.Quie)
			{
				this.Quie = false;
				this.inprogress = false;	
				this.fillNext = true;
				this.updateData();
			}
			else
			{
	  
				if ( this.animI != this.chartdata.chart.countries.countryitem.length )
				{
					
						if (this.hcInsertCounter == this.hcInsertCount )
						{
							this.hcInsertCounter = 1;
							//this.drawItem();
								setTimeout(this.drawItem.bind(this, null), 1);
						}
						else
						{
							this.hcInsertCounter ++;
							this.drawItem();
						}
					
					
				}
				else
				{
					//alert(this.fillNext);
					if (this.fillNext)
					{
						this.fillNext = false;
						
						this.drawPane();
						
					}
					else
					{
						this.fillNext = true;
						this.inprogress = false;	
					}
					
					
					
				}
			}
		
  }
  

}); 
