/**
 *
 * File:		worksafebc.js
 *
 * Abstract:	Site-specific Javascript stuff.
 *
 *
**/


$(document).ready(function () {
	// init rollovers
	$('.rollover').Rollover();
	
	// init search
	$('#formSearch').bind('submit', function(ev) {
		var searchBy = $('#searchBy').val();
		this.action  = searchBy + '.html'; 
		return true;
	});
})


/******************************************************************************/


/**
 * Creates, shows, and then destroys a simple dialog box.
 * Helper for jQuery UI Dialog.
 *
 * Params:		{String} message		- The message you wish to display in the Dialog box.
 *				{Object} options		- Optional settings (will override defaults).
 */
function notify(msg, options) {
	var html;
	var message = (msg && typeof msg == 'string') ? msg : 'No message.';
	var settings = $.extend({
		title: 'Notice',
		modal: true,
		draggable: false,
		bgiframe: true,
		width: 375,
		buttons: {
			'OK': function () {
				$(this).dialog('close');
			}
		},
		close: function () {
			$(this).remove(); // once closed, get rid of the html
		}
	}, options);
	
	// create and show the new dialog
	html = '<div>' + msg + '</div>';
	$(html).appendTo("body").dialog(settings).show();
}


/**
 * Navigates to the specified URL.
 *
 * Params:		{String} url		- The URL to which we should go.
 */
function goTo(url) {
	window.location.href = url;
}


/**
 *
 */
function baseHref(loc) {
	// loc is the relative path your wish to redirect to
	var b = document.getElementsByTagName('base');
	if (b && b[0] && b[0].href) {
		loc = b[0].href + loc;
	}
	return loc;
}
