function resizeJobtables()
{
		// if some local function to resize table is defined, it's used
	if ( window.local_resizeJobtable)
	{
		local_resizeJobtable();
		return;
	}

		// looking for g_jobstable_all
	if ( window.g_jobstable_all)
		g_jobstable_all.resizeColumns();
}
var a = "bb";
function jobtable(table_name,rows_total,rows_start,rows_end,rows_display_start,rows_displayed,rows_page_fixed,script_name,arr_row_ids,script_parameteres)
{
	this.table_name = table_name;
	this.pages_current = 0;
	this.pages_total = 0;
	this.pages_start = 0;
	this.pages_end = 0;
	this.rows_display_end = 0;
	this.rows_per_page = rows_page_fixed == 0 ? rows_displayed : rows_page_fixed;

	this.rows_total = rows_total;
	this.rows_start = rows_start;
	this.rows_end = rows_end;
	this.rows_display_start = rows_display_start;
	this.rows_page_max = 40;
	this.rows_page_min = 2;
	this.rows_page_fixed = rows_page_fixed;	/* 0 - table is not fixed; if table has fixed height, the amount of rows is always visually set to fit the amount of rows */
	this.stretched_column_width = 0;
	this.arr_column_widths = new Array();
	this.arr_column_classes = new Array();

	this.reserved_height = 45;
	this.row_height = 20;
	this.pages_max = 10;	/* must be even and at least four */
	this.fixed_visual_table_height = rows_page_fixed == 0 ? false : true;	/* if TRUE, the table is set to the height when is called optimizeDisplayedRows(), technically the table footer top border is set to replace missing rows */
	this.row_mouseover = true;		/* if mouseover event is captured */
	this.control_format = "arrows";	/* "arrows" or "numbers", determinates the format of control */
	this.script_name = script_name;
	this.script_parameteres = script_parameteres;
	this.tmp_arr_old_rows_html = new Array();
	this.arr_rows = new Array();
	this.IE = document.all ? true : false;

	this.refill = refill;
	this.refresh = refresh;
	this.recalculate = recalculate;
	this.getControlHTML = getControlHTML;
	this.navigatePage = navigatePage;
	this.arr_row_ids = arr_row_ids;
	this.arr_rows_temporarily_hidden = new Array();
	this.getCalculatedHeight = getCalculatedHeight;
	this.getOptimalPageRowsCount = getOptimalPageRowsCount;
	this.getRowsDisplayedCount = getRowsDisplayedCount;
	this.getCalculatedRowsNumber = getCalculatedRowsNumber;
	this.getStretchedColumnWidth = getStretchedColumnWidth;
	this.optimizeDisplayedRows = optimizeDisplayedRows;
	this.showOnlyBidRow = showOnlyBidRow;
	this.setFixedVisualTableHeight = setFixedVisualTableHeight;
	this.setOptimalFixedVisualTableHeight = setOptimalFixedVisualTableHeight;
	this.getDocumentHeight = getDocumentHeight;
	this.resizeColumns = resizeColumns;
	this.initialize = initialize;
	this.resizeTitles = resizeTitles;
	this.refreshContent = refreshContent;
	this.refreshDataLoaded = refreshDataLoaded;
	this.sortRows = sortRows;
	this.pom = 0;
	this.info = info;
	this.deleteRow = deleteRow;


	this.recalculate();

		// methods

	function info()
	{
		alert(this.arr_row_ids)

	//document.getElementById("tmpinfo").innerHTML = g_jobstable_past.getControlHTML()
//alert(this.arr_row_ids)
	}

	function refill(rows_total,rows_start,rows_end,rows_display_start,rows_displayed,arr_row_ids)
	{
		var i, ii, tmp;

		if ( this.rows_start <= rows_start && this.rows_end >= rows_start && this.arr_row_ids != null)
		{
			var arr_tmp = this.arr_row_ids;
			var arr_tmp2 = this.arr_rows;
			var tmp_start = this.rows_end - rows_start;
			var tmp_end = rows_start - this.rows_start;

			for (i=tmp_start;i<arr_row_ids.length;i++)
			{
				arr_tmp[arr_tmp.length] = arr_row_ids[i];
				//arr_tmp2[arr_tmp2.length] = new jobtable_row(arr_row_ids[i], document.getElementById("title_job" + arr_row_ids[i]).innerHTML, document.getElementById("timestamp_job" + arr_row_ids[i]).value, document.getElementById("category_job" + arr_row_ids[i]).innerHTML);
			}

			for (i=0;i<tmp_end;i++)
				document.getElementById('jobslist_' + this.table_name).innerHTML = this.tmp_arr_old_rows_html[tmp_end - i - 1] + document.getElementById('jobslist_' + this.table_name).innerHTML;

			rows_start = this.rows_start;
			arr_row_ids = arr_tmp;
		}
		else
		{
	//	42,14,34,14,7,new
	//	42,0,20,0,7,new
	//  42,0,20,0,7,new 
		//rows_total,rows_start,rows_end,rows_display_start,rows_displayed

			if ( this.rows_start <= rows_end && this.rows_end >= rows_end && this.arr_row_ids != null)
			{
				var arr_tmp = arr_row_ids;
				var arr_tmp2 = this.arr_rows;
				var tmp_start = rows_end - this.rows_start;
				//var tmp_end = rows_start - this.rows_start;

				for (i=tmp_start;i<this.arr_row_ids.length;i++)
				{
					arr_tmp[arr_tmp.length] = this.arr_row_ids[i];

//if ( document.getElementById(this.arr_row_ids[i]) == undefined)
	//alert("this " + this.rows_start + " " + this.rows_display_end + " " + i + " " + tmp_start + " " + tmp_end + " " + this.arr_row_ids.length + " - " + this.arr_row_ids)

					//else arr_tmp2[arr_tmp2.length] = new jobtable_row(this.arr_row_ids[i], document.getElementById("title_job" + this.arr_row_ids[i]).innerHTML, document.getElementById("timestamp_job" + this.arr_row_ids[i]).value, document.getElementById("category_job" + this.arr_row_ids[i]).innerHTML);
//if ( document.getElementById(this.arr_row_ids[i]) == undefined)
	//alert("this " + this.arr_row_ids[i] + " " + i + " " + this.arr_row_ids.length )

					document.getElementById('jobslist_' + this.table_name).innerHTML += this.tmp_arr_old_rows_html[i]; 
				}

				rows_end = this.rows_end;
				arr_row_ids = arr_tmp;
			}
		}

		this.rows_total = rows_total;
		this.rows_start = rows_start;
		this.rows_end = rows_end;
		this.rows_display_start = rows_display_start;
		this.arr_row_ids = arr_row_ids;
		
		if ( this.fixed_visual_table_height == false)
			this.rows_per_page = rows_displayed;

			// filling arr_rows
		this.arr_rows = new Array();
/*
		for (i=0;i<this.arr_row_ids.length;i++)
		{
			if ( document.getElementById("title_" + this.arr_row_ids[i]) == undefined)
				alert("aatitle_" + this.arr_row_ids[i])
			else	this.arr_rows[this.arr_rows.length] = new jobtable_row(this.arr_row_ids[i], document.getElementById("title_" + this.arr_row_ids[i]).innerHTML, document.getElementById("timestamp_" + this.arr_row_ids[i]) != undefined ? document.getElementById("timestamp_" + this.arr_row_ids[i]).value : 0, document.getElementById("category_" + this.arr_row_ids[i]) != undefined ? document.getElementById("category_" + this.arr_row_ids[i]).innerHTML : "", document.getElementById("bids_" + this.arr_row_ids[i]) != undefined ? document.getElementById("bids_" + this.arr_row_ids[i]).value : "");
		}
*/
		if ( this.row_mouseover == true)		// if mouseover event is captured
		{
			for (i=0;i<this.arr_row_ids.length;i++)
			{
			//	document.getElementById(this.arr_row_ids[i]).onmouseout = eval("function() { this.className = '" + document.getElementById(this.arr_row_ids[i]).className + "'; }");
				var tmp_function = new Function("this.className = '" + document.getElementById(this.arr_row_ids[i]).className + "'");
				document.getElementById(this.arr_row_ids[i]).onmouseout = tmp_function;
				document.getElementById(this.arr_row_ids[i]).onmouseover = function() { this.className = 'mouseover_highlight'; };
			}
		}

		this.recalculate();
	}

	function recalculate()
	{
		var tmp = this.pages_current;

		this.pages_current = Math.floor(this.rows_display_start/this.rows_per_page);
		this.pages_total = Math.ceil(this.rows_total/this.rows_per_page);
		this.pages_start = ( tmp = this.pages_current - (this.pages_max/2)) < 0 ? 0 : tmp;
		this.pages_end = ( tmp = this.pages_current + (this.pages_max/2) - ( tmp < 0 ? tmp : 0 ) ) > this.pages_total ? this.pages_total : tmp;
		this.rows_display_end = this.rows_end < this.rows_display_start + this.getRowsDisplayedCount() ? this.rows_end : this.rows_display_start + this.getRowsDisplayedCount();
//alert(this.rows_display_end + " " + this.rows_end + " " + this.rows_display_start + " " + this.getRowsDisplayedCount() + " " + this.rows_total + " " + this.rows_per_page);
		if ( tmp > this.pages_total)
			this.pages_start = ( tmp = this.pages_start - ( this.pages_total - this.pages_total) ) < 0 ? 0 : tmp;
	}

	function refresh(new_table_height)
	{
	alert("refresh");
		var tmp_rows_displayed = Math.floor( ( new_table_height - this.reserved_height ) / this.row_height );

		if ( tmp_rows_displayed == this.rows_displayed)
			return this.rows_displayed*this.row_height + this.reserved_height;

		if ( tmp_rows_displayed > ( this.rows_end - this.rows_start))
			return ( this.rows_end - this.rows_start)*this.row_height + this.reserved_height;

		if ( tmp_rows_displayed < this.rows_page_min)
			return this.rows_page_min*this.row_height + this.reserved_height;

		if ( tmp_rows_displayed > this.rows_displayed)
		{
			var i, tmp_start, tmp_end = tmp_rows_displayed - this.rows_displayed + this.rows_display_end;

			if ( tmp_end > this.rows_end)
			{
				tmp_start = this.rows_display_start - (tmp_end - this.rows_end) < this.rows_start ? this.rows_start : this.rows_display_start - (tmp_end - this.rows_end);

				this.rows_display_start = tmp_start;
				tmp_end = this.rows_end;
			}

			else tmp_start = this.rows_display_end;

			for (i=tmp_start;i<tmp_end;i++)
			{
				if ( this.arr_row_ids[i] == undefined)
				{
					//alert(i + this.table_name)
					continue;
				}
			
				document.getElementById(this.arr_row_ids[i]).style.display = "block";
			}
		}
		else
		{
			var i, tmp = this.rows_display_end - ( this.rows_displayed - tmp_rows_displayed);

			for (var i=tmp;i<this.rows_display_end;i++)
				if ( document.getElementById(this.arr_row_ids[i]) == undefined)
					alert("aaa " + this.arr_row_ids[i])
				else	document.getElementById(this.arr_row_ids[i]).style.display = "none";
		}

		this.rows_displayed = tmp_rows_displayed;
		this.recalculate();

		document.getElementById("jobtable_" + this.table_name + "_navigation_panel").innerHTML = this.getControlHTML();
	}

	function getRowsDisplayedCount()
	{
	//alert(" getRowsDisplayedCount "+this.pages_current +" " + this.pages_total +" " + this.rows_total%this.rows_page_fixed +" " + this.rows_total +" " +this.rows_page_fixed);
		if ( this.fixed_visual_table_height == true)
		{
			if ( this.pages_current == this.pages_total-1 )	// last page may have smaller amount of displayed rows
				return this.rows_total%this.rows_page_fixed == 0 ? this.rows_page_fixed : this.rows_total%this.rows_page_fixed;
			else	return this.rows_page_fixed;
		}
		else	return this.rows_per_page;
	}

	function deleteRow(id)
	{
	//alert(id + " " + document.getElementById(id));
		if ( document.getElementById(id) == undefined)
			return;

		document.getElementById(id).style.display = "none";
document.getElementById(id).innerHTML = "";
		--this.rows_total;
		--this.rows_end;
//		this.rows_start,

		var arr_tmp_ids = new Array();
//alert(this.arr_row_ids.length)
		for (var i=0;i<this.arr_row_ids.length;i++)
		{
			if ( this.arr_row_ids[i] == id)
			{
 a = "aa";
 	//alert(this.arr_row_ids[ this.rows_display_end ] + " "  + this.rows_display_end);
				if ( document.getElementById( this.arr_row_ids[ this.rows_display_end ] ) != undefined)
				{
					document.getElementById( this.arr_row_ids[ this.rows_display_end ] ).style.display = "block";
				}
				else
				{
					--this.rows_displayed_end;
				}
			}
			else	arr_tmp_ids[ arr_tmp_ids.length ] = this.arr_row_ids[i];
		}
//alert(arr_tmp_ids)
		this.arr_row_ids = arr_tmp_ids;

		this.recalculate();
		this.optimizeDisplayedRows();
		document.getElementById("jobtable_" + this.table_name + "_navigation_panel").innerHTML = this.getControlHTML();

		if ( this.rows_display_end <= this.rows_display_start)
		{
			var tmp_start_row = this.rows_display_start - this.rows_per_page;

			if ( tmp_start_row < 0)
				tmp_start_row = 0;

			this.navigatePage(tmp_start_row);

			if ( this.rows_total <= 0)
			{
				if ( document.getElementById("no_records_" + this.table_name) != undefined)
					document.getElementById("no_records_" + this.table_name).style.display = "block";
				else	document.getElementById("jobslist_" + this.table_name).innerHTML = '<div class="no_records">No records</div>';
			}
//				document.getElementById(id).innerHTML = "";<div class="jobslist" id="jobslist_all">'No messages found';
		}

			////////////////////////////////////////////////////////////
			// re-labeling rows if their class name is "sequence_number" 

		var tmp_id, ii, tmp_element, tmp_element_tag_name, arr_tmp_live_sequence_divs, arr_tmp_sequence_divs = document.getElementsByClassName("jt__sequence_number");

		arr_tmp_sequence_divs = document.getElementsByClassName("jt__sequence_number");
		arr_tmp_live_sequence_divs = new Array();

//alert(document.getElementById('jobslist_all'));
//alert(document.getElementById('jobslist_all').getElementsByClassName("__sequence_number"));

//alert(arr_tmp_live_sequence_divs);
		for (i=0;i<arr_tmp_sequence_divs.length;i++)
		{
			tmp_element = arr_tmp_sequence_divs[i];

			while ( tmp_element.tagName.toLowerCase() != "html")
			{
				if ( (tmp_id = tmp_element.id.match(/^job(\d+)$/)) != null)
				{
					arr_tmp_live_sequence_divs[ tmp_id[1] ] = arr_tmp_sequence_divs[i];
				}

				tmp_element = tmp_element.parentNode;
			}
		}

		for (i=0;i<this.arr_row_ids.length;i++)
		{
			tmp_id = this.arr_row_ids[i].match(/^job(\d+)$/)[1];
	//	alert(tmp_id)
			arr_tmp_live_sequence_divs[ tmp_id ].innerHTML = ( i + 1 ) + ".";
		}

//alert(arr_tmp_live_sequence_divs);
/*
	{
		if ( element_tag_name == "form")
			return element;

		element = element.parentNode;
	}while 
			for (ii=0;ii<this.arr_row_ids.length;ii++)
		{
			if ( this.arr_row_ids[i] == id)
			{
				
			}
		}
function getParentForm(element)
{
	var ;



	alert("There is no form defined!");
	return false;
}
*/
	//	if ( arr_tmp_divs != "")

// this.arr_column_classes[i] )

//	(table_name,rows_total,rows_start,rows_end,rows_display_start,rows_displayed,rows_page_fixed,script_name,arr_row_ids,script_parameteres)		
	
	}


	function getControlHTML()
	{
		var i, tmp, tmp_display_offset = 0, tmp_shift = 0, return_html = '';

		/*if ( this.fixed_visual_table_height == true)
		{
			if ( this.pages_current == this.pages_total-1 )// &&this.rows_total%this.rows_page_fixed != 0
			{
				var tmp = this.rows_total == 0 ? ( (this.row_height)*(jobs_table_rows_in_list - rows_per_page - 1)) : ( (this.row_height)*(jobs_table_rows_in_list - rows_per_page));

tmp = (this.row_height)*(jobs_table_rows_in_list - this.rows_total%this.rows_page_fixed);
			}
		}
		else	*/

		if ( this.control_format != "arrows")
		{
			var tmp_previous = this.rows_display_start - rows_per_page <= 0 ? 0 : this.rows_display_start - rows_per_page;
			var tmp_next = this.rows_display_start + rows_per_page > this.rows_total ? this.rows_total : this.rows_display_start + rows_per_page;

			return_html += '<div id="jobstable_' + this.table_name + '_control">Showing ' + ( this.rows_display_start + 1 ) + '-' + tmp_next + " of " + this.rows_total;

			if ( tmp_previous != this.rows_display_start)
				return_html += '<span onclick="javascript:' + 'g_jobstable_' + this.table_name + '.navigatePage(' + tmp_previous + ')" style="margin-left:50px">&lt; previous</span>';
			if ( tmp_next < this.rows_total)
				return_html += '<span onclick="javascript:' + 'g_jobstable_' + this.table_name + '.navigatePage(' + tmp_next + ')" style="margin-left:10px">next &gt;</span>';

			return return_html;

			alert(tmp_previous + " " + tmp_next + " " + this.rows_display_start + " " + rows_per_page)
		}


		return_html += '<div id="jobstable_' + this.table_name + '_control"><span onclick="javascript:' + 'g_jobstable_' + this.table_name + '.navigatePage(0)" title="first">|&lt; ' + '</span>';

		if ( this.pages_start == 0 && ( tmp_display_offset = this.rows_display_start%this.rows_per_page) != 0)
		{
			return_html += '<span onclick="javascript:' + 'g_jobstable_' + this.table_name + '.navigatePage(0)" id="' + this.table_name + '_control0">1-' + tmp_display_offset + '</span>';
			tmp_shift = 1;
		}

		for (i=this.pages_start;i<(this.pages_end - tmp_shift);i++)
		{
			tmp = i*this.rows_per_page + tmp_display_offset;
			return_html += '<span ' + ( this.pages_current == i ? ' class="current"' : "" ) + 'onclick="javascript:' + 'g_jobstable_' + this.table_name + '.navigatePage(' + tmp + ')" id="' + this.table_name + '_control' + ( i + tmp_shift ) + '">' + ( (tmp + 1 ) + '-' + ( tmp + this.rows_per_page >= this.rows_total ? this.rows_total : (tmp + this.rows_per_page) ) ) + '</span>';
		}

		tmp = (this.pages_total - 1)*this.rows_per_page + tmp_display_offset;
		return_html += ' <span onclick="javascript:' + 'g_jobstable_' + this.table_name + '.navigatePage(' + ( tmp < 0 ? 0 : tmp ) + ')" title="last">&gt;|' + '</span>';
		return_html += ' <span style="cursor:text">Total: ' + this.rows_total + '</span></div>';

		return return_html;
	}

	function getCalculatedHeight()
	{
		var rows_count;

		if ( this.fixed_visual_table_height == true)
			return this.rows_page_fixed*this.row_height + this.reserved_height;

		if ( ( rows_count = this.getRowsDisplayedCount()) == 0)		// no rows, but one row with "no data" message is displayed
			rows_count = 1;

		return rows_count*this.row_height + this.reserved_height;
	}

	function getCalculatedRowsNumber(height)
	{
		var tmp = Math.floor((height  - this.reserved_height)/this.row_height);

		return tmp > this.rows_total ? this.rows_total : tmp;
	}

	function optimizeDisplayedRows()
	{
		if ( this.fixed_visual_table_height == false)
			return;

		var tmp_start, tmp_end;

			// hide the rows that should not be displayed (e.g. this.rows_page_fixed=6 and there are 8 displayed rows

		//	jobs_table_rows_in_list = this.rows_page_fixed;
			//rows_per_page = this.pages_current == this.pages_total-1 ? this.rows_page_fixed : this.rows_displayed;
//alert(this.rows_displayed +" " + jobs_table_rows_in_list + " " + rows_per_page + " " + this.pages_current + " " + (this.pages_total-1))
			//if ( this.rows_displayed < jobs_table_rows_in_list)

			// display the rows that should be displayed (e.g. this.rows_page_fixed=9 and there are 6 displayed rows
//alert(this.rows_display_start+" "+this.rows_display_end);

			for (var i=this.rows_display_start-this.rows_start;i<this.rows_display_end-this.rows_start;i++)
			{
			//alert(i + " " + this.arr_row_ids[i]);
				if ( document.getElementById(this.arr_row_ids[i]) != undefined && document.getElementById(this.arr_row_ids[i]).style.display != "block")
					document.getElementById(this.arr_row_ids[i]).style.display = "block";
			}

//alert("fff");
// hide the rows that should not be displayed (e.g. this.rows_page_fixed=6 and there are 8 displayed rows
//alert(this.rows_display_start+" "+this.rows_display_end+" "+this.rows_start+" "+this.rows_end);
			for (var i=0;i<this.rows_display_start-this.rows_start;i++)
			{
				if ( document.getElementById(this.arr_row_ids[i]) != undefined && document.getElementById(this.arr_row_ids[i]).style.display != "none")
					document.getElementById(this.arr_row_ids[i]).style.display = "none";
			}
			for (var i=this.rows_display_end-this.rows_start;i<this.rows_end;i++)
			{
			
				if ( document.getElementById(this.arr_row_ids[i]) != undefined && document.getElementById(this.arr_row_ids[i]).style.display != "none")
					document.getElementById(this.arr_row_ids[i]).style.display = "none";
			}
			/**/
			
			/*
			// hide the rows that should not be displayed (e.g. this.rows_page_fixed=6 and there are 8 displayed rows
			tmp_start = this.rows_display_end;
			tmp_end = this.rows_end;

			for (i=tmp_start;i<tmp_end;i++)
			{
				if ( document.getElementById(this.arr_row_ids[i]) != undefined && document.getElementById(this.arr_row_ids[i]).style.display != "none")
					document.getElementById(this.arr_row_ids[i]).style.display = "none";
			}
*/

/**/
			var tmp_missing_rows_count = this.rows_page_fixed - this.getRowsDisplayedCount();

			if ( tmp_missing_rows_count != 0)// &&this.rows_total%this.rows_page_fixed != 0
			{
				var tmp = this.rows_total == 0 ? this.row_height*(tmp_missing_rows_count - 1) : ( this.row_height*tmp_missing_rows_count);

				document.getElementById("jobstable_" + this.table_name + "_footer").style.borderTopWidth = tmp + "px";
			}
			else
			{
				if ( document.getElementById("jobstable_" + this.table_name + "_footer") != undefined)
					document.getElementById("jobstable_" + this.table_name + "_footer").style.borderTopWidth = "0px";
			}


//document.getElementById("jobstable_" + this.table_name + "_footer").style.height += 10;
/*
		if ( this.rows_total == 0 || this.rows_displayed == jobs_table_rows_in_list)
			return;

		tmp_start = this.rows_display_start;
		tmp_end = this.rows_end - this.rows_display_start < jobs_table_rows_in_list ? this.rows_end : this.rows_display_start + jobs_table_rows_in_list;

		for (i=tmp_start;i<tmp_end;i++)
		{
			if ( document.getElementById(this.arr_row_ids[i]) == undefined)
				continue; 

			document.getElementById(this.arr_row_ids[i]).style.display = "block";
		}

		if ( tmp_end < this.rows_display_end)
		{
			for (i=tmp_end;i<this.rows_display_end;i++)
			{
				if ( document.getElementById(this.arr_row_ids[i]) == undefined)
					continue; 

				document.getElementById(this.arr_row_ids[i]).style.display = "none";
			}
		}
*/
		//this.rows_displayed = jobs_table_rows_in_list;	// @@!!! commented, no idea why it was uncommented before !!!
		//alert(this.table_name + " " + this.rows_displayed + " " + jobs_table_rows_in_list)
this.recalculate();

/*
alert("jobtable_" + this.table_name + "_footer")
alert(document.getElementById("jobtable_" + this.table_name + "_footer") + " " + document.getElementById("jobtable_ticket_pending_footer") + " " + "jobstable_" + this.table_name + "_footer")
tmp = ( (this.row_height)*(jobs_table_rows_in_list - this.rows_displayed));
div_table_footer.style.borderTopWidth = tmp;
alert( tmp )
*/
//alert("jobstable_" + this.table_name + "_footer")
//alert(document.getElementById("jobstable_" + this.table_name + "_footer").innerHTML);
			//alert("jobstable_" + this.table_name + "_control");
		//if ( document.getElementById("jobstable_" + this.table_name + "_control") != undefined)
			document.getElementById("jobtable_" + this.table_name + "_navigation_panel").innerHTML = this.getControlHTML();
			//document.getElementById("jobstable_" + this.table_name + "_control").innerHTML = this.getControlHTML();
	}

	function navigatePage(new_start)
	{
		var i, tmp_start, tmp_end;
		var rows_per_page = this.fixed_visual_table_height == true ? this.rows_page_fixed : this.rows_displayed;
//alert( this.rows_start +" "+ new_start  +" "+ this.rows_end  +" "+ ( new_start + this.getRowsDisplayedCount()) +" "+ this.rows_end +" "+  this.rows_total);

		if ( ( this.rows_start <= new_start && ( this.rows_end >= new_start + this.getRowsDisplayedCount() || this.rows_end >= this.rows_total)))
		{
			tmp_start = this.rows_display_start - this.rows_start;
			tmp_end = this.rows_display_end - this.rows_start;
//alert(tmp_start + " " + tmp_end)
			for (i=tmp_start;i<tmp_end;i++)
			{
				if ( document.getElementById(this.arr_row_ids[i]) == undefined)
					//alert(this.rows_display_start + " " + this.rows_display_end + " " + i + " " + tmp_start + " " + tmp_end + " " + this.arr_row_ids.length + " - " + this.arr_row_ids)
					continue;
				document.getElementById(this.arr_row_ids[i]).style.display = "none";
			}

			this.rows_display_start = new_start;
			this.recalculate();

			tmp_start = this.rows_display_start - this.rows_start;
			tmp_end = this.fixed_visual_table_height == true ? tmp_start + this.rows_page_fixed : this.rows_display_end - this.rows_start;

			for (i=tmp_start;i<tmp_end;i++){
			if ( document.getElementById(this.arr_row_ids[i]) == undefined)
				continue;//alert(this.arr_row_ids + " " + this.rows_display_start + " " + this.rows_display_end + " " + i + " " + tmp_start + " " + tmp_end)
				document.getElementById(this.arr_row_ids[i]).style.display = "block";
				//document.getElementById(this.arr_row_ids[i]).style.border = "1px solid black";
				//document.getElementById(this.arr_row_ids[i]).style.margin = "0px";
			}

			this.recalculate();
			document.getElementById("jobtable_" + this.table_name + "_navigation_panel").innerHTML = this.getControlHTML();

			set_jobstables_calculated_heights();
			this.optimizeDisplayedRows();
		}
		else
		{
			for (var i=0;i<this.arr_row_ids.length;i++)
				this.tmp_arr_old_rows_html[i] = '<div id="' + this.arr_row_ids[i] + '" class="' + document.getElementById( this.arr_row_ids[i] ).className + '" style="display:none">' + document.getElementById( this.arr_row_ids[i] ).innerHTML + '</div>' + '<div id="' + this.arr_row_ids[i] + '_sub" class="job_sub"></div>';
//alert(this.script_name + '?jobs_table_rows_in_list=' + this.rows_displayed + '&offset=' + new_start + '&jobs_table_time=' + this.table_name + this.script_parameteres);
//alert(this.script_name + '?jobs_table_rows_in_list=' + this.rows_displayed + '&offset=' + new_start + '&jobs_table_time=' + this.table_name + this.script_parameteres)
			jah(this.script_name + '?offset=' + new_start + '&jobs_table_time=' + this.table_name + this.script_parameteres,"jobstable_" + this.table_name,"auto", eval("initialize_" + this.table_name ));
		}
	}

	function showOnlyBidRow(visible_row_id,direction)
	{
		if ( direction == "hide")
		{
			for (var i=0;i<this.arr_row_ids.length;i++)
			{
				if ( visible_row_id != this.arr_row_ids[i] && document.getElementById( this.arr_row_ids[i] ).style.display != "none")
				{
					this.arr_rows_temporarily_hidden[ this.arr_rows_temporarily_hidden.length ] = this.arr_row_ids[i];
					document.getElementById( this.arr_row_ids[i] ).style.display = "none";
				}
			}

			document.getElementById("jobtable_" + this.table_name + "_navigation_panel").style.visibility = "hidden";
		}
		else
		{
			for (var i=0;i<this.arr_rows_temporarily_hidden.length;i++)
				document.getElementById( this.arr_rows_temporarily_hidden[i] ).style.display = "block";

			this.arr_rows_temporarily_hidden = new Array();
			document.getElementById("jobtable_" + this.table_name + "_navigation_panel").style.visibility = "visible";
		}
	}

	function initialize()
	{
		eval(document.getElementById('jobstable_' + this.table_name + '_hideout').innerHTML);
		//document.getElementById('jobstable_' + this.table_name + '_control').innerHTML = this.getControlHTML();
		document.getElementById("jobtable_" + this.table_name + "_navigation_panel").innerHTML = this.getControlHTML();
		set_jobstables_calculated_heights();
	}

	function resizeTitles(width)
	{
		if ( this.arr_row_ids == null)
			return;

		for (var i=0;i<this.arr_row_ids.length;i++)
			document.getElementById("title_" + this.arr_row_ids[i]).style.width = width + "px";
	}

	function refreshContent()
	{
		var post_query = "current_rows=";

		for (var i=0;i<this.arr_rows.length;i++)
			post_query += this.arr_rows[i].id.substr(3) + "-" + this.arr_rows[i].timestamp + "-" + this.arr_rows[i].bids + ",";

		post_query = post_query.substr(0,post_query.length - 1) + '&jobs_table_rows_in_list=' + ( this.rows_end - this.rows_start ) + '&offset=' + this.rows_start + '&jobs_table_time=' + this.table_name + this.script_parameteres;

		g_refreshed_jobstable_name = this.table_name;
//document.write('jobstable_refresh.php?' + post_query)
		jah_post('jobstable_refresh.php',post_query,"jobstable_" + this.table_name + "_refresh","auto", refresh_jobstable_done );
	}

	function refreshDataLoaded()
	{
	alert('hello');
	}
	
	function refreshDataLoaded22()
	{
		var i, ii, tmp, tmp_id, tmp_new_rows = "", tmp_new_joblist_html = "";

		if ( document.getElementById("jobstable_" + this.table_name + "_refresh_js") == undefined )
		{
		alert("jobstable_" + this.table_name + "_refresh_js");
			alert("Refresh failed");
			return;
		}

			// load new data into memory
		eval( document.getElementById("jobstable_" + this.table_name + "_refresh_js").innerHTML );

		for (i=0;i<arr_refreshed_rows.length;i++)
		{
			tmp_id = arr_refreshed_rows[i][0];

			if ( arr_refreshed_rows[i][2] == 0)
				document.getElementById("bids_text_job" + tmp_id).innerHTML = "No bids";
			else	document.getElementById("bids_text_job" + tmp_id).innerHTML = arr_refreshed_rows[i][2] + " bid" + ( arr_refreshed_rows[i][2] == 1 ? "" : "s" );

			document.getElementById("date_job" + tmp_id).innerHTML = arr_refreshed_rows[i][3];
			document.getElementById("time_job" + tmp_id).innerHTML = arr_refreshed_rows[i][4];
			document.getElementById("job" + tmp_id + "_toggle").className = arr_refreshed_rows[i][5];

			document.getElementById("timestamp_job" + tmp_id).value = arr_refreshed_rows[i][1];
			document.getElementById("bids_job" + tmp_id).value = arr_refreshed_rows[i][2];

			for (ii=0;ii<this.arr_rows.length;ii++)
			{
				if ( this.arr_rows[ii].id == "job" + tmp_id)
				{
					this.arr_rows[ii].timestamp = arr_refreshed_rows[i][1];
					this.arr_rows[ii].bids = arr_refreshed_rows[i][2];
				}
			}
		}

			// adding new rows into jobtable object
		if ( arr_new_rows.length > 0)
		{
			for (var i=0;i<arr_new_rows.length;i++)
			{
				tmp_id = "job" + arr_new_rows[i];
				tmp_new_rows += document.getElementById(tmp_id).innerHTML;

				this.arr_rows[this.arr_rows.length] = new jobtable_row(tmp_id, document.getElementById("title_" + tmp_id).innerHTML, document.getElementById("timestamp_" + tmp_id).value, document.getElementById("category_" + tmp_id).innerHTML, document.getElementById("bids_" + tmp_id).value);
			}

			document.getElementById('jobslist_' + this.table_name).innerHTML = tmp_new_rows + document.getElementById('jobslist_' + this.table_name).innerHTML;

			this.rows_total += arr_new_rows.length;
			this.rows_end += arr_new_rows.length;
		//	this.rows_displayed += arr_new_rows.length;

			document.getElementById("jobtable_" + this.table_name + "_navigation_panel").innerHTML = this.getControlHTML();
		}

			// removing deleted rows from jobtable object
		if ( arr_removed_rows.length > 0)
		{
			for (i=0;i<arr_removed_rows.length;i++)
			{
				for (var ii=0;ii<this.arr_rows.length;ii++)
				{
					tmp_id = "job" + arr_removed_rows[i];
	
					if ( this.arr_rows[ii].id == tmp_id)
					{
						this.arr_rows.splice(ii, 1);
						break;
					}
				}
			}

			document.getElementById('jobslist_' + this.table_name).innerHTML = tmp_new_rows + document.getElementById('jobslist_' + this.table_name).innerHTML;

			this.rows_total -= arr_removed_rows.length;
			this.rows_end -= arr_removed_rows.length;
			//this.rows_displayed -= arr_removed_rows.length;

			document.getElementById("jobtable_" + this.table_name + "_navigation_panel").innerHTML = this.getControlHTML();
		}

			//sortRows
		this.arr_rows.sort(sortRows);
		this.arr_row_ids = new Array();
		tmp = "";

		for (var i=0;i<this.arr_rows.length;i++)
		{
			document.getElementById("sequence_" + this.arr_rows[i].id).innerHTML = ( i + 1 ) + ".";
tmp += this.arr_rows[i].timestamp + " " + document.getElementById("date_" + this.arr_rows[i].id).innerHTML + "\n";
			tmp_new_joblist_html += '<div id="' + this.arr_rows[i].id + '" class="' + ( i%2 == 0 ? "even" : "odd" ) + '" style="display:' + ( i < this.rows_display_start || i >= this.rows_display_end ? "none" : "block" ) + '">' + document.getElementById(this.arr_rows[i].id).innerHTML + '</div>';
			this.arr_row_ids[i] = this.arr_rows[i].id;	
		}
//alert(tmp)
		document.getElementById('jobslist_' + this.table_name).innerHTML = tmp_new_joblist_html;
	}
}

	///////////////////////////////////////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////

	function sortRows(row1, row2)
	{
		return row1.timestamp - row2.timestamp;
	}

	function set_jobstables_calculated_heights()
	{
		// !! LAUNCHED while loading

		if ( arguments.length != 0)
		{
			if ( arguments[0] == "past")
			{
				document.getElementById("jobstable_past").style.height = g_jobstable_past.getCalculatedHeight() + "px";
			}
			if ( arguments[0] == "live")
				document.getElementById("jobstable_live").style.height = g_jobstable_live.getCalculatedHeight() + "px";

			return;
		}

		if ( document.getElementById("jobstable_live") == undefined)	
			return;
//alert(g_jobstable_past.getRowsDisplayedCount());
		document.getElementById("jobstable_past").style.height = g_jobstable_past.getCalculatedHeight() + "px";
		document.getElementById("jobstable_live").style.height = g_jobstable_live.getCalculatedHeight() + "px";
	}

	function resize_jobstables_height_start()
	{
		if ( document.getElementById("jobstable_past").style.display != "none" && document.getElementById("jobstable_live").style.display != "none")
		{
			g_start_position = g_position;
			//g_document_height = getJobstableTitleWidth();
			//g_document_height = 400;//IE ? document.documentElement.clientHeight - 250 : window.innerHeight - 250;
		}
	}

	function resize_jobstables_height_action()
	{
		if ( g_start_position == 0)
			return;

		var shift_size = g_start_position - g_position;
	
		var tmp_div1_height = Number(document.getElementById("jobstable_past").style.height.toString().substr(0,document.getElementById("jobstable_past").style.height.toString().length-2)) - shift_size;
		var tmp_div2_height = Number(document.getElementById("jobstable_live").style.height.toString().substr(0,document.getElementById("jobstable_live").style.height.toString().length-2)) + shift_size;//

		if ( (tmp_div1_height < 100 && shift_size > 0) || (tmp_div2_height < 100  && shift_size < 0 && g_document_height <= getDocumentHeight()))
		{
			g_start_position = g_position;
			return;
		}

		document.getElementById("jobstable_past").style.height = tmp_div1_height + "px";
		g_jobstable_past.refresh(tmp_div1_height);

		if ( !(tmp_div1_height + tmp_div2_height - shift_size < g_document_height && shift_size < 0))
		{
			document.getElementById("jobstable_live").style.height = tmp_div2_height + "px";
			g_jobstable_live.refresh(tmp_div2_height);
		}

		g_start_position = g_position;
	}

	function resize_jobstables_height_stop()
	{
		if ( g_start_position != 0)
		{
			g_start_position = 0;
			set_jobstables_calculated_heights();
		}
	}

		// Main function to retrieve mouse x-y pos.s
	function getMouseXY(e)
	{
		if (IE)  // grab the x-y pos.s if browser is IE
		{
			tempX = event.clientX + document.body.scrollLeft;
			tempY = event.clientY + document.body.scrollTop;
		}
		else	// grab the x-y pos.s if browser is NS
		{  	tempX = e.pageX;
			tempY = e.pageY;
		}

		// catch possible negative values in NS4
		if (tempX < 0)
			tempX = 0;
		if (tempY < 0)
			tempY = 0;

		g_position = tempY;
		return true;
	}

	function getDocumentHeight()
	{
		return this.IE ? document.body.clientHeight : window.innerHeight;
	//	return IE ? document.body.clientHeight - 330: window.innerHeight - 330;	// 250 - pixels used by various headers etc.
	}

	function getOptimalPageRowsCount(layout_reserved_height)
	{
		var optimal_height = Math.floor( (this.getDocumentHeight() - layout_reserved_height - this.reserved_height)/this.row_height );

		if ( this.rows_total < optimal_height)
			optimal_height = this.rows_total;
		
//alert("this.getDocumentHeight(): " + this.getDocumentHeight() + " window.innerHeight " + window.innerHeight)
		if ( optimal_height < this.rows_page_min)
			return	this.rows_page_min;

		if ( optimal_height > this.rows_page_max)
			return	this.rows_page_max;

		return	optimal_height;
	}

	function setOptimalFixedVisualTableHeight(layout_reserved_height)
	{
		this.setFixedVisualTableHeight( this.getOptimalPageRowsCount(layout_reserved_height) );
	}

	function getStretchedColumnWidth()
	{
		return this.stretched_column_width;
	}

	function setFixedVisualTableHeight(rows_page_fixed)
	{
		if ( rows_page_fixed != 0)
			this.rows_per_page = rows_page_fixed;

		this.rows_page_fixed = rows_page_fixed;
		this.fixed_visual_table_height = rows_page_fixed == 0 ? false : true;	/* if TRUE, the table is set to the height when is called optimizeDisplayedRows(), technically the table footer top border is set to replace missing rows */
		this.recalculate();

		document.getElementById("jobtable_" + this.table_name + "_navigation_panel").innerHTML = this.getControlHTML();

		this.optimizeDisplayedRows();
	}

	function resizeColumns()
	{
		var i, ii, table_width, flexible_width;
		var arr_header_columns = new Array();
		var flexible_column_is_last = false;

			/////////////////////////////
			// retrieve header columns - it can be done only once, when the page is loaded

		if ( document.getElementById("jobsheader_" + this.table_name) != undefined && this.arr_column_widths.length == 0)
		{
			var arr_tmp_header_divs = document.getElementById("jobsheader_" + this.table_name).getElementsByTagName("div");

			for (i=0;i<arr_tmp_header_divs.length;i++)
			{
				if ( arr_tmp_header_divs[i].parentNode.id == "jobsheader_" + this.table_name)
				{
					arr_header_columns.push( arr_tmp_header_divs[i] );
					this.arr_column_widths.push( Number( arr_tmp_header_divs[i].style.width.replace(/\D/g, "") ) );
					this.arr_column_classes.push( arr_tmp_header_divs[i].className );
				}
			}
		}

			// determinate table width
		table_width = document.getElementById("jobstable_" + this.table_name).offsetWidth;
		flexible_width = table_width;

		if ( this.arr_column_widths[ this.arr_column_widths.length-1 ] == 0)
			flexible_column_is_last = true;

		for (i=0;i<this.arr_column_widths.length;i++)
			flexible_width -= this.arr_column_widths[i];

		if ( flexible_width < 0)
			flexible_width = 50;
//flexible_width-=6;
//alert(flexible_width);
		for (i=0;i<this.arr_column_widths.length;i++)
		{
			var arr_tmp_columns, tmp_column_width, tmp_width_correction;

			tmp_column_width = this.arr_column_widths[ i ] == 0 ? flexible_width : this.arr_column_widths[ i ];

			if ( (arr_tmp_columns = document.getElementsByClassName( this.arr_column_classes[i] )) != null && arr_tmp_columns[ 0 ] != undefined)
			{
					// setting the first row separately to get real width for correction
				//	alert(arr_tmp_columns)
				arr_tmp_columns[ 0 ].style.width = tmp_column_width + "px";
//alert(tmp_column_width + "  " + arr_tmp_columns[ 0 ].offsetWidth)
					// style.width may be different from real width, a correction is calculated
				if ( ( tmp_width_correction = arr_tmp_columns[ 0 ].offsetWidth - tmp_column_width) != 0)
					tmp_column_width -= tmp_width_correction;
//alert(tmp_width_correction)
//alert(arr_tmp_columns[ 0 ].className + " "+arr_tmp_columns[ 0 ].id + " "+arr_tmp_columns[ 0 ].innerHTML +". "+ tmp_column_width +" "+ tmp_width_correction + " "+ this.arr_column_widths[i]);
					// if the last column (not with class "right") is set as flexible it causes issues.
						// its width must be calculated once more with its tmp_width_correction
			//=	if ( this.arr_column_widths[ i ] == 0 && flexible_column_is_last == true)
				//=	tmp_column_width -= tmp_width_correction;
/*			
				{
	this is how it should be done "propriately", eventhough the one line above should be enough
					tmp_column_width = flexible_width - tmp_width_correction;
					arr_tmp_columns = document.getElementsByClassName( this.arr_column_classes[i] );
					arr_tmp_columns[ 0 ].style.width = tmp_column_width + "px";
					
					if ( ( tmp_width_correction = arr_tmp_columns[ 0 ].offsetWidth - tmp_column_width) != 0)
						tmp_column_width -= tmp_width_correction;
				}
*///alert(222);
				for (ii=0;ii<arr_tmp_columns.length;ii++)
				{
				//alert(arr_tmp_columns[ ii ].className)
					arr_tmp_columns[ ii ].style.width = tmp_column_width + "px";
					//arr_tmp_columns[ ii ].style.border = "1px solid black";
			//alert(this.arr_column_widths[ i ] + "  " + arr_tmp_columns[ ii ].offsetWidth)
				
				}//alert(233);
			}
		}
		//alert(document.getElementById("kontrola1").offsetWidth);
	//	alert(2)
	}
	

		function resizeColumns11()
	{
		var i, ii, table_width, flexible_width;
		var arr_header_columns = new Array();

			/////////////////////////////
			// retrieve header columns - it can be done only once, when the page is loaded

		if ( document.getElementById("jobsheader_" + this.table_name) != undefined && this.arr_column_widths.length == 0)
		{
			var arr_tmp_header_divs = document.getElementById("jobsheader_" + this.table_name).getElementsByTagName("div");

			for (i=0;i<arr_tmp_header_divs.length;i++)
			{
				if ( arr_tmp_header_divs[i].parentNode.id == "jobsheader_" + this.table_name)
				{
					arr_header_columns.push( arr_tmp_header_divs[i] );
					this.arr_column_widths.push( Number( arr_tmp_header_divs[i].style.width.replace(/\D/g, "") ) );
					this.arr_column_classes.push( arr_tmp_header_divs[i].className );
				}
			}
		}

			// determinate table width
		table_width = document.getElementById("jobstable_" + this.table_name).offsetWidth;
		flexible_width = table_width;

		for (i=0;i<this.arr_column_widths.length;i++)
			flexible_width -= this.arr_column_widths[i];

		if ( flexible_width < 0)
			flexible_width = 50;
//alert(table_width + " " + flexible_width)
		for (i=0;i<this.arr_column_widths.length;i++)
		{
			var arr_tmp_columns, tmp_column_width, tmp_width_correction;

			tmp_column_width = this.arr_column_widths[ i ] == 0 ? flexible_width : this.arr_column_widths[ i ];

			if ( (arr_tmp_columns = document.getElementsByClassName( this.arr_column_classes[i] )) != null && arr_tmp_columns[ 0 ] != undefined)
			{
					// setting the first row separately to get real width for correction
				//	alert(arr_tmp_columns)
				arr_tmp_columns[ 0 ].style.width = tmp_column_width + "px";
//alert(tmp_column_width + "  " + arr_tmp_columns[ 0 ].offsetWidth)
					// style.width may be different from real width, a correction is calculated
				if ( ( tmp_width_correction = arr_tmp_columns[ 0 ].offsetWidth - tmp_column_width) != 0)
					tmp_column_width -= tmp_width_correction;

				for (ii=0;ii<arr_tmp_columns.length;ii++)
				{
					arr_tmp_columns[ ii ].style.width = tmp_column_width + "px";
					//arr_tmp_columns[ ii ].style.border = "1px solid black";
			//alert(this.arr_column_widths[ i ] + "  " + arr_tmp_columns[ ii ].offsetWidth)
				
				}
			}
		}
		//alert(document.getElementById("kontrola1").offsetWidth);
	//	alert(2)
	}