function $(id){ return document.getElementById(id); }
function showank(){
var wn=open( 'http://wood-work.ru/ank/?eqcid=15', 'eqank', 'width=500,height=600,toolbar=no,scrollbars=yes,resizable=no');
wn.moveTo(Math.round(screen.width/2-250),100 );
closeank(1);
}
function closeank(force){
	$('askme').style.display = 'none';
	if(!force) {
		var stat = document.createElement('iframe');
		stat.src="http://www.wood-work.ru/?template=40&eqcid=15&otkaz=1";
		stat.width=1;
		stat.height=1;
		stat.style.position='absolute';
		stat.style.left = '-1000px';
		document.body.appendChild(stat);
 	}
}
function showaskme(){
		$('askme').style.left = Math.round((screen.width-200)/2) + 'px';
		$('askme').style.top = Math.round((screen.height-100)/2) + 'px';
		set_cookie('eqankasked',100,(new Date(2010,1,1)));
		var stat = document.createElement('iframe');
		stat.src="http://www.wood-work.ru/?template=40&eqcid=15";
		stat.width=1;
		stat.height=1;
		stat.style.position='absolute';
		stat.style.left = '-1000px';
		document.body.appendChild(stat);
}
function set_cookie(name, value, expires) {
	if (!expires) expires = new Date();
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}
function get_cookie(name) {
	cookie_name = name + "=";
	cookie_length = document.cookie.length;
	cookie_begin = 0;
	while (cookie_begin < cookie_length) {
		value_begin = cookie_begin + cookie_name.length;
		if (document.cookie.substring(cookie_begin, value_begin) == cookie_name) {
			var value_end = document.cookie.indexOf (";", value_begin);
			if (value_end == -1) value_end = cookie_length;
			return unescape(document.cookie.substring(value_begin, value_end));
		}
		cookie_begin = document.cookie.indexOf(" ", cookie_begin) + 1;
		if (cookie_begin == 0) break;
	}
	return null;
}
document.write( "<style>"+
"#askme { position:absolute; left:-1000px; top:-300px; font-size:10px; width:200px;  border:1px solid #a6a6a6; padding:5px 15px 15px 15px; background-color:#fff; z-index:100; }"+
"#askme_title { font-size:11px; padding:20px 0px 25px 80px; color:#0c79c2; background:url(http://www.wood-work.ru/a1/3x.gif) 0px 0px no-repeat;  }"+
"#askme_btn1, #askme_btn2 { cursor:pointer; }"+
"</style>"+
"<div id=\"askme\"><div id=\"askme_title\">Уважаемый посетитель!</div><p>Благодорим Вас за внимание к сайту. Мы будем признательны, если вы ответите на вопросы анкеты.</p><div align=center><img src=\"http://www.wood-work.ru/a1/ok.gif\" width=\"131\" height=\"28\" id=\"askme_btn1\" onclick=\"showank();\" alt=\"продолжить\" /><br /><img src=\"http://www.wood-work.ru/a1/quit.gif\" width=\"131\" height=\"27\" id=\"askme_btn2\" onclick=\"closeank(0);\" alt=\"закрыть\" /></div></div>"  );
var kuka = parseInt(get_cookie('eqankasked'));
if( !kuka ) {
	set_cookie('eqankasked',1,(new Date(2010,1,1)));
} else {
	if( kuka<2 ) {
		kuka++;
		set_cookie('eqankasked',kuka,(new Date(2010,1,1)));
	} else {
		if( kuka==2 ) showaskme();
	}
}
