var xmlDoc = null ;
var hostname = 'beta.djmix.com.ua';

if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
else if (document.childNodes && !document.all && !navigator.taintEnabled) window.khtml = true;
else if (document.getBoxObjectFor != null) window.gecko = true;


function Navigator() {
	
	var ua = navigator.userAgent.toLowerCase();
	
	text = '';
	popupWin = '';
	if(ua.indexOf("gecko") != -1 && ua.indexOf("safari") == -1) {
		text = '<html>';
		text += '<head>';
		text += '<link href="http://img.'+hostname+'/tpl2/styles/real.css" rel="stylesheet" media="" />';
		text += '<title>Сделать стартовой</title>';
		text += '</head>';
		text += '<body>';
		text += '<table class="sit"><tr><td class="log"></td></tr><tr><td class="tt"><strong class="ff">Mozilla</strong></td></tr></table>';
		text += '- Зайдите в меню <b>Tools (Инструменты)</b> выберите пункт <b>Options (Настройки)</b><br />';
     	text += '- Вы должны увидеть новое окошко, в котором нужно выбрать закладку <b>Main (Основные)</b><br />';
     	text += '- В секции <b>Startup (Запуск)</b>, в опциях <b>When Firefox starts (При запуске Firefox)</b><br />';
    	text += '  выберите <b>Show my home page (Показывать домашнюю страницу)</b><br />';
    	text += '- Заполните поле <b>Home Page (Домашняя страница)</b> - введите ссылку <a href="http://siteua.org" target="_blank">http://siteua.org/</a><br />';
    	text += '- Нажмите Ok';
    	text += '</body>';
    	text += '</html>';
    	popupWin = window.open('', '', 'location,width=600,height=300,top=150');
		popupWin.document.write(text);
		popupWin.document.close();
	}
	if(ua.indexOf("opera") != -1) {
		text = '<html>';
		text += '<head>';
		text += '<link href="http://img.'+hostname+'/tpl2/styles/real.css" rel="stylesheet" media="" />';
		text += '<title>Сделать стартовой</title>';
		text += '</head>';
		text += '<body>';
		text += '<table class="sit"><tr><td class="log"></td></tr><tr><td class="tt"><strong class="opera">Opera</strong></td></tr></table>';
		text += '- Зайдите в меню <b>Tools (Инструменты)</b> и выберите пункт <b>Preferences (Настройки)</b><br />';
		text += '- Вы должны увидеть новое окошко, в котором нужно выбрать закладку <b>General (Основное)</b><br />';
		text += '- В опциях поля <b>Startup (Запуск)</b> выберите <b>Start with home page (Начинать с домашней страницы)</b><br />';
		text += '- Заполните поле <b>Home Page (Домашняя страница)</b> - введите ссылку <a href="http://siteua.org" target="_blank">http://siteua.org/</a><br />';
		text += '- Нажмите Ok';
		popupWin = window.open('', '', 'location,width=630,height=300,top=0');
		popupWin.document.write(text);
		popupWin.document.close();
	}
	if(ua.indexOf("safari") != -1) {
		text = '<html>';
		text += '<head>';
		text += '<link href="http://img.'+hostname+'/tpl2/styles/real.css" rel="stylesheet" media="" />';
		text += '<title>Сделать стартовой</title>';
		text += '</head>';
		text += '<body>';
		text += '<table class="sit"><tr><td class="log"></td></tr><tr><td class="tt"><strong class="safari">Safari</strong></td></tr></table>';
		text += '- Зайдите в меню <b>Edit (Правка)</b> и выберите пункт <b>Preferenсes (Настройки)</b><br />';
		text += '- Вы должны увидеть новое окошко, в котором нужно выбрать закладку <b>General (Основные)</b><br />';
		text += '- В поле <b>New window open with (В новых окнах открывать)</b> выберите пункт <b>Home Page (Домашнюю страницу)</b><br />';
		text += '- Заполните поле <b>Home Page (Домашняя страница)</b> - введите ссылку <a href="http://siteua.org" target="_blank">http://siteua.org/</a><br />';
		text += '- Закройте окно <b>Preferenсes (Настройки)</b>';
		text += '</body>';
    	text += '</html>';
		popupWin = window.open('', '', 'location,width=600,height=300,top=0');
		popupWin.document.write(text);
		popupWin.document.close();
	}
	
	return popupWin;
}

