function NewOdnaknopka2() {
this.domain=location.href+'/';
this.domain=this.domain.substr(this.domain.indexOf('://')+3);
this.domain=this.domain.substr(0,this.domain.indexOf('/'));
this.location=false;
this.selection=function() {
var sel;
if (window.getSelection) sel=window.getSelection();
else if (document.selection) sel=document.selection.createRange();
else sel='';
if (sel.text) sel=sel.text;
return encodeURIComponent(sel);
}
this.redirect=function() {
if (this.location) location.href=this.location;
this.location=false;
}
this.go=function(i) {
window.open(this.url(i));
return false;
}
this.url=function(system) {
var title=encodeURIComponent(document.title);
var url=encodeURIComponent(location.href);
switch (system) {
case 1: return 'http://memori.ru/link/?sm=1&u_data[url]='+url+'&u_data[name]='+title;
case 2: return 'http://bobrdobr.ru/addext.html?url='+url+'&title='+title;
case 3: return 'http://www.google.com/bookmarks/mark?op=add&bkmk='+url+'&title='+title;
case 4: return 'http://zakladki.yandex.ru/userarea/links/addfromfav.asp?bAddLink_x=1&lurl='+url+'&lname='+title;
case 5: return 'http://twitter.com/home?status='+title+' '+url;
case 6: return 'http://del.icio.us/post?v=4&noui&jump=close&url='+url+'&title='+title;
case 7: return 'http://text20.ru/add/?source='+url+'&title='+title+'&text='+this.selection();
case 8: return 'http://news2.ru/add_story.php?url='+url;
case 9: return 'http://www.mister-wong.ru/index.php?action=addurl&bm_url='+url+'&bm_description='+title;
case 10: return 'http://moemesto.ru/post.php?url='+url+'&title='+title;
case 11: return 'http://smi2.ru/add/?url='+url+'&precaption='+title;
case 12: return 'http://www.vaau.ru/submit/?action=step2&url='+url;
case 13: return 'http://myscoop.ru/add/?URL='+url+'&title='+title;
case 14: return 'http://www.linkstore.ru/servlet/LinkStore?a=add&url='+url+'&title='+title;
case 15: return 'http://www.ruspace.ru/index.php?link=bookmark&action=bookmarkNew&bm=1&url='+url+'&title='+title;
case 16: return 'http://www.100zakladok.ru/save/?bmurl='+url+'&bmtitle='+title;
}
}
this.hide=function() {
if (this.timeout) clearTimeout(this.timeout);
document.getElementById('odnaknopka').style.visibility='hidden';
}
this.show=function(element) {
if (this.timeout) clearTimeout(this.timeout);
var left=0,top=0;
var style=document.getElementById('odnaknopka').style;
while (element) {
left+=element.offsetLeft;
top+=element.offsetTop;
element=element.offsetParent;
}
style.left=left+'px';
style.top=top+'px';
style.visibility='visible';
}
this.init=function() {
var titles=new Array('Memori','&#1041;&#1086;&#1073;&#1088;&#1044;&#1086;&#1073;&#1088;','&#1047;&#1072;&#1082;&#1083;&#1072;&#1076;&#1082;&#1080; Google','&#1071;&#1085;&#1076;&#1077;&#1082;&#1089;.&#1047;&#1072;&#1082;&#1083;&#1072;&#1076;&#1082;&#1080;','Twitter','del.icio.us','&#1058;&#1077;&#1082;&#1089;&#1090; 2.0','News2','&#1052;&#1080;&#1089;&#1090;&#1077;&#1088; &#1042;&#1086;&#1085;&#1075;','&#1052;&#1086;&#1105;&#1052;&#1077;&#1089;&#1090;&#1086;','&#1057;&#1052;&#1048; 2','&#1042;&#1072;&#1072;&#1091;!','AddScoop','LinkStore','RuSpace','&#1057;&#1090;&#1086; &#1047;&#1072;&#1082;&#1083;&#1072;&#1076;&#1086;&#1082;');
if (!document.getElementById('odnaknopka')) {
var div=document.createElement('div');
div.id='odnaknopka';
div.style.position='absolute';
div.style.visibility='hidden';
div.style.width='264px';
div.style.height='182px';
div.style.backgroundColor='transparent';
div.style.backgroundImage='url(/img/panel.png)';
div.style.border='0';
div.style.margin='0';
div.style.padding='0 1px 4px 1px';
div.style.overflow='hidden';
div.style.zIndex='1000';
div.style.font='normal 12px arial';
div.style.lineHeight='20px';
div.style.color='#666';
html='<a href="javascript:{}" onclick="return false;" style="display:block;float:left;width:258px;height:20px;overflow:hidden;margin:1px 0;padding:0;background-color:transparent;font:bold 11px arial;color:#666;text-decoration:none"></a>';
for (var i=0;i<16;i++) {
html+='<a href="'+this.url(i+1)+'" style="display:block;float:left;width:108px;height:16px;overflow:hidden;margin:1px 0;padding:0 0 0 24px;background-color:transparent;background:url(/img/panel.png) no-repeat -266px '+(-i*16)+'px;font:normal 12px arial;color:#666;text-decoration:none;text-align:left" onmouseover="this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'" onclick="return odnaknopka2.go('+(i+1)+');">'+titles[i]+'</a>';
}
div.innerHTML=html;
div.onmouseover=function() {if (odnaknopka2.timeout) clearTimeout(odnaknopka2.timeout)}
div.onmouseout=function() {odnaknopka2.timeout=setTimeout('odnaknopka2.hide()',200)};
document.body.insertBefore(div,document.body.firstChild);
}

ge('zakladka').innerHTML='<a href="javascript:{}" title="Добавить в закладки" onclick="return false;"><img src="/img/button.gif" width="136" height="16" alt="Добавить в закладки" style="border:0;margin:0;padding:0" onmouseover="odnaknopka2.show(this);" onmouseout="odnaknopka2.timeout=setTimeout(\'odnaknopka2.hide()\',200);"></a>';
}
}

