function $clear(timer) {
	clearTimeout(timer);
	clearInterval(timer);
}

function $preload(path, width, height) {
	if (document.images) {
		var img = new Image(width, height);
		img.src = path;
	}
}

function include(file) {
	document.write('<script type="text/javascript" src="/js/'+file+'"><\/script>');
}

function str_replace(search, replace, string) {
	while (-1 != string.indexOf(search)) {
		string = string.replace(search, replace);
	}
	return string;
}

function is_empty_string(string) {
	return ('' == str_replace(' ', '', str_replace('&nbsp;', '', string)));
}

function popup_img(href,w,h,title) {
	var wo = window.open(href,'_blank','scrollbars=0, menubar=0, title=0, titlebar=0, directories=0, status=0, statusbar=0, resizable=0, width='+w+', height='+h);
	wo.document.write('<html><head><title>'+title+'</title></head><body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0"><a href="#" onclick="window.close();"><img src="'+href+'" width="'+w+'" height="'+h+'" vspace="0" hspace="0" border="0" alt="Закрыть окно" /></a></body></html>');
	wo.focus();
	return wo;
}

function loadym(page) {
	page = str_replace(location.protocol + '//' + location.host, '', page);
	page = str_replace('?', '_', page);
	page = str_replace('/', '_', page);
	page = str_replace('&', '_', page);
	page = str_replace('__', '_', page);
	if ('_' == page[0]) page = page.substr(1);
	path = '/ym/?p='+page;
	$('ym-counter').src = path;
}
