/** ***************************************************************************
* Escape frames
*/
if(window!=top)top.location.href=location.href;

/** ***************************************************************************
* JavaScript-based form prompts
*/
function promptInit(selector, label)
{
	$(selector)
		.addPromptElement(label)
		.css('display', 'none')
		.blur(function() {
			if ($(this).val() == '') {
				$(this).css('display', 'none');
				$(selector + 'Prompt')
					.css('display', 'inline');
			}
		});
	$(selector + 'Prompt')
		.css('display', 'normal')
		.focus(function() {
			$(this).css('display', 'none');
			$(selector)
				.css('display', 'inline')
				.focus();
		});
}

jQuery.fn.addPromptElement = function(promptValue) {
	return this.each(function(){
		oldElement = $(this);
		newElement = oldElement
			.after('<input type="text" />')
			.next()
			.attr('class', oldElement.attr('class'))
			.attr('id', oldElement.attr('id') + 'Prompt')
			.attr('size', oldElement.attr('size'))
			.attr('maxlength', oldElement.attr('maxlength'))
			.css('color', '#888')
			.val(promptValue);
	});
};

/** ***************************************************************************
* onclick confirmation dialogs
*/
function confirmAction(url, msg, dialogTitle) {
	if (typeof dialogTitle == 'undefined') dialogTitle = 'Confirm Action';
	jConfirm(msg, dialogTitle, function(returnValue) {
		if (returnValue) window.location.href = url;
	});
	return false;
}

/** ***************************************************************************
* jQuery tab panel hovering
*/
function tabHover(obj, isHovering)
{
	if (isHovering == true) {
		obj.className = obj.className.replace(/default/, 'hover');
	} else {
		obj.className = obj.className.replace(/hover/, 'default');
	}
}
