function SelectForm(name,bool)
{
	var object = document.getElementById(name);

	for (var i=0;i<object.options.length;i++) object.options[i].selected = bool;

	return true;
}

function CalculateCoordinate(object)
{
	var dimensions = new Array(0,0);

	object.offsetParent && (dimensions = CalculateCoordinate(object.offsetParent));

	dimensions[0] += object.offsetLeft;
	dimensions[1] += object.offsetTop;

	alert(object.tagName + " " + dimensions.join(", "));

	return dimensions;
}

function openWindow(link,name,features,position,width,height,views,extra)
{
	width		|| (width = screen.width);
	height	|| (height = screen.height);

	var top = (position == "center" ? (screen.height - height)/2 : (position.match(/^top/) ? 0 : screen.height - height));
	var left = (position == "center" ? (screen.width - width)/2 : (position.match(/left$/) ? 0 : screen.width - width));

	features += (features ? "," : "") + "top=" + top + ",left=" + left + ",width=" + width + ",height=" + height;

	var myWindow = window.open(link,name,features); eval('myWindow && myWindow.' + (extra & 1 ? 'blur' : 'focus') + '();');

	link && SetCookie("cms[" + name + "][views]",++views,(extra & 2 ? -1 : 365*24*3600));

	return myWindow;
}

function PopUp(title,image,width,height)
{
	myWindow = openWindow('',title.replace(/\s+/,''),'','topleft',width,height);

	myWindow.document.write("<HTML>\n<HEAD>\n<TITLE>" + title + "</TITLE>\n</HEAD>\n<BODY>\n<CENTER>\n<A HREF=\"javascript: window.close();\">\n<IMG SRC='" + image + "' BORDER=0>\n</A></CENTER>\n</BODY>\n</HTML>\n");
}

function SetCookie(name,value,expires)
{
	expires += (expires > 0 ? (new Date()).getTime()/1000 : 0);

	document.cookie = name + "=" + value + (expires > 0 ? ";expires=" + expires : "");
}

function ShowProps(object)
{
	var property, content = "";

	for (property in object)
	{
		content += "name: " + property + "; value: " + object[property] + "\n";
	}

	alert (content);
}