function cookie(name, value, options) 
{
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, ';path=/', domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
}
function trim(text)
{
	rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g;
	return (text || "").replace( rtrim, "" );
}
function ge()
{
  var ea;
  for( var i = 0; i < arguments.length; i++ ) {
    var e = arguments[i];
    if( typeof e == 'string' ){
      e = document.getElementById(e);
	}
    if( arguments.length == 1 ){
      return e;
	}
    if( !ea ){
      ea = new Array();	
	}
    ea[ea.length] = e;
  }
  return ea;
}
function searchc()
{
	var v = ge('searchi').value;
	if(v.length==0)
	{
		alert('Введите ключевое слово из Вашего сна');
	}
	else if(v.length<2)
	{
		alert('Ключевое слово должно состоять минимум из 2 букв');
	}
	else
	{
		cookie("search",1);
		cookie("stext",v);
		cookie("ssource",ge('ssource').value);
		ge('searchf').submit();
	}
}
function init() {
if (arguments.callee.done) return;
arguments.callee.done = true;
if(ge('zakladka')!=null)
{
odnaknopka2=new NewOdnaknopka2();
odnaknopka2.init();
}	
sselect();
}

function sselect()
{
	if(cookie("search")==1)
	{
		ssource = cookie("ssource");
	    if(ssource*1>=0 && ssource*1<8)
	    {
	    	ge('ssource').value = ssource;
	    }
	    if(ssource*1>0 && ssource*1<8)
	    {
		    for(i=1;i<8;i++)
		    {
		    	if(ssource!=i)
		    	{
		    		id = "source_"+i;
		    		if(ge(id)!=null)
		    		{
		    			cookie("search",0);
		    			hide(id);
		    		}
		    	}
		    }
	    }
	}
}
function hide(id)
{
	if(ge(id)!=null)
	{
		ge(id).style['display'] = "none";
	}
}
// ff, opera
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}

// ie
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)>");
document.write("<\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
    if (this.readyState == "complete") {
        init();
    }
};
/*@end @*/

// safari
if (/WebKit/i.test(navigator.userAgent)) {
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            clearInterval(_timer);
            delete _timer;
            init();
        }
    }, 10);
}

// others
window.onload = init;



