function init(){

}

function Panels() {
  $('#tab-menu li').bind('click', function() {
    show_panel($(this).attr('id').substr(5));
    return false;
  });
  
  function show_panel(id) {
    el = $('#link_' + id);
    $('.panel>div').hide();
    $('#panel_' + id).fadeIn(300);
    $('#tab-menu li').removeClass('selected');
    $(el).addClass('selected');
    $('a', el).blur();
    $.cookie('selected_on_line', id);
  }
  
  if(!$.cookie('selected_on_line')){
    $('#tab-menu li:first').click();
  } else {
    show_panel($.cookie('selected_on_line'));
  }  
}

function show_hidden_panel(object){
	if(getCookie('panel_'+object)==0){	    
		
		$("#panel_"+object).removeClass("dashed-underline-link");
		$.cookie('panel_'+object, '1');
		
	}else{
	    
	    $("#panel_"+object).addClass("dashed-underline-link");		
		$.cookie('panel_'+object, '0');
	}
}


//загрузка данных Ajax 
function load_ajax(type,value,func){
	var req = new JsHttpRequest();
	// Код, АВТОМАТИЧЕСКИ вызываемый при окончании загрузки.
	req.onreadystatechange = function()
	{
		// we've got the data
		if(req.readyState == 4) {
			func(req.responseJS);
		}
	}
	// Подготавливаем объект.
	req.open('GET', '/files/data_loader.php', true);
	// Посылаем данные запроса (задаются в виде хэша).
	req.send({
		'type':	type,
		'value': value		
	});
	
}

// перекрестие в таблице

function table_highlight()
{
var table=document.getElementById('highlight');

function highlight(row, col, state)
{
for(var i=2; i<table.rows.length-2; i++)
{
if(state=='off')
{
for(var j=0; j<table.rows[i].cells.length; j++)
{
table.rows[i].cells[j].style.backgroundColor
='#fff';
}
}

if(state=='on')
{
table.rows[i].cells[col].style.backgroundColor
='#efefef';
}
}

for(var i=0; i<table.rows[row].cells.length; i++)
{
if(state=='on')
{
table.rows[row].cells[i].style.backgroundColor
='#efefef';
table.rows[row].cells[col].style.backgroundColor
='#fff';
}
}
}
// end function highlight

// detect cursor position
for(var i=2; i<table.rows.length-2; i++)
{
table.rows[i].row_index=i;
for(var j=0; j<table.rows[i].cells.length; j++)
{
table.rows[i].cells[j].column_index=j;
table.rows[i].cells[j].onmouseover=function()
{
highlight(this.parentNode.row_index, this.column_index, 'on');
}
table.rows[i].cells[j].onmouseout=function()
{
highlight(this.parentNode.row_index, this.column_index, 'off');
}
}
}
}


// Получение значения кукисов в JavaScript
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function encode_utf8( s )
{
  return unescape( encodeURIComponent( s ) );
}

function decode_utf8( s )
{
  return decodeURIComponent( escape( s ) );
}
