function unset_checkbox(id) {
  var setID = document.getElementById(id);
  setID.checked = false;
}

function translitText(what, where){
  var txt = $("#"+what).attr("value");

  txt = txt.replace(/А/g, 'a'); 
  txt = txt.replace(/Б/g, 'b'); 
  txt = txt.replace(/В/g, 'v'); 
  txt = txt.replace(/Г/g, 'g'); 
  txt = txt.replace(/Д/g, 'd'); 
  txt = txt.replace(/Е/g, 'e'); 
  txt = txt.replace(/Ё/g, 'yo'); 
  txt = txt.replace(/Ж/g, 'zh'); 
  txt = txt.replace(/З/g, 'z'); 
  txt = txt.replace(/И/g, 'i'); 
  txt = txt.replace(/Й/g, 'j'); 
  txt = txt.replace(/К/g, 'k'); 
  txt = txt.replace(/Л/g, 'l'); 
  txt = txt.replace(/М/g, 'm'); 
  txt = txt.replace(/Н/g, 'n'); 
  txt = txt.replace(/О/g, 'o'); 
  txt = txt.replace(/П/g, 'p'); 
  txt = txt.replace(/Р/g, 'r'); 
  txt = txt.replace(/С/g, 's'); 
  txt = txt.replace(/Т/g, 't'); 
  txt = txt.replace(/У/g, 'u'); 
  txt = txt.replace(/Ф/g, 'f'); 
  txt = txt.replace(/Х/g, 'h'); 
  txt = txt.replace(/Ц/g, 'c'); 
  txt = txt.replace(/Ч/g, 'ch'); 
  txt = txt.replace(/Ш/g, 'sh'); 
  txt = txt.replace(/Щ/g, 'sh'); 
  txt = txt.replace(/Ъ/g, ''); 
  txt = txt.replace(/Ы/g, 'y'); 
  txt = txt.replace(/Ь/g, ''); 
  txt = txt.replace(/Э/g, 'e'); 
  txt = txt.replace(/Ю/g, 'yu'); 
  txt = txt.replace(/Я/g, 'ya'); 

  txt = txt.replace(/а/g, 'a'); 
  txt = txt.replace(/б/g, 'b'); 
  txt = txt.replace(/в/g, 'v'); 
  txt = txt.replace(/г/g, 'g'); 
  txt = txt.replace(/д/g, 'd'); 
  txt = txt.replace(/е/g, 'e'); 
  txt = txt.replace(/ё/g, 'yo'); 
  txt = txt.replace(/ж/g, 'zh'); 
  txt = txt.replace(/з/g, 'z'); 
  txt = txt.replace(/и/g, 'i'); 
  txt = txt.replace(/й/g, 'j'); 
  txt = txt.replace(/к/g, 'k'); 
  txt = txt.replace(/л/g, 'l'); 
  txt = txt.replace(/м/g, 'm'); 
  txt = txt.replace(/н/g, 'n'); 
  txt = txt.replace(/о/g, 'o'); 
  txt = txt.replace(/п/g, 'p'); 
  txt = txt.replace(/р/g, 'r'); 
  txt = txt.replace(/с/g, 's'); 
  txt = txt.replace(/т/g, 't'); 
  txt = txt.replace(/у/g, 'u'); 
  txt = txt.replace(/ф/g, 'f'); 
  txt = txt.replace(/х/g, 'h'); 
  txt = txt.replace(/ц/g, 'c'); 
  txt = txt.replace(/ч/g, 'ch'); 
  txt = txt.replace(/ш/g, 'sh'); 
  txt = txt.replace(/щ/g, 'sh'); 
  txt = txt.replace(/ъ/g, ''); 
  txt = txt.replace(/ы/g, 'y'); 
  txt = txt.replace(/ь/g, ''); 
  txt = txt.replace(/э/g, 'e'); 
  txt = txt.replace(/ю/g, 'yu'); 
  txt = txt.replace(/я/g, 'ya'); 

  txt = txt.replace(/ /g, '_'); 
  txt = txt.toLowerCase(txt);
  txt = txt.replace(/([^a-z0-9-_])/g, '');
  $("#"+where).attr("value", txt);
}
function confirm_text(text_of_confirmation)
{
	var yes=confirm(text_of_confirmation);
	if (yes)
	return true ;
	else
	return false ;
}

