var jump_page = '{LA_JUMP_PAGE}:';
var on_page = '{ON_PAGE}';
var per_page = '{PER_PAGE}';
var base_url = '{A_BASE_URL}';
var style_cookie = 'phpBBstyle';
var style_cookie_settings = '{A_COOKIE_SETTINGS}';
var onload_functions = new Array();
var onunload_functions = new Array();

/**
* Find a member
*/
function find_username(url)
{
	popup(url, 760, 570, '_usersearch');
	return false;
}

function trim(s){
	return s.replace(/^\s+|\s+$/g,"");
}
function ltrim(s){
	return s.replace(/^\s+/,"");
}
function rtrim(s){
	return s.replace(/\s+$/,"");
}

function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;

	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
		return true;

	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
		return true;

	// decimal point jump
	else if (dec && (keychar == "."))
	{
		myfield.form.elements[dec].focus();
		return false;
	}
	else
		return false;
}

function ValidateMsgForm( frm ) {
	if (frm.FullName.value == ''){
		alert( "Please enter your name." );
		frm.FullName.focus();
		return false;
	}
	regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	if (!regex.test(frm.Email.value)) {
		alert( "Please enter a valid e-mail address." );
		frm.Email.focus();
		return false;
	}
	if (frm.MsgBody.value == '') {
		alert( "Please make sure the form is complete." );
		frm.MsgBody.focus();
		return false;
	}
	return true;
}

function ValidateUnsubForm(frm){
	regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	if (frm.Email.value == '' || !regex.test(frm.Email.value)) {
		alert( "Please enter a valid e-mail address." );
		frm.Email.focus();
		return false;
	}
	return true;
}

function ValidateCreateLicForm( frm ) {
	if (frm.FullName.value == ''){
		alert( "Please enter the name of the license holder" );
		frm.FullName.focus();
		return false;
	}
	if (!frm.Verified.checked) {
		alert( "If you have verified all information are correct, please put a check mark here." );
		frm.Verified.focus();
		return false;
	}
	return true;
}

// isIntegerInRange (STRING s, INTEGER a, INTEGER b)
function isIntegerInRange(s, a, b)
{
	// Now, explicitly change the type to integer via parseInt
	// so that the comparison code below will work both on
	// JavaScript 1.2 (which typechecks in equality comparisons)
	// and JavaScript 1.1 and before (which doesn't).
	var num = parseInt(s);
	return ((num >= a) && (num <= b));
}

function ValidatePurchaseForm( frm ) {
	if (!isIntegerInRange(frm.LicMonthlyCount.value, 1, 999) &&
		!isIntegerInRange(frm.LicLifetimeCount.value, 1, 999)){
		alert('Please enter the number of client seats (1-999) for either Monthly Subscription or Lifetime License');
		frm.LicMonthlyCount.focus();
		return false;
	}
	return true;
}

window.onload = function()
{
	for (var i = 0; i < onload_functions.length; i++)
	{
		eval(onload_functions[i]);
	}
}

window.onunload = function()
{
	for (var i = 0; i < onunload_functions.length; i++)
	{
		eval(onunload_functions[i]);
	}
}