browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

NS4 = (browserName=="Netscape" && browserVer==4) ? true : false;
NS5 = (browserName=="Netscape" && browserVer==5) ? true : false;
IE4 = (browserName=="Microsoft Internet Explorer" && browserVer==4) ? true : false;

UNK = (NS4 || NS5 || IE4) ? false : true;

// по умолчанию IE4
if (UNK) {UNK=false;IE4=true;}

if (NS4 || NS5) window.captureEvents(Event.RESIZE);

function ResizeToBigWindow()
{
	self.moveTo(0,0);
	self.resizeTo(window.screen.width,window.screen.height); 
}

function LoginWindowOpen(hr)
{
	var WindowWidth=500;
	var WindowHeight=280;
	MyWindowName="_blank";
	
	var ScreenWidth=window.screen.width;
	var ScreenHeight=window.screen.height;
	var NewWindowWidth=WindowWidth;
	var NewWindowHeight=WindowHeight;
	var StartAtLeft=(ScreenWidth-NewWindowWidth)/2;
	var StartAtTop=(ScreenHeight-NewWindowHeight)/2

	window.open(hr,MyWindowName,"left=" + StartAtLeft + ", top=" + StartAtTop + ", width=" + NewWindowWidth + ", height=" + NewWindowHeight + ", scrollbars=yes, resizable=yes, toolbar=no, location=no, directories=no, menubar=no");
}
function CustomWindowOpen(hr,WindowHeight,WindowWidth,WithToolBars)
{
	var hr_len = hr.length;
	var MyWindowName;

	MyWindowName="_blank";
	
	var ScreenWidth=window.screen.width;
	var ScreenHeight=window.screen.height;
	var NewWindowWidth=WindowWidth;
	var NewWindowHeight=WindowHeight;
	var StartAtLeft=(ScreenWidth-NewWindowWidth)/2;
	var StartAtTop=(ScreenHeight-NewWindowHeight)/2

	if (WithToolBars)
		{window.open(hr,MyWindowName,"left=" + StartAtLeft + ", top=" + StartAtTop + ", width=" + NewWindowWidth + ", height=" + NewWindowHeight + ", scrollbars=yes, resizable=yes, toolbar=yes, location=yes, directories=yes, menubar=yes")}
	else	
		{window.open(hr,MyWindowName,"left=" + StartAtLeft + ", top=" + StartAtTop + ", width=" + NewWindowWidth + ", height=" + NewWindowHeight + ", scrollbars=yes, resizable=yes, toolbar=no, location=no, directories=no, menubar=no")}		
}
function BigWindowOpenWithToolBars(hr)
{
	var ScreenWidth=window.screen.width;
	var ScreenHeight=window.screen.height;

	CustomWindowOpen(hr,ScreenHeight*0.85,ScreenWidth*0.95,true);
}
function BigWindowOpen(hr)
{
	var ScreenWidth=window.screen.width;
	var ScreenHeight=window.screen.height;

	CustomWindowOpen(hr,ScreenHeight*0.99,ScreenWidth*0.95,false);
}
function MiddleWindowOpen(hr)
{
	var ScreenWidth=window.screen.width;
	var ScreenHeight=window.screen.height;

	CustomWindowOpen(hr,ScreenHeight*0.6,ScreenWidth*0.6,false);
}
function trim(InputStr)
{
	var tmpStr = "" + InputStr;
	var FirstNoBlankAtBeginning,LastNoBlankAtEnd,i,j;
	for (i=0; i<tmpStr.length; i++)
	{
		var NowChar = tmpStr.charAt(i)
		if (NowChar != " ") break;
	}
	FirstNoBlankAtBeginning = i;
	for (j=tmpStr.length-1; j>=0; j--)
	{
		var NowChar = tmpStr.charAt(j)
		if (NowChar != " ") break;
	}
	LastNoBlankAtEnd = j;
	if (FirstNoBlankAtBeginning<=LastNoBlankAtEnd)
		tmpStr = tmpStr.substring(FirstNoBlankAtBeginning,LastNoBlankAtEnd+1);
	else	
		tmpStr = "";
		
	return	tmpStr;
}
function replace(InputStr,SearchStr,ReplaceStr)
{
	InputStr = "" + InputStr;var SCHlen=SearchStr.length;var RPLlen=ReplaceStr.length;var sTmp=InputStr;sOut="";
	while (sTmp.length>0) 
	{
		var iP=sTmp.indexOf(SearchStr);
		if (iP==-1) {sOut = sOut + sTmp; sTmp="";};
		if (iP==0) {sOut=sOut + ReplaceStr;sTmp=sTmp.substring(iP+SCHlen,sTmp.length);};
		if (iP>0) 
		{
			sOut=sOut + sTmp.substring(0,iP) + ReplaceStr;
			sTmp=sTmp.substring(iP+SCHlen,sTmp.length);
		};
	}
	return sOut;
}
function ProcToNum(NumWithProc)
{
	var N;N=trim(NumWithProc);
	N=replace(N,",",".");
	var iP=N.indexOf("%");var IsNumeric;
	
	if (iP>-1) 
	{N=N.substring(0,iP);IsNumeric = !isNaN(N);if (IsNumeric) {N=N/100};}
	else
	{IsNumeric = !isNaN(N)}
	
	var res;
		if (IsNumeric) {res=parseFloat(N)} else {res="___err___"};
	return res;
}
function ShowSubItems(ItemName)
{
	if (IE4)
	{
	 	if (document.all[ItemName].style.visibility=='hidden') 
	 		document.all[ItemName].style.visibility='visible';
 		else 
 			document.all[ItemName].style.visibility='hidden';
	}
	else if (NS5) 
	{
	 	if (document.getElementById(ItemName).style.visibility=='hidden') 
	 		document.getElementById(ItemName).style.visibility='visible';
 		else 
 			document.getElementById(ItemName).style.visibility='hidden';		
	}	
	else if (NS4) 
	{
		if (document.layers["content"].layers[ItemName].visibility=="hide")
	 		document.layers["content"].layers[ItemName].visibility='show';
	 	else	
	 		document.layers["content"].layers[ItemName].visibility='hide';
 	}	
}

function ShowSubItems2(ItemName)
{
	if (IE4)
	{
	 	if (document.all[ItemName].style.display=='none') 
	 		document.all[ItemName].style.display='';
 		else 
 			document.all[ItemName].style.display='none';
	}
	else if (NS5) 
	{
	 	if (document.getElementById(ItemName).style.display=='none') 
	 		document.getElementById(ItemName).style.display='';
 		else 
 			document.getElementById(ItemName).style.display='none';
	}	
	else if (NS4) 
	{
		if (document.layers["content"].layers[ItemName].visibility=="hide")
	 		document.layers["content"].layers[ItemName].visibility='show';
	 	else	
	 		document.layers["content"].layers[ItemName].visibility='hide';
 	}	
}