function slice( current , newest ) 
{
	var adress = '/moveslice/' + current + '/' + newest + '/' + Math.random();
	xmlSendReq( adress );
}

function hide_slice( current ) 
{
	var adress = '/moveslice/hide/' + current + '/' + Math.random();
	xmlSendReq( adress );
}

function show_slice( current ) 
{

	var adress = '/moveslice/show/' + current + '/' + Math.random();
	xmlSendReq( adress );
}

function show_unreg ( type , show )
{

	if(show) {
		document.getElementById('unreg_'+type).innerHTML = 'Зарегистрируйтесь, пожалуйста, чтобы иметь возможность настроить порядок рубрик';
		document.getElementById('unreg_'+type).style.visibility = 'visible';
	}
	else {
		document.getElementById('unreg_'+type).innerHTML = '';
		document.getElementById('unreg_'+type).style.visibility = 'hidden';
	}
}

function download ( id ) {
	count = 5;
	for(i=0;i<=5;i++) {
		time  = 'document.getElementById("my_counter").innerHTML = "Осталось: '+count+' сек."';
		setTimeout(time,i*1000);
		count--;
	}
	hreff = 'document.getElementById("download").innerHTML = "<a href=\'http://download.'+hostname+'/'+id+'/start\' class=\'themaindownload active\'></a>"';
	setTimeout(hreff,5*1000);
}

function Toggle(){
    if(document.getElementById('city_list').style.display == 'block')
    {
        document.getElementById('str_img').src = 'http://k.img.com.ua/img/str.gif';
    }
    else{
        document.getElementById('str_img').src = 'http://k.img.com.ua/img/str_up.gif';
    }   
    document.getElementById('city_list').style.display = (document.getElementById('city_list').style.display=='block') ? 'none' : 'block';
    document.getElementById('city_current').className = (document.getElementById('city_list').style.display=='block') ? 'city_current on' : 'city_current';
    return false;
}





function change_town( town ,i , current_town ) {
		
		document.getElementById( 'select_date_kyev').className = 'invisible';
		document.getElementById( 'select_date_don').className = 'invisible';
		document.getElementById( 'select_date_dnepr').className = 'invisible';
		document.getElementById( 'select_date_odessa').className = 'invisible';
		document.getElementById( 'select_date_lvov').className = 'invisible';
		document.getElementById( 'select_date_hark').className = 'invisible';
		for(z=0;z<=3;z++) {
			document.getElementById( 'kyev-'+z).className = 'invisible';
			document.getElementById( 'don-'+z).className = 'invisible';
			document.getElementById( 'dnepr-'+z).className = 'invisible';
			document.getElementById( 'odessa-'+z).className = 'invisible';
			document.getElementById( 'lvov-'+z).className = 'invisible';
			document.getElementById( 'hark-'+z).className = 'invisible';
			document.getElementById( 'town_list' ).className = 'invisible';
		}
		if( town == 'town_list') {
			document.getElementById( town ).className = 'town_list';
			document.getElementById ( current_town + '-' + i).className = 'block';
			document.getElementById( 'select_date_' + current_town).className = 'invisible';
		}
		if(town == 'list') {
			document.getElementById( 'select_date_' + current_town).className = 'town_list_2';
			document.getElementById ( current_town + '-' + i).className = 'block';
			for(z=0;z<=3;z++) {
				document.getElementById ( 'curr_date_'+ current_town + '_' + z).className = 'block';
			}
		}
		if(town == 'list2') {
			document.getElementById( 'select_date_' + current_town).className = 'invisible';
			document.getElementById ( current_town + '-' + i).className = 'block';
			document.getElementById('hide_status').value = i;
			
		}
		if (town == 'kyev' || town == 'don' || town == 'dnepr' || town == 'odessa' || town == 'lvov' || town == 'hark') {
			document.getElementById( town +'-' + i ).className = 'block';
			for(z=0;z<=3;z++) {
				 document.getElementById ( 'curr_date_'+ town + '_' + z).className = 'invisible';
			}
		}
}

	var tmp_id = 0;
   	var tmp_child_id = 0;
   	var tmp_type = 0;
	

