function openWindow(theURL, width, height)
{
	var left = parseInt((screen.width-width)/2);
	if (left < 0)
		left = 0;
	var top = parseInt((screen.height-height)/2);
	if (top < 0)
		top = 0;
	
	window.open(theURL, 'image', 'width='+width+', height='+height+', toolbar=no, scrollbars=no, resizable=no, status=no, left='+left+', top='+top);
	return false;
}

function onImageView(id)
{
	url="/image_view.php?id="+id;
	window.open(url,"","width=640; height=480; location=0; scrollbars=1; resizable=1;");
}

var cur_cat_id, cur_sub_cat_id;
function onCatalogMenu(id, first)
{
	//alert("11 == "+id);
	id_ = (id);
	if (!id_)
		id = 0;
	var c_obj = document.getElementById("cat_menu_a_"+cur_cat_id);
	if (c_obj)
		c_obj.style.fontWeight = 'normal';
	//alert("22 == "+id);
/*	
	if (cur_cat_id != id)
	{
		var obj = document.getElementById("cat_menu_"+cur_cat_id);
		if (obj)
			obj.style.display = 'none';
	}
*/
	var obj1 = document.getElementById("cat_menu_"+id);
	if (obj1)
	{
		obj1.style.display = obj1.style.display == 'block' ? 'none' :'block';
	}
	var obj = document.getElementById("cat_menu_a_"+id);
	if (obj)
	{
		if (obj1.style.display == 'none')
			obj.style.fontWeight = 'normal';
		else 
			obj.style.fontWeight = 'bold';
	}
	cur_cat_id = id;
	return false;
}

function updatePosition(e) 
{
	cursor = window.event;if (!cursor) cursor = e;
	_mx = cursor.clientX;
	_my = cursor.clientY;
}

document.onmousemove = updatePosition;

function defPosition() 
{ 
      var x = y = 0; 
      if (document.attachEvent != null) { // Internet Explorer & Opera 
            x = _mx + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); 
            y = _my + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
      } else if (!document.attachEvent && document.addEventListener) { // Gecko 
            x = _mx + window.scrollX; 
            y = _my + window.scrollY; 
      } else { 
            // Do nothing 
      } 
      return {x:x, y:y}; 
}

var LastVisual;

function visual(URL)
{
	document.getElementById("catvisual").style.left=defPosition().x+16+"px";
	document.getElementById("catvisual").style.top=defPosition().y-document.getElementById("catvisual").offsetHeight+16+"px";
	document.getElementById("catvisual").style.display="block";

	if(LastVisual!=("/cat_images/"+URL))
	{
		document.getElementById("catvisual").src="/cat_images/"+URL;
		LastVisual="/cat_images/"+URL;
	}
}



function stopvisual()
{document.getElementById("catvisual").style.display="none";}



function onCheckAll(obj)
{
        var checked = obj.checked;
        var boxes = document.getElementsByName("checked[]");
        for (var i = 0; i < boxes.length; i++)
        {
            var box = boxes(i);
            box.checked = checked;
        }
}

