function get_obj(obj_id)

{
	return document.getElementById(obj_id)? document.getElementById(obj_id) : false;
}

function clearInp(obj, txt)

{
	(obj.value == txt)? obj.value='': obj.select();
}

function setInp(obj, txt)

{
	if((!obj.value) || (obj.value == ' ')) obj.value = txt;
}

function get_workspace()
{
	var workspace = Object();
	if (window.event)
	{
		workspace["w"] = document.body.clientWidth;
		workspace["h"] = document.body.clientHeight;
	}
	else
	{
		workspace["w"] = window.innerWidth;
		workspace["h"] = window.innerHeight;
	}
	return workspace;
}

function tablesAddCorner()
{
	var t, h, i, j, first_th, last_th, rows, l, k;
	var tables = document.getElementById('mt_content').getElementsByTagName('table');
	for (i = 0; i < tables.length; ++i)
	{
		t = tables[i];
		if (t.getElementsByTagName('tr')[0].getElementsByTagName('th').length > 1)
		{
			t.className = 'ttable';
			if ((t.getAttribute('border') == 0))
			{
				
				if ((navigator.appName == 'Microsoft Internet Explorer') && ((t.getAttribute('border') == '')))
				{
					//
				}
				else {
					var ths = t.getElementsByTagName('tr')[0].getElementsByTagName('th');
					for (var p = 0; p < ths.length; ++p)
					{
						ths[p].style.background = 'white'
					}
					continue;
					var td = t.getElementsByTagName('td');
					for (l = 0; l < td.length; ++l)
					{
						td[l].style.border = 'none';
						td[l].style.borderTop = 'none';
					}
				}
			}
			if (t.getAttribute('border') > 0)
			{
				t.setAttribute('border', 0);
			}
			h = t.getElementsByTagName('tr')[0];
			first_th = h.getElementsByTagName('th')[0];
			last_th = h.getElementsByTagName('th')[h.getElementsByTagName('th').length - 1];
			first_th.className = 'tt_lcorner';
			var fd = document.createElement('div');
			// fd.style.width = '100%';
			var fc = first_th.innerHTML;
			fd.innerHTML = fc;
			first_th.innerHTML = '';
			first_th.appendChild(fd);
			last_th.className = 'tt_rcorner';
			last_th.innerHTML = '<div>' + last_th.innerHTML + '</div>';
			rows = t.getElementsByTagName('tr');
			for (k = 1; k < rows.length; ++k)
			{
				if ((k % 2) == 0)
				{
					rows[k].className = 'even';
				}
				else 
				{
					rows[k].className = 'odd';
				}
			}
		}
		else
		{
			t.className = 'ttable';
			h = t.getElementsByTagName('tr')[0];
			first_th = h.getElementsByTagName('th')[0];
			first_th.className = 'tt_lcorner';
			if ((t.getAttribute('border') == 0))
			{
				if ((navigator.appName == 'Microsoft Internet Explorer') && ((t.getAttribute('border') == '')))
				{
					//
				}
				else 
				{
					var ths = t.getElementsByTagName('tr')[0].getElementsByTagName('th');
					for (var p = 0; p < ths.length; ++p)
					{
						ths[p].style.background = 'white'
					}
					continue;
					var td = t.getElementsByTagName('td');
					for (l = 0; l < td.length; ++l)
					{
						td[l].style.border = 'none';
						td[l].style.borderTop = 'none';
					}
				}
			}
			first_th.innerHTML = '<div class="p1"><div class="p2">' + first_th.innerHTML + '</div></div>';
			rows = t.getElementsByTagName('tr');
			for (k = 1; k < rows.length; ++k)
			{
				if (navigator.appName == "Microsoft Internet Explorer") 
				{
					//blank_td.style.border = "none";
				}
				if ((k % 2) == 0)
				{
					rows[k].className = 'even';
				}
				else 
				{
					rows[k].className = 'odd';
				}
			}
		}
	}
}
function tableStylize(table)
{
	if ((table.border == 0) && (table.border != ''))
	{
		return;
	}
	table.border = 0;
	var rows = $('tr', table);
	// first row;
	table.cellPadding = "0";
	table.cellSpacing = "0";
	var first_row = rows[0];
	var chlds = $(first_row).children()
	var first_row_tds = new Array;
	for (var i = 0; i < chlds.length; ++i)
	{
		first_row_tds[i] = chlds[i];
	}
	// 
	if (first_row_tds.length <= 1)
	{
		
	}
	else
	{
		var first_td = first_row_tds[0];
		first_td.style.height = '100%';
		first_td.valign = 'top';
		var last_td = first_row_tds[first_row_tds.length - 1];
		last_td.style.height = '100%';
		last_td.height = '100%';
		last_td.valign = 'top';
		var first_td_content = first_td.innerHTML;
		var last_td_content = last_td.innerHTML;
		first_td.innerHTML = "<table valign='top' cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100%\" style=\"padding: 0px; margin: 0px;\"><tr><td style=\"background: url('/images/tt2/lt.gif') top left no-repeat;border: none; width: 4px; height: 4px;\" width=\"4\" height=\"4\"></td><td style=\"background: url('/images/tt2/mt.gif') top left repeat-x;border: none; height: 4px;\" height=\"4\"></td></tr><tr><td style=\"background: url('/images/tt2/mg.gif') top left repeat-x #b3ab99; border: none; height: 18px;\"></td><td style=\"background: url('/images/tt2/mg.gif') top left repeat-x #b3ab99; border: none; font-weight: bold; text-align: left;\" height=\"100%\" valign='top'><div style=\"padding: 5px; padding-left: 10px;\">"+first_td_content+"</div></td></tr><tr><td style=\"background: url('/images/tt2/lb.gif') bottom left no-repeat; width: 4px; height: 4px; border: none;\"></td><td style=\"background: url('/images/tt2/mb.gif') bottom left repeat-x; border: none;\"></td></tr></table>";
		last_td.innerHTML = "<table valign='top' cellpadding=\"0\" cellspacing=\"0\" height=\"100%\" width=\"100%\" style=\"padding: 0px; margin: 0px;\" id=\"rtb\"><tr><td style=\"background: url('/images/tt2/mt.gif') top left repeat-x; border: none; height: 4px;\" height=\"4\"></td><td style=\"background: url('/images/tt2/rt.gif') top right no-repeat; border: none; width: 4px; height: 4px;\" width=\"4\" height=\"4\"></td></tr><tr><td style=\"background: url('/images/tt2/mg.gif') top left repeat-x #b3ab99; border: none; font-weight: bold; text-align: left;\" height=\"100%\" valign='top'><div style=\"padding: 5px;\">"+last_td_content+"</div></td><td style=\"background: url('/images/tt2/mg.gif') top left repeat-x #b3ab99; border: none; height: 18px;\" height=\"18\"></td></tr><tr><td style=\"background: url('/images/tt2/mb.gif') bottom left repeat-x; border: none;\"></td><td style=\"background: url('/images/tt2/rb.gif') bottom left no-repeat; width: 4px; height: 4px; border: none;\"></td></tr></table>";
		for (j = 1; j < first_row_tds.length - 1; ++j)
		{
			var td = first_row_tds[j];
			td.style.textAlign = 'left';
			td.style.fontWeight = 'bold';
			td.style.padding = '0px';
			td.style.paddingTop = '5px';
			td.style.verticalAlign = 'top';
			td.style.valign = 'top';
			td.style.background = "url('/images/tt2/grad.gif') top left repeat-x #b3ab99";
			td.style.height = '100%';
			td.innerHTML = '<div style="padding: 5px">' + td.innerHTML + '</div>';
		}
	}
	for(i = 1; i < rows.length; ++i)
	{
		var tds = $(rows[i]).children();

		if ((i % 2) == 1)
		{
			for (var m = 0; m < tds.length; ++m)
			{		
				tds[m].style.background = "#E8E7E5";
				tds[m].style.padding = "5px";
				tds[m].style.lineHeight = '18px';
				if (m == 0)
				{
					tds[m].style.paddingLeft = '10px'
				}
			}
		}
		else
		{
			for (var m = 0; m < tds.length; ++m)
			{		
				tds[m].style.background = "#F2F1EF";
				tds[m].style.padding = "5px";
				tds[m].style.lineHeight = '18px';
				if (m == 0)
				{
					tds[m].style.paddingLeft = '10px'
				}
			}
		}
	}
	var t = first_row.clientHeight;
	if ((navigator.appName == 'Opera') || navigator.vendor)
	{
		for (var i = 0; i < chlds.length; ++i)
		{
			chlds[i].style.height = (first_row.clientHeight-0) + 'px';
		}
		first_td.innerHTML = "<table valign='top' cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100%\" style=\"padding: 0px; margin: 0px;\"><tr><td style=\"background: url('/images/tt2/lt.gif') top left no-repeat;border: none; width: 4px; height: 4px;\" width=\"4\" height=\"4\"></td><td style=\"background: url('/images/tt2/mt.gif') top left repeat-x;border: none; height: 4px;\" height=\"4\"></td></tr><tr><td style=\"background: url('/images/tt2/mg.gif') top left repeat-x #b3ab99; border: none; height: 18px;\"></td><td style=\"background: url('/images/tt2/mg.gif') top left repeat-x #b3ab99; border: none; font-weight: bold; text-align: left;\" height=\"100%\" valign='top'><div style=\"padding: 5px; padding-left: 10px;\">"+first_td_content+"</div></td></tr><tr><td style=\"background: url('/images/tt2/lb.gif') bottom left no-repeat; width: 4px; height: 4px; border: none;\"></td><td style=\"background: url('/images/tt2/mb.gif') bottom left repeat-x; border: none;\"></td></tr></table>";
		last_td.innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" height=\"100%\" width=\"100%\" style=\"padding: 0px; margin: 0px;\" id=\"rtb\"><tr><td style=\"background: url('/images/tt2/mt.gif') top left repeat-x; border: none; height: 4px;\" height=\"4\"></td><td style=\"background: url('/images/tt2/rt.gif') top right no-repeat; border: none; width: 4px; height: 4px;\" width=\"4\" height=\"4\"></td></tr><tr><td style=\"background: url('/images/tt2/mg.gif') top left repeat-x #b3ab99; border: none; font-weight: bold; text-align: left;\" height=\"100%\"><div style=\"padding: 5px;\">"+last_td_content+"</div></td><td style=\"background: url('/images/tt2/mg.gif') top left repeat-x #b3ab99; border: none; height: 18px;\" height=\"18\"></td></tr><tr><td style=\"background: url('/images/tt2/mb.gif') bottom left repeat-x; border: none;\"></td><td style=\"background: url('/images/tt2/rb.gif') bottom left no-repeat; width: 4px; height: 4px; border: none;\"></td></tr></table>";
	}
}
function centering()
{
	if (get_obj("login_form") && get_obj("auth_form_bg"))
	{
		var workspace = get_workspace();
		//alert(navigator.vendor);
		get_obj("login_form").style.left = ((workspace["w"] - get_obj("login_form").offsetWidth) / 2)+'px';
	
		if(document.documentElement.scrollTop)
		{
			get_obj("login_form").style.top = ((workspace["h"] - get_obj("login_form").offsetHeight) / 2)+document.documentElement.scrollTop+'px';
			get_obj("auth_form_bg").style.top = document.documentElement.scrollTop+'px';
		}
		else
		{
			get_obj("login_form").style.top = ((workspace["h"] - get_obj("login_form").offsetHeight) / 2)+document.body.scrollTop+'px';
			get_obj("auth_form_bg").style.top = document.body.scrollTop+'px';
		}
		get_obj("auth_form_bg").style.width = workspace["w"]+'px';
		//get_obj("auth_form_bg").style.height = workspace["h"]+'px';
	}
}
function show_login_form(t, f)
{
	document.getElementById('login_form').style.display = 'block';
	document.getElementById('auth_form_bg').style.display='block';
	document.getElementById('from').value = f
	if (t == 'p')
	{
		document.getElementById('login_form').setAttribute('t', 'p');
	}
	else 
	{
		document.getElementById('login_form').setAttribute('t', 'c');
	}
	centering();
}
function hide_login_form()
{
	document.getElementById('login_form').style.display='none';
	document.getElementById('auth_form_bg').style.display='none';
}
function select()
{
	if (document.getElementById('select_menu').style.display == '')
	{
		document.getElementById('select_menu').style.display = 'none';
	}
	else {
	document.getElementById('select_menu').style.display = ''; }
}
function set_select(id, title)
{
	document.getElementById('select_menu_data').innerHTML = title;
	document.getElementById('select_menu').style.display = 'none';
}
function select_hide()
{
	document.getElementById('select_menu').style.display = 'none';
}
var select_items = 3;
function select_up()
{
	var current = get_obj('select_menu').getAttribute('k');
	get_obj('si_'+(current-1)).style.display = '';
	var last = (current-1) +  (0+select_items);
	get_obj('si_'+(last-0)).style.display = 'none';
	get_obj('select_menu').setAttribute('k', current-1);
	//	select_update();
	current = (current-0)- 1;
	get_obj('sa_'+current).className = 'arrow_up';
	get_obj('sa_'+current).onclick = 'select_up();';
	last = last -1
	get_obj('sa_'+last).className = 'arrow_down';
	for(var i = current+1; i < last; ++i)
	{
		get_obj('sa_'+i).className = '';
	}
}
function select_down()
{
	var current = get_obj('select_menu').getAttribute('k');
	if (get_obj('select_menu').childNodes.length+1 > select_items ) {
	get_obj('si_'+current).style.display = 'none';
	var last = (current-0) +  (0+select_items);
	get_obj('si_'+last).style.display = '';
	get_obj('select_menu').setAttribute('k', current+1);
//	select_update();
	current = (current-0)+ 1;
	get_obj('sa_'+current).className = 'arrow_up';
	get_obj('sa_'+current).onclick = function () { select_up(); };
	get_obj('sa_'+last).className = 'arrow_down';
	for(var i = (current+1); i < last; ++i)
	{
		get_obj('sa_'+i).className = '';
	}}
}
function select_update()
{
	var current = get_obj('select_menu').getAttribute('k');
	var last = (current-0) +  (0+select_items);
	
	
}