var MOCA_HOME_ID = 225;
var MOCA_BASE_URL = 'https://www.businessaxis.nz/';
var MOCA_BASE_DIR = '/';
var MOCA_HOME_URL = 'https://www.businessaxis.nz/home';
// Default table listing row bg colour
var MOCA_TABLE_BG_DEFAULT = '#fff';
// Used to stripe listing tables for readability
var MOCA_TABLE_BG = '#f3f3f3'; // Back-end
var MOCA_SITE_TABLE_BG = '#e5e8ea'; // Front-end
var MOCA_TABLE_BG_BLUE = '#eceff5';
// Highlight record being edited
var MOCA_TABLE_HIGHLIGHT = '#ffc';
// Highlight just-created field
var MOCA_TABLE_NEW_ROW = 'pink';
var MOCA_GST_RATE = 15;
// eg: Optional ticket holder fields
var MOCA_FIELD_EXISTS = 1;
var MOCA_FIELD_REQUIRED = 2;
var MOCA_BR_ADMIN_PRICE_TYPE_DOLLARS = 'dollars';
var MOCA_BR_ADMIN_PRICE_TYPE_PERCENTAGE = 'percentage';
/* Common Stylesheet colours: */
var MOCA_BR_CSS_ORANGE = '#d76927';
var MOCA_BR_CSS_BROWN = '#6B4936';
var MOCA_BR_CSS_DISABLED = '#9a9a9a';
var MOCA_MONTHS = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var MOCA_MONTH_NAMES = ['January','February','March','April','May','June','July','August','September','October','November','December'];
$.ajaxSetup({
//cache:false,
error:function(x,e){
$('#ajaxBusy').hide();
if(x.status==0){
mocaAlert('No network found');
}else if(x.status==404){
mocaAlert('Requested url not found');
}else if(x.status==500){
mocaAlert('A server error'+x.responseText+' - please contact the administrator','Whoops!');
}else if(e=='parsererror'){
mocaAlert('A system error has occurred - please contact the administrator','Whoops!');
}else if(e=='timeout'){
mocaAlert('Request time out');
}else {
mocaAlert('Unknown Ajax Error:\\n'+x.responseText);
}
}
});
function throb(){return $('#ajaxBusy').show();}
function unthrob(){return $('#ajaxBusy').hide(); }
// Dismiss status messages when anything clicked:
// $(document).ready(function(){$("*", document.body).bind('click',function(){$('#statusMessage').text('');});});
// Populated by MocaForm::initJavascript()
var Help = {};
// Whether fckeditor should use default fe stylesheet
var MocaFckStyles = true;
function logout(){
window.location.href = MOCA_BASE_URL + 'sitemgr/logout.php';
}
function highlightRows(table_id, no_header_row,skip){
/* Given the ID of a table element, set every alternate
row's background colour to MOCA_TABLE_BG colour. Unless
no_header_row is set, the first row will be left untouched.
Apply the class 'nonList' to any rows you want skipped
*/
var odd = false;
var first = true;
$('TABLE#' + table_id + ' TR:not(.nonList)').map(
function(){
if(!no_header_row && first){skip--;first = false;return;}
if(skip){odd=true;skip--;return;}
if($(this).css('display')!='none'){
$('*:not(.nonList)',$(this)).map(function(){this.style.backgroundColor = odd ? MOCA_TABLE_BG : '';});
odd = !odd;
}
})
}
function feHighlightRows(table_id, no_header_row,skip,colour){
/* Same for front-end
*/
var odd = true;
var first = true;
var clr = colour ? colour : MOCA_SITE_TABLE_BG;
$('TABLE#' + table_id + '>TBODY>TR:not(.nonList)').map(
function(){
if(!no_header_row && first){skip--;first = false;return;}
if(skip){odd=true;skip--;return;}
if($(this).css('display')!='none'){
$('TD',$(this)).map(function(){this.style.backgroundColor = odd ? clr : '';});
odd = !odd;
}
})
}
function highlightOptions(select_id,colour ){
/* Given the ID of a select element, set every alternate
option's background colour to given colour.MOCA_TABLE_BG colour.
*/
colour = colour ? colour : MOCA_TABLE_BG;
var odd = false;
$('SELECT#' + select_id + ' OPTION:not(.nonList)').map(
function(){
if($(this).css('display')!='none'){
this.style.backgroundColor = odd ? colour : '';
odd = !odd;
}
})
}
function feHighlightOptions(select_id,colour ){
/* Given the ID of a select element, set every alternate
option's background colour to given colour.MOCA_TABLE_BG colour.
*/
colour = colour ? colour : MOCA_SITE_TABLE_BG;
var odd = false;
$('SELECT#' + select_id + ' OPTION:not(.nonList)').map(
function(){
if($(this).css('display')!='none'){
this.style.backgroundColor = odd ? colour : '';
odd = !odd;
}
})
}
function FCKeditor_OnComplete(ed){
// Called by editor onLoad, change internal
// stylesheet to that initialised by moca.form
if(!MocaFckStyles){return;}
//var ht = ed.GetData();
if($('#moca_browser').val()){
ed.Config['ImageBrowserWindowWidth'] = ed.Config['ScreenWidth'] * 0.4;
ed.Config['ImageBrowserWindowHeight'] = ed.Config['ScreenHeight'] * 0.4;
ed.Config['LinkBrowserWindowWidth'] = ed.Config['ScreenWidth'] * 0.5;
ed.Config['LinkBrowserWindowHeight'] = ed.Config['ScreenHeight'] * 0.5;
ed.Config['LinkBrowserURL'] = ed.Config['BasePath'] + 'filemanager/browser/link/fe_browser.php' ;
}
}
function deleteFromListing(frm,ids){
// Delete records from listing page - ids is either array or
// comma-separated string of ids. Form is DOM element
frm.id_list.value = typeof ids == 'string' ? ids : ids.join(',');
frm.func.value = 'delete';
frm.submit();
}
// Convenience func for use in mocaConfirm & ilk
function goto(href){window.location.href=href;}
function showHelp(id){
if((Help == undefined) || !Help[id]){return;}
mocaAlert(Help[id],'Help');
}
function initHelp(){
$('.mfHelp').click(function() {
if($(this).data("qtip")) $(this).qtip("destroy");
var n = this.id.substr(7)=='mfHelp_' ? this.id.substr(7) : this.id;
if((Help == undefined) || !Help[n]){return;}
var pos = $(this).hasClass('topLeft') ?
{corner:{target:'topLeft',tooltip:'topRight'}} :
($(this).hasClass('bottomLeft') ?
{corner:{target:'bottomLeft',tooltip:'topRight'}} :
{corner:{target:'topRight',tooltip:'leftBottom'}});
$(this).qtip({
content:Help[n],
position:pos,
show:{when:false, ready:true},
hide:{when:'unfocus'},
style: {
border:{width:5,radius:10,color:'#80bd26'},
padding:10,
background:'#80bd26',
color:'#ffffff',
textAlign: 'left',
tip: true,
name: 'cream'
}
});
});
}
// Front-end BR help
$(document).ready(function(){
initHelp();
return false;});
function mocaPrompt(str,func,title) {
str = str.indexOf('<')>-1 ? str : '
');
$('#mocaDialog').dialog({ appendTo:document.body,
'close':function(){$('#mocaDialog').remove();},
'buttons': {
'Ok': function() {func(); $(this).dialog("close");},
'Cancel': function() {$(this).dialog("close");}
}
});
break;
case 'jqalert':
return jAlert(str,title);
break;
default:
return alert(str);
break;
}
}
function mocaAlert(str,title){
/* Custom alert. First arg is message string. Second is title. Third is
function to be executed on close. Only the first is mandatory */
title = title ? title : 'Message';
var func = arguments[2] ? arguments[2] : null;
switch('jquidialog'){
case 'jquidialog':
str = str.indexOf('<')>-1 ? str : '