
function hmenuhover() {
	if(!document.getElementById("nav"))
	return;
	var lis = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0;i<lis.length;i++)
	{
		lis[i].onmouseover=function(){this.className+=" over";}
		lis[i].onmouseout=function() {this.className=this.className.replace(new RegExp(" over\\b"), "");}
	}

}
if (window.attachEvent)	window.attachEvent("onload", hmenuhover);

function switchVisible(id) {
	var block = document.getElementById(id);
	if(block.style.display == "block") block.style.display = "none";
	else block.style.display = "block";
	return false;
}

function changeImage(bigUrl, bigWidth, bigHeight, midUrl, midWidth, midHeight) {
	img = document.getElementById('imageImg');
	anchor = document.getElementById('imageAnchor');

	img.src = midUrl;
	img.width = midWidth;
	img.height = midHeight;

	anchor.href = bigUrl;
	anchor.onclick = function(){showImage(this.href, bigWidth, bigHeight); return false;}
}

function switchClass(id, first, second, ref) {
	var block = document.getElementById(id);
	var children = block.getElementsByTagName('ul');
	// у последнего из имеющихся месяцев по умолчанию прописаны документы
	if(children.length == 0) {
		var listElem=document.createElement('ul');
		tempItem = addListItem(listElem,'Подождите...');
		block.appendChild(listElem);

		var req = new Subsys_JsHttpRequest_Js();
		req.onreadystatechange = function() {
			if (req.readyState == 4 && req.responseJS != null) {
				listElem.removeChild(tempItem);
				if(req.responseJS.subs != false) {
					for(var sub in req.responseJS.subs) {
						addListItem(listElem, req.responseJS.subs[sub]);
					}
				}
			}
		}
		req.open(null, '?jsmodule=Blog', true);
		req.send( { id:id, ref: ref } );

	}
	if(block.className == first) block.className = second;
	else block.className = first;
	
	return false;
}

function addListItem(parent, text) {
	var newElem=document.createElement('li');
	newElem.innerHTML = text;
	parent.appendChild(newElem);
	return newElem;
}
