// ..................................................................
function findObj(n, d)
{
	var p, i, x;

	if(!d) d = document;
	if((p = n.indexOf("?")) > 0 && parent.frames.length)
	{
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}

	for(i = 0; !x && i < d.forms.length; i++)
	{
		x = d.forms[i][n];
	}
	if(!x)
	{
		if(!(x = d[n]) && d.all)
		{
			x = d.all[n];
		}
		for(i = 0; !x && d.layers && i < d.layers.length; i++)
		{
			x = findObj(n, d.layers[i].document);
		}
		if(!x && document.getElementById)
		{
			x = document.getElementById(n);
		}
	}


return x;
}

// ..................................................................

function EnableObject(obj_name, bEnable)
{
	obj = findObj(obj_name);
	if (obj)
	{
		obj.disabled = (bEnable) ? false : true;
	}
}

// ..................................................................

function DisplayObject(obj_name, bDisplay)
{
	obj = findObj(obj_name);
	if (obj)
	{
		obj.style.display = (bDisplay) ? "block" : "none";
	}
}

// ..................................................................

function openWindow(href, title, scroll, resizable, width, height, position)
{
	if(scroll != "yes")
	{
		scroll = "no";
	}

	if(resizable != "yes")
	{
		resizable = "no";
	}

	if(position != 'center')
	{
		xx = window.open(href, title, 'toolbar=no, scrollbars=' + scroll + ', menubar=no, directories=no, status=no, resizable=' + resizable + ', width=' + width + ', height=' + height);
	}
	else
	{
		this_top = (screen.height - height) / 2;
		this_left = (screen.width - width) / 2;
		xx = window.open(href, title, 'toolbar=no, scrollbars=' + scroll + ', menubar=no, directories=no, status=no, resizable=' + resizable + ', width=' + width + ', height=' + height + ', top=' + this_top + ', left=' + this_left);
	}
	xx.focus();
	return false;
}

// ..................................................................

function imagePopup(imageUrl, imageW, imageH, title)
{
	x3 = imageW;
	y3 = imageH;
	x4 = (screen.width < 2000) ? (screen.width / 2 - (x3 / 2)) : (screen.width / 4 - (x3 / 2));
	y4 = screen.height / 2 - (y3 / 2);
	mywin = window.open('', 'big', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=' + x3 + ',height=' + y3 + ',top=' + y4 + ',left=' + x4 + '');
	mywin.document.open();
	mywin.document.write("<html><head><title>"+title+"</title><style>body { overflow:-moz-scrollbars-none; }</style></head><body bgcolor=#ffffff leftmargin=0 topmargin=0 marginheight=0 marginwidth=0><a href='javascript:window.close()'><img src='" + imageUrl + "' border=0></a></body></html>");
	mywin.document.close();
	mywin.focus();
	return false;
}

// ..................................................................

function CopyClipboard(obj)
{
	obj = findObj(obj);
	if(obj)
	{
		window.clipboardData.setData('Text', obj.value);
	}
}