function change_table( id, cols, rows, style, data, title, type_table, is_file )
	{
		var table;
		var i;
		var j;
		var data;
		var import_data;
		var data_array = [];
		var import_data_array = [];
		if(is_file == false) import_data = document.getElementById('import').value;
		else import_data = document.getElementById('import1').value;
		if(id != 0) {
			if(data) data_array = data.split(",");
			if(import_data) import_data_array = import_data.split(",");
			table = '<div class="table_edit_sport ' + type_table + id +'"><table class="' + style + '" border=0 cellspacing=0 cellpadding=0>';
			table += '<tr class="'+style+'_head">';
			for(i = 1; i <= cols; i++) {
				table += '<th name="head[' + i + ']">' + (data_array[i-1] ? data_array[i-1] : "") + '</th>';
			}
			table += '</tr>';
			for(i = 1; i <= rows; i++) {
				table += '<tr class="' + style + '_bg' + (i%2) + '">';
				for(j = 1; j <= cols; j++) {
					table += '<td class="'+style+'_r' + i + ' '+style+'_c' + j + '"><input type="box" class="table_box" style="background:none;border:0px;" name="data[' + i + j + ']" value="'+ (import_data_array[(j-1)+(i-1)*cols] ? import_data_array[(j-1)+(i-1)*cols] : '')  +'" /></td>'
				}
				table += '</tr>'
			}
			table += '</table></div>'
			//alert(table);
			//document.getElementById('current_table').innerHTML = '<div class="table_edit_sport ' + type_table + id +'"><table class="' + style + '" border=0 cellspacing=0 cellpadding=0><tr><td>1</td><td>1</td><td>1</td><td>1</td><td>11111111111</td><td>1</td><td>11111111111</td><td>1</td><td>111111111</td></tr></table></div>';
			document.getElementById('current_table').innerHTML = table;
			document.getElementById('hide_rows').value = rows;
			document.getElementById('hide_cols').value = cols;
			document.getElementById('hide_style').value = style;
			document.getElementById('hide_head').value = data;
			document.getElementById('hide_type').value = type_table;
		}
		else {
			document.getElementById('current_table').innerHTML = "";
		}
	}

function ShowChild( id_parent )
{
		if(tmp_id != 0) {
			document.getElementById('parent_'+tmp_id).className = '';
			document.getElementById('sub_parent_'+tmp_id).style.display = 'none'
		}
		document.getElementById('parent_'+id_parent).className = 'pr_blank';
		document.getElementById('sub_parent_'+id_parent).style.display = 'block'
		tmp_id = id_parent;
		
}

var tmp_sub = 0;

function ShowSub ( id )
{
	if(id == 0) { 
		if(document.getElementById('submenu3_' + tmp_sub)) document.getElementById('submenu3_' + tmp_sub).style.display = 'none';
	}
	if(tmp_sub != 0) {
		if(document.getElementById('submenu3_' + tmp_sub)) document.getElementById('submenu3_' + tmp_sub).style.display = 'none';
	}
	
	if(document.getElementById('submenu3_' + id)) document.getElementById('submenu3_' + id).style.display = 'block';
	tmp_sub = id;
}

var tmp_sub_id = 0;

function ActiveSub ( id )
{
	if( id == 0 ) {
		if(tmp_sub_id != 0 && document.getElementById('sub3_'+tmp_sub_id)) document.getElementById('sub3_'+tmp_sub_id).className = '';
	}
	else {
		if(tmp_sub_id != 0) {
				if(document.getElementById('sub3_'+tmp_sub_id)) document.getElementById('sub3_'+tmp_sub_id).className = '';
		}
		if(document.getElementById('sub3_'+id)) document.getElementById('sub3_'+id).className = 'pr_blank';
		tmp_sub_id = id;
		if(document.getElementById('id_category2')) {
			document.getElementById('id_category2').value = id;
		}
	}
}

