
function open_file(obj)
{
	window.open(obj.href,obj.target,'width=700,height=500, location=no,toolbar=no,menubar=no,status=no,top=50,left=200,scrollbars=yes');
}

function open_file_str(obj)
{
	window.open(obj.href,obj.target,'width=700,height=600, location=no,toolbar=no,menubar=no,status=no,top=50,left=200,scrollbars=yes');
}

var showmenu = false;

function startList() {
	if(document.getElementById) {
		for(k = 1;; k++) {
			navRoot = document.getElementById("fake"+k);
			if(navRoot==null) break;
			navRoot.style.width = navRoot.clientWidth-2+'px';
			if(document.all) {
				navRoot.onmouseover=function() {
					this.className+=" over";
					showmenu = true;
				}
				navRoot.onmouseout=function() {
					this.className=this.className.replace(" over", "");
					showmenu = false;
				}
			}
		}
	}

return false;
}

function dummyClick(me)
{
	if(me)
		me.blur();
	return false;
}

var time,thelayer,thelayer1,amount,amount1,maxlayeroffset,maxlayeroffset1;
var theTime = 150;
var mytop = 0, mytop1 = 0;

function setScrollWidth() {
// „«ï IE
	thelayer = document.getElementById('leftbtext');
	thelayer1 = document.getElementById('rightbtext');
	var cbox = document.getElementById('leftbblock');
	var cbox1 = document.getElementById('rightbblock');
	if(thelayer)
		thelayer.style.width = cbox.clientWidth+'px';
	if(thelayer1)
		thelayer1.style.width = cbox1.clientWidth+'px';
}

function initscroll()
{
	thelayer = document.getElementById('leftbtext');
	thelayer1 = document.getElementById('rightbtext');
	maxlayeroffset = 0;
	maxlayeroffset1 = 0;
	var cbox = document.getElementById('leftbblock');
	var cbox1 = document.getElementById('rightbblock');
	var cheight = cbox ? cbox.clientHeight : 75;
	var cheight1 = cbox1 ? cbox1.clientHeight : 75;
	if(thelayer)
	{
		maxlayeroffset = -(thelayer.clientHeight-cheight+5);
		if(maxlayeroffset > 0)
			maxlayeroffset = 0;
	}
	if(thelayer1)
	{
		maxlayeroffset1 = -(thelayer1.clientHeight-cheight1+5);
		if(maxlayeroffset1 > 0)
			maxlayeroffset1 = 0;
	}
}

function scrollayer(amt)
{
	initscroll();
	if(thelayer && thelayer1)
	{
		amount = amt * 10;
		amount1 = amt * 10;
		realscroll();
	}
}

function realscroll()
{
	mytop += amount;
	mytop1 += amount1;
	if(mytop>0)
		mytop = 0;
	if(mytop1>0)
		mytop1 = 0;
	if(mytop < maxlayeroffset)
		mytop = maxlayeroffset;
	if(mytop1 < maxlayeroffset1)
		mytop1 = maxlayeroffset1;
	thelayer.style.top = mytop + 'px';
	thelayer1.style.top = mytop1 + 'px';
	time = setTimeout('realscroll()',theTime);
}

function stopscroll()
{
	if (time) clearTimeout(time);
}

addLoadHandler(startList);
addLoadHandler(setScrollWidth);

function addLoadHandler(handler)
{
	if(window.addEventListener)
	{
		window.addEventListener("load",handler,false);
	}
	else if(window.attachEvent)
	{
		window.attachEvent("onload",handler);
	}
	else if(window.onload)
	{
		var oldHandler = window.onload;
		window.onload = function piggyback()
		{
			oldHandler();
			handler();
		};
	}
	else
	{
		window.onload = handler;
	}
}

// Replaces the currently selected text with the passed text.
function replaceText(text, textarea)
{
	// Attempt to create a text range (IE).
	if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
	{
		var caretPos = textarea.caretPos;

		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
		caretPos.select();
	}
	// Mozilla text range replace.
	else if (typeof(textarea.selectionStart) != "undefined")
	{
		var begin = textarea.value.substr(0, textarea.selectionStart);
		var end = textarea.value.substr(textarea.selectionEnd);
		var scrollPos = textarea.scrollTop;

		textarea.value = begin + text + end;

		if (textarea.setSelectionRange)
		{
			textarea.focus();
			textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
		}
		textarea.scrollTop = scrollPos;
	}
	// Just put it on the end.
	else
	{
		textarea.value += text;
		textarea.focus(textarea.value.length - 1);
	}
}
