var _eCache = {};
function $(id) {
	return _eCache[id] || (_eCache[id] = (document.getElementById) ? document.getElementById(id) : document.all(id));
}

function init() {
	AdCookie = getCookie("progimp-links-close");
	if (AdCookie == "yes") close_ad();
//	if (self.parent && !(self.parent === self)) self.parent.location = document.location;
	document.onkeydown = register;
}

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 register(e) {
	var event = e || window.event; 
	if($('prev_page')) {
		if(event.ctrlKey == true && event.keyCode == 37) {
			window.location =  $('prev_page').href;
		};
	}
	if($('next_page')) {
		if(event.ctrlKey == true && event.keyCode == 39) {
			window.location =  $('next_page').href;
		};
	}
}

function ad_cookie() {
    var d = new Date();
    d.setDate(d.getDate()+1000);
    var str = "progimp-links-close=yes; path=/; expires="+d.toUTCString();
    document.cookie = str;
	close_ad();
    return false;
}

function close_ad() {
	var Links = document.getElementById("sp");
	if (Links) Links.style.display = "none";
	Links = null;
}


function cp_() {$('comment_field').innerHTML=this.req.responseText;$('message_field').innerHTML=' ';

	$('comment').onkeyup = function (e) {
		if (!e) e = window.event;
		if (e.ctrlKey	 && 	e.keyCode	== 13) 	post();
	}
	delete _eCache['comment']; 
}
function ce_() {$('message_field').innerHTML='Произошла ошибка. Повторите попытку позднее.';}

function post(){
	

	
	
	var p='comment='+encodeURIComponent($('comment').value)+'&answer='+encodeURIComponent($('answer').value);
	if($('name')) {p+=
	'&name='+encodeURIComponent($('name').value)+
	'&email='+encodeURIComponent($('email').value)+
	'&pass='+encodeURIComponent($('password').value)+
	
	'&alienpc='+encodeURIComponent($('alienpc').value);
	}
	$('postcomment').disabled=true;
	$('comment').disabled=true;
	
	//$('message_field').innerHTML=p;
	
	var u= window.location+'?ajax=1',l=new net.ContentLoader(u,cp_,ce_,'POST',p);
	
	 delete _eCache['postcomment'];
	 delete _eCache['comment'];
	 delete _eCache['answer'];
	$('message_field').innerHTML='ждем ответа...';
}