function debugAlert(sMsg){}
function debugStartTimer(){}
function debugGetTime(){}
function encode(text)
{
return escape(text).replace(/\+/g, '%2B');
}
function alphafirst(str)
{
var re = new RegExp("([A-Za-z].*)");
return (re.exec(str)!=null && RegExp.$1==str);
}
function stacktrace()
{
var s = "stacktrace: "
for (var a=arguments.callee.caller; a!=null; a=a.caller)
{
s += _funcname(a) + "\n";
if (a.caller == a) break;
}
return s;
}
function scrollDiv()
{
document.getElementById('div__label').scrollLeft = document.getElementById('div__body').scrollLeft;
}
function getDocumentClientHeight()
{
return document.body.clientHeight;
}
function getDocumentClientWidth()
{
return document.body.clientWidth;
}
// Do not use the two functions below to get width and height of document client area
// In IE, the value will not include scroll bar; In FF and Safari, the value will include scrollbar
function getDocumentHeight()
{
if (window.innerHeight)
return window.innerHeight;
else
return document.body.clientHeight;
}
function getDocumentWidth()
{
if (window.innerWidth)
return window.innerWidth ;
else
return document.body.clientWidth;
}
var ieDiffWidth=0;
var ieDiffHeight=0;
function initOuter() {
var w, h, offW, offH, diffW, diffH;
var fixedW = 800;
var fixedH = 600;
if (document.all) {
offW = document.body.offsetWidth;
offH = document.body.offsetHeight;
window.resizeTo(fixedW, fixedH);
diffW = document.body.offsetWidth - offW;
diffH = document.body.offsetHeight - offH;
w = fixedW - diffW;
h = fixedH - diffH;
ieDiffWidth = w - offW;
ieDiffHeight = h - offH;
window.resizeTo(w, h);
}
}
function outerWd() {
if (document.all)
{
if (ieDiffHeight==0) initOuter();
return document.body.offsetWidth + ieDiffWidth;
}
else
return window.outerWidth;
}
function outerHt() {
if (document.all)
{
if (ieDiffHeight==0) initOuter();
return document.body.offsetHeight + ieDiffHeight;
}
else
return window.outerHeight;
}
function onBeforePrint()
{
var t= document.getElementById('div__label');
if (t != null)
{
t.style.width = null ;
t.style.height = null;
};
t = document.getElementById('div__body');
if (t != null)
{
t.style.width = null;
t.style.height = null;
}
document.body.scroll = 'auto';
}
function onAfterPrint()
{
if(document.getElementById("resetdivwascalled") != null)
resetDivSizes();
}
window.onbeforeprint = onBeforePrint;
window.onafterprint = onAfterPrint;
function resetDivSizes()
{
if(document.getElementById("resetdivwascalled") == null)
{
var hasBeenCalled = document.createElement("input");
hasBeenCalled.type = "hidden";
hasBeenCalled.value = "T";
hasBeenCalled.id = "resetdivwascalled";
document.body.appendChild(hasBeenCalled);
}
var header = document.getElementById('div__header');
var title = document.getElementById('div__title');
var label = document.getElementById('div__label');
var list = document.getElementById('div__body');
var nav = document.getElementById( 'div__nav');
var footer = document.getElementById('div__footer');
if (list == null)
return;
// we never want vertical scroll bars, but horizontal scroll bars are ok if necessary
// There should never be Y-overflow since we are sizing all of the elements to fit and scrolling individually
document.body.style.overflowY = "hidden";
var childnodes = footer.childNodes;
for(var i = 0; i < childnodes.length; i++)
{
var tableFooter = childnodes[i];
if(tableFooter.tagName == "TABLE")
{
document.body.style.overflow =
(tableFooter.scrollWidth > document.body.clientWidth) ? "-moz-scrollbars-horizontal" : "-moz-scrollbars-none";
break;
}
}
var nHeight = getDocumentHeight() - 10;
nHeight -= getHeight(header) + getHeight(footer) + getHeight(title) + getHeight(label) + 25;
list.style.height = ( nHeight > 0 ? nHeight : 0);
list.clientWidth;
var docwidth = getDocumentWidth();
var reportDataTable = document.getElementById('_rptdata');
if ( nav != null )
{
list.style.height = ( nHeight - list.offsetTop > 0 ? nHeight - list.offsetTop : 0);
var tree = document.getElementById('div__nav_tree');
if (tree)
tree.style.height = ( nHeight - tree.offsetTop > 0 ? nHeight - tree.offsetTop : 0 );
docwidth -= isIE ? nav.offsetWidth : nav.scrollWidth;
var node = nav.parentNode;
var cellSpacing = 0;
while (node != null)
{
if (node.getAttribute("cellspacing"))
{
cellSpacing = node.getAttribute("cellspacing");
break;
}
node = node.parentNode;
}
docwidth -= 4*cellSpacing;
}
list.style.width = Math.max( docwidth, 0 );
nHeight = getDocumentHeight() - 10;
nHeight -= getHeight(header) + getHeight(footer) + getHeight(title) + getHeight(label) + 25;
list.style.height = ( nHeight > 0 ? nHeight : 0);
if ( nav != null )
{
list.style.height = ( nHeight - list.offsetTop > 0 ? nHeight - list.offsetTop : 0);
var tree = document.getElementById('div__nav_tree');
if (tree)
tree.style.height = ( nHeight - tree.offsetTop > 0 ? nHeight - tree.offsetTop : 0 );
}
if (label != null )
{
label.style.width = list.clientWidth;
label.style.left = -document.getElementById('div__body').scrollLeft;
}
if( reportDataTable )
{
var labtab = document.getElementById('div__labtab');
labtab.style.width = reportDataTable.clientWidth;
}
for (var i=0; i==0 || document.getElementById('div__labcol'+i) != null; i++)
{
var col = document.getElementById('div__labcol'+i);
var lab = document.getElementById('div__lab'+i);
if (lab != null)
{
if ( isIE || lab.tagName == 'TD' )
{
lab.style.width = col.offsetWidth;
if (col.offsetWidth > (lab.offsetWidth - col.offsetWidth))
lab.style.width = col.offsetWidth - (lab.offsetWidth - col.offsetWidth);
}
else
{
lab.offsetParent.style.width = col.offsetWidth;
}
}
}
makeVisible(label);
makeVisible(list);
makeVisible(footer);
hideInvisibleRows();
}
function hideInvisibleRows()
{
var div = document.getElementById("squeezeBox");
if (div == null)
return;
var trs = div.getElementsByTagName("tr");
var hiddenHeight = 0;
for (var i=0; i < trs.length; i++)
{
if (trs[i].className == "labelRow" && isValEmpty(trs[i].getAttribute("squeezeBox")) )
{
hiddenHeight += trs[i].offsetHeight + 1;
trs[i].setAttribute("squeezeBox","T");
}
}
if (hiddenHeight > 0)
{
div.style.overflow = "hidden";
div.style.height = div.offsetHeight - hiddenHeight + (isIE ? 0 : 28);
}
}
function resizePopupWindow()
{
var list = document.getElementById('div__body');
if (list == null)
return;
var docwidth = getDocumentWidth()-10;
var maxspanwidth = getMaxContentWidth(list.getElementsByTagName("span"));
var maxdivwidth = getMaxContentWidth(list.getElementsByTagName("div"));
var maxwidth = Math.max(list.scrollWidth,Math.max(maxspanwidth,maxdivwidth));
if ( maxwidth > docwidth )
window.resizeBy(maxwidth -docwidth,0);
}
function getMaxContentWidth(elems)
{
var size = 0;
for ( i = 0; i < elems.length; i++ )
{
if ( elems[i].scrollWidth > size )
size = elems[i].scrollWidth;;
}
return size;
}
function getHeight(elem)
{
if (elem == null)
return 0;
else
return elem.offsetHeight ? elem.offsetHeight : 0;
}
function makeVisible(elem)
{
if (elem != null)
elem.style.visibility = 'visible';
}
function display(elem, on )
{
if (elem != null)
elem.style.display = on ? '' : 'none';
}
function visible(elem, on )
{
if (elem != null)
elem.style.visibility = on ? 'inherit' : 'hidden';
}
function endsWith(str, token)
{
return str != null && token != null && str.indexOf(token) == str.length-token.length;
}
function trim(str)
{
return str.replace(/^\s+/,"").replace(/\s+$/,"");
}
function onlydigitsandchars(str)
{
var re = new RegExp("([A-Za-z0-9]+)");
return (re.exec(str)!=null && RegExp.$1==str);
}
function onlydigits(str)
{
var re = new RegExp("([0-9]+)");
return (re.exec(str)!=null && RegExp.$1==str);
}
function checkzipcode(f, bIsCanada)
{
var v = f.value;
var n = bIsCanada ? 6 : 5;
if(!onlydigits(f) || v.length != n)
{
if ( bIsCanada )
alert('Please enter a valid '+n+' digit Postal Code.');
else
alert('Please enter a valid '+n+' digit Zip Code.');
return false;
}
return true;
}
function isValidUSZipCode(value)
{
var re = /^\d{5}([\-]\d{4})?$/;
return (re.test(value));
}
function splitIntoRows( value )
{
return value != null ? (value.length > 0 ? value.split(String.fromCharCode(2)) : new Array()) : null;
}
function splitIntoCells( value )
{
return value != null ? value.split(String.fromCharCode(1)) : null;
}
function checkemailvalue(s_email,alrt)
{
if ((s_email.length < 6) ||
(s_email.indexOf('@',0) < 1) ||
(s_email.lastIndexOf('@') != s_email.indexOf('@',0)) ||
(s_email.lastIndexOf('@') > (s_email.length - 5)) ||
(s_email.lastIndexOf('.') > (s_email.length - 3)) ||
(s_email.lastIndexOf('.') < (s_email.length - 5)) ||
(s_email.indexOf('..',0) > -1) ||
(s_email.indexOf('@.',0) > -1))
{
if (alrt)
{
alert('Please enter a valid email address.');
}
return false;
}
if ((s_email.indexOf(' ',0) > -1) ||
(s_email.indexOf(',',0) > -1) ||
(s_email.indexOf('"',0) > -1) ||
(s_email.indexOf(':',0) > -1) ||
(s_email.indexOf('>',0) > -1) ||
(s_email.indexOf('<',0) > -1))
{
if (alrt)
{
alert('Please enter a valid email address. NetSuite does not accept email addresses with quotation marks, commas, colons, spaces, or greater than or less than signs.');
}
return false;
}
if ((s_email.indexOf('.@',0) > -1))
{
if (alrt)
{
alert('Please proofread this email address. It may contain an error.');
}
}
return true;
}
function checkemailprefix(s_email)
{
if (s_email.indexOf('@',0) >= 2 &&
s_email.lastIndexOf('@') == s_email.indexOf('@',0) &&
s_email.indexOf('..',0) < 0 &&
s_email.indexOf(' ',0) < 0 &&
s_email.indexOf(',',0) < 0 &&
s_email.indexOf('"',0) < 0 &&
s_email.indexOf('>',0) < 0 &&
s_email.indexOf('<',0) < 0)
{
return true;
}
return false;
}
function checkemail(fld1,emptyok,alrt)
{
fld1.value = trim(fld1.value);
return checkemail2(fld1,fld1,emptyok,alrt);
}
function checkemail2(fld1,fld2,emptyok,alrt)
{
var s_email = fld1.value;
if (s_email != fld2.value)
{
alert('Email addresses must match.');
return false;
}
if (emptyok && s_email.length==0)
{
return true;
}
return checkemailvalue(s_email,alrt);
}
function checkccnumber(fld1,fld2)
{
var cardnum = fld1.value;
if(cardnum.length > 0) cardnum = cardnum.replace(/ /gi,'');
if(cardnum.length > 0) cardnum = cardnum.replace(/-/gi,'');
if (cardnum.length<13 || cardnum.length>20)
{
alert("Credit card numbers must contain between 13 and 20 digits.");
return false;
}
if (!onlydigits(cardnum))
{
alert("Credit card numbers must contain only digits.");
return false;
}
var no_digit = cardnum.length;
var oddoeven = no_digit & 1;
var sum = 0;
for (var count = 0; count < no_digit; count++)
{
var digit = parseInt(cardnum.charAt(count),10);
if (!((count & 1) ^ oddoeven))
{
digit *= 2;
if (digit > 9)
digit -= 9;
}
sum += digit;
}
if (sum % 10 != 0)
{
alert("Credit card number is not valid. Please check that all digits were entered correctly.");
return false;
}
if (fld2 != null)
fld2.value = cardnum;
else
fld1.value = cardnum;
return true;
}
function isValEmpty(val,nam)
{
if (val == null)
return true;
val = new String(val);
return (val.length == 0) || (val.search(/\S/) < 0);
}
function isHTMLValEmpty(val)
{
if (val == null || val.length == 0)
return true;
val = val.replace(/ |<(?!NL)[^>]*>/gi, '');
return val.search(/\S/) < 0;
}
function isempty(fld1,nam)
{
var val = fld1.value;
return isValEmpty(val,nam);
}
function nvl(val,val2)
{
return val == null ? val2 : val;
}
function emptyIfNull(val)
{
return val == null ? '' : val;
}
function nullIfEmpty(val)
{
return isValEmpty(val) ? null : val;
}
function checknotempty(fld1,nam)
{
if (isempty(fld1))
{
alert( chooseAorAn(nam, true) +" "+ nam +" must be entered");
try {
fld1.focus();
fld1.select();
} catch (e) { }
return false;
}
return true;
}
function amount_string(amount)
{
var cents = Math.floor((amount-Math.floor(amount))*100+0.5);
var centstring = (cents < 10) ? '0'+cents.toString() : cents.toString();
var dollarstring = dollars_string(Math.floor(amount));
return dollarstring.charAt(0).toUpperCase() + dollarstring.substr(1) + 'and ' + centstring + '/100';
}
function format_rate(a,p)
{
var returnMe;
if (isNaN(parseFloat(a)))
{
returnMe= '';
}
else
{
var s=(a<0);
if (s) a=-a;
var d=Math.floor(a);
var c=Math.floor((a-d)*(p?10:100)+0.5);
if (a == d+c/(p?10:100))
{
if (c==(p?10:100)) {d++;c=0;}
var cs=p?c.toString():((c < 10)?'0'+c.toString():c.toString());
returnMe = (s?'-':'')+d.toString()+'.'+cs+(p?'%':'');
}
else
returnMe = (s?'-':'')+a+(p?'%':'');
}
return returnMe;
}
function round_currency(amount, numofdecimals)
{
var precision = numofdecimals;
if (precision==null)
{
var cp = getFormElementViaFormName('main_form', 'currencyprecision');
precision = 2;
if (cp != null)
{
precision = parseFloat(cp.value);
if (isNaN(precision))
{
precision = 2;
}
}
}
var b = Math.abs(amount);
b = Math.floor((b * 100000.0)+0.5) / 100000.0 + 0.000001;
factor = 1.0;
if (precision==0) {
factor = 1.0;
} else if (precision==1) {
factor = 10.0;
} else {
factor = 100.0;
}
b = Math.floor((b * factor)+0.5) / factor;
b = b * (amount >= 0.0 ? 1.0 : -1.0);
if( b == 0.0 )
return 0.0;
return b;
}
function round_float(a)
{
var b = Math.abs(a);
b = Math.floor((b * 100000.0)+0.5) / 100000.0;
b = b * (a >= 0.0 ? 1.0 : -1.0);
if( b == 0.0 )
return 0.0;
return b;
}
function pad_to_atleast_two_decimal_places(a)
{
var s;
if(a == null)
{
s = '';
}
else
{
s = a.toString();
var n = s.indexOf('.');
if(n == -1)
{
s = s + '.00';
}
else if(n == s.length-1)
{
s = s + '00';
}
else if(n == s.length-2)
{
s = s + '0';
}
if (n == 0)
{
s = '0' + s;
}
}
return s;
}
function pad_decimal_places(a, noOfDecimalPlaces)
{
var s;
if(a == null)
{
s = '';
}
else
{
s = a.toString();
var n = s.indexOf('.');
if (noOfDecimalPlaces==0)
{
if(a == 0.0)
{
s = 0;
}
else if(n > -1)
{
s = s.substring(0, n) ;
}
}
else if (noOfDecimalPlaces==1)
{
if(n == -1)
{
s = s + '.0';
}
else if(n == s.length-1)
{
s = s + '0';
}
else if (n == 0)
{
s = '0' + s;
}
}
else
{
if(n == -1)
{
s = s + '.00';
}
else if(n == s.length-1)
{
s = s + '00';
}
else if(n == s.length-2)
{
s = s + '0';
}
if (n == 0)
{
s = '0' + s;
}
}
}
return s;
}
function format_currency(a, bDoNotRound)
{
var cp = getFormElementViaFormName('main_form', 'currencyprecision');
var noOfDecimalPlaces = 2;
if (cp != null)
{
noOfDecimalPlaces = parseFloat(cp.value);
if (isNaN(noOfDecimalPlaces))
{
noOfDecimalPlaces = 2;
}
}
var returnMe;
if(isNaN(a))
{
return '';
}
else if( !(bDoNotRound == true))
{
returnMe = round_currency(a, noOfDecimalPlaces);
}
else
{
returnMe = a;
}
returnMe = pad_decimal_places(returnMe, noOfDecimalPlaces);
return returnMe;
}
function format_currency2(n)
{
if(isNaN(n))
{
return '';
}
var returnMe = round_float(n);
returnMe = pad_to_atleast_two_decimal_places(returnMe);
return returnMe;
}
function format_percent(p) {
return p+(p==Math.floor(p) ? '.0%' : '%'); }
function parseCJKNumbers(field)
{
if ( field.value != null )
return field.value.replace(/@/g,"@").replace(/./g,".").replace(/-/g,"-").replace(/_/g,"_")
.replace(/1/g,"1").replace(/2/g,"2").replace(/3/g,"3").replace(/4/g,"4").replace(/5/g,"5").replace(/6/g,"6").replace(/7/g,"7").replace(/8/g,"8").replace(/9/g,"9").replace(/0/g,"0")
.replace(/A/g,"A").replace(/B/g,"B").replace(/C/g,"C").replace(/D/g,"D").replace(/E/g,"E").replace(/F/g,"F").replace(/G/g,"G").replace(/H/g,"H").replace(/I/g,"I").replace(/J/g,"J").replace(/K/g,"K").replace(/L/g,"L").replace(/M/g,"M").replace(/N/g,"N").replace(/O/g,"O").replace(/P/g,"P").replace(/Q/g,"Q").replace(/R/g,"R").replace(/S/g,"S").replace(/T/g,"T").replace(/U/g,"U").replace(/V/g,"V").replace(/W/g,"W").replace(/X/g,"X").replace(/Y/g,"Y").replace(/Z/g,"Z")
.replace(/a/g,"a").replace(/b/g,"b").replace(/c/g,"c").replace(/d/g,"d").replace(/e/g,"e").replace(/f/g,"f").replace(/g/g,"g").replace(/h/g,"h").replace(/i/g,"i").replace(/j/g,"j").replace(/k/g,"k").replace(/l/g,"l").replace(/m/g,"m").replace(/n/g,"n").replace(/o/g,"o").replace(/p/g,"p").replace(/q/g,"q").replace(/r/g,"r").replace(/s/g,"s").replace(/t/g,"t").replace(/u/g,"u").replace(/v/g,"v").replace(/w/g,"w").replace(/x/g,"x").replace(/y/g,"y").replace(/z/g,"z");
else
return field.value;
}
function validate_textfield_maxlen(field, maxLen, bAlert, bMaxInChars)
{
if (field.value == null || field.value.length == 0)
{
window.isvalid = true;
return true;
}
var bValid = true, truncOffset = null;
if (bMaxInChars)
{
var len = field.value.length;
if (len > maxLen)
{
if (bAlert)
alert('You have exceeded the '+maxLen+' character limit for this field. Please shorten your entry by '+(len-maxLen)+' characters.');
truncOffset = maxLen;
}
}
else
{
var toTrim = analyzeUTF8(field.value, maxLen);
if (toTrim)
{
if (bAlert)
alert('You have exceeded the length limit for this field. Please shorten your entry by '+toTrim+' characters.');
truncOffset = UTF8toUTF16index(field.value, maxLen);
}
}
if (truncOffset)
{
window.focusedTextArea = field;
setTimeout("setSelectionRange(window.focusedTextArea, " + truncOffset + ", " + field.value.length + ");",0);
bValid = false;
}
window.isvalid = bValid;
return bValid;
}
function truncateStringInUnicode(str, maxlen)
{
var totalnum = 0;
var sLower = 128;
var sHigher = 2048;
var strOut = "";
for (var i=0; i < str.length; i++ )
{
var chnum = str.charCodeAt(i);
if ( chnum < sLower )
totalnum += 1;
else if ( chnum >= sLower && chnum < sHigher )
totalnum += 2;
else if ( chnum >= sHigher )
totalnum += 3;
if ( totalnum < maxlen )
strOut = strOut + str.charAt(i);
}
return strOut;
}
function UTF8toUTF16index(str, utf8index)
{
var utf8len = 0;
var sLower = 128;
var sHigher = 2048;
for (var i=0; i utf8index)
return i;
}
return 0;
}
function analyzeUTF8(str, maxByteLen)
{
var byteLen = 0, bucket = [null, 0, 0, 0];
for (var i=0; i0 && i<=3; ++i)
{
var trimmedFromBucket = Math.min(Math.floor((excessBytes + i - 1) / i), bucket[i]);
charsToTrim += trimmedFromBucket;
excessBytes -= trimmedFromBucket * i;
}
return charsToTrim;
}
var NLDate_short_months = new Array("Jan","Feb","Mar",
"Apr","May","Jun","Jul",
"Aug","Sep","Oct","Nov","Dec");
if ( 13 > 12 )
NLDate_short_months.push();
function validate_field(field, type, doalert, autoplace, minval, maxval, mandatory, separator)
{
window.isvalid=false;
type = type.toLowerCase();
if (field.value == null || field.value.length == 0)
{
if (mandatory == true)
{
if (doalert) alert("Field must contain a value.");
if (isIE)
{
field.focus();
field.select();
}
else
{
setTimeout("document.getElementById('"+field.id+"').focus();document.getElementById('"+field.id+"').select();",0);
}
window.isvalid = false;
return false;
}
else
{
window.isvalid = true;
return true;
}
}
if ( (type != "text" && type != "identifier" && type != "identifieranycase" && type != "address" && type != "visiblepassword") &&
("en" == "ja" || "en" == "ko" || "en" == "zh") )
field.value = parseCJKNumbers(field);
var validflag = true;
if (type =="url")
{
var val = trim(field.value.toLowerCase());
if (!(val.indexOf('/') == 0 || val.indexOf('http://') == 0 || val.indexOf('https://') == 0 || val.indexOf('ftp://') == 0 || val.indexOf('file://') == 0))
{
if (val.indexOf('://') != -1)
{
if (doalert)
alert("Invalid url. Url must start with http://, https://, ftp://, or file://");
validflag = false;
}
else
field.value = 'http://' + trim(field.value);
}
if ( val.indexOf( ' ' ) > 0 || val.indexOf( '\t' ) > 0 )
{
if (doalert)
alert("Invalid url. Spaces are not allowed in the URL");
validflag = false;
}
}
else if (type == "currency" || type == "currency2" || type == "poscurrency")
{
var val = field.value.replace(/\$/g,"");
val = val.replace(/\ /g,"");
val = val.replace(/,/g,"");
val = val.toLowerCase();
if(val.charAt(0) == '=') val = val.substr(1);
if (val.substr(1).search(/[\+\-\*\/]/g) != -1)
{
var c = val.charAt(0);
if(val.charAt(0) >='a' && val.charAt(0) <='z')
{
value = "error";
}
else
{
try {
val = eval(val);
} catch (e) { val = "error"; }
autoplace = false;
}
}
numval = parseFloat(val);
if (type == "currency2")
{
if (isNaN(numval) || Math.abs(numval)>=(maxval == 1.0e+11 ? 1.0e+11 : 1.0e+8))
{
if (doalert) alert(maxval == 1.0e+11 ? "Invalid currency value. Values must be numbers up to 99,999,999,999.99" : "Invalid Rate Value. Values must be numbers up to 99,999,999.9999999");
validflag = false;
}
}
else
{
if (isNaN(numval) || Math.abs(numval)>=(maxval == 1.0e+11 ? 1.0e+11 : 1.0e+10))
{
if (doalert) alert(maxval == 1.0e+11 ? "Invalid currency value. Values must be numbers up to 99,999,999,999.99" : "Invalid currency value. Values must be numbers up to 9,999,999,999.99");
validflag = false;
}
}
if ((type == "poscurrency" || minval == 0) && numval < 0)
{
if (doalert) alert("Invalid currency value. Value can not be negative.");
validflag = false;
}
if (validflag)
{
if(autoplace && val.indexOf(".") == -1) numval/=100;
if(type == "currency" || type == "poscurrency")
field.value = format_currency(numval);
else
field.value = format_currency2(numval);
}
}
else if (type == "date")
{
var dt = NLDate_parseString(field.value, doalert);
if(dt == null)
{
validflag = false;
}
else
{
validflag = true;
field.value = getdatestring2(dt, NLDate_short_months);
}
}
else if (type == "mmyydate")
{
var month;
var day = 0;
var year;
// Depending on the user date format, the valid formats are [MMYY, MMYYYY, MM/DD/YYYY, MM/DD/YY] or [MMYY, MMYYYY, DD/MM/YYYY, DD/MM/YY]
var fmterr = "MMYY, MMYYYY, " + ((window.dateformat == "DD/MM/YYYY" || window.dateformat == "DD.MM.YYYY" || window.dateformat == "DD-MM-YYYY") ? "DD/MM/YY, DD/MM/YYYY" : "MM/DD/YY, MM/DD/YYYY");
if(window.dateformat == "DD-Mon-YYYY" && field.value.indexOf("/") == -1 && !onlydigits(field.value))
{
var ms = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
var val = field.value;
if (val.indexOf("-") != -1)
{
var c = val.split("-");
month = getMonthIndex(c[0]);
year=parseInt(c[1],10);
}
else
{
var l = val.length, str;
str = val.substr(0,3);
if ( "en_US".substring(0,2) == "en" ) {
if (ms.indexOf(str.toUpperCase()) >= 0) month = (ms.indexOf(str.toUpperCase())+3)/3;
} else {
month = getMonthIndex(str);
}
str = val.substr(3);
year=parseInt(str,10);
}
fmterr = "Mon-YY, Mon-YYYY, MonYY or MonYYYY";
}
else
{
if (field.value.indexOf("/") == -1)
{
var l = field.value.length;
month = parseInt(field.value.substr(0,2-l%2),10);
year = parseInt(field.value.substr(2-l%2),10);
}
else
{
var comps = field.value.split("/");
// We want users who normally write the day first to enter "01/03/2004" and
// get "03/2004" instead of "01/2004". European users expect this.
// If the user date format has day first (e.g. "DD/MM/YYYY"), parse the input
// using "DD/MM/YYYY". Otherwise, parse the input using "MM/DD/YYYY".
// Even though we don't support "-" or "." as a delimiter in this field, we'll still
// look at date formats of the type "DD-MM-YYYY" and "DD.MM.YYYY" to determine whether
// to use "DD/MM/YYYY" or "MM/DD/YYYY".
var bIsDayFirst = (window.dateformat == "DD/MM/YYYY" || window.dateformat == "DD-MM-YYYY" || window.dateformat == "DD.MM.YYYY");
if (comps[2] == null)
{
month = parseInt(comps[0],10);
year = parseInt(comps[1],10);
}
else
{
day = parseInt(comps[bIsDayFirst ? 0 : 1],10);
month = parseInt(comps[bIsDayFirst ? 1 : 0],10);
year = parseInt(comps[2],10);
}
}
}
if (month >= 1 && month <= 12 && ((year >= 0 && year < 100) || (year > 1900 && year <2100)))
{
if (year < 50)
year += 2000;
else if (year < 100)
year += 1900;
if (day == 0 || day > 31)
{
if (month == 2)
{
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
day = 29;
else
day = 28;
}
else if (month == 4 || month == 6 || month == 9 || month == 11)
day = 30;
else
day = 31;
}
field.value = getmmyydatestring(new Date(year, month-1, day), NLDate_short_months);
validflag = true;
}
else
{
if (doalert) alert('Invalid date value (must be '+fmterr+')');
validflag = false;
}
}
else if (type == "ccexpdate" || type == "ccvalidfrom")
{
validflag = true;
var m=0, y=0;
if(field.value.indexOf('/') != -1)
{
var dToday = new Date();
var Y = dToday.getFullYear();
var M = dToday.getMonth() + 1;
if(Y <= 999) Y += 1900;
var c = field.value.split('/');
if(onlydigits(c[0])) m = parseInt(c[0],10);
if(onlydigits(c[1])) y = parseInt(c[1],10);
if(m<1) m=1; else if(m>12) m=12;
if(y<100) y+=((y>=70)?1900:2000);
if(type == "ccexpdate" && (y < Y || (y==Y && m < M)) ||
type == "ccvalidfrom" && (y > Y || (y==Y && m > M)))
{
if (doalert) alert("Notice: The credit card appears to be incorrect");
}
field.value = (m<10?'0':'')+m+'/'+y;
}
else
{
if (doalert)
{
if (type == "ccexpdate") alert("Please enter an expiration date in MM/YYYY format");
else alert("Please enter a Valid From / Start Date in MM/YYYY format");
}
validflag = false;
}
}
else if (type == "ccnumber")
{
validflag = checkccnumber(field);
}
else if (type == "rate")
{
var numval;
var minclip=-10000000000;
var maxclip=10000000000;
var val = field.value;
val = val.replace(/,/g,"");
var pctidx = val.lastIndexOf("%");
if (pctidx!=-1)
val = val.substr(0,pctidx);
numval = parseFloat(val);
if (isNaN(numval))
{
if (doalert) alert("Invalid number or percentage");
validflag = false;
}
else if (numval >= maxclip)
{
if (doalert) alert("Number exceeds maximum value");
validflag = false;
}
else if (numval <= minclip)
{
if (doalert) alert("Number is less than minimum value");
validflag = false;
}
else
{
if(autoplace && pctidx == -1 && val.indexOf(".") == -1) numval/=100;
field.value = format_rate(numval,pctidx!=-1);
validflag = true;
}
}
else if (type == "integer" || type == "posinteger" || type == "float" || type == "posfloat" || type == "percent")
{
var numval;
var custrange=false;
if ((minval != null || maxval != null) || type == "percent")
custrange=true;
var minclip= minval == null ? (type == "percent" ? 0 : -Math.pow(2,32)) : minval;
var maxclip = maxval == null ?(type == "percent" ? 100 : Math.pow(2,64)) : maxval;
var val = field.value;
val = val.replace(/,/g,"");
val = val.replace(/%/g,"");
if (type == "integer")
numval = parseInt(val,10);
else if (type == "posinteger")
{
numval = parseInt(val,10);
minclip=0;
}
else if (type == "posfloat")
{
numval = round_float(parseFloat(val));
minclip=0;
}
else
numval = parseFloat(val);
if (isNaN(numval) || (custrange && (numval > maxclip || numval < minclip)) || (!custrange && (numval >= maxclip || numval <= minclip)))
{
if (doalert)
{
if (type == "percent")
{
alert("Invalid percentage (must be between 0 and 100)");
}
else if (custrange == true)
{
if (minval == null)
alert("Invalid number (must be at most "+maxclip+")");
else if (maxval == null)
alert("Invalid number (must be at least "+minclip+")");
else
alert("Invalid number (must be between "+minclip+" and "+maxclip+")");
}
else if (type=="posinteger" || type=="posfloat")
alert("Invalid number (must be positive)");
else if (type=="integer" || type=="float")
{
if (isNaN(numval))
alert('You may only enter numbers into this field');
else
alert("Illegal number: " + numval);
}
else
alert("Invalid number (must be greater than -4.29B");
}
validflag = false;
}
else
{
if (type == "percent")
field.value=format_percent(numval);
else
field.value = numval;
validflag = true;
}
}
else if (type == "address")
{
var err = '';
if (field.value.length>999)
{
err = "Address too long (truncated at 1000 characters)";
newval = field.value.substr(0,999);
}
if (err != '')
{
if (doalert) alert(err);
field.value = newval;
}
}
else if (type == "time" || type == "timetrack")
{
var hours;
var minutes;
var re = /([0-9][0-9]?)?(:[0-5][0-9])?/
var result = re.exec(field.value)
if (result==null || result.index > 0 || result[0].length != field.value.length)
{
timeval = parseFloat(field.value);
if (isNaN(timeval))
hours = -1;
else
{
hours = Math.floor(timeval);
minutes = Math.floor((timeval-hours)*60+0.5);
}
}
else
{
if (RegExp.$1.length > 0)
hours = parseInt(RegExp.$1,10);
else
hours = 0;
if (typeof(RegExp.$2) != "undefined" && RegExp.$2.length > 0)
minutes = parseInt(RegExp.$2.substr(1),10);
else
minutes = 0;
}
if (hours >= 0 && minutes >= 0 && minutes < 60)
{
field.value = hours + ":" + (minutes < 10 ? "0" : "") + minutes;
validflag = true;
}
else
{
if (doalert) alert("Invalid time value (must be HH:MI)");
validflag = false;
}
}
else if (type == "timeofday")
{
var hours;
var minutes;
var amorpm;
var am_str = "am";
var pm_str = "pm";
var re;
var result;
var fldvalue = field.value;
fldvalue = hhmmtotimestring( fldvalue );
re = new RegExp("([0-9][0-9]?)(:[0-5][0-9])\\s?("+am_str+"|"+pm_str+"|"+am_str.charAt(0)+"|"+pm_str.charAt(0)+")?", "i");
result = re.exec(fldvalue);
if (result==null || result.index > 0 || result[0].length != fldvalue.length)
hours = -1;
else
{
if (RegExp.$1.length > 0)
hours = parseInt(RegExp.$1,10);
else
hours = -1;
if (typeof(RegExp.$2) != "undefined" && RegExp.$2.length > 0)
minutes = parseInt(RegExp.$2.substr(1),10);
else
minutes = -1;
amorpm = (RegExp.$3.length == 0 || RegExp.$3.toLowerCase() == am_str || RegExp.$3.toLowerCase() == am_str.charAt(0)) ? "" : pm_str;
}
if (hours > 0 && hours <=12 && minutes >= 0 && minutes < 60)
{
if (amorpm == "") amorpm = am_str;
field.value = hours + ":" + (minutes < 10 ? "0" : "") + minutes + " " + amorpm;
validflag = true;
}
else if (hours > 12 && hours <= 25 && minutes >= 0 && minutes < 60 && amorpm == "")
{
amorpm = pm_str;
hours -= 12;
field.value = hours + ":" + (minutes < 10 ? "0" : "") + minutes + " " + amorpm;
}
else
{
if (doalert) alert("Enter the time of day as HH:MI or HH:MI AM/PM. You can enter hours from 1 to 12 and minutes from 0 to 59.");
validflag = false;
}
}
else if (type == "visiblepassword")
{
validflag = checkpassword(field, field, doalert);
}
else if (type == "email")
{
validflag = checkemail(field, true, doalert);
}
else if (type == "emails")
{
var bademails = new Array();
var validcount = 0;
if (!separator) separator = /[,;]/;
var emails = field.value.split(separator);
for (var j=0; j < emails.length; j++)
{
var semail = trim(emails[j]);
if (semail)
{
if (checkemailvalue(semail, false))
validcount += 1;
else
bademails.push(emails[j]);
}
}
if (bademails.length > 0)
{
validflag = false;
if (doalert) alert('Invalid email(s) found: '+bademails.join('; '));
}
else if (validcount < 1)
{
validflag = false;
if (doalert) alert('No valid emails found in \"'+field.value+'\"');
}
}
else if (type == "printerOffset")
{
var maxclip = 2.0;
var minclip = -2.0;
var val = field.value;
val = val.replace(/,/g,"");
numval = parseFloat(val);
if (isNaN(numval) || numval >= maxclip || numval <= minclip)
{
if (doalert)
{
if (numval >= maxclip)
alert("Invalid number (must be lower than " + maxclip + ").");
else if (numval <= minclip)
alert("Invalid number (must be greater than " + minclip + ").");
else
alert("Illegal number: " + numval);
}
validflag = false;
}
else
{
validflag = true;
}
}
else if (type == "metricPrinterOffset")
{
var maxclip = 50.0;
var minclip = -50.0;
var val = field.value;
val = val.replace(/,/g,"");
numval = parseFloat(val);
if (isNaN(numval) || numval >= maxclip || numval <= minclip)
{
if (doalert)
{
if (numval >= maxclip)
alert("Invalid number (must be lower than " + maxclip + ").");
else if (numval <= minclip)
alert("Invalid number (must be greater than " + minclip + ").");
else
alert("Illegal number: " + numval);
}
validflag = false;
}
else
{
validflag = true;
}
}
else if (type == "phone" || type == "fullphone")
{
var val = field.value;
if(val.length!=0 && val.length<7)
{
if (doalert) alert("Phone number should have seven digits or more.");
validflag = false;
}
if (validflag && type == "fullphone")
{
if(val.length!=0 && val.length<10)
{
if (doalert) alert("Please include the area code for phone number: " + val);
validflag = false;
}
}
if (autoplace && validflag)
{
var extidx = val.search(/[A-Za-z]/);
var ext = '';
if (extidx >= 0)
{
ext = ' '+val.substring(extidx);
val = val.substring(0,extidx);
}
var re = /^[0-9()-.\s]+$/;
if (re.test(val))
{
var digits = val.replace(/[()-.\s]/g,'');
if (digits.length == 7)
field.value=window.phoneformat.replace(window.phoneformat.substring(0,window.phoneformat.indexOf('4')),'').replace('456',digits.substring(0,3)).replace('7890',digits.substring(3)) + ext;
else if (digits.length == 10)
field.value=window.phoneformat.replace('123',digits.substring(0,3)).replace('456',digits.substring(3,6)).replace('7890',digits.substring(6)) + ext;
else if (digits.length == 11 && digits.substring(0,1) == '1')
field.value='1 '+window.phoneformat.replace('123',digits.substring(1,4)).replace('456',digits.substring(4,7)).replace('7890',digits.substring(7)) + ext;
}
}
}
else if (type == "color")
{
var val = field.value;
if (val.substring(0,1) == "#")
val = val.substring(1);
var re = /^[0-9ABCDEFabcdef]{6,}$/;
if (val.length > 6 || !re.test(val))
{
if (doalert) alert("Color value must be 6 hexadecimal digits of the form: #RRGGBB. Example: #FF0000 for red.");
validflag = false;
}
else
field.value = "#"+val;
}
else if (type == "identifier" || type == "identifieranycase")
{
var val = field.value;
var re = /^[0-9A-Za-z_]+$/;
if (!re.test(val))
{
if (doalert) alert("Identifiers can contain only digits, alphabetic characters, or \"_\" with no spaces");
validflag = false;
}
else
field.value = type == "identifier" ? val.toLowerCase() : val;
}
if (mandatory == true)
{
if (field.value.length == 0)
{
if (doalert) alert("Field must contain a value.");
validflag = false;
}
}
if (!validflag)
{
if (isIE)
{
field.focus();
field.select();
}
else
{
setTimeout("document.getElementById('"+field.id+"').focus();document.getElementById('"+field.id+"').select();",0);
}
}
window.isvalid = validflag;
return validflag;
}
function validatePeriodRange(fldPeriodStart, fldPeriodEnd)
{
if( getSelectIndex(fldPeriodEnd) < getSelectIndex(fldPeriodStart) )
{
alert('Please enter a valid date range. The From date must precede the To date.');
return false;
}
return true;
}
function setSelectionRange(input, selectionStart, selectionEnd) {
if (input.setSelectionRange) {
input.focus();
input.setSelectionRange(selectionStart, selectionEnd);
}
else if (input.createTextRange) {
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
range.select();
}
}
function nlGetFullYear(d)
{
if (navigator != null && navigator.appName == "Netscape")
{
if (d.getFullYear=="undefined")
return d.getYear();
}
return d.getFullYear();
}
function nlSetFullYear(d,val)
{
if (navigator != null && navigator.appName == "Netscape")
{
if (d.setFullYear=="undefined")
d.setYear(val);
}
d.setFullYear(val);
}
function getdatestring(d)
{
if (window.dateformat == "DD-Mon-YYYY")
return d.getDate()+"-"+window.datetime_short_months[d.getMonth()]+"-"+nlGetFullYear(d);
else if (window.dateformat == "DD.MM.YYYY")
return d.getDate()+"."+(d.getMonth()+1)+"."+nlGetFullYear(d);
else if (window.dateformat == "DD/MM/YYYY")
return d.getDate()+"/"+(d.getMonth()+1)+"/"+nlGetFullYear(d);
else if (window.dateformat == "YYYY/MM/DD")
return nlGetFullYear(d)+"/"+(d.getMonth()+1)+"/"+d.getDate();
else
return (d.getMonth()+1)+"/"+d.getDate()+"/"+nlGetFullYear(d);
}
function getdatestring2(d, NLDate_short_months)
{
if (window.dateformat == "DD-Mon-YYYY")
return d.getDate()+"-"+NLDate_short_months[d.getMonth()]+"-"+nlGetFullYear(d);
else
return getdatestring(d);
}
function getdefaultformatdatestring(d)
{
return (d.getMonth()+1)+"/"+d.getDate()+"/"+nlGetFullYear(d);
}
function gettimestring(time,amvar,pmvar)
{
var hours = time.getHours();
var minutes = time.getMinutes();
var ampm = hours < 12 ? window.datetime_am_string : window.datetime_pm_string;
return timestr = (hours%12 < 1 ? 12 : hours%12) + ':' + (minutes < 10 ? '0'+minutes.toString() : minutes) + ' ' + ampm;
}
function getdatetimestring(date)
{
return getdatestring(date) + " " + gettimestring(date);
}
function getdatetimestring2(date, NLDate_short_months)
{
return getdatestring2(date, NLDate_short_months) + " " + gettimestring(date);
}
function getmmyydatestring(d, NLDate_short_months)
{
if (window.dateformat == "DD-Mon-YYYY")
return NLDate_short_months[d.getMonth()]+"-"+nlGetFullYear(d);
else if (window.dateformat == "DD.MM.YYYY")
return (d.getMonth()+1)+"."+nlGetFullYear(d);
else if (window.dateformat == "DD/MM/YYYY")
return (d.getMonth()+1)+"/"+nlGetFullYear(d);
else if (window.dateformat == "YYYY/MM/DD")
return (d.getMonth()+1)+"/"+nlGetFullYear(d);
else
return (d.getMonth()+1)+"/"+nlGetFullYear(d);
}
function stringtodate(arg, dateformat)
{
var comps;
var month, day, year;
var datetime = arg.split(" ");
var d = datetime[0];
if (d.indexOf("/") != -1)
{
comps = d.split("/");
if ( dateformat == null )
dateformat = window.dateformat;
if (comps.length == 2)
{
month = parseInt(comps[0],10)-1;
day = 1;
year = parseInt(comps[1],10);
}
else if (dateformat == "DD/MM/YYYY")
{
day = parseInt(comps[0],10);
month = parseInt(comps[1],10)-1;
year = parseInt(comps[2],10);
}
else if (dateformat == "YYYY/MM/DD")
{
year = parseInt(comps[0],10);
month = parseInt(comps[1],10)-1;
day = parseInt(comps[2],10);
}
else
{
month = parseInt(comps[0],10)-1;
day = parseInt(comps[1],10);
year = parseInt(comps[2],10);
}
}
else if (d.indexOf(".") != -1)
{
comps = d.split(".");
if (comps.length == 2)
{
day = 1;
month = parseInt(comps[0],10);
year = parseInt(comps[1],10)-1;
}
else
{
day = parseInt(comps[0],10);
month = parseInt(comps[1],10)-1;
year = parseInt(comps[2],10);
}
}
else if (d.indexOf("-") != -1)
{
comps = d.split("-");
if (comps.length == 2)
{
day = 1;
month = arrayIndexOf(window.datetime_short_months,comps[0]);
year = parseInt(comps[1], 10);
}
else
{
day = parseInt(comps[0],10);
month = arrayIndexOf(window.datetime_short_months,comps[1]);
year = parseInt(comps[2],10);
}
}
var result;
var t = datetime[1];
if (t != null)
{
comps = t.split(":");
var hour = parseInt(comps[0],10);
var min = parseInt(comps[1],10);
var sec = (comps[2] != null ? parseInt(comps[2],10) : 0);
if (datetime[2].toLowerCase() == "pm" || datetime[2].toLowerCase() == window.datetime_pm_string)
hour += 12;
result = new Date(year,month,day,hour,min,sec);
}
else
result = new Date(year,month,day);
if (year < 50)
nlSetFullYear(result, year+2000);
else if (year < 100)
nlSetFullYear(result, year+1900);
return result;
}
function stringtotime(date, time, pm)
{
var flddate = date != null ? stringtodate( date ) : new Date();
if ( !isValEmpty( time ) )
{
var result = time.match( /([0-2]?\d):([0-5]\d)\s*(.*)/ );
var hours = parseInt(result[1]);
var minutes = parseInt(result[2]);
var isPM = result[3].toUpperCase() == window.datetime_pm_string.toUpperCase() || (pm && time.indexOf(pm) != -1);
if (!isPM && hours == 12)
hours = 0;
else if (isPM && hours < 12)
hours += 12;
flddate.setHours(hours,minutes,0,0);
}
return flddate;
}
function hhmmtotime( hhmm )
{
return stringtotime( null, hhmmtotimestring( hhmm ) );
}
// -- handle shorthand time notation i.e. 5p -> 5:00 pm, 18 -> 6:00 pm, 900 -> 9:00 am, 1433p -> 2:33 pm
function hhmmtotimestring( hhmm )
{
var fldvalue = hhmm;
if ( window.datetime_am_string.charAt(0) == window.datetime_pm_string.charAt(0) )
re = new RegExp("^[0-9]{1,4}("+window.datetime_am_string+"|"+window.datetime_pm_string+")*$", "i");
else
re = new RegExp("^[0-9]{1,4}(["+window.datetime_am_string.charAt(0)+"|"+window.datetime_pm_string.charAt(0)+"]?)$","i");
if ( re.test(fldvalue) )
{
var aorp = '';
if ( RegExp.$1 )
{
if ( window.datetime_am_string.charAt(0) == window.datetime_pm_string.charAt(0) )
aorp = RegExp.$1.toLowerCase() == window.datetime_pm_string ? window.datetime_pm_string : window.datetime_am_string;
else
aorp = RegExp.$1.toLowerCase().charAt(0) == window.datetime_pm_string.charAt(0) ? window.datetime_pm_string : window.datetime_am_string;
}
if ( fldvalue.length < 3 || ( fldvalue.length == 3 && RegExp.$1 ) )
{
var hh = RegExp.$1 ? fldvalue.substring(0,fldvalue.length-1) : fldvalue;
hh = parseInt( hh, 10 ) == 0 ? 12 : ( parseInt( hh, 10 ) > 12 ? parseInt( hh, 10 ) % 12 : hh ) ;
var mm = "00";
var ampm = RegExp.$1 ? aorp :
( parseInt( fldvalue, 10 ) > 11 ? window.datetime_pm_string : window.datetime_am_string );
fldvalue = hh + ":" + mm + " "+ampm;
}
else if (fldvalue.length == 3 || (fldvalue.length == 4 && RegExp.$1) )
{
var hh = fldvalue.substring(0,1) == "0" ? "12" : fldvalue.substring(0,1);
var mm = RegExp.$1 ? fldvalue.substring(1,3) : fldvalue.substring(1);
var ampm = RegExp.$1 ? aorp : window.datetime_am_string;
fldvalue = hh + ":" + mm + " "+ampm;
}
else
{
var hh = fldvalue.substring(0,2);
hh = parseInt( hh, 10 ) == 0 ? 12 : ( parseInt( hh, 10 ) > 12 ? parseInt( hh, 10 ) % 12 : hh );
var mm = RegExp.$1 ? fldvalue.substring(2,4) : fldvalue.substring(2);
var ampm = parseInt( fldvalue.substring(0,2), 10 ) > 11 ? window.datetime_pm_string : window.datetime_am_string;
ampm = RegExp.$1 ? aorp : ampm;
fldvalue = hh + ":" + mm + " "+ampm;
}
}
return fldvalue;
}
function adddays(d, daystoadd)
{
var d2 = new Date(d.getTime() + 86400 * daystoadd * 1000);
if (d2.getHours() != d.getHours())
{
if ((d.getHours() > 0 && d2.getHours() < d.getHours()) || (d.getHours() == 0 && d2.getHours() == 23))
d2.setTime(d2.getTime() + 3600*1000);
else
d2.setTime(d2.getTime() - 3600*1000);
}
d.setTime(d2.getTime());
return d;
}
function isLeapYear(year)
{
return (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0));
}
MONTH_LENGTH = [[31,28,31,30,31,30,31,31,30,31,30,31],[31,29,31,30,31,30,31,31,30,31,30,31]];
function getMonthLength(year, month)
{
return MONTH_LENGTH[isLeapYear(year)?1:0][month];
}
function addmonths(d, mtoadd)
{
if (mtoadd != 0)
{
var year = nlGetFullYear(d);
var dom = d.getDate();
var month = d.getMonth() + mtoadd;
if (month < 0)
{
month += 1;
nlSetFullYear(d, year + Math.ceil(month / 12) - 1);
month = 11 + (month % 12);
}
else if (month > 11)
{
nlSetFullYear(d, year + Math.floor(month / 12));
month %= 12;
}
eom = getMonthLength(year, month);
if (dom > eom) d.setDate(eom);
d.setMonth(month);
}
return d;
}
function addhours(d, hourstoadd, truncate)
{
var d2 = new Date(d.getTime() + 3600 * hourstoadd * 1000);
d.setTime(d2.getTime());
if (truncate)
{
d.setMinutes(0);
d.setSeconds(0);
d.setMilliseconds(0);
}
return d;
}
function setDate(d, day, noRollover)
{
if (noRollover)
{
var eom = getMonthLength(nlGetFullYear(d), d.getMonth());
day = Math.min(eom, day);
}
d.setDate(day);
}
function createTDWindow(dest)
{
var wide = screen.width*(0.35);
var high = screen.height*(0.3);
if(wide<150 || high<150)
{
wide = 150;
high = 150;
}
var leftpos = screen.width-(wide+20);
var toppos = screen.height-(high+60);
window.open(dest,'test','scrollbars=yes,width='+wide+',height='+high+',left='+leftpos+',top='+toppos);
}
function DoFieldFocus(form)
{
if (form == null)
return;
var i;
for (i=0;i< form.elements.length;i++)
{
var el = form.elements[i];
if (el.type == "text" || el.type == "select-one" || el.type == "checkbox")
{
el.focus();
return;
}
}
}
function clearMultiSelect(sel)
{
if ( isNLMultiDropDown( sel ) )
getMultiDropdown( sel ).removeAll();
else if (sel.type == "select-multiple")
{
for ( i=sel.length-1; i >=0 ; i-- )
sel.options[i].selected = false;
}
else
{
sel.value='';
sel.form.elements[sel.name+'_display'].value='';
}
}
function getnamevaluelisttext(val,delim,alllabels)
{
if (val.length == 0)
return "";
var nvarray = val.split(String.fromCharCode(4));
var result = "";
for (i=0; i < nvarray.length; i++)
{
var nv = nvarray[i].split(String.fromCharCode(3));
var dv = nv.length==5?nv[4]:nv[3];
if (dv.length > 0 || alllabels == true)
{
if (!isValEmpty(result)) result += delim;
result += nv[2]+": "+dv;
}
}
return result;
}
function getnamevaluelistdata(val)
{
if (val.length == 0)
return "";
var nvarray = val.split(String.fromCharCode(4));
var result = "";
for (i=0; i < nvarray.length; i++)
{
if (i>0)
result += String.fromCharCode(4);
var nv = nvarray[i].split(String.fromCharCode(3));
var v = nv.length>3?nv[3]:"";
result += nv[0]+String.fromCharCode(3)+v;
}
return result;
}
function getnamevaluelistvalue(nvlist,name)
{
if (nvlist.length == 0)
return null;
var nvarray = nvlist.split(String.fromCharCode(4));
for (i=0; i < nvarray.length; i++)
{
var nv = nvarray[i].split(String.fromCharCode(3));
if (nv[0].toLowerCase() == name.toLowerCase())
return nv[3];
}
return null;
}
function getnamevaluelistdisplayvalue(nvlist,name)
{
if (nvlist.length == 0)
return null;
var nvarray = nvlist.split(String.fromCharCode(4));
for (i=0; i < nvarray.length; i++)
{
var nv = nvarray[i].split(String.fromCharCode(3));
if (nv[0].toLowerCase() == name.toLowerCase())
return nv.length==5?nv[4]:nv[3];
}
return null;
}
function setnamevaluelistvalue(nvlist,name,value)
{
if (nvlist.length == 0)
return "";
var nvarray = nvlist.split(String.fromCharCode(4));
for (i=0; i < nvarray.length; i++)
{
var nv = nvarray[i].split(String.fromCharCode(3));
if (nv[0].toLowerCase() == name.toLowerCase())
{
nv[3] = value;
nvarray[i] = nv.join(String.fromCharCode(3));
break;
}
}
return nvarray.join(String.fromCharCode(4));
}
function syncnamevaluelist(list)
{
var fldDisp = list.form.elements[list.name+"_display"];
fldDisp.value = getnamevaluelisttext(list.value,"\n", true);
if(fldDisp.onchange)
{
fldDisp.onchange();
}
}
function NLNameValueList_onKeyPress(evt, sFieldName, sOptionHelperSuffix)
{
var keyCode = getEventKeypress(evt);
if( keyCode == 32 )
{
var ndAction = document.getElementById(sFieldName + '_helper_' + sOptionHelperSuffix);
if( ndAction && ndAction.click)
{
ndAction.click();
}
}
return true;
}
function synclist(list,val,makedefault)
{
if (list.className == 'nldropdown')
{
var dd = getDropdown(list);
if(dd != null)
{
var idx = dd.getIndexForValue(val);
dd.setIndex(idx, true );
if (makedefault)
dd.setDefaultIndex(idx);
}
}
else if (list.type == 'select-one')
{
for (var i=0; i < list.length; i++)
{
if (list.options[i].value == val)
{
list.selectedIndex=i;
if (makedefault)
list.options[i].defaultSelected = true;
break;
}
}
}
else
list.value = val;
}
function syncpopup(list,val,name,makedefault)
{
var i;
if (list.className == 'nldropdown')
{
var dd = getDropdown(list);
var idx = dd.getIndexForValue(val);
dd.setIndex(idx, true );
if (makedefault)
dd.setDefaultIndex(idx);
}
else if (isNLMultiDropDown(list))
{
var dd = getMultiDropdown(list);
dd.setValues(val);
}
else if (list.type == "select-one" || list.type == "select-multiple")
{
for (i=0; i < list.length; i++)
if (list.options[i].value == val)
{
list.selectedIndex=i;
if (makedefault)
list.options[i].defaultSelected = true;
break;
}
}
else if ( isPopupSelect( list ) )
{
list.value = val;
if (makedefault)
list.defaultValue = val;
var dispfld = list.form.elements[list.name+"_display"];
if (val.length > 0 || (name != null && name.length > 0))
{
dispfld.value = name;
if (makedefault)
dispfld.defaultValue = name;
}
else
dispfld.value = dispfld.type == 'text' ? _popup_help : _mult_popup_help;
}
else
{
list.value = val;
if (makedefault)
list.defaultValue = val;
}
}
function syncmultiselectlist(list,val,labels, bDontFireOnChange)
{
clearMultiSelect(list);
if (isNLMultiDropDown(list))
{
if ( typeof val != "string" )
val = val.join( String.fromCharCode(5) );
var dd = getMultiDropdown(list);
dd.setValues(val, bDontFireOnChange);
}
else if (list.type != "select-multiple")
{
list.form.elements[list.name].value = val;
if(labels)
{
var labelsfld = list.form.elements[list.name+"_labels"];
if (labelsfld != null)
labelsfld.value = labels.split('\n').join(String.fromCharCode(5));
}
}
else
{
if ( typeof val == "string" )
val = val.split( String.fromCharCode(5) );
for ( var i=0; i < val.length; i++)
{
for ( var j=0; j < list.length; j++)
{
if (list.options[j].value == val[i])
list.options[j].selected = true;
}
}
}
}
function syncradio(radio,val,makedefault)
{
var i;
for (i=0; i < radio.length; i++)
{
if (radio[i].value == val)
{
radio[i].checked=true;
if (makedefault)
radio[i].defaultChecked = true;
break;
}
}
}
function getlisttext(list, val, frommultisel)
{
if (list.className == 'nldropdown')
return getDropdown(list).getTextForValue(val);
if (list.type != "select-one" && !frommultisel)
return '';
for (var i=0; i < list.length; i++)
if (list.options[i].value == val)
return list.options[i].text;
return "";
}
function getmultiselectlisttext(list, val)
{
if ( isNLMultiDropDown(list) )
{
return getMultiDropdown(list).getSelectedTextFromValues(val, '
');
}
else if (list.type != "select-multiple")
{
return '';
}
else
{
var selvals = val.split(String.fromCharCode(5));
var label = '';
for (i=0; i < selvals.length; i++)
{
if (i > 0) label += '
';
label += getlisttext(list, selvals[i], true);
}
return label;
}
}
function getradiotext(radio, val)
{
var i;
for (i=0;i< radio.length;i++)
if (radio[i].value == val)
return radio[i].textValue;
return "";
}
function getRadioValue(radio)
{
var val = '';
for (var i=0; i < radio.length; i++)
{
if (radio[i].checked == true)
{
val = radio[i].value;
break;
}
}
return val;
}
function getSelectValue(sel)
{
var returnMe;
if (sel.type != null && sel.type == "select-one")
returnMe = (sel.options.length == 0 || sel.selectedIndex == -1 || sel.selectedIndex >= sel.options.length) ? '' : sel.options[sel.selectedIndex].value;
else if (isMultiSelect(sel))
returnMe = getMultiSelectValues(sel);
else if (sel.className == 'nldropdown')
returnMe = getDropdown(sel).getValue();
else if (isNLMultiDropDown(sel))
returnMe = getMultiDropdown(sel).getSelectedValues();
else
returnMe = sel.value;
return returnMe;
}
function getSelectValueArray(sel)
{
var returnMe;
if (sel.type == "select-one" || sel.type == "select-multiple")
{
returnMe = new Array(sel.length);
for ( var i = 0; i < sel.length; i++ )
returnMe[i] = sel.options[i].value;
}
else if (sel.className == 'nldropdown')
returnMe = getDropdown(sel).valueArray;
else if (isNLMultiDropDown(sel))
returnMe = getMultiDropdown(sel).valueArray;
return returnMe;
}
function getIndexForValue(sel,val)
{
var returnM=-1;
if (sel.type == "select-one" || sel.type == "select-multiple")
{
for ( var i = 0; i < sel.length; i++ )
if(sel.options[i].value==val)
{
returnMe=i;
break;
}
}
else if (sel.className == 'nldropdown')
returnMe = getDropdown(sel).getIndexForValue(val);
else if (isNLMultiDropDown(sel))
returnMe = getMultiDropdown(sel).getIndexForValue(val);
return returnMe;
}
function getSelectTextForValue( sel, val )
{
var textArray = getSelectValueArray(sel);
var i;
for (i = 0; i < textArray.length; i++)
{
if (textArray[i] == val)
return getSelectTextAtIndex(sel, i);
}
return null;
}
function getSelectTextArray(sel)
{
var returnMe;
if (sel.type == "select-one" || sel.type == "select-multiple")
{
returnMe = new Array(sel.length);
for ( var i = 0; i < sel.length; i++ )
returnMe[i] = sel.options[i].text;
}
else if (sel.className == 'nldropdown')
returnMe = getDropdown(sel).textArray;
else if (isNLMultiDropDown(sel))
returnMe = getMultiDropdown(sel).textArray;
return returnMe;
}
function getSelectText(sel)
{
if (sel.type == "select-one")
return (sel.options.length == 0 || sel.selectedIndex == -1 || sel.selectedIndex >= sel.options.length) ? null : sel.options[sel.selectedIndex].text;
else if (sel.className == 'nldropdown')
return getDropdown(sel).getText();
else if ( isMultiSelect(sel) )
return getMultiSelectText( sel );
else if (sel.type == "hidden" && sel.form != null && getFormElement(sel.form,sel.name+'_display') != null)
return getFormElement(sel.form,sel.name+'_display').value.replace(/\s$/,'');
else
return sel.text;
}
function copySelectValue(sel, sel2)
{
if (sel2.type == "hidden" && sel2.form != null && getFormElement(sel2.form,sel2.name+'_display') != null)
{
sel2.value = getSelectValue(sel);
if (sel2.value.length > 0)
getFormElement(sel2.form,sel2.name+'_display').value = getSelectText(sel);
}
else
setSelectValue(sel2,getSelectValue(sel));
}
function setSelectValue(sel, val)
{
if (sel.className == 'nldropdown')
{
var dd = getDropdown(sel);
var idx = dd.getIndexForValue(val);
if (idx == null)
return false;
dd.setIndex(idx, true );
if(dd.isOpen)
dd.setCurrentCellInMenu(dd.divArray[idx]);
}
else if (isNLMultiDropDown(sel))
{
var dd = getMultiDropdown(sel);
var idx = dd.getIndexForValue(val);
if (idx == null)
return false;
dd.setIndex(idx);
}
else if (sel.type == "select-one")
{
var opt = sel.options;
for (var i=0; i < opt.length; i++)
{
if (opt[i].value==val)
{
sel.selectedIndex=i;
return true;
}
}
return false;
}
else if (sel.type == "select-multiple")
{
var opts = sel.options;
var result = false;
for (var i=0; i < opts.length; i++)
{
opts[i].selected = opts[i].value == val;
result = result || opts[i].value == val;
}
return result;
}
else
sel.value = val;
return true;
}
function addMultiSelectValue(sel, val, name)
{
if (isNLMultiDropDown(sel))
{
var dd = getMultiDropdown(sel);
var idx = dd.getIndexForValue(val);
dd.addIndex(idx);
}
else if (sel.type == "select-multiple")
{
var opts = sel.options;
for (var i=0; i < opts.length; i++)
if ( opts[i].value == val )
opts[i].selected = true;
}
else
{
var values = sel.value.split(String.fromCharCode(5));
for (var i=0;i < values.length;i++)
if (values[i] == val) return;
if (values.length == 0 || values[0].length == 0)
{
sel.value = val;
sel.form.elements[sel.name+"_display"].value = name;
sel.form.elements[sel.name+"_labels"].value = name;
}
else
{
sel.value += String.fromCharCode(5)+val;
sel.form.elements[sel.name+"_labels"].value += String.fromCharCode(5)+name;
var lines = sel.form.elements[sel.name+"_display"].value.split(/\n|\r/);
if (lines.length == values.length)
sel.form.elements[sel.name+"_display"].value += "\n"+name;
else
{
lines[values.length] = name;
sel.form.elements[sel.name+"_display"].value = lines.join("\n");
}
}
}
}
function getSelectValueForText(sel, txt)
{
var textArray = getSelectTextArray(sel);
var i;
for (i = 0; i < textArray.length; i++)
{
if (textArray[i] == txt)
return getSelectValueAtIndex(sel, i);
}
return null;
}
function deleteAllSelectOptions(sel, win)
{
if (sel.className == 'nldropdown')
{
getDropdown(sel, win).deleteAllOptions();
}
else if (isNLMultiDropDown(sel))
{
getMultiDropdown(sel, win).deleteAllOptions();
}
else if (sel.type == 'select-one' || sel.type == 'select-multiple')
{
sel.options.length = 0;
}
else if ( sel.form.elements[sel.name+"_display"] != null )
{
sel.form.elements[sel.name+"_display"].value = "";
sel.value = "";
}
}
function deleteOneSelectOption(sel, value, bDontSetWidth)
{
if (sel.className == 'nldropdown')
{
getDropdown(sel).deleteOneOption(value, bDontSetWidth);
}
else if (isNLMultiDropDown(sel))
{
getMultiDropdown(sel).deleteOneOption(value);
}
else if (sel.type == 'select-one' || sel.type == 'select-multiple')
{
var opts = sel.options;
for (var i=0; i < opts.length; i++)
if (opts[i].value == value)
opts[i] = null;
}
else if ( sel.form.elements[sel.name+"_display"] != null )
{
sel.form.elements[sel.name+"_display"].value = "";
sel.value = "";
}
}
function getSelectIndex(sel,win)
{
if (sel.className == 'nldropdown')
{
return getDropdown(sel,win).getIndex();
}
else
{
return sel.selectedIndex;
}
}
function setSelectIndex(sel, val)
{
if (sel.className == 'nldropdown')
{
return getDropdown(sel).setIndex(val, true );
}
else if (isNLMultiDropDown(sel))
{
return getMultiDropdown(sel).setIndex(val);
}
else
{
sel.selectedIndex = val;
}
}
function setMultiSelectValues(sel, val)
{
syncmultiselectlist( sel, val );
}
function getMultiSelectValues( sel, returnArray )
{
var val = null;
if (isMultiSelect(sel))
{
if ( isNLMultiDropDown(sel) )
val = getMultiDropdown(sel).getSelectedValues();
else
{
val = '';
for (var i=0; i < sel.length; i++)
{
if (sel.options[i].selected)
val += ((val == '' ? '' : String.fromCharCode(5)) + sel.options[i].value);
}
}
}
else
val = sel.value;
if ( returnArray && val != null )
val = val.split( String.fromCharCode(5) );
return val;
}
function getMultiSelectText(sel,inmachine)
{
if ( isMultiSelect(sel) )
{
var val = '';
if ( isNLMultiDropDown(sel) )
val = getMultiDropdown(sel).getSelectedText(inmachine ? '\n' : ', ');
else
{
var i, numParams = 0;
for (i=0; i < sel.length; i++)
{
if (sel.options[i].selected)
val += ((numParams++ == 0 ? '' : (inmachine ? '\n' : ', ')) + sel.options[i].text);
}
}
return val;
}
else if ( isPopupSelect(sel) )
return getFormElement(sel.form,sel.name+'_display').value;
else
return sel.text;
}
function updateMultiSelectValue(fld,displayfld,val,displayval,labelsfld)
{
fld.value = val;
labelsfld.value = displayval;
var sellabels = displayval.split(String.fromCharCode(5));
var displaytempval = '', numParams = 0;
for (i=0; i < sellabels.length; i++)
{
displaytempval += ((numParams==0 ? '' : '\n') + sellabels[i]) ;
numParams++;
}
displayfld.value = displaytempval;
}
function addSelectOption(doc,sel,text,value,selected,win)
{
if (sel.className == 'nldropdown')
{
var dd = getDropdown(sel,win);
dd.addOption(text, value);
if (selected !== false)
{
var idx = dd.getIndexForValue(value);
dd.setIndex(idx, true );
}
}
else if (isNLMultiDropDown(sel))
{
var dd = getMultiDropdown(sel,win);
dd.addOption(text, value, selected);
}
else
{
var opt = doc.createElement('OPTION');
opt.text= text;
opt.value= value;
if (isIE)
{
if (typeof(idx)=='undefined') idx = sel.length;
sel.add(opt, idx);
}
else
{
var optInsertBefore = null;
if (typeof(idx)!='undefined' && idx >=0 && idx < sel.length)
optInsertBefore = sel.options[idx];
sel.add(opt, optInsertBefore);
}
if (selected !== false)
{
opt.selected = true;
if (isIE)
sel.selectedIndex = sel.length - 1;
}
}
}
function setSelectOptionText(sel,value,text,win)
{
if (sel.className == 'nldropdown')
{
var dd = getDropdown(sel,win);
dd.setOptionText(value,text);
}
else if (sel.type == 'select-one' || sel.type == 'select-multiple')
{
var opts = sel.options;
for (var i=0; i < opts.length; i++)
if (opts[i].value == value)
opts[i].text = text;
}
}
function getCascadedStyle(object, property, attribute)
{
if ( object.currentStyle )
return object.currentStyle[property];
else if ( window.getComputedStyle )
{
if ( object.nodeType != 1 )
return null;
var objStyle = window.getComputedStyle(object, "");
return objStyle.getPropertyValue( attribute );
}
return null;
}
function isFocusable( fld )
{
if ( fld == null || fld.type == "hidden" || fld.disabled || fld.type == "button")
return false;
return elementIsFocusable(fld);
}
function elementIsFocusable(elem)
{
while ( elem != null )
{
var visibility = getCascadedStyle(elem, "visibility", "visibility");
var display = getCascadedStyle(elem, "display", "display");
if ( display == 'none' || visibility == 'hidden' || visibility == 'hide' )
return false;
elem = elem.parentNode;
}
return true;
}
function isPopupSelect(sel)
{
return sel != null && sel.type == "hidden" && getFormElement(sel.form, sel.name+'_display' ) != null && getFormElement(sel.form, sel.name+'_display' ).type == "text";
}
function isPopupMultiSelect(sel)
{
return isPopupSelect( sel ) && getFormElement(sel.form, sel.name+'_labels' ) != null;
}
function isSelect(sel)
{
return sel != null && ( sel.type == "select-one" || isNLDropDown( sel ) );
}
function isNLDropDown(sel)
{
return sel != null && sel.className == 'nldropdown';
}
function isMultiSelect(sel)
{
return sel != null && (isNLMultiDropDown(sel) || sel.multiple || sel.type == 'select-multiple');
}
function isNLMultiDropDown(sel)
{
return sel != null && sel.getAttribute && !isValEmpty(sel.getAttribute("nlmultidropdown"));
}
function resetlist(sel)
{
if ( sel != null )
{
if (sel.type == "select-one" || sel.type == 'select-multiple')
{
var i;
for (i=0; i < sel.length; i++)
{
if (sel.options[i].defaultSelected)
{
sel.selectedIndex=i;
return;
}
}
sel.selectedIndex=0;
}
else if (sel.className == 'nldropdown')
{
getDropdown(sel).resetDropDown();
}
else if (isNLMultiDropDown(sel))
{
getMultiDropdown(sel).resetDropDown();
}
else
{
sel.value = sel.defaultValue;
sel.form.elements[sel.name+"_display"].value = sel.form.elements[sel.name+"_display"].defaultValue;
}
}
}
function setSelectFocus(sel,win)
{
if ( sel != null )
{
if (sel.type == "select-one" || sel.type == "select-multiple")
{
if ( isFocusable( sel ) )
sel.focus();
}
else if (sel.className == 'nldropdown')
{
if ( isFocusable( getDropdown(sel,win).getContainer( ) ) )
getDropdown(sel,win).setFocus();
}
else if (isNLMultiDropDown(sel))
{
if ( isFocusable( getMultiDropdown(sel,win).getContainer( ) ) )
getMultiDropdown(sel,win).setFocus();
}
else
{
if ( isFocusable( sel.form.elements[sel.name+"_display"] ) )
sel.form.elements[sel.name+"_display"].focus();
}
}
}
function restoreSelectToOriginalValue(sel, win)
{
if(sel != null)
{
if (sel.type == "select-one" || sel.type == "select-multiple")
{
var valueWhenRendered = sel.getAttribute("valuewhenrendered");
if(valueWhenRendered != null && valueWhenRendered.length > 0)
setSelectValue(sel, valueWhenRendered);
}
else if (sel.className == 'nldropdown')
{
getDropdown(sel, win).restoreToOriginalValue();
}
}
}
function disableSelect(sel, val, win)
{
if ( sel != null )
{
var doc = win != null ? win.document : sel.document != null ? sel.document : window.document;
if (sel.type == "select-one" || sel.type == "select-multiple")
sel.disabled = val;
else if (sel.className == 'nldropdown')
getDropdown(sel, win).setDisabled(val);
else if (isNLMultiDropDown(sel))
getMultiDropdown(sel, win).setDisabled(val);
else
{
var displaytext = sel.form.elements[sel.name+"_display"];
if (displaytext != null)
displaytext.disabled=val;
var listlink = doc.getElementById(sel.name+"_popup_list");
if (listlink != null)
listlink.style.visibility = val ? "hidden" : "inherit";
var searchlink = doc.getElementById(sel.name+"_popup_search");
if (searchlink != null)
searchlink.style.visibility = val ? "hidden" : "inherit";
var alllink = doc.getElementById(sel.name+"_popup_all");
if (alllink != null)
alllink.style.visibility = val ? "hidden" : "inherit";
}
var newlink = isNS4x ? null : doc.getElementById(sel.name+"_popup_new");
if (newlink != null)
newlink.style.visibility = val ? "hidden" : "inherit";
var linklink = isNS4x ? null : doc.getElementById(sel.name+"_popup_link");
if (linklink != null)
linklink.style.visibility = val ? "hidden" : "inherit";
}
}
function getSelectValueAtIndex(sel, idx)
{
if ( sel != null )
{
if (sel.type == "select-one" || sel.type == "select-multiple")
{
if ((sel.options != null) && (sel.options.length > idx))
return sel.options[idx].value;
else
return null;
}
else if (sel.className == 'nldropdown')
{
return getDropdown(sel).getValueAtIndex(idx);
}
else if (isNLMultiDropDown(sel))
{
return getMultiDropdown(sel).getValue(idx);
}
}
}
function getSelectTextAtIndex(sel, idx)
{
if ( sel != null )
{
if (sel.type == "select-one" || sel.type == "select-multiple")
{
if ((sel.options != null) && (sel.options.length > idx))
return sel.options[idx].text;
else
return null;
}
else if (sel.className == 'nldropdown')
{
return getDropdown(sel).getTextAtIndex(idx);
}
else if (isNLMultiDropDown(sel))
{
return getMultiDropdown(sel).getText(idx);
}
}
}
function setRequired(fld,required)
{
if ( fld.className == 'nldropdown')
getDropdown(fld).setRequired(required);
else if ( isNLMultiDropDown( fld ) )
getMultiDropdown(fld).setRequired(required);
else if ( window.getHtmlEditor != null && getHtmlEditor( fld.name ) != null && getHtmlEditor(fld.name).setMandatory)
getHtmlEditor( fld.name ).setMandatory( required );
else if ( fld.form != null && fld.form.elements[fld.name+"_display"] != null )
fld.form.elements[fld.name+"_display"].className = 'input' + (required ? 'req' : '');
else
fld.className='input' + (required ? 'req' : '');
}
function setDefaultOrNotRequired(fld, val)
{
setRequired(fld, val ? hasAttribute(fld, 2048) : false);
}
function hasAttribute(fld,flag)
{
if ( fld.className == 'nldropdown' )
return getDropdown(fld).hasAttribute(flag);
else if ( isNLMultiDropDown( fld ) )
return getMultiDropdown(fld).hasAttribute(flag);
else if ( window.getHtmlEditor != null && getHtmlEditor( fld.name ) != null )
return getHtmlEditor(fld.name).hasAttribute(flag);
else
return (fld.getAttribute("flags") & flag) != 0;
}
function getRequired(fld)
{
if ( fld.className == 'nldropdown' )
return getDropdown(fld).getRequired( );
else if ( isNLMultiDropDown( fld ) )
return getMultiDropdown(fld).getRequired( );
else if ( window.getHtmlEditor != null && getHtmlEditor( fld.name ) )
return getHtmlEditor( fld.name ).getMandatory( );
else if ( fld.form != null && fld.form.elements[fld.name+"_display"] != null )
return fld.form.elements[fld.name+"_display"].className == 'inputreq';
else
return fld.className == 'inputreq' || fld.className == 'inputrtreq';
}
function disableField(fld, val)
{
if (fld == null)
return;
if (fld.className == 'nldropdown' || isNLMultiDropDown(fld) || fld.form.elements[fld.name+"_display"] != null)
disableSelect(fld, val);
else if ( window.getHtmlEditor != null && getHtmlEditor( fld.name ) != null )
getHtmlEditor( fld.name ).setDisabled( val );
else
{
fld.disabled = val;
var docObj = (fld.document) ? fld.document : document;
var datelink = docObj.getElementById(fld.name+"_helper_calendar");
if(datelink != null)
datelink.style.visibility = val ? "hidden" : "inherit";
}
}
function setOptionsFromMachineField( machine_name, field_name, selectObject, alternate_label, test_field, test_value )
{
deleteAllSelectOptions( selectObject, window );
var doc = window.document;
var mch = eval( machine_name + '_machine');
addSelectOption( doc, selectObject, "", "", true, window );
var bNewOptions = false;
for ( var i = 1; i <= getLineCount(machine_name); i++)
{
if (mch.getMachineIndex() == i || ( test_field != null && getEncodedValue( machine_name, i, test_field) != test_value ) )
continue;
bNewOptions = true;
addSelectOption( doc, selectObject, getEncodedValue( machine_name,i, alternate_label != null ? alternate_label :field_name + '_display'), getEncodedValue( machine_name,i,field_name ), false, window);
}
return bNewOptions;
}
function getSyncFunctionName(fldname, machine)
{
var syncFuncName = "Sync"+fldname;
if ( machine != null )
{
var machSyncFunc = syncFuncName + machine;
if ( eval( "window." + machSyncFunc ) != null )
return machSyncFunc;
}
return syncFuncName;
}
function safeSetDocumentLocation(url)
{
try {
document.location = url;
} catch (e) {}
}
function addParamToURL(url, param, value,replace)
{
if ( url == null )
return null;
if (url.length && url.charAt(url.length - 1) == '#')
url = url.substring(0, url.length - 1);
if ( isValEmpty( param ) )
return url;
if (replace == true)
url = removeParamFromURL(url,param);
return addNextParamPrefixToURL( url ) + param + "=" + emptyIfNull(value);
}
function addNextParamPrefixToURL( url )
{
return url + ( url.indexOf("?") == -1 ? "?" : "&" );
}
function removeParamFromURL(url, param)
{
var sep = "&";
var startIndex = url.indexOf("&"+param+"=");
if (startIndex == -1)
{
startIndex = url.indexOf("?"+param+"=")
sep = "?";
}
if (startIndex != -1)
{
var endIndex = url.indexOf("&",startIndex+1);
return url.substring(0,startIndex)+ (endIndex > 0 ? (sep == "?" ? "?"+url.substr(endIndex+1) : url.substr(endIndex)) : "");
}
return url;
}
function formEncodeURLParams( params )
{
var paramString = '';
for ( var param in params )
paramString += (isValEmpty(paramString) ? '' : '&') + escape( param ) + '=' + escape( emptyIfNull( params[param] ) );
return paramString;
}
function previewMedia(mediaid, bIsHref, document)
{
if (bIsHref)
mediaid = mediaid.substr(mediaid.lastIndexOf('/')+1);
var url = '/core/media/previewmedia.nl?id='+mediaid;
preview(url, 'prevmedia');
}
function previewTemplate(id, entity)
{
var url = '/app/crm/common/merge/previewtemplate.nl?id='+id;
if ( !isValEmpty(entity) )
url = addParamToURL( url, 'entity', entity );
preview(url, 'previewtemplate');
}
function siteMedia(mediaid, bIsHref, document)
{
if (bIsHref)
mediaid = mediaid.substr(mediaid.lastIndexOf('/')+1);
var url = '/app/site/media/sitemedia.nl?id='+mediaid;
preview(url, 'sitemedia');
}
function preview(url, winname)
{
var prms = 'location=no,width=600,height=500,menubar=yes,scrollbars=yes,resizable=yes';
var win = window.open(url, winname, prms);
win.focus();
}
function getCookieVal(offset)
{
var endstr = document.cookie.indexOf (';', offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie(name)
{
var arg = name + '=';
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
{
var val = getCookieVal(j);
if ( name == 'JSESSIONID' && val != null && val.indexOf('.') != -1 )
val = val.substring( 0, val.indexOf('.') );
return val;
}
i = document.cookie.indexOf(' ', i) + 1;
if (i == 0) break;
}
return null;
}
function getStickyTag( pageName )
{
var cbody = GetCookie('stickytags');
if (cbody != null)
{
var b=cbody.indexOf(','+pageName+':') + 1;
if (b>=1)
{
var e=cbody.indexOf(',',b);
if (e<0)
e=cbody.length;
return unescape(cbody.substring(b+pageName.length+1, e));
}
}
return null;
}
function addStickyTagToUrl(url, pageName)
{
return url + (url.indexOf('?') >= 0 ? '&t=' : '?t=') + getStickyTag(pageName);
}
function redirectToStickyPage(url,pageName,framed)
{
var newUrl = addStickyTagToUrl(url, pageName);
try {
if (typeof(framed) == "number")
parent.frames[framed].document.location = newUrl;
else if (framed)
parent.document.location = newUrl;
else
document.location = newUrl;
} catch (e) { }
}
var SelectKeyPressMaxKeyPause = 2000;
function SelectKeyPressHandler (evnt, sorted)
{
keyString = String.fromCharCode (getEventKeypress(evnt)).toUpperCase();
if (!(keyString >= " " && keyString <= "_"))
{
SelectKeyPressTypedString = "";
return true;
}
if (SelectKeyPressTimeoutID != null)
window.clearTimeout (SelectKeyPressTimeoutID);
SelectKeyPressTimeoutID = window.setTimeout ("SelectKeyPressTimeout()",
SelectKeyPressMaxKeyPause);
SelectKeyPressTypedString += keyString;
if (sorted)
{
if (SelectKeyPressTypedString.length == 1)
option = SelectKeyPressLookupFirst (evnt, SelectKeyPressTypedString);
else
option = SelectKeyPressLookupNext (evnt, SelectKeyPressTypedString);
}
else
option = SelectKeyPressLookupLinear (evnt, SelectKeyPressTypedString);
setEventPreventDefault(evnt);
if (option != -1)
{
getEventTarget(evnt).selectedIndex = option;
getEventTarget(evnt).onchange();
}
return false;
}
var SelectKeyPressTypedString = "";
SelectKeyPressTimeoutID = null;
function SelectKeyPressTimeout ()
{
SelectKeyPressTypedString = "";
SelectKeyPressTimeoutID = null;
}
function SelectKeyPressLookupFirst (evnt, str)
{
select = getEventTarget(evnt);
options = select.options;
low = 0;
high = options.length;
while (high - low > 1)
{
i = Math.floor ((high + low) / 2);
if (str.charAt(0) <= options(i).text.charAt(0).toUpperCase())
high = i;
else
low = i;
}
while (high > 0 &&
str.charAt(0) == options(high - 1).text.charAt(0).toUpperCase())
--high;
if (high < options.length &&
str.charAt(0) == options(high).text.charAt(0).toUpperCase())
return high;
else
return -1;
}
function SelectKeyPressLookupNext (evnt, str)
{
select = getEventTarget(evnt);
options = select.options;
selIndex = select.selectedIndex;
while (selIndex < options.length - 1 &&
options(selIndex).text.toUpperCase() < str)
++selIndex;
if (selIndex < options.length - 1 &&
options(selIndex).text.substr(0, str.length).toUpperCase() == str)
return selIndex;
else
return -1;
}
function SelectKeyPressLookupLinear (evnt, str)
{
select = getEventTarget(evnt);
options = select.options;
for (i = 0; i < options.length; ++i)
if (options(i).text.substr(0, str.length).toUpperCase() == str)
return i;
return -1;
}
function disableFilter(radio, disableVal, fld1,fld2)
{
if (getRadioValue(radio) == disableVal)
{
fld1.disabled = true;
if (fld2)
fld2.disabled = true;
}
else
{
fld1.disabled = false;
if (fld2)
fld2.disabled = false;
}
}
function NLDate_parseString(sDate, bDoAlert)
{
var m=0;
var d=0;
var y=0;
var val = sDate;
var fmterr;
var year="";
var rtnDate = null;
if(!window.dateformat)
window.dateformat = "MM/DD/YYYY";
if(window.dateformat == "MM/DD/YYYY")
{
if (val.indexOf("/") != -1)
{
var c = val.split("/");
if(onlydigits(c[0])) m = parseInt(c[0],10);
if(onlydigits(c[1])) d = parseInt(c[1],10);
if ( d > 1970 )
{
year = y = d;
d = 1;
}
else
{
if(onlydigits(c[2])) y = parseInt(c[2],10);
year=c[2];
}
}
else
{
var l = val.length, str;
str = val.substr(0,2-l%2); if(onlydigits(str)) m = parseInt(str,10);
str = val.substr(2-l%2,2); if(onlydigits(str)) d = parseInt(str,10);
str = val.substr(4-l%2); if(onlydigits(str)) y = parseInt(str,10);
year=str;
}
fmterr = "MM/DD/YY, MM/DD/YYYY, MMDDYY or MMDDYYYY";
}
else if(window.dateformat == "DD/MM/YYYY")
{
if (val.indexOf("/") != -1)
{
var c = val.split("/");
if(onlydigits(c[0])) d = parseInt(c[0],10);
if(onlydigits(c[1])) m = parseInt(c[1],10);
if(onlydigits(c[2])) y = parseInt(c[2],10);
year=c[2];
}
else
{
var l = val.length, str;
str = val.substr(0,2-l%2); if(onlydigits(str)) d = parseInt(str,10);
str = val.substr(2-l%2,2); if(onlydigits(str)) m = parseInt(str,10);
str = val.substr(4-l%2); if(onlydigits(str)) y = parseInt(str,10);
year=str;
}
fmterr = "DD/MM/YY, DD/MM/YYYY, DDMMYY or DDMMYYYY";
}
else if(window.dateformat == "YYYY/MM/DD")
{
if (val.indexOf("/") != -1)
{
var c = val.split("/");
if(onlydigits(c[0])) y = parseInt(c[0],10);
if(onlydigits(c[1])) m = parseInt(c[1],10);
if(onlydigits(c[2])) d = parseInt(c[2],10);
year=c[0];
}
else
{
var l = val.length, str;
str = val.substr(0,2-l%2); if(onlydigits(str)) y = parseInt(str,10);
str = val.substr(2-l%2,2); if(onlydigits(str)) m = parseInt(str,10);
str = val.substr(4-l%2); if(onlydigits(str)) d = parseInt(str,10);
year=str;
}
fmterr = "YY/MM/DD, YYYY/MM/DD, YMMDD or YYYYMMDD";
}
else if(window.dateformat == "DD.MM.YYYY")
{
if (val.indexOf(".") != -1)
{
var c = val.split(".");
if(onlydigits(c[0])) d = parseInt(c[0],10);
if(onlydigits(c[1])) m = parseInt(c[1],10);
if(onlydigits(c[2])) y = parseInt(c[2],10);
year=c[2];
}
else
{
var l = val.length, str;
str = val.substr(0,2-l%2); if(onlydigits(str)) d = parseInt(str,10);
str = val.substr(2-l%2,2); if(onlydigits(str)) m = parseInt(str,10);
str = val.substr(4-l%2); if(onlydigits(str)) y = parseInt(str,10);
year=parseInt(str,10);
}
fmterr = "DD.MM.YY, DD.MM.YYYY, DDMMYY or DDMMYYYY";
}
else if(window.dateformat == "DD-Mon-YYYY")
{
if (val.indexOf("-") != -1)
{
var c = val.split("-");
if(onlydigits(c[0])) d = parseInt(c[0],10);
m = getMonthIndex(c[1]);
if(onlydigits(c[2])) y = parseInt(c[2],10);
year=c[2];
}
else
{
var l = val.length, str;
str = val.substr(0,1+l%2); if(onlydigits(str)) d = parseInt(str,10);
str = val.substr(1+l%2,3);
m = getMonthIndex(str);
str = val.substr(4+l%2); if(onlydigits(str)) y = parseInt(str,10);
year=str;
}
fmterr = "DD-Mon-YY, DD-Mon-YYYY, DDMonYY or DDMonYYYY";
}
if(m==0 || d==0)
{
if(bDoAlert)
{
alert("Invalid date value (must be "+fmterr+")");
}
}
else
{
if (y==0 && !onlydigits(year)) y = (new Date()).getFullYear();
if(m<1) m=1; else if(m>12) m=12;
if(d<1) d=1; else if(d>31) d=31;
if(y<100) y+=((y>=70)?1900:2000);
if(y<1000) y*=10;
if (y > 9999) y = (new Date()).getFullYear();
year = y;
rtnDate = new Date(y, m-1, d);
}
return rtnDate;
}
function getMonthIndex(sMonth)
{
var m = -1;
for ( var i=0; i < NLDate_short_months.length; i++ )
{
if ( NLDate_short_months[i].toUpperCase() == sMonth.toUpperCase() )
{
m = i + 1; break;
}
}
if ( m == -1 )
{
var ms = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
m = (ms.indexOf(sMonth.toUpperCase())+3)/3;
}
return m;
}
var NLDate_pnDaysInMonths = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
function NLDate_getLastDayOfMonth(dDate)
{
var m = dDate.getMonth();
var days = NLDate_pnDaysInMonths[m];
if(m == 1)
{
var y = dDate.getYear();
if ( (y% 400 == 0) || ((y % 4 == 0) && (y % 100 != 0)) )
days++;
}
return days;
}
function setDateComponents(theDate, monthsToAdd, theDay, noRollover)
{
var newDate = new Date(theDate);
if (typeof(noRollover) != 'boolean')
noRollover = false;
addmonths(newDate,monthsToAdd);
setDate(newDate, theDay, noRollover);
return newDate;
}
function setDisabledState(elementid,enable)
{
var childnodes=document.getElementById(elementid).getElementsByTagName('INPUT');
for(var i=0;i< childnodes.length;i++)
{
if(childnodes[i].name.indexOf('_send')==-1)
childnodes[i].disabled=!enable;
}
var childnodes=document.getElementById(elementid).getElementsByTagName('A');
for(var i=0;i< childnodes.length;i++)
{
if(!enable && !childnodes[i].disabled)
{
childnodes[i].enabledonclick=childnodes[i].onclick;
childnodes[i].onclick= new Function('return false;');
}
else if (enable && childnodes[i].enabledonclick!=null && childnodes[i].disabled)
{
childnodes[i].onclick=childnodes[i].enabledonclick;
}
childnodes[i].disabled=!enable;
}
}
function checkMandatoryFields(fields,labels)
{
var result = "";
for (i=0; i < fields.length; i++)
{
if (fields[i] == null)
continue;
if ((new String(fields[i].value)).indexOf(String.fromCharCode(3)) != -1)
{
var nvarray = fields[i].value.split(String.fromCharCode(4));
for (j=0; j < nvarray.length; j++)
{
var nv = nvarray[j].split(String.fromCharCode(3));
if (nv[1] == 'T' && nv[3].length == 0)
result += (result.length ? ", " : "") + nv[2];
}
continue;
}
if (!getRequired(fields[i]))
continue;
if (fields[i].type == "select-one")
{
var field = (fields[i].selectedIndex == -1? "" : fields[i].options[fields[i].selectedIndex]);
var val = (field == null ? "" : field.value);
if (val == null || val.length == 0 || val == -1)
result += (result.length ? ", " : "") + labels[i];
}
else if ( window.getHtmlEditor != null && getHtmlEditor( fields[i].name ) != null )
{
if ( isValEmpty( fields[i].value.replace("","") ) )
result += (result.length ? ", " : "") + labels[i];
}
else
{
if ( isempty(fields[i]) )
result += (result.length ? ", " : "") + labels[i];
}
}
return result;
}
function nlOpenWindow(url, winname, widthOrFeatures, height, fld, scrollbars)
{
if ( window.doPageLogging )
logStartOfRequest( 'popup' );
if ( widthOrFeatures == null )
return window.open(url, winname);
else if ( isNaN(parseInt( widthOrFeatures )) )
return window.open(url, winname, widthOrFeatures);
else if ( isIE )
return window.open(url, winname, 'scrollbars='+(scrollbars ? 'yes' : 'no')+',width='+Math.min(screen.availWidth,widthOrFeatures)+',height='+Math.min( screen.availHeight-40,height)+',left='+Math.min(screen.availWidth-widthOrFeatures,getObjectLeft(fld))+',top='+Math.min( (screen.availHeight-40)-height,getObjectTop(fld))+',resizable=yes');
else
return window.open(url, winname, 'scrollbars='+(scrollbars ? 'yes' : 'no')+',width='+widthOrFeatures+',height='+height+',resizable=yes');
}
function getObjectLeft(obj)
{
var offset=0;
while (obj != null && obj != document.body)
{
offset += obj.offsetLeft;
obj = obj.offsetParent;
}
return offset + (isIE ? window.screenLeft : window.screenX + window.outerWidth - window.innerWidth);
}
function getObjectTop(obj)
{
var offset=0;
while (obj != null && obj != document.body)
{
offset += obj.offsetTop;
obj = obj.offsetParent;
}
if (isIE)
return offset + window.screenTop;
//mozilla browsers
var statusbarHeight = 0;
if (typeof window.statusbar != "undefined" && window.statusbar != null && window.statusbar.visible)
statusbarHeight = 20; //rough number
return offset + window.screenY + window.outerHeight - window.innerHeight - statusbarHeight;
}
function setFieldVisibility ( spanId, on )
{
var spanInput = document.getElementById( spanId );
visible ( spanInput, on );
}
function setLabelVisibility ( spanId, on )
{
var spanLabel = document.getElementById( spanId + "_lbl" );
visible( spanLabel, on );
}
function setFieldAndLabelVisibility( spanId, on )
{
setLabelVisibility( spanId, on );
setFieldVisibility( spanId, on );
}
function showField ( spanId, on )
{
var spanInput = document.getElementById( spanId );
display ( spanInput, on );
}
function showLabel ( spanId, on )
{
var spanLabel = document.getElementById( spanId + "_lbl" );
display( spanLabel, on );
}
function showHelperText ( spanId, on )
{
var spanLabel = document.getElementById( spanId + "_hlp" );
display( spanLabel, on );
}
function setLabel( spanId, label)
{
var spanLabel = document.getElementById( spanId + "_lbl" );
spanLabel.innerHTML = label;
}
function getLabel( spanId )
{
var spanLabel = document.getElementById( spanId + "_lbl" );
return spanLabel.innerHTML;
}
function showFieldAndLabel( spanId, on )
{
showLabel( spanId, on );
showField( spanId, on );
}
function showSpan( spanToShow, spanSet, mach )
{
var children = spanSet.childNodes;
var disp;
for (var i=0; i < children.length; i++)
{
if (children[i].nodeName == 'SPAN')
{
var span = children[i];
if ( span.id == spanToShow )
disp = span;
else if (span.style.display != 'none' )
display( span, false );
}
}
getFieldSetSpan( spanSet ).value = spanToShow;
if ( disp != null )
display( disp, true );
if ( mach != null )
{
var table = document.getElementById(mach.getTableName());
var newRow = table.rows[mach.getMachineIndex() ];
moveButtons( mach.name, newRow );
}
}
function hideTab( tabName, hide )
{
var displayVal = hide ? 'none' : '';
var elem = document.getElementById(tabName + 'upperlt');
if (elem != null)
elem.style.display = displayVal;
elem = document.getElementById(tabName + 'uppermiddot');
if (elem != null)
elem.style.display = displayVal;
elem = document.getElementById(tabName + 'uppermid');
if (elem != null)
elem.style.display = displayVal;
elem = document.getElementById(tabName + 'upperrt');
if (elem != null)
elem.style.display = displayVal;
var elem = document.getElementById(tabName + 'lt');
if (elem != null)
elem.style.display = displayVal;
elem = document.getElementById(tabName + 'lnkdot');
if (elem != null)
elem.style.display = displayVal;
elem = document.getElementById(tabName + 'lnk');
if (elem != null)
elem.style.display = displayVal;
elem = document.getElementById(tabName + 'rt');
if (elem != null)
elem.style.display = displayVal;
elem = document.getElementById(tabName + '_layer');
if (elem != null)
elem.style.display = displayVal;
elem = document.getElementById(tabName + '_umh');
if (elem != null)
elem.style.display = displayVal;
}
function setFormValue(fld,value)
{
if (fld == null)
return;
if (fld.type == 'checkbox')
fld.checked = value == 'T';
else if (fld.type == 'select-one')
synclist(fld,value);
else if (fld.className == 'nldropdown')
getDropdown(fld).setValue(value, true );
else if (isMultiSelect(fld))
syncmultiselectlist(fld, value);
else if ( window.getHtmlEditor != null && getHtmlEditor( fld.name ) != null )
return getHtmlEditor( fld.name ).setValue( value, true );
else if (fld.nodeName == 'INPUT' || fld.nodeName == 'TEXTAREA')
fld.value = value != null && value.join != null && isPopupMultiSelect( fld ) ? value.join( String.fromCharCode(5) ) : value ;
else
fld.innerHTML = value;
}
function getFormValue(fld, returnArray)
{
if (fld == null)
return null;
if (fld.type == "checkbox")
return fld.checked ? 'T' : 'F';
else if (fld.type == "radio" || (fld.length > 0 && fld[0].type == "radio") )
return getRadioValue(fld);
else if (fld.type == "select-one" || fld.className == 'nldropdown')
return getSelectValue(fld);
else if (isMultiSelect(fld))
return getMultiSelectValues(fld, returnArray);
else if ( window.getHtmlEditor != null && getHtmlEditor( fld.name ) != null )
return getHtmlEditor( fld.name ).getValue( );
else
return returnArray && fld.value != null && isPopupMultiSelect( fld ) ? fld.value.split( String.fromCharCode(5) ) : fld.value;
}
function getEditFlag()
{
var bReturnMe = false;
if ( document.forms['main_form'].elements['id'] )
{
if ( !isempty(document.forms['main_form'].elements['id']) && document.forms['main_form'].elements['id'].value != -1 )
bReturnMe = true;
}
return bReturnMe;
}
function getParameter( param )
{
var re = new RegExp(".*[?&]"+param+"=([^&]*)");
var matches = re.exec( document.location.href.toString() ) ;
return matches != null && matches.length > 0 ? matches[1] : null;
}
function getBooleanParameter( param )
{
return getParameter( param ) == "T";
}
function getParameterValuesArray( )
{
var url = document.location.href.toString();
if ( url.indexOf('?') < 0 )
return null;
var pairs = url.substring( url.indexOf('?')+1 ).split("&");
var a = new Array();
for ( var i = 0; i < pairs.length; i++ )
{
var pair = pairs[i].split("=");
a[a.length] = pair[0];
a[a.length] = pair.length > 0 ? pair[1] : null;
}
return a;
}
function getFormElement(frm,fldname)
{
var returnMe = null;
if ( frm != null )
{
if ( fldname == 'language' || (!isIE && (fldname == 'item' || fldname == 'cash')) )
{
for ( var i = 0; i < frm.elements.length; i++ )
if ( frm.elements[i].name == fldname )
returnMe = frm.elements[i];
}
else
returnMe = frm.elements[fldname];
}
return returnMe;
}
function getFormElementViaFormName(frmName,fldname)
{
return getFormElement( document.forms[ frmName ], fldname );
}
var isIE = document.all ? true : false;
var isNS = document.addEventListener ? true : false;
var isNS4x = document.layers ? true : false ;
var NODE_TD = "TD";
var NODE_TR = "TR";
var NODE_TEXT = "#text";
var NODE_TABLE = "TABLE";
function findPosX(obj)
{
var curleft = 0;
if (document.getElementById || document.all)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (document.layers)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
if (document.getElementById || document.all)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop;
obj = obj.offsetParent;
}
}
else if (document.layers)
curtop += obj.y;
return curtop;
}
function getParentElementByTag(tag, element)
{
var elem = element;
while(elem != null)
{
if (elem.tagName == tag)
return elem;
if (elem == elem.parentNode)
break;
elem = elem.parentNode;
}
return null;
}
function fireProperOnChange(elem, win)
{
if(elem != null)
{
if(win == null)
win = window;
if(elem.getAttribute('onChangeFunc'))
win.localEval(elem.getAttribute('onChangeFunc').replace(/this/g,'document.forms.'+elem.form.name+'.'+elem.name));
else if(elem.onchange)
elem.onchange();
}
}
function getInlineTextValue(node)
{
if (isIE)
return node.innerText ? node.innerText : node.innerHTML;
else
{
while(node != null)
{
if (node.nodeName == "#text")
return node.nodeValue;
node = node.firstChild;
}
// IE will always return an empty string if the SPAN parameter is empty.
// Firefox will end up not finding any children, so we want to explicitly
// return an empty string for compatibility with IE.
return "";
}
}
function setInlineTextValue(node, value)
{
if ( node == null )
return;
node.innerHTML = value;
}
function findUp(node, type)
{
while ((node != null) && (node.nodeName != type))
node = node.parentNode;
return node;
}
function getEvent(evnt)
{
return (typeof(evnt)!='undefined' && evnt) ? evnt : ((typeof(event)!='undefined' && event) ? event : null);
}
function getEventKeypress(evnt)
{
evnt = getEvent(evnt);
return (evnt.which) ? evnt.which : evnt.keyCode;
}
function getEventAltKey(evnt)
{
evnt = getEvent(evnt);
return (evnt) ? evnt.altKey : false;
}
function getEventCtrlKey(evnt)
{
evnt = getEvent(evnt);
return (evnt) ? evnt.ctrlKey : false;
}
function getEventShiftKey(evnt)
{
evnt = getEvent(evnt);
return (evnt) ? evnt.shiftKey : false;
}
function getEventTarget(evnt)
{
evnt = getEvent(evnt);
if (evnt)
{
if (evnt.srcElement)
return evnt.srcElement;
if (evnt.target)
return evnt.target;
}
return null;
}
function getEventTargetType(evnt)
{
evnt = getEventTarget(evnt);
return (evnt) ? evnt.type : null;
}
function setEventPreventDefault(evnt)
{
evnt = getEvent(evnt);
if (evnt)
{
if (evnt.preventDefault)
evnt.preventDefault();
else
evnt.returnValue = false;
}
}
function setEventCancelBubble(evnt)
{
evnt = getEvent(evnt);
if (evnt)
{
if (evnt.stopPropagation)
evnt.stopPropagation();
else
evnt.cancelBubble = true;
}
}
function restoreHtmlEditors( frm )
{
if ( window.htmleditors != null )
{
for ( i in window.htmleditors )
{
var editor = getHtmlEditor(String(i));
if ( frm == null || editor.hddn.form == frm )
editor.setValue( editor.hddn.value, true );
}
}
}
function nlFieldHelp(db,p,f,fld)
{
var url = '/core/help/fieldhelp.nl?fld='+f+'&perm='+p;
if ( window.isOLC )
url = '/offline/pages/core/help/offlinefieldhelp.html?field='+f+'&recordType='+p.toLowerCase();
var winname = 'fieldhelp';
var width = 350;
var height = 150;
if (fld != null)
{
var left= Math.min(screen.availWidth-width,getObjectLeft(fld));
var top = Math.min((screen.availHeight-40)-height,getObjectTop(fld) + fld.offsetHeight);
}
var win = window[winname];
if (typeof win == "undefined" || win == null || win.closed )
win = window.open(url, winname, 'scrollbars='+(isIE ? 'no' : 'yes')+',width='+Math.min(screen.availWidth,width)+',height=50,left=' + left + ',top=' + top + ',resizable=yes');
else
{
win.location = url;
win.moveTo(left, top);
}
win.focus();
window[winname] = win;
return false;
}
function dumpObj(obj)
{
for(var prop in obj)
{
var str = prop + ": " + obj[prop];
document.body.appendChild(document.createTextNode(str));
document.body.appendChild(document.createElement("BR"));
}
if (obj.style)
{
document.body.appendChild(document.createTextNode("STYLE:"));
document.body.appendChild(document.createElement("BR"));
dumpObj(obj.style);
}
}
function NLAlert(msg,ignoreServerSide)
{
alert(msg);
}
/** password utility functions **/
function checkpassword(fld1,fld2,alrt,strictcheck,fld3,len)
{
var strict = (strictcheck == true || strictcheck == null);
var msg = getpassworderror(fld1,fld2,strict,fld3,len);
if (msg != null)
{
if (alrt) alert(msg);
return false;
}
else
return true;
}
function getpassworderror(fld1,fld2,strictcheck,fld3,len)
{
var strict = (strictcheck == true || strictcheck == null);
var val = fld1.value;
if (len == null)
len = 6;
msg = "";
if (fld1.value != fld2.value)
{
msg += "Passwords don\'t match.\n";
}
else if (!strict)
{
if (val.length == 0)
msg = "Passwords cannot be empty.\n";
}
else
{
if (val.length < len)
{
msg += "Passwords must be at least {1} characters long.\n".replace("{1}", String(len));
}
if (!/[A-Za-z]/.test(val))
{
msg += "Passwords must contain at least one letter (A-Z).\n";
}
if (!/[0-9!@#$%^&*.:;~'`*",_|= \<\>\/\\\+\?\-\(\)\[\]\{\}]/.test(val))
{
msg += "Passwords must contain at least one number or special character.\n";
}
if (!/^[A-Za-z0-9!@#$%^&*.:;~'`*",_|= \<\>\/\\\+\?\-\(\)\[\]\{\}]+$/.test(val))
{
msg += "Passwords may contain only letters, numbers, and special characters.\n";
}
}
if (msg.length == 0 && fld3 != null)
{
var oldval = fld3.value;
var charDiffCount = 0;
for (i=0;i < val.length; i++)
{
var c = val.charAt(i);
if (oldval.indexOf(c) == -1)
charDiffCount++;
}
if (charDiffCount < 2)
msg = "Old and new passwords are too similar.";
}
if (msg.length > 0)
return msg;
else
return null;
}
/** helper extensions to Array object **/
function arrayIndexOf(array, val)
{
for ( var i = 0; array != null && i < array.length; i++ )
if ( val == array[i] )
return i;
return -1;
}
function arrayContains(array, val)
{
return arrayIndexOf(array, val) >= 0;
}
function arrayAdd(array, val)
{
if ( !arrayContains(array, val) )
array.push(val);
}
function arrayRemove(array, val)
{
var newarray = new Array();
for ( var i = 0; i < array.length; i++ )
if ( val != array[i] )
newarray.push(array[i]);
return newarray;
}
function nlInsertCanvas(insertCanvasDiv)
{
var canvas = document.getElementById( getCanvasId(insertCanvasDiv) );
if ( canvas == null )
{
canvas = document.createElement('IFRAME');
canvas.id = getCanvasId(insertCanvasDiv);
canvas.src = 'javascript:false';
canvas.scrolling = 'no';
canvas.style.display = 'none';
canvas.style.frameBorder = '0';
if ( isIE )
canvas.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
canvas.style.position = 'absolute';
canvas.style.top = '0px';
canvas.style.left = '0px';
document.body.appendChild( canvas );
}
nlSyncCanvas( insertCanvasDiv );
canvas.style.display = "block";
}
function nlSyncCanvas(syncCanvasDiv)
{
var canvas = document.getElementById( getCanvasId(syncCanvasDiv) );
if ( canvas == null )
return;
canvas.style.width = syncCanvasDiv.offsetWidth;
canvas.style.height = syncCanvasDiv.offsetHeight;
canvas.style.top = syncCanvasDiv.style.top;
canvas.style.left = syncCanvasDiv.style.left;
canvas.style.zIndex = syncCanvasDiv.style.zIndex - 1;
}
function nlRemoveCanvas(div)
{
var canvas = document.getElementById( getCanvasId(div) );
if (canvas != null)
document.body.removeChild( canvas );
}
function getCanvasId(div)
{
return div.id+'_canvas';
}
function findClassUp(node, clss)
{
while ((node != null) && (node.className != clss))
node = node.parentNode;
return node;
}
function getScrollLeftOffset(btn)
{
var scrollLeftOffset = 0;
var scrollDiv;
if(btn != null && (scrollDiv = findClassUp(btn,'scrollarea')) != null)
{
scrollLeftOffset = scrollDiv.scrollLeft;
}
else if ( (scrollDiv = document.getElementById('div__body')) != null )
{
scrollLeftOffset = scrollDiv.scrollLeft;
}
return scrollLeftOffset;
}
function getScrollTopOffset(btn)
{
var scrollTopOffset = 0;
var scrollDiv;
if(btn != null && (scrollDiv = findClassUp(btn,'scrollarea')) != null)
{
scrollTopOffset = scrollDiv.scrollTop;
}
else if ( (scrollDiv = document.getElementById('div__body')) != null )
{
scrollTopOffset = scrollDiv.scrollTop;
}
return scrollTopOffset;
}
/**
* remove all the child nodes
*/
function removeAllChildren(obj)
{
while (obj.childNodes[0])
{
obj.removeChild(obj.childNodes[0]);
}
}
function setObjectOpacity(opacity, styleElem)
{
var style = styleElem.style;
style.opacity = (opacity / 100);
style.MozOpacity = (opacity / 100);
style.filter = "alpha(opacity=" + opacity + ")";
}