
var isNS4 = (navigator.appName=="Netscape")?1:0;

function getObjectByID( id, o )
{
	var c, el, els, f, m, n;
	if ( !o )
	{
		o = document;
	}; //if
	if ( o.getElementById )
	{
		el = o.getElementById( id );
	} else 
	if ( o.layers )
	{
		c = o.layers;
	} else
	if ( o.all )
	{
		el = o.all[id];
	}; //if
	if ( el )
	{
		return el;
	}; //if
	if ( o.id == id || o.name == id )
	{
		return o;
	}; //if
	if ( o.childNodes )
	{
		c = o.childNodes;
	}; //if
	if ( c )
	{
		for ( n = 0; n < c.length; n++ )
		{
			el = getObjectByID( id, c[n] );
			if ( el )
			{
				return el;
			}; //if
		}; //for
	}; //if
	f = o.forms;
	if ( f )
	{
		for ( n = 0; n < f.length; n++ )
		{
			els = f[n].elements;
			for ( m = 0; m < els.length; m++ )
			{
				el = getObjectByID( id, els[n] );
				if ( el )
				{
					return el;
				}; //if
			}; //for
		}; //for
	}; //if
	return null;
}; //func

function setInnerHtml( id, text )
{
	obj = getObjectByID( id );
	if ( obj != null )
	{
		obj.innerHTML = text;
	}; //if
}; //func

function copyInnerHtml( sid, did )
{
	sobj = getObjectByID( sid );
	if ( sobj != null )
	{
		setInnerHtml( did, sobj.innerHTML );
	}; //if
}; //func

function setClassName( id, className )
{
	obj = getObjectByID( id );
	if ( obj != null )
	{
		if ( obj.className )
		{
			obj.className = className;
		}; //if
	}; //if
}; //func

function getClassName( id )
{
	obj = getObjectByID( id );
	if ( obj != null )
	{
		if ( obj.className )
		{
			return obj.className;
		}; //if
	}; //if
}; //func

function set1of2ClassName( id, class1, class2 )
{
	if ( getClassName( id ) != class1 )
	{
		setClassName( id, class1 );
	} else
	{
		setClassName( id, class2 );
	}; //func
}; //func

function showObject( id, className )
{
	if ( !className )
	{
		className = "visible";
	}; //if
	obj = getObjectByID( id );
	if ( ( obj ) && ( obj.className ) )
	{
		obj.className = className;
	}; //if
}; //func

function hideObject( id, className )
{
	if ( !className )
	{
		className = "hidden";
	}; //if
	obj = getObjectByID( id );
	if ( ( obj ) && ( obj.className ) )
	{
		obj.className = className;
	}; //if
}; //func

function sAll()
{
	svform_ = document.forms.svform;
	for ( j = 0; j < svform_.elements.length; j++ )
	{
		var formObj = svform_.elements[j];
		if ( formObj.type.toLowerCase() == "checkbox" )
		{
			if ( formObj.checked )
			{
				formObj.checked = false;
				if ( formObj.style )
				{
					formObj.style.backgroundColor = 'white';
				}; //if
			} else
			{
				formObj.checked = true;
				if ( formObj.style )
				{
					formObj.style.backgroundColor = 'red';
				}; //if
			}; //if
		}; //if
	}; //for
}; //func

function sSMT()
{
	var result = false;
	svform_ = document.forms.svform;
	for ( j = 0; j < svform_.elements.length; j++ )
	{
		var formObj = svform_.elements[j];
		if ( formObj.checked )
		{
			result++;
		}; //if
	}; //for
	return result;
}; //func

function sh( objid, linkid )
{
	obj = getObjectByID( objid );
	if ( obj && ( obj != "null" ) )
	{
		if ( obj.className == "visible" )
		{
			obj.className = "hidden";
			inline = "sh( '" + objid + "', '" + linkid + "' )";
			setInnerHtml( linkid, '<a href="javascript:' + inline + ';" title="показать">показать</a>' );
		} else
		{
			obj.className = "visible";
			inline = "sh( '" + objid + "', '" + linkid + "' )";
			setInnerHtml( linkid, '<a href="javascript:' + inline + ';" title="спрятать">спрятать</a>' );
		}; //if
	}; //if
}; //func

function sOK()
{
	svform_ = document.forms.svform;
	svcount = sSMT();
	if ( svform_.action.options[svform_.action.selectedIndex].value == "save" )
	{
		svform_.submit();
		return true;
	}; //if
	if ( !svcount )
	{
		alert( 'Не выбран ни один объект!' );
	} else
	{
		if ( confirm( "Вы действительно хотите применить `" + svform_.action.options[svform_.action.selectedIndex].text + "` к выбранным объектам ?" ) )
		{
			svform_.submit();
		}; //if
	}; //if
}; //func


function setCookie( name, value )
{ 
	var expire = "Fri, 01 Jan 2010 00:00:00 GMT";
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + expire;
}; //func

function getCookie( Name )
{   
	var search = Name + "=";
	if ( document.cookie.length > 0 )
	{
		offset = document.cookie.indexOf( search );
		if ( offset != -1 )
		{
			offset += search.length;
			end = document.cookie.indexOf( ";", offset );
			if ( end == -1 ) end = document.cookie.length;
			return unescape( document.cookie.substring( offset, end ) );
		}; //if
	}; //if
}; //func

function centralizeObject( id, width, height )
{
	obj = getObjectByID( id );
	if ( ( obj ) && ( obj.style ) )
	{
		screenWidth = document.body.clientWidth;
		screenHeight = document.body.clientHeight;
		obj.style.width = width;
		obj.style.height = height;
		obj.style.left = ( screenWidth - width ) / 2;
		obj.style.top = ( ( screenHeight - height ) / 2 ) + document.body.scrollTop;
	}; //if
}; //func

function _ajax( id, www )
{
	setInnerHtml( id, "<img src='" + www + "images/ajax.gif' alt='_R<гз_-Ё_/RвЇа ўЄ  ¤ --ле...' border='0'>" );
}; //func

function retFalse() {}; //func

function hFlash()
{
	hideObject( 'flash' );
}; //func

function sFlash()
{
	showObject( 'flash' );
}; //func

function hForm( fid, lang )
{
	hideObject( fid + "_" + lang  );
	sFlash();
}; //func				

function sForm( fid, lang, nohide )
{
	if (
		( !nohide ) ||
		( nohide == "undefined" )
	)
	{
		hFlash();
	}; //if

	showObject( fid + "_" + lang  );
}; //func				

function addEvent( obj, evType, fn )
{ 
	if ( obj.addEventListener )
	{
		obj.addEventListener(evType, fn, false);
		return true; 
	} else
	if ( obj.attachEvent )
	{
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else
	{ 
		return false; 
	}; //if
}; //func