function SpecText ( id ) 
{
	if(id == 94 ) {
		document.getElementById('main_button').innerHTML = '<input type="hidden" name="type_flag" value="s"><input type="submit" class="adone_big" name="sub2" value="Добавить демо" >';
		document.getElementById('left_demo_text').style.display = 'block';
		document.getElementById('left_main_text').style.display = 'none';
		document.getElementById('demo_text').style.display = 'block';
		document.getElementById('ganeral_text').style.display = 'none';
	}
	else {
		document.getElementById('left_demo_text').style.display = 'none';
		document.getElementById('left_main_text').style.display = 'block';
		document.getElementById('demo_text').style.display = 'none';
		document.getElementById('ganeral_text').style.display = 'block';
		document.getElementById('main_button').innerHTML = '<input type="hidden" name="type_flag" value="m"><input type="submit" class="adone_big" name="sub" value="Добавить" >';
	}
}

var tmp_change_ganre = 0;
function ChangeGanre ( id ) {
	if(tmp_change_ganre != 0) document.getElementById('ganre_'+tmp_change_ganre).className = 'none';
	
	document.getElementById('ganre_'+id).className = 'pr_blank';
	tmp_change_ganre = id;
	document.getElementById('real_ganre').value = id;
}
	
var tmp_price_type = 0;	
function ActivePriceType ( type ) {

	if(tmp_price_type != 0) document.getElementById('price_type_' + tmp_price_type ).className = 'none';
	
	document.getElementById('price_type_' + type ).className = 'pr_blank';
	tmp_price_type = type;
	document.getElementById('original_type').value = type;
}

function ActiveChild ( id_child , id, title)
{

		if(tmp_child_id != 0) {
			document.getElementById('ch_'+tmp_child_id).className = '';
		}
		document.getElementById('ch_'+id).className = 'pr_blank';
		tmp_child_id = id;
		if(document.getElementById('id_category')) {
			document.getElementById('id_category').value = id_child;
		}
		if(document.getElementById('title_pre')) {
			document.getElementById('title_pre').value = title;
		}
		if(document.getElementById('id_category2')) {
			document.getElementById('id_category2').value = id;
		}
		
		if(id == 48) {
			document.getElementById('marker1').style.display = 'block';
		}
		else {
			document.getElementById('marker1').style.display = 'none';
		}
		//if(id == 49) document.getElementById('marker2').style.display = 'block';
		//else document.getElementById('marker2').style.display = 'none';
}

function ActiveChild2 ( id )
{
		if(tmp_child_id != 0) {
			document.getElementById('child_'+tmp_child_id).className = '';
		}
		document.getElementById('child_'+id).className = 'pr_blank';
		tmp_child_id = id;
		style = document.getElementById('style').value;
		style_array = style.split(" ");
		document.getElementById('hide_id').value = id;
		document.getElementById('style').value = "cat" + id + " " + style_array['1'];
}

function ActiveType( type )
{
	if(tmp_type != 0) {
		document.getElementById('type_'+tmp_type).className = '';
	}
	if(type == 'none') style = 'navical';
	if(type == 'table') style = 'navical2';
	if(type == 'res') style = 'navical3';
	if(type == 'calendar') style = 'navical4';
	if(type == 'playoff') style = 'navical5';
	if(type == 'group') style = 'navical6';
	if(type == 'bomb') style = 'navical7';
	if(type == 'next') style = 'navical8';
	if(type == 'cup') style = 'navical3';
	document.getElementById('type_'+type).className = 'pr_blank';
	document.getElementById('hide_type').value = type;
	tmp_type = type;
	style2 = document.getElementById('style').value;
	style_array = style2.split(" ");
	document.getElementById('style').value = style_array['0'] + " " + style;
}

function ShowSelectedType ( type ) 
{
	var type_array = [];
	type_array['none'] = '---';
	type_array['table'] = 'Таблица';
	type_array['res'] = 'Результаты';
	type_array['calendar'] = 'Календарь';
	type_array['bomb'] = 'Бомбардиры';
	type_array['playoff'] = 'Календарь плей-офф';
	type_array['group'] = 'Календарь группы';
	type_array['next'] = 'Следующий тур';
	type_array['cup'] = 'Кубок';
	document.getElementById('title_f').value = type_array[type];
} 

