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){
		setcookie ("articles_" + the_id, "1", 36000);
		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_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 id='com_body' name='com_body' rows='2' style='width:90%'></textarea>"+
			 "<br><input type='button' value='скрыть' onclick='close_answer(" + the_id + ")'> <input type='submit' value='добавить'></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).slideDown('slow');
			document.answer.com_body.focus();
		}
		else {
			//the_element.style.display = "none";
			$('#answer_'+the_id).slideUp('slow');
			the_element.innerHTML = "";
		}
}
function update_comments (module, the_id, idi){
		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", encodeURIComponent(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 () {
	$("#logo").corner("10px tl tr");
	$("#menu").corner("10px bl br");
	$("#footer").corner("10px");
	$("#main_table").corner("10px");
	$("#user_karma").corner("10px");
	$(".block").corner("10px tl bl");
	//$(".blog_info").corner("10px");
	$(".site_message").corner("8px");
	$(".site_error").corner("8px");
	$("#second_navigation li").corner("8px tl tr");
	$("#second_navigation").corner("8px bl br");
	$("#block_last_user_arts").corner("10px");
	$("#block_users_top").corner("10px");
});
function close_answer (the_id) {
	$('#answer_'+the_id).slideUp('slow');
}

function delete_comments(the_id, module, idi){
		if (confirm("Правда удалить?") == true) {
			var ajax = new dle_ajax();
			ajax.onShow ("");
			var varsString = "";
			ajax.setVar("id", idi);
			ajax.setVar("delete", "true");
			ajax.setVar("module", module);
			ajax.setVar("comment", the_id);
			ajax.requestFile = "/include/ajax/update_comments.php";
			ajax.method = "POST";
			ajax.element =  "comments_div";
			ajax.sendAJAX(varsString);
		}
}

window.defaultStatus = "";      
function grtdm(divID, oDoc ){
if( !oDoc ) { oDoc = document; } 
if( document.layers ) { if( oDoc.layers[divID] ) { return oDoc.layers[divID]; }
else { for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) { y = grtdm(divID,oDoc.layers[x].document);}return y;}}if( document.getElementById ) { return oDoc.getElementById(divID); }if( document.all ) { return oDoc.all[divID]; }return document[divID];} function win_up(oSrc, oWidth, oTitle, oText){ PositionX = 20;	PositionY = 20; defaultWidth  = 765; defaultHeight = 400; var AutoClose = ''; var oW1 = oWidth+30; var oContent; var buttonclose = "<input class='button' type='button' value='Р·Р°РєС_С<С'С_' onClick='window.close();' />"; oContent  = "<table border='0' cellspacing='10' cellpadding='0' style='text-align:center; width:"+oWidth+"px; height:100px;'>\n"; oContent  += "<tr><td style='white-space:nowrap; width:"+oWidth+"px;'>"; oContent  += "<img src='"+oSrc+"' alt='' style='width:"+oWidth+"px;'  />"; oContent  += "</td></tr>\n"; oContent  += "<tr><td class='poptext' style='width:"+oWidth+"px; text-align:left;'>"+oText+"</td></tr>\n"; oContent  += "<tr><td colspan='2' style='white-space:nowrap; width:"+oWidth+"px; text-align:right;'>"+buttonclose+"</td></tr>\n"; oContent  += "</table>\n"; var imgWin = window.open('','name','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);if( !imgWin ) { return true; } imgWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html>\n'+'<head>\n'+'<title>'+oTitle+'<\/title>\n'+'<script type="text/javaScript">\n'+'function grtdm( divID, oDoc ) {\n'+'if( !oDoc ) { oDoc = document; }\n'+' if( document.layers ) {\n'+' if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {\n'+'for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {\n'+' y = grtdm(divID,oDoc.layers[x].document);\n'+'}\n'+' return y;\n'+'}\n'+' }\n'+' if( document.getElementById ) { return oDoc.getElementById(divID); }\n'+' if( document.all ) { return oDoc.all[divID]; }\n'+' return document[divID];\n'+'}\n'+'\n'+'function re_win() {\n'+' if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }\n'+' if( !document.images[0].height || window.doneAlready ) { return; } \n'+' var oH = grtdm( "myID" ); if( !oH ) { return false; }\n'+' var oW = oH.clip ? oH.clip.width : oH.offsetWidth;\n'+' var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }\n'+' if( !oH || window.doneAlready ) { return; } //in case images are disabled\n'+' window.doneAlready = true; \n'+' var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+' var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+' if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+' else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+' else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+' if( window.opera && !document.childNodes ) { myW += 16; }\n'+' x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+' }\n'+' <\/script>\n'+' <style type="text/css">\n'+' html,body{\n'+' text-align:center;\n'+' font-family: arial, verdana, helvetica, tahoma, sans-serif;\n'+' font-size: 11px;\n'+' color: #444;\n'+' margin-left: auto;\n'+' margin-right: auto;	\n'+' margin-top:0px;\n'+' margin-bottom:0px;\n'+' padding: 0px;\n'+' background-color:#FFF;\n'+' height:100%;\n'+' cursor:default;\n'+' }\n'+' .poptext{\n'+' font-size: 11px;\n'+' text-align:left;\n'+' color:#444;\n'+' line-height:140%;\n'+' vertical-align:top;\n'+' text-align:left;\n'+' }\n'+'.button{\n'+' border:1px solid #444;\n'+' color: #444;\n'+' background-color:#FFF;\n'+' font-size: 11px;\n'+' padding:2px;\n'+' cursor:pointer;\n'+' text-align:center;\n'+' width:60px;\n'+'}\n'+'<\/style>\n'+'<\/head>\n'+' <body onload="re_win();">\n'+(document.layers?('<layer left="0" top="0" id="myID">\n'):('<div style="width:'+oW1+'px; position:absolute;left:0px;top:0px;" id="myID" >\n'))+oContent+(document.layers?'<\/layer>\n':'<\/div>\n')+'<\/body>\n'+'<\/html>\n');imgWin.document.close();if( imgWin.focus ) { imgWin.focus(); }} function win_up2(oSrc, oWidth){ PositionX = 20; PositionY = 20;	defaultWidth  = 600; defaultHeight = 400; var AutoClose = ''; var oW1 = oWidth+30; var imgWin = window.open(oSrc,'name','scrollbars=yes,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY); if( !imgWin ) { return true; } imgWin.document.close();
if( imgWin.focus ) { imgWin.focus(); } }
