/**
 * FLC Default functions.
 * 
 * To be included with all the windows
 * 
 * Created: 2008-09-04 by Oleg Baranovsky
 * Last Modified: 2009-01-27 by -ob.
 * 
*/

var new_window;
//var is_focused = false;
//window.onfocus = new function(){"is_focused = true;"};
//window.onblur  = new function(){"is_focused = false;"};
/**
 * open_window -- function to open window and bring it in focus
 *
 */
function open_window(url, width, height, window_name)
{
	//var new_window;
	var window_options = 'toolbar=no, location=no, menubar=1, directories=no, status=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+width+', height='+height;
//	var extras = '';

	// mozilla allows window.focus() to be disabled in settings
	// so, if window does not get the focus, close it and open again

	//	if(navigator.appName=="Netscape") { 
//		new_window = window.open(url, window_name, window_options);
//		new_window.focus();
//		if(new_window.is_focused == false) {
//			//extras = ', screenX=' + new_window.screenX + ', screenY=' + new_window.screenY;
//			new_window.close();
//		}
//	}

	//new_window = window.open('', window_name, window_options);
	if (typeof new_window == 'object' && typeof new_window.close == 'function') {
		new_window.close();
	}
	
	new_window = window.open(url, window_name, window_options);
	//new_window.resizeTo(width, height);
	if (typeof new_window == 'object' && typeof new_window.focus == 'function') {
		new_window.focus();
	}
	
	return new_window;
}

// Click throttling functions
// Set up click throttling to prevent server overload from click pinging
var THROTTLE_PERIOD = 1000;		// Click throttling  delay in miliseconds
var throttle_flag = false;		// throttling flag

function click_throttle_reset()
{
	throttle_flag = false;
}

function click_throttle()
{
	if ( !throttle_flag ) {
		throttle_flag = true;
		setTimeout(click_throttle_reset, THROTTLE_PERIOD);
		return true;
	}
	return false;
}