function checkformTable ( obj )
			{
    				if( obj.num_cols.value <= 0)
    				{
    					alert("Количество столбцев должно быть больше 0");
    					return false;
					}
					if ( obj.num_rows.value <= 0 )
    				{
       					alert( "Количество строк должно быть больше 0" );
        				return false;
    				}
    				if( obj.num_cols.value > 50)
    				{
    					alert("Уменьшите количество столбцев! Максимальная длина 50");
    					return false;
					}
					if ( obj.num_rows.value > 50 )
    				{
       					alert( "Уменьшите количество строк! Максимальная длина 50" );
        				return false;
    				}
    				obj.submit();
			}
				
			function cols( count , data ) 
			{
				var z;
				var input ="";
				var data_array = [];
				if(data) data_array = data.split(",");
				if (count > 0) {
					for(z = 1; z <= count;z++) {
						input += z + '<input type="text" name="head[' + z + ']" value="' + (data_array[z-1] ?  data_array[z-1] : "") + '"/><br />';
					}
				}
				document.getElementById("head").innerHTML = input; 
			}
			
			function ShowChildCategory( id_parent )
			{
				if(tmp_id != 0) {
					document.getElementById('parent_category_'+tmp_id).style.display = 'none';
				}
				if(id_parent != 0) {
					document.getElementById('parent_category_'+id_parent).style.display = 'block';
					tmp_id = id_parent;
				}
		
			}

function setHome(ob) {
	ob.style.behavior='url(#default#homepage)';
	ob.setHomePage(document.location); 
}  

function xmlSendReq( reqText ) {
  if (typeof window.ActiveXObject != 'undefined' ) {
    xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
    xmlDoc.onreadystatechange = xmlProcess ;
  }
  else {
    xmlDoc = new XMLHttpRequest();
    xmlDoc.onload = xmlProcess ;
  }
  xmlDoc.open( "GET", reqText, true );
  xmlDoc.send( null );
}

var ajax_text;

function xmlProcess() {
  if ( xmlDoc.readyState != 4 ) return ;
//  alert(xmlDoc.responseText);
  var response = xmlDoc.responseText.split("\n");
  switch ( response[0] )
  {
	case 'error':
		document.getElementById('unit_ul'+response[2]).innerHTML = ajax_text;
		alert(response[1]);
		break;
	case 'UpdateKarmaUnreg':
		document.getElementById('informburo').innerHTML = '<span style="color: red;">Спасибо, ваш голос учтён. Пожалуйста, зарегистрируйтесь, чтобы повысить вес своего голоса в 10 раз.</span>';
		UpdateKarmaText( response[1], response[2] );
		break;
	case 'UpdateKarma':
		document.getElementById('informburo').innerHTML = '<span style="color: green">Спасибо, ваш голос учтён.</span>';
		UpdateKarmaText( response[1], response[2] );
		break;
	case 'UpdateComment':
		UpdateComment( response[1], response[2] );
		break;
	case 'UpdateProfile':
		UpdateProfile( response[1], response[2] );
		break;
	case 'PostMove':
		PostMoveResult( response[1], response[2] );
		break;
	case 'UpdateStarUnreg':
		document.getElementById('informburo_'+response[1]).innerHTML = '<span style="color: red">Пожалуйста, <a href="/login">Авторизируйтесь</a> или <a href="/register">зарегистрируйтесь</a>, тогда вы сможете проголосовать.</span>';
  		UpdateStarText( response[1], response[2] );
  		break;
	case 'UpdateStar':
		document.getElementById('informburo').innerHTML = '<span style="color: green">Спасибо, ваш голос учтён.</span>';
		UpdateStarText( response[1], response[2] );
		document.getElementById('is_voted').innerHTML = response[3];
		break;
  	case 'newslice':
  		document.getElementById('slice').innerHTML = response[1];
  		break;
  	case 'UpdateFile':
  		//document.getElementById('slice').innerHTML = response[1];
  		UpdateStarText( response[1], response[2] );
  		//document.getElementById('rating_'+response[1]).innerHTML = response[3];
  		break;
  }
  	
}

