function setcookie (name, value, the_time) {
	var expDate = new Date();
	expDate.setTime (expDate.getTime() + (the_time * 1000));
	document.cookie = name + "=" + escape (value) + "; expires=" + expDate.toGMTString ();
}

function add_art_rating (the_id, the_value){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("id", the_id);
		ajax.setVar("value", the_value);
		ajax.requestFile = "/include/ajax/articles/add_art_rating.php";
		ajax.method = "POST";
		ajax.element = "rating_" + the_id;
		ajax.sendAJAX(varsString);
}

function add_com_rating (the_id, the_value){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("id", the_id);
		ajax.setVar("value", the_value);
		ajax.requestFile = "/include/ajax/comments_rating.php";
		ajax.method = "POST";
		ajax.element = "comm_rating_" + the_id;
		ajax.sendAJAX(varsString);
}





function add_answer (the_id, module, idi){
		var the_form = "<form name='answer' id='answer_form_" + the_id + "' action='' onsubmit=\"update_comments('" + module + "', " + the_id +", " + idi + "); return false;\" method=post><input type=hidden name=parent value='" + the_id + "'><textarea name=com_body rows=4 style='width:100%'></textarea>"+
			 "<br><input type=submit value='добавить' style='float: right;clear: both;'></form>";
		var the_element = document.getElementById('answer_' + the_id);
		if (the_element.style.display == "none") {
			//the_element.style.display = "";
			the_element.innerHTML = the_form;
			$('#answer_'+the_id).slideToggle(500);
			document.answer.com_body.focus();
		}
		else {
			//the_element.style.display = "none";
			$('#answer_'+the_id).slideToggle(500);
			the_element.innerHTML = "";
		}
}
function update_comments (module, the_id, idi){
		$(".site_error").remove();
		$(".site_message").remove();
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("id", idi);
		ajax.setVar("parent", the_id);
		ajax.setVar("module", module);
		ajax.setVar("com_body", document.getElementById("answer_form_" + the_id).com_body.value);
		ajax.requestFile = "/include/ajax/update_comments.php";
		ajax.method = "POST";
		ajax.element = "comments_div";
		ajax.sendAJAX(varsString);
  }
function reload_captcha () {
	var rndval = new Date().getTime();
	document.getElementById('captcha_image').innerHTML = "<img src='/image.php?mod=bot&rnd=" + rndval + "' align='absmiddle' />";
}
function add_friend (the_id){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("id", the_id);
		ajax.requestFile = "/include/ajax/add_friend.php";
		ajax.method = "POST";
		ajax.element = "friends_list_false";
		ajax.sendAJAX(varsString);
}
function change_karma (the_id, value){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("user_id", the_id);
		ajax.setVar("value", value);
		ajax.requestFile = "/include/ajax/karma.php";
		ajax.method = "POST";
		ajax.element = "karma_value";
		ajax.sendAJAX(varsString);
}
function vote_blog_karma (value, the_id){
		setcookie ("blog_" + the_id, "1", 36000);
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("blog_name", the_id);
		ajax.setVar("value", value);
		ajax.requestFile = "/include/ajax/articles/karma.php";
		ajax.method = "POST";
		ajax.element = "karma_value";
		ajax.sendAJAX(varsString);
}
function blog (the_id, type){
		var ajax = new dle_ajax();
		ajax.onShow ("");
		var varsString = "";
		ajax.setVar("blog_id", the_id);
		if (type == "join") ajax.setVar("type", "join");
		else ajax.setVar("type", "exit");
		ajax.requestFile = "/include/ajax/articles/blog.php";
		ajax.method = "POST";
		ajax.element = "blog_options";
		ajax.sendAJAX(varsString);
}


function show_reg_form () {
	document.getElementById('reg_form').style.display = "block";
	document.getElementById('screen').style.display = "block";
}

function close_reg_form () {
	document.getElementById('reg_form').style.display = "none";
	document.getElementById('screen').style.display = "none";
}


$(document).ready(function () {
    $('.site_msg').load(close_msg(6000));
	$.jcorners("#block_users_top",{radius:6});
	$.jcorners("#block_last_publish",{radius:6});
	$.jcorners("#block_karma",{radius:6});
	$.jcorners("#block_services",{radius:6});
	$.jcorners("#block_live_comments",{radius:6});
	$.jcorners("#user_block",{radius:4});
});

function close_msg(spd) {
   $('.site_msg').fadeOut((spd), function () {
    $('.site_msg').css("display", 'none');
    });
}

function close_answer (the_id) {
	$('#answer_'+the_id).slideUp('slow');
}

