
nN = navigator.appName;

function fsearch(str) {
	if(document.fform.myradio[0].checked) {
		open('http://yandex.ru/yandsearch?text=' + str + '&serverurl=' + document.location.hostname);
	} else {
		open('http://yandex.ru/yandsearch?text=' + str);
	}
}

function MouseUpHandler(e) {
	if(nN == 'Netscape' || nN == 'Opera') {
		if(document.getSelection()) {
			str = document.getSelection();

			newstr = str.replace(/\n+/g, ' ');
			str = newstr.replace(/\ +/g, ' ');

			if(str.length > 100){
				var i;
				i = 0;
				str = str.slice(0, 100);
				i = str.lastIndexOf(' ');

				if(i > 0){
					str = str.slice(0, i);
				}
			}

			document.fform.strf.value = str;
		}
	} else if(nN == 'Microsoft Internet Explorer') {
		if(document.selection.createRange()) {
			var range = document.selection.createRange();
			var str = range.text;
		}

		if(str) {
			str = str.replace(/\ +/g, " ");
			document.fform.strf.value = str;
		}
	}
	return true;
}


if(window.Event) {
	document.captureEvents(Event.MOUSEUP);
}

document.onmouseup = MouseUpHandler;




function ahref(txt, a_href, a_title, a_class){
    var html = "<a";
    html += (a_href) ? " href=\"" + a_href + "\"" : "";
    html += (a_title) ? " title=\"" + a_title + "\"" : "";
    html += (a_class) ? " class=\"" + a_class + "\"" : "";
    html += (">" + txt + "</a>");
    return html;
}



function mycopy(){
    var str;
    if (window.getSelection)
    {
        str = window.getSelection().toString();
    }
    else if (document.getSelection)
    {
        str = document.getSelection();
    }
    else if (document.selection)
    {
        str = document.selection.createRange().text;
    }
    if (str.length > 500) {
        str = str.substring(0, 500);
        str += "...\r\n\r\nПолная версия здесь: ";
    }
    else {
        str += "\r\n\r\nВзято с ";
    }
    str += window.location.href;
    window.clipboardData.setData("Text", str);
    return false;
}

function l(){
	window.clipboardData.setData("Text", window.location.href);
	alert("Ссылка на страницу скопирована. Для вставки нажмите Ctrl+V.");
	return false;
}
//document.onselectstart = l;
//document.oncontextmenu = l;


function rl(url, title){
document.write('<a'+' href="'+url+'" mce_href="'+url+'" target="_blank">'+title+'<'+'/a>');
}
