function IsArray(obj) { return obj instanceof Array; }
function IncludeLibraries(libraries) {
	libraries.each(function(library) {
		document.write('<script type="text/javascript" src="' + library + '"></script>');
	});
}
function IncludeStyles(styles) {
	styles.each(function(style) {
		document.write('<link rel="stylesheet" type="text/css" media="all" href="' + style + '" />');
	});
}
function SetNotice(content, status) {
	// :KLUDGE: having to force background colors
	//          highlight effect isn't reading new color
	//          from dynamically set classname
	// status related colors
	var colors = new Array();
	colors['success'] = '#e2f9e3';
	colors['error']   = '#ffcfce';
	var bgcolor = (status) ? colors[status] : colors['success'];
	
	// update notice
	var e = $('notice');
	e.update(unescape(content));
	e.className = 'notice-' + ((status) ? status : 'info');
	e.show();
	new Effect.Highlight(e, {duration:1.5, keepBackgroundImage:true, startcolor:'#ffff88', endcolor:bgcolor, restorecolor:bgcolor});
}
function ClearNotice() {
	var e = $('notice');
	e.update('');
	e.hide();
}
function PopWindow(title, url, width, height, modal) {
	var id = 'popwindow';
	if (!$(id)) {
		BuildWindow({id:id, title:title, url:url, width:width, height:height, modal:modal});
	}
}
function SafeMail(name, domain, addinfo) {
	style     = (addinfo.style)   ? ' class="' + addinfo.style + '"' : '';
	subject   = (addinfo.subject) ? '?subject=' + addinfo.subject : '';
	displayed = (addinfo.display) ? addinfo.display : name + '@' + domain;
	mailto    = name + '@' + domain + subject;
	document.write('<a href="mailto:' + mailto + '"' + style + '>' + displayed + '</a>');
}
function ToggleElement(id) {
	if ($(id)) { $(id).toggle(); }
}
function Mailto(address) {
	var url    = '/ajax_mailto.php';
	var pars   = 'address=' + address;
	new Ajax.Request(url, {
		method:'post',
		parameters:pars,
		onComplete:function(req) {
			window.location = req.responseText;
		}
	});
}
function SubmitForm(obj, action) {
	obj.disable = true;
	obj.innerHTML = 'In progress...';
	obj.form.form_action.value = action;
	obj.form.submit();
}
