if (typeof(techPageObj)=="object")
{
	techPageObj.cell3text=['продуктов','проектов','разработчиков','интеграторов','ит-специалистов','новостей'];
	techPageObj.cell3href=['system','otr','vendors','integrator','special','news'];
	techPageObj.debug=document.getElementById('debug');
	techPageObj.branchesSelect=document.getElementById('branches');
	techPageObj.branchSelected='Все отрасли';
	techPageObj.tables=new Array();
	techPageObj.arrays={'Все отрасли':techPageObj.array};
	techPageObj.table_cont=document.getElementById('tbl_cont');

	branchesHTML='<select name="branchSelect" onchange="techPageObj.branchSelect(value);" style="width: 350px;">';
	branchesHTML+='<option value="Все отрасли" selected>Все отрасли</option>';
	for (i=0; i<techPageObj.branches.length; i++)
	{
		branchesHTML+='<option value="'+techPageObj.branches[i]+'">'+techPageObj.branches[i]+'</option>';
	}
	branchesHTML+='</select>';
	techPageObj.branchesSelect.innerHTML=branchesHTML;

	techPageObj.showTable = function (id)
	{	this.currentTableId=id;
		for (i=0; i<this.tables.length; i++)
			if (typeof(this.tables[i])=="object")
				this.tables[i].style.display='none';

		//alert(id);
		if (typeof(this.tables[id])!="object")
		{
			if (id!=0)
			{
				this.sort(id);
			}
			t=document.createElement("TABLE");
			t.id="thechPageTable"+id;
			t.className="cwiki_table";
			t.cellspacing="0";
			k=-1;
			for (i=0; i<this.count; i++)
			{
				if (id!=0)
				{	if (this.orderA[i])
						key=this.orderA[i].key;
					else continue;
				}
				else
				{
					key='t'+(i+1);
				}

				c2text='';
				c3text='';
				for (j=0; j<this.cell3text.length; j++)
				{
					if (this.array[key]) {
						val=this.array[key][j+2];
						if (val>0)
						{
							c2text+=this.cell3text[j]+'<br />';
							c3text+='['+val+']<br />';
						}
					}
				}

				if (c3text!='') {
					k++;
					r=t.insertRow(k);
					r.className=(k%2==1) ? 'odd' :'even';
					c=r.insertCell(0);
					c.innerHTML='<h3>'+this.array[key][1]+'</h3>';
					if (document.addEventListener)
						eval('c.addEventListener("click",function () {location.href="/index.php/'+this.array[key][0]+'";},false)');
					else
						eval('c.attachEvent("onclick",function () {location.href="/index.php/'+this.array[key][0]+'";})');

					//c=r.insertCell(1);
					//c.innerHTML='<h4>'+this.array[key][1]+'</h4>';
					c2=r.insertCell(1);
					c2.className="no_decore";
					c3=r.insertCell(2);
					c3.className="no_decore";

					for (j=0; j<this.cell3text.length; j++)
					{
						val=this.array[key][j+2];
						if (val>0)
						{	c2.innerHTML+='<nobr><a href="/index.php?title='+this.array[key][0]+'&cache=no&ptype='+this.cell3href[j]+'#ttop">'+this.cell3text[j]+'</a></nobr><br />';
							c3.innerHTML+='<a href="/index.php?title='+this.array[key][0]+'&cache=no&ptype='+this.cell3href[j]+'#ttop">'+val+'</a><br />';
						}
					}
				}
			}
			if (k==-1) {
				r=t.insertRow(0);
				c=r.insertCell(0);
				c.align="center";
				c.innerHTML='<h3>Данные не найдены</h3>';
			}
			this.table_cont.appendChild(t);
			this.tables[id]=t;
		}
		this.tables[id].style.display='';
	}
	techPageObj.sort = function (id) {
		k=parseInt(id)+1;
		//alert(k);
		this.orderA=[];
		for (i=0; i<this.count; i++)
		{	key='t'+(i+1);
			//this.debug.innerHTML+=key+'-';
			//this.debug.innerHTML+=this.array[key][k]+' ';
			if (this.array[key]) {
				val=this.array[key][k];
				ok=false;
				for (j=0; j<this.orderA.length; j++)
				{
					if (parseInt(this.orderA[j].val)<parseInt(val))
					{	this.orderA.splice(j, 0, {'val':val,'key':key});
						ok=true;
						break;
					}
				}
				if (!ok) this.orderA[this.orderA.length]={'val':val,'key':key};
			}
		}
		//alert(k);
		/*this.debug.innerHTML+='<br />'+k+':&nbsp;&nbsp;&nbsp;';
		for (i=0; i<this.count; i++)
		{
			this.debug.innerHTML+=this.orderA[i].key+'='+this.orderA[i].val+';&nbsp;&nbsp;&nbsp;';
		}*/
		return true;
	}
	techPageObj.branchSelect = function (br)
	{
		techPageObj.branchSelected=br;
		//alert(techPageObj.arrays[br]);
		if (typeof(techPageObj.arrays[br])=='object')
		{	techPageObj.array=techPageObj.arrays[br];
			techPageObj.rebuild();
			//alert('1');
		}
		else
			sajax_do_call('ajaxTechPage',[br], techPageObj.ret);
	}

	techPageObj.rebuild = function ()
	{
		while (techPageObj.table_cont.childNodes.length>0)
			techPageObj.table_cont.removeChild(techPageObj.table_cont.firstChild);
		techPageObj.tables=new Array();
		techPageObj.showTable(document.getElementById('orderSelect').value);
	}

	techPageObj.ret = function (resp)
	{	//alert(resp.responseText);
		techPageObj.array=eval('({'+resp.responseText+'})');
		techPageObj.arrays[techPageObj.branchSelected]=techPageObj.array;
		techPageObj.rebuild();
		//alert('2');
	}
}