if (self != top) top.location = self.location;
function addBookmark(url, title)
{
 if (!url) url = location.href;
 if (!title) title = document.title;
 
 //Gecko
 if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
 //IE4+
 else if (typeof window.external == "object") window.external.AddFavorite(url, title);
 //Opera7+
 else if (window.opera && document.createElement)
 {
   var a = document.createElement('A');
   if (!a) return false; //IF Opera 6
   a.setAttribute('rel','sidebar');
   a.setAttribute('href',url);
   a.setAttribute('title',title);
   a.click();
 }
 else return false;
 
 return true;
}
function setimage(id, n, cols) {
	if(!cols) cols = 5;
	for(i=1;i<=cols;i++) {
		//alert('i'+id+i);
		if(i<=n) document.getElementById('i'+id+i).src="/i/s_1.png";
		else document.getElementById('i'+id+i).src="/i/s_0.png";
	}
}
function setimageclass(id, n, cols) {
	if(!cols) cols = 5;
	for(i=1;i<=cols;i++) {
		//alert('i'+id+i);
		if(i<=n) document.getElementById('i'+id+i).className="s_1";
		else document.getElementById('i'+id+i).className="s_0";
	}
}
//Функция установки cookie
function set_cookie(name, value, seconds)
{
	if(!seconds) seconds = 86400;
	expires = new Date();
	expires.setTime(expires.getTime() + (1000 * seconds));
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

//Функция получения cookie
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;
}
function addSmile(context,smile){
	var m=document.getElementById(context);
	if(document.selection){
		m.focus();
		sel=document.selection.createRange();
		sel.text=':'+smile+': ';
	}
	else if(m.selectionStart || m.selectionStart=="0") {
		var s=m.selectionStart;
		var e=m.selectionEnd;
		m.value=m.value.substring(0,s)+':'+smile+': '+m.value.substring(e,m.value.length);
	}else{
		m.value += ':'+smile+': ';
	}
}
