function ajs ( url, p, obj, f )
{
	var x;
	try
	{
		x = new XMLHttpRequest();
	}
	catch(e)
	{
		var xv = new Array("MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.5.0");
		for( var i = 0; i < xv.length && !x; i++ )
		{
			try
			{
				x = new ActiveXObject(xv[i]);
			}
			catch(e)
			{
				//alert("ActiveX error!")
			}
		}
	}
	if ( !x )
	{
		return false;
	}
	else
	{
		try
		{
			if ( p.length > 0 ) p = "?" + p;
			x.open("GET", url + p, true);
			x.onreadystatechange = function()
			{
				if ( x.readyState == 4 )
				{
					if ( x.status == 200 || x.status == 0 )
					{
						if ( obj ) obj.innerHTML = x.responseText;
						if ( f ) f(x);
					}
					/*else
					{
						alert('XMLHttpRequest: '+x.status);
					}*/
				}
			}
			x.send(null);
		}
		catch(e)
		{
			return false;
		}
	}
	return true;
}
function h2s(a)
{
	if(typeof(a)!="object" || a==null)
	{
		if(typeof(a)=="string")
			a='"'+encodeURI(a)+'"';
		return a;
	}
	var res='{',z='"';
	for(var k in a)
	{
		res+=z+k+'":'+h2s(a[k]);z=',"';
	}
	return res+"}";
}
function s2h(a)
{
	return eval('('+a+')');
}

function menuOut(m, s)
{
	var d = - parseInt(m.style.marginTop);
	if (d > 0)
	{
		m.style.marginTop = - d + Math.min(s, d) + 'px';
		m.parentNode.timer = setTimeout(function(){menuOut(m, s)}, 1);
	}
	else
		clearTimeout(m.parentNode.timer);
}

function menuIn(m, s)
{
	var d = - parseInt(m.style.marginTop);
	if (d < m.offsetHeight)
	{
		m.style.marginTop = - d - Math.min(s, m.offsetHeight - d) + 'px';
		m.parentNode.timer = setTimeout(function(){menuIn(m, s)}, 1);
	}
	else
		clearTimeout(m.parentNode.timer);
}

function menuSH(o)
{
	var m = o.nextSibling.childNodes[0];
	if (o.nextSibling.timer)
		clearTimeout(m.parentNode.timer);
	if (m.className == 'open') // если открыто
	{
		m.style.display = 'block';
		m.style.marginTop = '0px';
		m.className = '';
		menuIn(m, 30);
	}
	else
	{
		m.className = 'open';
		m.style.marginTop = - m.offsetHeight + 'px';
		menuOut(m, 30);
	}
	
}

function optionChange(url, param, value)
{
	if (value == 'none')
	{
		if (window.location != url) window.location = url;
	}
	else
	{
		window.location = url+param+value;
	}
}
