/*
	Common JavaScript functions and global variables for Blast site.
	Mike Taylor <Michael.Taylor1@bbc.co.uk> 2009-01-12
	Requires:
		Glow

	Adds:

		gs_blast_lib_
		window.blastLib (containing library functions)

	to the global namespace.
	
*/

// GLOBAL VARIABLES:

var gb_lib = (function(){

	// LOCAL FUNCTIONS:
	
	// EXPORTED FUNCTIONS:
	var o_lib = {
	
		dbg_msg: function(s_text) {

			var b_force_alert = 0
				;
	
			// log errors to console object if it exists
			if (window.console && (typeof window.console.log == 'function') && !b_force_alert) {
				console.log(s_text);
			}
			else {
				alert(s_text);
			}
		},
		//-----

		dummy_field: null // so all other can end with ","
	};
	
	return o_lib; // return library as object

})();

gloader.load(
	["glow", "1", "glow.widgets.AutoSuggest"],
	{
		async: true,
		onLoad: function(glow) {
			glow.ready(function() {
				new glow.widgets.AutoSuggest("#search-text","/blast/js/autocomplete.js",{
					activeOnShow: false,
					anim: "fade",
					complete: true,
					delim: " ",
					maxListLength: 15
				});
			});
		}
	}
);

var blastPopupWin;
var blastPopup = function(url,width,height) {
	blastPopupWin = window.open(url, 'blastpopup', 'width='+width+',height='+height+',location=0');
	blastPopupWin.focus();
	return false;
}