function highlight(field) 
{
	field.focus();
 	field.select();
}
function loadjs(page)
{
 $.get(page + "/rand" + Math.random() , function(data) {
  $('#mainspan').html("<script type='text/javascript'>" + data + "</script>");
});
}
function check_register(sysdir, id)
{
		var login = $("#"+id).attr("value");
		if(login != '') {
			loadjs(sysdir+'check'+id+'/'+login);
		}
		else {
			$('#login_form').css( {background: '#fff url(inc/img/userbig.gif) no-repeat 4px 50%'} )
		}
}
function vote_item(sysdir, id, vote, check, item)
{
	loadjs(sysdir+'rating/'+item+'/'+id+'/'+vote+'/'+check);
}
function fav_item(sysdir, id, vote, check, item)
{
	loadjs(sysdir+'favorites/'+item+'/'+id+'/'+vote+'/'+check);
}
function remove(sysdir, id, target, check)
{
	loadjs(sysdir+'remove/'+id+'/'+target+'/'+check);
}
function unhide(id_info){
	$("#"+id_info).css("display", "inline");
}
function hide(id_info){
	$("#"+id_info).css("display", "none");
}
function show_editing_options(){
	unhide('edit_options');
	$("#textarea_new").css("height", "300px");
	$("#textarea_new").css("color", "#111");
	$("#textarea_new").html("");
}
function send_comment(sysdir, id, user, topic_id) {
	var body = $("#body_"+id).val();
	var check = $("#check_"+id).val();
	var parent_id = $("#parent_id_"+id).val();
	if(body != '') {
		$("#button_reply_"+id).css("display", "none");
		$("#reply_"+id).attr("id", "current_reply");
		$("#current_reply").html("<img src='"+sysdir+"inc/img/loading.gif'/>");
		$.post(sysdir+'id/'+topic_id, { body: body, check: check, parent_id: parent_id }, onsendcomment);
	}
}
function onsendcomment(data)
{
	$("#current_reply").html(data);
	$("#current_reply").attr("id", "replied");
}
function show_comment(sysdir, id, check, insystem_login, topic_id) {
	$("#container_reply_"+id).css("display", "block");
	$("#button_reply_"+id).attr("onClick", "hide_comment('container_reply_"+id+"', '"+sysdir+"', "+id+", '"+check+"', '"+insystem_login+"', "+topic_id+")");
	$("#container_reply_"+id).html("<div id=\"reply_"+id+"\"><textarea id=\"body_"+id+"\" name=\"body\" class=\"comment_textarea\"></textarea><br/><input type=\"hidden\" id=\"check_"+id+"\" name=\"check\" value=\""+check+"\" /><input type=\"hidden\" id=\"parent_id_"+id+"\" name=\"parent_id\" value=\""+id+"\" />	<input type=\"submit\" class=\"reply_submit\" id=\"href_send_comment_"+id+"\" onClick=\"send_comment('"+sysdir+"', "+id+", '"+insystem_login+"', "+topic_id+"); return false;\" value=\"OK\" /></div>");
}
function show_cid(id) {
	$("#"+id).css("display", "block");
	$("#button_"+id).css("display", "none");
}
function hide_comment(id_info, sysdir, id, check, insystem_login, topic_id){
	$("#"+id_info).css("display", "none");
	$("#button_reply_"+id).attr("onClick", "show_comment('"+sysdir+"', "+id+", '"+check+"', '"+insystem_login+"', "+topic_id+")");
}