function PostMoveResult( id, tocat )
{
	document.getElementById('postmover_'+id).style.display = 'none';
	document.getElementById('postmover2_'+id).innerHTML = 'перемещено в <b>'+tocat+'</b>';
}

function rssiJSVote( id, updown )
{
	var voting = "up";
	if ( updown == 2 ) voting = "down";
	var adress = '/system_category/'+id+'/vote/'+voting+'/'+Math.random();
	xmlSendReq( adress );
}

function StarVote(id, ncount, units, flag)//element id, [1,2,3,4,5], , op. flag
{

	ajax_text = document.getElementById('unit_ul'+id).innerHTML;
	var theUL = document.getElementById('unit_ul'+id);
	theUL.innerHTML = '<div class="loading"></div>';
	
	var adress = '/system_category/'+id+'/starvote/'+ncount+'/' + units + '/' + flag + '/' + Math.random();
	xmlSendReq( adress );
}

function UpdateStarText ( id, text )
{
	//var el=document.getElementById( 'unit_ul_'+id );
	var el = document.getElementById('unit_ul'+id);
    el.innerHTML = text;
}

function UpdateKarmaText( id, text )
{
	var el=document.getElementById( 'recommend_text');
	el.innerHTML = 'Рейтинг: <b>'+text+'</b>';
	
}

function UpdateKarma( id, text )
{
	var el=document.getElementById( 'kval_'+id );
	if ( text > 1.5 ) el.className = 'p3';
	else if ( text > 1 ) el.className = 'p2';
	else el.className = 'p1';
	
	if ( text > 0 ) text = "+" + text;
	
	UpdateKarmaText( id, text );
}

function rateComment( id, updown )
{
	var adress = '/'+id+'/ratecomment/'+updown+'/'+Math.random();
	xmlSendReq( adress );
}

function UpdateComment( id, text )
{
	document.getElementById('cratep_'+id).style.display = 'none';
	document.getElementById('cratem_'+id).style.display = 'none';
	document.getElementById('crate_'+id).className = 'ratefull';
	document.getElementById('crate_'+id).innerHTML = text;
}

function startSiteSearch()
{
	var value = document.getElementById('overall_srch').value;
	var iscat = 0;
	//alert ( ' ' + document.getElementById('is_cat') );
	if(document.getElementById('is_cat')) {
		if(document.getElementById('is_cat').checked) {
			iscat = 1;
		}
	}
	//alert(iscat);
	if ( value.length < 3 ) alert('Поисковая фраза слишком мала. Попробуйте написать больше букавок.');
	else
	{
		document.location.href = '/search/prepare/'+value+'/'+iscat;
	}
}

function searchKeyPress(e)
{
      var kk = navigator.appName == 'Netscape' ? e.which : e.keyCode;
      if (kk == 13) startSiteSearch();
}

var RTR1 = 2;
var RTR2 = 1;
var RTR3 = 1;

function ActiveParent ( catname ) {
	if(document.getElementById('parent_news')) document.getElementById('parent_news').className = '';
	if(document.getElementById('parent_it')) document.getElementById('parent_it').className = '';
	if(document.getElementById('parent_showbiz')) document.getElementById('parent_showbiz').className = '';
	if(document.getElementById('parent_kino')) document.getElementById('parent_kino').className = '';
	if(document.getElementById('parent_music')) document.getElementById('parent_music').className = '';
	if(document.getElementById('parent_games')) document.getElementById('parent_games').className = '';
	if(document.getElementById('parent_sport')) document.getElementById('parent_sport').className = '';
	
	document.getElementById('parent_' + catname).className = 'pr_blank';
	document.getElementById('cattype').value = catname;
}

