jQuery.noConflict();

SEARCHCHEKER = {
	DEFAULTPHRASE: 'Enter tag for search...',
	/**
	 * Add mask to user interface
	 */
	blockUI: function(container)
	{
		var contain = jQuery(typeof(container) == 'undefined' ? 'body' : container );
		//var blockdiv = '<div class="x-mask" style="display: block" />';
	//	var mask = contain.prepend(blockdiv).children('.x-mask');
	
		//contain.addClass('x-masked');
	},
	
	/**
	 * Remove mask
	 */
	unblockUI: function()
	{
		//jQuery('.x-masked').removeClass('x-masked').children('.x-mask').hide().remove();
	},
	
	enter_search_popup: function()
	{
		SEARCHCHEKER.blockUI();
	
		var message = 'Please enter your search text, and try again.';
		var msg = jQuery('<div />').addClass('popupwindow').css({position:'absolute', left: parseInt(jQuery('body').width() / 2 - 160), display: 'none'}).html( '<p style="margin: 0 auto; text-align: center">'+message+'</p>'+'<div class="popupbtns"></div>');
	
		jQuery('.popupbtns', msg).append(
			jQuery('<input type="button" class="popupbutton ok" />').click(
				function(){
					msg.fadeIn('slow', function(){
							msg.remove();
							SEARCHCHEKER.unblockUI();
					});
				}
			)
		);
	
		jQuery('body').append(msg);
		msg.fadeIn('slow');
	},
	
	check_search_popup: function ()
	{
		var val = jQuery("#query").val();
		
		if (val.replace(/[ ]*/, '') == '' || val == SEARCHCHEKER.DEFAULTPHRASE)
		{
			SEARCHCHEKER.enter_search_popup();
			return false;
		}
	},
	
	init: function()
	{
		jQuery(function() {
			jQuery('#cse-search-box').submit(SEARCHCHEKER.check_search_popup);
		
			jQuery(window).resize(function(){
			 	jQuery('.popupwindow').css({left: parseInt(jQuery('body').width() / 2 - 160)});
			});
		});
	}
};

SEARCHCHEKER.init();
