// ------------------------------- my 'super' globals ----------------------------------------
var projects=new Array();
var contacts=new Array();

var actionList=new Array();
var isLoading=0;
var MAXLOADING=7;

var newActivityCounter=0;

var inputDate=new Date();

var substitutions=["No answer/line busy","The contact person"," was unavailable","Conversation with "];
//                         0-no1                1-no2                2-no2             3-con

// ------------------------------- multi-purpose contants -----------------------------------
var NOTFOUND=-1;
var NOTSET=-1;
var UNKNOWN=-2;

var NOW=0;
var OLD=1;

var ALLSUBS=-1;

var ONFIRSTCALL=-2;
var NODECISION=0;
var RED=1
var YELLOW=2;
var GREEN=3;
var CONFIRMED=4;
var NOTCONTACTED=5;
var UNABLETOCONTACT=6;
var INVALID=7;
var PRIVATE=8;

// ------------------------------- object utility functions, used by several objects ----------------------------------------
function _formatText(text) {
   // removes whitespace, double space, &amp;, &nbsp;, etc., and also html tags
   // called by processActivities on comment;
   // called by project on name and background
   // called by company on name
}

function _formatTextForPHP(text) {
   // substitutes +,~,`, etc. for PHP
   // called by company:phone number, background ; activity:comment
}

function _replaceAccentedText(text) {
   // substitutes accents to be back-converted by PHP
   // called by company:name,background,address ; activity:comment ; contact:name
}

function _tidyText(text) {
   // remove double space
   var pos;
   while ((pos=text.indexOf("  "))!=NOTFOUND) text=text.slice(0,pos)+text.slice(pos+1);
   // remove leading spaces
   while (text.charAt(0)==" ") text=text.slice(1);
   // remove trailing spaces
   while (text.charAt(-1)==" ") text=text.slice(0,text.length-1);
   return text;
}

function _shortened(name,maxLen) {
   if (name.length>maxLen) name=name.slice(0,maxLen-3)+"...";
   return name;
}

function _combine(proj,comp) {
   if (comp==undefined) var comp=0;
   var projStr="00"+proj;
   var compStr="00"+comp;
   return projStr.slice(-3)+compStr.slice(-3);
}

function _uncombine(text,rootText) {
   text=text.slice(rootText.length);
   var proj=_int(text.slice(0,3));
   if (text.length>3) var comp=_int(text,3);
   else comp=0;
   var retData=[proj,comp];
   return retData;
}