function changeOption ( catname )
{/*
	
	if(catname == '0' || catname == 'take_all') 
	{
		document.getElementById('news').style.display = 'none';
		document.getElementById('it').style.display = 'none';
		document.getElementById('showbiz').style.display = 'none';
		document.getElementById('kino').style.display = 'none';
		document.getElementById('music').style.display = 'none';
		document.getElementById('games').style.display = 'none';
		document.getElementById('sport').style.display = 'none';
		
	}
	else  {
		document.getElementById('news').style.display = 'none';
		document.getElementById('it').style.display = 'none';
		document.getElementById('showbiz').style.display = 'none';
		document.getElementById('kino').style.display = 'none';
		document.getElementById('music').style.display = 'none';
		document.getElementById('games').style.display = 'none';
		document.getElementById('sport').style.display = 'none';
		document.getElementById( catname ).style.display = 'block';
	}*/
}

function changeSource ( catname )
{/*
	document.getElementById('news_source').style.display = 'none';
	document.getElementById('it_source').style.display = 'none';
	document.getElementById('showbiz_source').style.display = 'none';
	document.getElementById('kino_source').style.display = 'none';
	document.getElementById('music_source').style.display = 'none';
	document.getElementById('games_source').style.display = 'none';
	document.getElementById('sport_source').style.display = 'none';
	document.getElementById( catname ).style.display = 'block';*/
}

function checkform ()
{
    //if ( document.obj.value == '' )
    //{
        alert( "Add image" );
      //  return false;
    //}
    //document.obj.submit();
}

function Filter ( cat, cat_sub, author )
{
	//var value = document.getElementById(filter_table).value;
	alert(cat_sub);
	//document.location.href = '/admin/stories/filter/'+filter_table+'/'+value;
}

function changeRateTable( rtrow, rtvalue )
{
	// Меняем классы на ссылках
	document.getElementById('rta'+rtrow+rtvalue).className = 'active';
	document.getElementById('rta'+rtrow+( 3 - rtvalue) ).className = 'inactive';
	
	switch ( rtrow )
	{
		case 1:
			RTR1 = rtvalue;
			break;
		case 2:
			RTR2 = rtvalue;
			break;
		case 3:
			RTR3 = rtvalue;
			break;
	}
	
	// Прячем видимый элемент
	if ( document.getElementById('rtt_111').style.display == 'block' )document.getElementById('rtt_111').style.display = 'none';
	if ( document.getElementById('rtt_121').style.display == 'block' )document.getElementById('rtt_121').style.display = 'none';
	if ( document.getElementById('rtt_122').style.display == 'block' )document.getElementById('rtt_122').style.display = 'none';
	if ( document.getElementById('rtt_222').style.display == 'block' )document.getElementById('rtt_222').style.display = 'none';
	if ( document.getElementById('rtt_221').style.display == 'block' )document.getElementById('rtt_221').style.display = 'none';
	if ( document.getElementById('rtt_211').style.display == 'block' )document.getElementById('rtt_211').style.display = 'none';
	if ( document.getElementById('rtt_212').style.display == 'block' )document.getElementById('rtt_212').style.display = 'none';
	if ( document.getElementById('rtt_112').style.display == 'block' )document.getElementById('rtt_112').style.display = 'none';
	
	// Показываем что нужно
	document.getElementById('rtt_'+RTR1+RTR2+RTR3).style.display = 'block';
}

function changeTimelineTable( index )
{
	// Скрываем всё
	for ( var i = 1; i < 4; i++ )
	{
		document.getElementById('tlid'+i).style.display = 'none';
		document.getElementById('chtl'+i).className = 'inactive';
	}
	document.getElementById('tlid'+index).style.display = 'block';
	document.getElementById('chtl'+index).className = 'active';
}

function moveToSite( id_post )
{
	var mt = document.getElementById('postmover_'+id_post).value;
	
	if ( mt == 'nochange' ) return true;
	
	var adress = '/'+id_post+'/moveto/'+mt+'/'+Math.random();
	xmlSendReq( adress );
}

function showHiddenComment( id_comment )
{
	document.getElementById('hcl_'+id_comment).style.display = 'none';
	document.getElementById('hc_'+id_comment).style.display = 'block';
}

function doProfileEdit( fieldName )
{
	document.getElementById('prof_v_'+fieldName).style.display = 'none';
	document.getElementById('prof_c_'+fieldName).style.display = 'block';
}

