function Core()
{
} // Core
Core.path = '';
Core._userAjaxCommandCb = null;
Core._userAjaxRequest   = null;
Core._windowCloseTimer = null;
Core.ajaxSendXml = function(data,
cb,
cbData)
{
var ajax = new Ajax();
Core._userAjaxRequest = data;
ajax.sendXml('/ajax.php',
data,
cb,
cbData);
} // ajaxSendXml
Core.ajaxSendCommand = function(cmd,
params,
cb,
cbData)
{
var ajax = new Ajax();
var data = {
'cmd'       : cmd,
'userData'  : cbData
}
params['cmd'] = cmd;
Core._userAjaxCommandCb = cb;
Core.ajaxSendXml(params,
Core._ajaxCommandCallback,
data);
} // ajaxSendCommand
Core.changeAdminUserStatus = function(select)
{
switch (select.value)
{
case 'approved':  var msg = 'Notify user that their request has been approved?'; break;
case 'denied':    var msg = 'Notify user that their request has been denied?';   break;
default:          return;
} // switch
var ans = confirm(msg);
if (ans)
{
document.getElementById('notify').value = '1';
} // if
else
{
document.getElementById('notify').value = '0';
} // else
} // changeAdminUserStatus
Core.displayError = function(msg)
{
var div = document.getElementById('errorBlock');
Utils.removeChildren(div);
div.appendChild(document.createTextNode(msg));
div.style.display = 'block';
} // displayError
Core.displayMessage = function(msg)
{
var div = document.getElementById('messageBlock');
Utils.removeChildren(div);
div.appendChild(document.createTextNode(msg));
div.style.display = 'block';
} // displayMessage
Core.enableAccessControls = function(rb,
formName)
{
if ((formName == undefined) ||
(!formName))
{
formName = 'adminForm';
} // if
var form = document[formName];
if (form.allowAll[0].checked)
{
form['groups[]'].disabled = 'disabled';
form.ips.disabled = 'disabled';
form['users[]'].disabled = 'disabled';
} // if
else
{
form['groups[]'].disabled = '';
form.ips.disabled = '';
form['users[]'].disabled = '';
} // else
} // enableAccessControls
Core.setupIntlFields = function(prefix)
{
if ((prefix == null) ||
(prefix == undefined))
{
prefix = new Array('');
} // if
else if (typeof(prefix) != 'object')
{
prefix = new Array(prefix);
} // else
for (var i = 0; i < prefix.length; i++)
{
var country = document.getElementById(prefix[i] + 'country');
var postalCode = document.getElementById(prefix[i] + 'postalCode');
var region = document.getElementById(prefix[i] + 'region');
if ((!country) ||
(!postalCode) ||
(!region))
{
return;
} // if
if (country.value == 'CA')
{
var r = document.getElementById(prefix[i] + 'caProvince');
var pc = document.getElementById(prefix[i] + 'caPostalCode');
} // if
else
{
var r = document.getElementById(prefix[i] + 'intlRegion');
var pc = document.getElementById(prefix[i] + 'intlPostalCode');
} // else
if (pc)
{
postalCode.value = pc.value;
} // if
if (r)
{
region.value = r.value;
} // if
} // for
} // setupIntlFields
Core.onChangeCountry = function(select,
withZips,
prefix)
{
if ((prefix == null) ||
(prefix == undefined))
{
prefix = '';
} // if
var usRow = 'none';
var usStateCell = 'hidden';
var usStateRow = 'none';
var usZipCell = 'hidden';
var usZipRow = 'none';
var caRow = 'none';
var caProvinceRow = 'none';
var caProvinceCell = 'hidden';
var caPostalCodeRow = 'none';
var caPostalCodeCell = 'hidden';
var intlRow = 'none';
var intlRegionCell = 'hidden';
var intlRegionRow = 'none';
var intlPostalCodeCell = 'hidden';
var intlPostalCodeRow = 'none';
if (select.value == 'US')
{
usRow = '';
usStateRow = '';
usStateCell = '';
usZipRow = '';
usZipCell = '';
} // if
else if (Utils.inArray(select.value, withZips))
{
usRow = '';
usZipRow = '';
usZipCell = '';
} // else if
else if (select.value == 'CA')
{
caRow = '';
caProvinceRow = '';
caProvinceCell = '';
caPostalCodeRow = '';
caPostalCodeCell = '';
} // else
else if (select.value)
{
intlRow = '';
intlRegionRow = '';
intlRegionCell = '';
intlPostalCodeRow = '';
intlPostalCodeCell = '';
} // else
Core._changeCountryDisplay(prefix + 'usRow',             usRow);
Core._changeCountryDisplay(prefix + 'usErrorRow',        usRow);
Core._changeCountryDisplay(prefix + 'usStateRow',        usStateRow);
Core._changeCountryDisplay(prefix + 'usStateErrorRow',   usStateRow);
Core._changeCountryDisplay(prefix + 'usZipRow',          usZipRow);
Core._changeCountryDisplay(prefix + 'usZipErrorRow',     usZipRow);
Core._changeCountryDisplay(prefix + 'caRow',                caRow);
Core._changeCountryDisplay(prefix + 'caErrorRow',           caRow);
Core._changeCountryDisplay(prefix + 'caProvinceRow',        caProvinceRow);
Core._changeCountryDisplay(prefix + 'caProvinceErrorRow',   caProvinceRow);
Core._changeCountryDisplay(prefix + 'caPostalCodeRow',      caPostalCodeRow);
Core._changeCountryDisplay(prefix + 'caPostalCodeErrorRow', caPostalCodeRow);
Core._changeCountryDisplay(prefix + 'intlRow',                 intlRow);
Core._changeCountryDisplay(prefix + 'intlErrorRow',            intlRow);
Core._changeCountryDisplay(prefix + 'intlRegionRow',           intlRegionRow);
Core._changeCountryDisplay(prefix + 'intlRegionErrorRow',      intlRegionRow);
Core._changeCountryDisplay(prefix + 'intlPostalCodeRow',       intlPostalCodeRow);
Core._changeCountryDisplay(prefix + 'intlPostalCodeErrorRow',  intlPostalCodeRow);
Core._changeCountryVisibility(prefix + 'usStateCell', usStateCell);
Core._changeCountryVisibility(prefix + 'usZipCell',   usZipCell);
Core._changeCountryVisibility(prefix + 'caProvinceCell',    caProvinceCell);
Core._changeCountryVisibility(prefix + 'caPostalCodeCell',  caPostalCodeCell);
Core._changeCountryVisibility(prefix + 'intlRegionCell',       intlRegionCell);
Core._changeCountryVisibility(prefix + 'intlPostalCodeCell',   intlPostalCodeCell);
} // onChangeCountry
Core.onChangePagerPage = function(select,
path,
queryString,
doName,
itemsPerPage)
{
if (queryString)
{
queryString = '?' + queryString;
} // if
document.location.pathname = path + '/_pager/' + doName + '.' + itemsPerPage + '.' + select.value + '/' + queryString;
} // onChangePagerPage
Core.openWindow = function(url,
title,
width,
height,
scrollbars)
{
var x = (640 - width) / 2;
var y = (480 - height) / 2;
if (screen)
{
y = (screen.availHeight - height) / 2;
x = (screen.availWidth - width) / 2;
} // if
if (screen.availWidth > 1800)
{
x = ((screen.availWidth / 2) - width) / 2;
} // if
params = 'width='    + width  + ',' +
'height='   + height + ',' +
'screenX='  + x      + ',' +
'screenY='  + y      + ',' +
'top='      + y      + ',' +
'left='     + x      + ',' +
'dependent=yes,'  +
'directories=no,' +
'location=no,'    +
'menubar=no,'     +
'status=no,'      +
'toolbar=no';
if (scrollbars)
{
params += ',scrollbars=yes';
} // if
else
{
params += ',scrollbars=no';
} // else
newWin = window.open(url,
title,
params);
return (newWin);
} // openWindow
Core.openWindowImg = function(imgUrl,
title,
width,
height)
{
newWin = Core.openWindow('',
title,
width + 50,
height + 50);
newWin.document.write('<html><head><script src="' + Core.path + '/scripts/core/Core.js" language="javascript" type="text/javascript"></script></head><body onblur="Core.startWindowCloseTimer(5);" onfocus="Core.stopWindowCloseTimer();"><img src="' + imgUrl + '" /></body></html>');
newWin.document.close();
return (newWin);
} // openWindowImg
Core.removeImage = function(dataObj,
id,
name,
idx)
{
if (name == undefined)
{
name = 'image';
} // if
Core.ajaxSendCommand('removeImage',
{ 'doName':dataObj, 'name':name, 'id':id },
null,
null);
if (idx != undefined)
{
try
{
document.getElementById('_input_image_img_' + idx).style.display = 'none';
document.getElementById('_input_image_br_' + idx).style.display = 'none';
document.getElementById('_input_image_note_' + idx).style.display = 'none';
} // try
catch(e) {}
} // if
} // removeImage
Core.startWindowCloseTimer = function(secs)
{
Core._windowCloseTimer = window.setTimeout('window.close()',
secs * 1000)
} // startWindowCloseTimer
Core.stopWindowCloseTimer = function()
{
if (Core._windowCloseTimer)
{
window.clearTimeout(Core._windowCloseTimer);
Core._windowCloseTimer = null;
} // if
} // stopWindowCloseTimer
Core.updateResponse = function(text)
{
if (text)
{
var div = document.getElementById('coreDebugResponse');
if (div)
{
Utils.removeChildren(div);
var h1 = document.createElement('h1');
div.appendChild(h1);
h1.appendChild(document.createTextNode('AJAX Response'));
var p = document.createElement('p');
var temp = text.split('\n');
for (i in temp)
{
p.appendChild(document.createTextNode(temp[i]));
p.appendChild(document.createElement('br'));
} // for
div.appendChild(p);
} // if
} // if
} // updateResponse
Core._ajaxCommandCallback = function(obj,
data,
status,
reason,
xml,
text)
{
var elem = document.getElementById('debugResponse');
if (elem)
{
var request = '';
for (var i in Core._userAjaxRequest)
{
request += ', ' + i + ':' + Core._userAjaxRequest[i];
} // for
if (request)
{
request = request.substring(2)
} // if
var lt = new RegExp('<', 'g');
var gt = new RegExp('>', 'g');
text = text.replace(lt, '&lt;').replace(gt, '&gt;');
Utils.removeChildren(elem);
var html = '<h1>AJAX Information</h1>';
html += '<p><strong>Request:</strong> ' + request + '</p><br />';
html += '<p><strong>Response: </strong>' + text + '</p>';
elem.innerHTML = html;
elem.style.display = 'block';
} // if
if ((Core._userAjaxCommandCb) &&
(data.cmd))
{
if ((obj) &&
(obj[data.cmd]))
{
obj[data.cmd]._name = data.cmd;
Core._userAjaxCommandCb(obj[data.cmd],
data.userData,
Core._userAjaxRequest,
status,
reason);
} // if
else
{
Core._userAjaxCommandCb(null,
data.userData,
Core._userAjaxRequest,
status,
reason);
} // else
} // if
} // _ajaxCommandCallback
Core._changeCountryDisplay = function(id,
display)
{
var elem = document.getElementById(id);
if (elem)
{
elem.style.display = display;
} // if
var i = 0;
elem = document.getElementById(id + i);
while (elem)
{
elem.style.display = display;
i = i + 1;
elem = document.getElementById(id + i);
} // while
} // _changeCountryDisplay
Core._changeCountryVisibility = function(id,
visibility)
{
var elem = document.getElementById(id);
if (elem)
{
elem.style.visibility = visibility;
} // if
var i = 0;
elem = document.getElementById(id + i);
while (elem)
{
elem.style.visibility = visibility;
i = i + 1;
elem = document.getElementById(id + i);
} // while
} // _changeCountryVisibility