function doProfileSave( fieldName )
{
	if ( fieldName == 'birthdate' )
	{
		var url = '/user/'+profile_user_name+'/profile/ajaxsave/'+fieldName+'/'+Math.random()+'/'+document.getElementById('birthdate_year').value+'-'+document.getElementById('birthdate_month').value+'-'+document.getElementById('birthdate_day').value;
	}
	else if ( fieldName == 'sex' )
	{
		var url = '/user/'+profile_user_name+'/profile/ajaxsave/'+fieldName+'/'+Math.random()+'/'+document.getElementById('prof_f_'+fieldName).value;
	}
	else if ( fieldName == 'send_mail')
	{
		var url = '/user/'+profile_user_name+'/profile/ajaxsave/'+fieldName+'/'+Math.random()+'/'+document.getElementById('prof_f_'+fieldName).value;
	}
	else
	{
		
		var priv = '';
		if ( document.getElementById('prof_p_'+fieldName) )
		{
			if ( document.getElementById('prof_p_'+fieldName).checked ) priv = 'yes';
		}
		var url = '/user/'+profile_user_name+'/profile/ajaxsave/'+fieldName+'/'+Math.random()+'/'+document.getElementById('prof_f_'+fieldName).value+'/'+priv;
	}
//	alert( url );
	xmlSendReq( url );
	document.getElementById('prof_v_'+fieldName).style.display = 'block';
	document.getElementById('prof_v_'+fieldName).innerHTML = '<i>сохранение</i>';
	document.getElementById('prof_c_'+fieldName).style.display = 'none';
}

function UpdateProfile( fieldName, fieldValue )
{
	document.getElementById('prof_v_'+fieldName).innerHTML = fieldValue;
}

var rollerTimeout = 0;
Effects = {};
Effects.fade = function(id, opacStart, opacEnd, duration, callback)
{

	//Effects.changeOpacity(0, id);
	var speed = Math.round(duration/10);
	var timer = 0;

	if(opacStart > opacEnd)
	{
		for(var i=opacStart; i>=opacEnd; i-=10)
		{
			setTimeout("Effects.changeOpacity("+ i +", '"+ id +"', "+ opacEnd +", '"+ callback +"')", (timer*speed));
			timer++;
		}
	}
	else if(opacStart < opacEnd)
	{
		for(var i=opacStart; i<=opacEnd; i+=10)
		{
			setTimeout("Effects.changeOpacity("+ i +", '"+ id +"', "+ opacEnd +", '"+ callback +"')", (timer*speed));
			timer++;
		}
	}
}

Effects.changeOpacity = function(opacity, id, endPoint, callback)
{
	var _style = document.getElementById(id).style;
	if ( window.ie )
	{
	    _style.filter = "alpha(opacity=" + opacity + ")";
		_style.zoom = 1;
	}
	else
	{
	    _style.opacity = (opacity / 100);
	    _style.MozOpacity = (opacity / 100);
	    _style.KhtmlOpacity = (opacity / 100);
	}
	if(opacity == endPoint && callback != null)
	{
		if ( window.ie && endPoint == 100 )
		{
			_style.filter = "none";
		}
		eval(callback);
	}
}



Effects.onFaded = function()
{
	// Add callback code here
}

function rollerGo( delta )
{
	clearTimeout(rollerTimeout);
	var oldId = current_roller_id;
	current_roller_id = current_roller_id + delta;
	if ( current_roller_id == 0 ) current_roller_id = last_roller_id;
	if ( current_roller_id > last_roller_id ) current_roller_id = 1;
	rollerHide();
}

function rollerHide()
{
	Effects.fade('roller_master', 100, 0, 400, 'rollerShow()');
}

function rollerShow()
{
	Effects.changeOpacity(0, 'roller_roll_'+current_roller_id, 1, '');
	document.getElementById( 'roller_master' ).innerHTML = document.getElementById( 'roller_roll_'+current_roller_id ).innerHTML;
	Effects.fade('roller_master', 0, 100, 400, 'Effects.onFaded()');
	rollerTimeout = setTimeout('rollerGo(1)',5000);
}
