function handleError(msg,errDocUrl,line)
{
var errorUrl = "/core/pages/logJavascriptError.nl";
xmlDoc = new ActiveXObject("Msxml.DOMDocument");
xmlDoc.loadXML("");
jsErrorNode = xmlDoc.documentElement;
var msgNode = xmlDoc.createElement('MSG');
msgNode.appendChild( xmlDoc.createTextNode(msg ) );
jsErrorNode.appendChild( msgNode );
var winHrefNode = xmlDoc.createElement('WINHREF');
winHrefNode.appendChild( xmlDoc.createTextNode(window.location.href ) );
jsErrorNode.appendChild( winHrefNode );
var lineNode = xmlDoc.createElement('LINE');
lineNode.appendChild( xmlDoc.createTextNode(line) );
jsErrorNode.appendChild( lineNode );
var isInitedNode = xmlDoc.createElement('ISINITED');
isInitedNode.appendChild( xmlDoc.createTextNode(window.isinited) );
jsErrorNode.appendChild( isInitedNode );
if (window.parent != window)
{
var parHrefNode = xmlDoc.createElement('PARENTHREF');
parHrefNode.appendChild( xmlDoc.createTextNode(window.parent.location.href) );
jsErrorNode.appendChild( parHrefNode );
}
if (errDocUrl != window.location.href)
{
var errDocUrlNode = xmlDoc.createElement('ERRORDOCURL');
errDocUrlNode.appendChild( xmlDoc.createTextNode(errDocUrl) );
jsErrorNode.appendChild( errDocUrlNode );
}
// Create a request object and post the xml document
var xmlReq= new ActiveXObject("Microsoft.XMLHTTP");
xmlReq.Open("POST", errorUrl, true);
xmlReq.Send(xmlDoc);
return false; // show the default error message
}
window.onerror = handleError;
function encode(text)
{
return escape(text);
}
function alphafirst(str)
{
var re = new RegExp("([A-Za-z].*)");
return (re.exec(str)!=null && RegExp.$1==str);
}
function scrollDiv()
{
document.getElementById('div__label').scrollLeft = document.getElementById('div__body').scrollLeft;
}
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;
}
function NLGetXMLDocument(url)
{
var response;
var xmlReq = new ActiveXObject("Microsoft.XMLDOM");
xmlReq.async='false';
xmlReq.load(url);
response = xmlReq;
return response;
}
function NLCreateXMLRoot(doc, name)
{
var response;
doc.loadXML("<"+name+"/>");
response = doc.documentElement;
return response;
}
function NLCreateXMLDocument()
{
var response;
xmlDoc = new ActiveXObject("Msxml.DOMDocument");
response = xmlDoc;
return response;
}
function NLPostXMLDocument(url, doc, async, callback)
{
var debugXml = false;
var response;
var xmlReq= new ActiveXObject("Microsoft.XMLHTTP");
xmlReq.Open("POST", url, async);
xmlReq.Send(doc);
response = xmlReq.responseXml;
if( debugXml )
{
alert(xmlReq.responseText);
}
var errors = response.getElementsByTagName('NLXMLERROR');
if( errors.length > 0 )
{
alert('An error occured on the server while processing your request.');
}
return response;
}
function onBeforePrint()
{
var t = document.getElementById('div__body');
if (t != null)
{
t.style.width = null;
t.style.height = null;
}
document.body.scroll = 'auto';
}
function onAfterPrint()
{
resetDivSizes();
}
window.onbeforeprint = onBeforePrint;
window.onafterprint = onAfterPrint;
function resetDivSizes()
{
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 footer = document.getElementById('div__footer');
if (list == null)
return;
document.body.scroll = 'no';
var nHeight = getDocumentHeight() - 10;
nHeight -= getHeight(header) + getHeight(footer) + getHeight(title) + getHeight(label) + 4;
list.style.height = ( nHeight > 0 ? nHeight : 0);
list.clientWidth;
var docwidth = getDocumentWidth() - 10;
list.style.width = Math.max( docwidth, 0 );
if (label != null )
{
label.style.width = isIE ? list.clientWidth : list.scrollWidth;
}
for (var i=1; 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;
else
lab.offsetParent.style.width = col.offsetWidth;
}
}
makeVisible(label);
makeVisible(list);
makeVisible(footer);
hideInvisibleRows();
}
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;
}
function makeVisible(elem)
{
if (elem != null)
elem.style.visibility = 'visible';
}
function display(elem, on )
{
if (elem != null)
elem.style.display = on ? '' : 'none';
}
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 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)
{
alert('Please enter a valid '+n+' digit '+(bIsCanada?'Postal':'Zip')+' Code.');
return false;
}
return true;
}
function checkpassword(fld1,fld2,alrt)
{
return checkpassword(fld1,fld2,alrt,true);
}
function checkpassword(fld1,fld2,alrt,strict,fld3)
{
var val = fld1.value;
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 < 6)
{
msg += "Passwords must be at least 6 characters long.\n";
}
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) {
if (alrt) alert(msg);
return false;
} else {
return true;
}
}
/**
* This function will apply javascript validation to an oracle password
**/
function checkoraclepassword(fld1)
{
var val = fld1.value;
msg = "";
if (val.length < 6)
{
msg += "Passwords must be at least 6 characters long.\n";
}
if (!/[A-Za-z]/.test(val))
{
msg += "Passwords must contain at least one letter (A-Z).\n";
}
if (!/^[A-Za-z]/.test(val))
{
msg += "Passwords must begin with a letter (A-Z).\n";
}
if (!/[0-9$#_= \<\>\/\\\+\?\-\(\)\[\]\{\}]/.test(val))
{
msg += "Passwords must contain at least one number or special character including the underscore (_), dollar sign ($), and pound sign (#).\n";
}
if (!/^[A-Za-z0-9#$_= \<\>\/\\\+\?\-\(\)\[\]\{\}]+$/.test(val))
{
msg += "Passwords can only contain alphanumeric characters and the underscore (_), dollar sign ($), and pound sign (#).\n";
}
if (msg.length > 0) {
alert(msg);
return false;
} else {
return true;
}
}
function splitIntoRows( value )
{
return value != null ? value.split(String.fromCharCode(2)) : 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 e-mail 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 e-mail address. NetSuite does not accept e-mail addresses with apostrophes, quotation marks, commas, 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('E-mail addresses must match');
return false;
}
if (emptyok && s_email.length==0)
{
return true;
}
return checkemailvalue(s_email,alrt);
}
function checkacctname(fld1)
{
var val = fld1.value;
if (!onlydigitsandchars(val))
{
alert("Company login names must contain only letters and digits.");
return false;
}
if (val.length < 4)
{
alert("Company login names must be at least 4 characters long.");
return false;
}
if (!alphafirst(val))
{
alert("Company login names must begin with a letter");
return false;
}
return true;
}
function checkusername(fld1)
{
var val = fld1.value;
if (!onlydigitsandchars(val))
{
alert("User names must contain only letters and digits.");
return false;
}
if (val.length < 4)
{
alert("User names must be at least 4 characters long.");
return false;
}
if (!alphafirst(val))
{
alert("Usernames must begin with a letter.");
return false;
}
return true;
}
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>16)
{
alert("Credit card numbers must contain between 13 and 16 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;
if (val.length == 0)
return true;
re = / /gi;
val = val.replace(re,'');
return (val.length == 0)
}
function isempty(fld1,nam)
{
var val = fld1.value;
return isValEmpty(val,nam);
}
function emptyIfNull(val)
{
return 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 chooseAorAn(sField, capsflag)
{
var sReturn = (capsflag ? "A":"a");
var cVowels = ['a','e','i','o','u'];
var iLength = cVowels.length;
sField = sField.toLowerCase();
for (var i = 0; i < iLength; i++)
{
if (sField.charAt(0) == cVowels[i])
{
sReturn = sReturn + "n";
break;
}
}
return sReturn;
}
function dollars_string(amount)
{
var temp = amount;
DigitStrings = new Array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
TeenStrings = new Array('ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eightteen', 'nineteen');
DecadeStrings = new Array('zero', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety');
result = '';
if (temp >= 1000)
{
result = result + dollars_string(Math.floor(temp/1000)) + 'thousand ';
temp = temp % 1000;
}
if (temp >= 100)
{
result = result + DigitStrings[Math.floor(temp/100)] + ' hundred ';
temp = temp % 100;
}
if (temp >= 20)
{
result = result + DecadeStrings[Math.floor(temp/10)] + ' ';
temp = temp % 10;
}
if (temp >= 10)
{
result = result + TeenStrings[Math.floor(temp-10)] + ' ';
temp = temp - Math.floor(temp);
}
else if ((amount == 0) || (temp > 0))
{
result = result + DigitStrings[Math.floor(temp)] + ' ';
temp = temp - Math.floor(temp);
}
return result;
}
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(a)
{
var b = Math.abs(a);
b = Math.round(b * 10000000.0) / 100000.0;
b = Math.round(b) / 100.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 format_currency(a, bDoNotRound)
{
var returnMe;
if(isNaN(a))
{
return "";
}
else if( !(bDoNotRound == true))
{
returnMe = round_currency(a);
}
else
returnMe = a;
returnMe = pad_to_atleast_two_decimal_places(returnMe);
return returnMe;
}
function validate_textarea(field, maxlen, doalert)
{
if (field.value == null || field.value.length == 0)
{
window.isvalid = true;
return true;
}
var validflag = true;
var err = '';
if (field.value.length > maxlen)
{
err = "Text too long (truncated at "+maxlen+" characters)";
newval = field.value.substr(0,maxlen);
}
if (err != '')
{
if (doalert) alert(err);
field.value = newval;
validflag = false;
}
window.isvalid = validflag;
return validflag;
}
function validate_field(field, type, doalert, autoplace, minval, maxval, mandatory)
{
type = type.toLowerCase();
if (field.value == null || field.value.length == 0)
{
if (mandatory == true)
{
if (doalert) alert("Field must contain a value.");
field.focus();
field.select();
window.isvalid = false;
return false;
}
else
{
window.isvalid = true;
return true;
}
}
var validflag = true;
if (type =="url")
{
var val = field.value;
if ( val.indexOf('http://') == -1 && val.indexOf('https://') == -1)
{
if (doalert)
alert("Invalid url. Url must start with http:// or https://");
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 (isNaN(numval) || Math.abs(numval)>=1.0e+10)
{
if (doalert) alert("Invalid currency value. Values must be numbers up to 9,999,999,999.99");
validflag = false;
}
if (type == "poscurrency" && 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_currency(numval, true);
}
}
else if (type == "date")
{
validflag = true;
var m=0,d=0,y=0,val=field.value;
var fmterr;
var year="";
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 == "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")
{
var ms = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
if (val.indexOf("-") != -1)
{
var c = val.split("-");
if(onlydigits(c[0])) d = parseInt(c[0],10);
m = (ms.indexOf(c[1].toUpperCase())+3)/3;
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); if (ms.indexOf(str.toUpperCase()) >= 0) m = (ms.indexOf(str.toUpperCase())+3)/3;
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 (doalert) alert("Invalid date value (must be "+fmterr+")");
validflag = false;
}
else
{
if (y==0 && !onlydigits(year)) y = (new Date()).getYear();
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()).getYear();
field.value = getdatestring(new Date(y, m-1, d));
}
}
else if (type == "mmyydate")
{
var month;
var day = 0;
var year;
var fmterr = "MMYY, MMYYYY, 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 = (ms.indexOf(c[0].toUpperCase())+3)/3;
year=parseInt(c[1],10);
}
else
{
var l = val.length, str;
str = val.substr(0,3); if (ms.indexOf(str.toUpperCase()) >= 0) month = (ms.indexOf(str.toUpperCase())+3)/3;
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("/");
month = parseInt(comps[0],10);
if (comps[2] != null)
{
day = parseInt(comps[1],10);
year = parseInt(comps[2],10);
}
else
year = parseInt(comps[1],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));
validflag = true;
}
else
{
if (doalert) alert("Invalid date value (must be "+fmterr+")");
validflag = false;
}
}
else if (type == "ccexpdate")
{
validflag = true;
var m=0, y=0;
if(field.value.indexOf('/') != -1)
{
var dToday = new Date();
var Y = dToday.getYear();
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(y= 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
{
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 = 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")
{
if (numval == Math.floor(numval))
field.value = numval + ".0%";
else
field.value = 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 re;
var re = /([0-9][0-9]?)(:[0-5][0-9])\s?([AaPp])?[Mm]?/
var result = re.exec(field.value)
if (result==null || result.index > 0 || result[0].length != field.value.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 == 'a' || RegExp.$3 == 'A') ? "" : "pm";
}
if (hours > 0 && hours <=12 && minutes >= 0 && minutes < 60)
{
if (amorpm == "") amorpm = "am";
field.value = hours + ":" + (minutes < 10 ? "0" : "") + minutes + " " + amorpm;
validflag = true;
}
else if (hours > 12 && hours <= 25 && minutes >= 0 && minutes < 60 && amorpm == "")
{
amorpm = "pm";
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")
{
if (checkpassword(field, field, doalert))
validflag = true;
else
validflag = false;
}
else if (type == "email")
{
if (checkemail(field, true, doalert))
validflag = true;
else
validflag = false;
}
else if (type == "emails")
{
var bademail;
var emails1 = field.value.split(',');
for (var i=0; i= 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")
{
var val = field.value;
if(val.length!=0 && val.length<10)
{
if (doalert) alert("Please include the area code for phone number: " + val);
validflag = false;
}
}
}
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")
{
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 = val.toLowerCase();
}
if (mandatory == true)
{
if (field.value.length == 0)
{
if (doalert) alert("Field must contain a value.");
validflag = false;
}
}
if (!validflag)
{
field.focus();
field.select();
}
window.isvalid = validflag;
return validflag;
}
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 validate_html(field, val_type)
{
var doalert = true;
if (field.value == null || field.value.length == 0 || val_type == null)
{
window.isvalid = true;
return true;
}
html = field.value.toLowerCase().replace(/\n/g,"").replace(/\t/g," ");
var validflag = true;
var err = '';
if (val_type == 'html')
{
if (html.indexOf(' html.indexOf(' tag is in the wrong place";
else
val_type = "table";
}
else
{
if (html.indexOf('";
var newindex;
var bFirst = true;
var iNestLevel = 0;
var scriptSave;
var attributeIdx;
while ((newindex = html.indexOf("<", index)) != -1)
{
if (newindex < attributeIdx) newindex = attributeIdx;
index = newindex+1;
var tag = html.substring(newindex);
if (tag.indexOf(">") != -1)
tag = tag.substring(0, tag.indexOf(">"));
if (tag.indexOf(" ") != -1)
tag = tag.substring(0, tag.indexOf(" "));
if (tag == "", index);
if (index == -1) index = html.length;
continue;
}
if (tag.substring(0,2) == "<"+"%")
{
var endindex = html.indexOf("%"+">", index);
if (endindex == -1) { err='Missing substitution closing tag sequence %'+'> for open tag at character '+(index); break; }
index = endindex;
continue;
}
tag += ">"
len = tag.length;
attributeIdx = newindex+len-1;
var openQuoteIdx;
var bInSingQuot = false;
var bInDoubQuot = false;
while (attributeIdx < html.length)
{
var c = html.charAt(attributeIdx);
if (c == '\\') { attributeIdx+=2; continue; }
else if (c == '\'') { if (!bInDoubQuot) {bInSingQuot=!bInSingQuot; if (bInSingQuot)openQuoteIdx=attributeIdx;} }
else if (c == '\"') { if (!bInSingQuot) {bInDoubQuot=!bInDoubQuot; if (bInDoubQuot)openQuoteIdx=attributeIdx;} }
else if (c == '>' && !(bInSingQuot || bInDoubQuot)) { break; }
attributeIdx++;
}
if (bInSingQuot || bInDoubQuot)
{
index = openQuoteIdx+1;
len = 1;
err = "Missing closing quote on tag attribute at character "+(index-newindex)+" for:\n"+html.substring(newindex, attributeIdx+1);
break;
}
if (tag != "| " && tag != " | "
&& tag != "" && tag != "
"
&& tag != ""
&& tag != "")
continue;
if (tag.substring(0,2) == "")
iNestLevel--;
else
iNestLevel++;
if (iNestLevel < 0)
{
err = "There are too many closing table tags due to tag "+tag.toUpperCase()+" at character "+newindex;
break;
}
if (bFirst)
{
if (tag != '')
{
bFirst = false;
if (expectedtags.indexOf(tag) == -1)
{
err = "The first table tag in your HTML must be a "+expectedtags.toUpperCase()+" tag, not "+tag.toUpperCase();
break;
}
}
}
else
{
if (expectedtags.indexOf(tag) == -1)
{
var list = expectedtags.replace(/> or <');
err = "Expected "+list+" at character "+newindex+", but found a "+tag.toUpperCase()+" tag";
break;
}
}
if (tag == "" || tag == "")
{
expectedtags = "
";
}
else if (tag == "")
{
expectedtags = scriptSave; scriptSave = "";
}
}
if (err == '' && iNestLevel > 0)
{
err = "Not all table tags were closed ("+iNestLevel+"). Your HTML is missing a closing "+expectedtags.substring(0, expectedtags.indexOf('>'))+"> tag at the end";
}
}
if (err != '')
{
if (doalert)
alert(err);
validflag = false;
setSelectionRange(field, index-1, index+len-1);
}
window.isvalid = validflag;
return validflag;
}
function nlGetFullYear(d)
{
if (navigator.appName == "Netscape")
{
if (d.getFullYear=="undefined")
return d.getYear();
}
return d.getFullYear();
}
function nlSetFullYear(d,val)
{
if (navigator.appName == "Netscape")
{
if (d.setFullYear=="undefined")
d.setYear(val);
}
d.setFullYear(val);
}
function getdatestring(d)
{
if (window.dateformat == "DD-Mon-YYYY")
{
var m = "JanFebMarAprMayJunJulAugSepOctNovDec";
return d.getDate()+"-"+m.substring(d.getMonth()*3,d.getMonth()*3+3)+"-"+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
return (d.getMonth()+1)+"/"+d.getDate()+"/"+nlGetFullYear(d);
}
function gettimestring(time)
{
var hours = time.getHours();
var minutes = time.getMinutes();
var ampm = hours < 12 ? 'am' : 'pm';
return timestr = (hours%12 < 1 ? 12 : hours%12) + ':' + (minutes < 10 ? '0'+minutes.toString() : minutes) + ' ' + ampm;
}
function getmmyydatestring(d)
{
return ((d.getMonth()+1) < 10 ? "0" : "") + (d.getMonth()+1) + "/" + nlGetFullYear(d);
}
function stringtodate(arg)
{
var comps;
var month, day, year;
var datetime = arg.split(" ");
var d = datetime[0];
if (d.indexOf("/") != -1)
{
comps = d.split("/");
if (comps.length == 2)
{
month = parseInt(comps[0],10)-1;
day = 1;
year = parseInt(comps[1],10);
}
else if (window.dateformat == "DD/MM/YYYY")
{
day = parseInt(comps[0],10);
month = parseInt(comps[1],10)-1;
year = 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("-");
var ms = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
if (comps.length == 2)
{
day = 1;
month = parseInt(comps[0],10);
year = ms.indexOf(comps[1].toUpperCase())/3;
}
else
{
day = parseInt(comps[0],10);
month = ms.indexOf(comps[1].toUpperCase())/3;
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")
hour += 12;
result = new Date(year,month,day,hour,min,sec);
}
else
result = new Date(year,month,day);
if (year < 50)
nlSetFullYear(r, year+2000);
else if (year < 100)
nlSetFullYear(r, year+1900);
return result;
}
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 addmonths(d, mtoadd)
{
var curmonth = d.getMonth()+mtoadd;
while (curmonth < 0)
{
curmonth += 12;
nlSetFullYear(d, nlGetFullYear(d)-1);
}
while (curmonth > 11)
{
curmonth -= 12;
nlSetFullYear(d,nlGetFullYear(d)+1);
}
d.setMonth(curmonth);
return d;
}
function modifydate(d, val, mmyyyy)
{
timenow = d;
var v = val.split(",");
var num = 0;
for (var i=0; i<3; i++)
{
if (v[i] == "-")
{
continue;
}
else if (v[i].charAt(0) == "-" || v[i].charAt(0) == "+")
{
num = parseInt(v[i],10);
if (i==0)
adddays(timenow, num);
else if (i==1)
addmonths(timenow, num);
else if (i==2)
nlSetFullYear(timenow,nlGetFullYear(timenow)+num);
}
else
{
num = parseInt(v[i],10);
if (i==0)
timenow.setDate(num);
else if (i==1)
timenow.setMonth(num);
else if (i==2)
nlSetFullYear(timenow,num);
}
}
if (v[3] == "0"||v[3] == "1"||v[3] == "2")
{
var qstart = parseInt(v[3],10);
num = timenow.getMonth();
addmonths(timenow, 0-((num-qstart+3)%3));
}
if (v[4] == "Y")
{
adddays(timenow,-1);
}
if (v[5] == "E")
{
num = timenow.getDay();
adddays(timenow, ((5+window.weekstart-num)%7));
}
else if (v[5] == "B")
{
num = timenow.getDay();
adddays(timenow, -((num+1-window.weekstart) % 7));
}
return (mmyyyy ? getmmyydatestring(timenow) : getdatestring(timenow));
}
function nlutil_getmodifieddate(type,which,fm,mmyyyy)
{
var curdate = new Date();
if (type=="ALL")
return "";
timenow = new Date();
if (type=="TODAY")
modifier = (which==1 ? "-,-,-,N,N,-" : "-,-,-,N,N,-");
else if (type=="TMTD")
modifier = (which==1 ? "1,-,-,N,N,-" : "-,-,-,N,N,-");
else if (type=="OY")
modifier = (which==1 ? "+1,-,-1,N,N,-" : "-,-,-,N,N,-");
else if (type=="OQ")
modifier = (which==1 ? "+1,-3,-,N,N,-" : "-,-,-,N,N,-");
else if (type=="YESTERDAY")
modifier = (which==1 ? "-1,-,-,N,N,-" : "-1,-,-,N,N,-");
else if (type=="OW")
modifier = (which==1 ? "-6,-,-,N,N,-" : "-,-,-,N,N,-");
else if (type=="TW")
modifier = (which==1 ? "-,-,-,N,N,B" : "-,-,-,N,N,E");
else if (type=="LW")
modifier = (which==1 ? "-7,-,-,N,N,B" : "-7,-,-,N,N,E");
else if (type=="LWTD")
modifier = (which==1 ? "-7,-,-,N,N,B" : "-7,-,-,N,N,-");
else if (type=="TWTD")
modifier = (which==1 ? "-,-,-,N,N,B" : "-,-,-,N,N,-");
else if (type=="TM")
modifier = (which==1 ? "1,-,-,N,N,-" : "1,+1,-,N,Y,-");
else if (type=="OM")
modifier = (which==1 ? "+1,-1,-,N,N,-" : "-,-,-,N,N,-");
else if (type=="LM")
modifier = (which==1 ? "1,-1,-,N,N,-" : "1,-,-,N,Y,-");
else if (type=="LMTD")
modifier = (which==1 ? "1,-1,-,N,N,-" : "-,-1,-,N,N,-");
else if (type=="NW")
modifier = (which==1 ? "+7,-,-,N,N,B" : "+7,-,-,N,N,E");
else if (type=="N4W")
modifier = (which==1 ? "+7,-,-,N,N,B" : "+29,-,-,N,N,E");
else if (type=="NM")
modifier = (which==1 ? "1,+1,-,N,N,-" : "1,+2,-,N,Y,-");
else if (type=="NOW")
modifier = (which==1 ? "+1,-,-,N,N,-" : "+7,-,-,N,N,-");
else if (type=="NOM")
modifier = (which==1 ? "+1,-,-,N,N,-" : "-,+1,-,N,N,-");
else if (type=="NOQ")
modifier = (which==1 ? "+1,-,-,N,N,-" : "-,+3,-,N,N,-");
else if (type=="NOY")
modifier = (which==1 ? "+1,-,-,N,N,-" : "-,-,+1,N,N,-");
else if (type=="SMLFQ")
modifier = (which==1 ? "1,-3,-,N,N,-" : "1,-2,-,N,Y,-");
else if (type=="SMLFY")
modifier = (which==1 ? "1,-,-1,N,N,-" : "1,+1,-1,N,Y,-");
else if (type=="SMLFQTD")
modifier = (which==1 ? "1,-3,-,N,N,-" : "-,-3,-,N,N,-");
else if (type=="SMLFYTD")
modifier = (which==1 ? "1,-,-1,N,N,-" : "-,-,-1,N,N,-");
else if (type=="CUSTOM")
modifier = (which==1 ? "-,-,-,-,N,-" : "-,-,-,-,N,-");
else if (type=="")
modifier = (which==1 ? "" : "");
else if (type.search("FQ")!=-1)
{
var curmonth = curdate.getMonth();
var monthmod=0;
var yearmod;
var endmodifier;
if (which==1)
{
modifier = "1,";
yearmod = (type == "SFQLFY" || type == "SFQLFYTD") ? "-1" : "-";
endmodifier = yearmod+","+(fm%3)+",N,-";
if (type=="LFQTD" || type=="LFQ")
monthmod += -3;
else if (type=="TFQTD" || type=="SFQLFYTD")
monthmod += 0;
else if (type=="TFQ" || type == "SFQLFY")
monthmod += 0;
else if (type=="NFQ")
monthmod += 3;
}
else
{
if (type=="LFQTD" || type=="TFQTD" || type=="SFQLFYTD")
{
modifier = "-,";
yearmod = type=="SFQLFYTD" ? "-1" : "-"
endmodifier = yearmod+",N,N,-";
}
else
{
modifier = "1,";
yearmod = type=="SFQLFY" ? "-1" : "-"
endmodifier = yearmod+","+(fm%3)+",Y,-";
}
if (type=="TFQTD" || type=="LFQ" || type=="SFQLFYTD")
monthmod = 0;
else if (type=="LFQTD")
monthmod += -3;
else if (type=="TFQ" || type=="SFQLFY")
monthmod += 3;
else if (type=="NFQ")
monthmod += 6;
}
if (monthmod < 0)
modifier += monthmod+",";
else if (monthmod == 0)
modifier += "-,";
else if (monthmod > 0)
modifier += "+"+monthmod+",";
modifier += endmodifier;
}
else if (type.search("FY")!=-1)
{
var curmonth = curdate.getMonth();
var yearmod = (curmonth< fm) ? -1 : 0;
var endmodifier;
if (which==1)
{
modifier = "1,"+fm+",";
endmodifier = "N,N,-";
if (type=="LFYTD" || type=="LFY")
yearmod += -1;
else if (type=="TFYTD" || type=="TFY")
yearmod += 0;
else if (type=="NFY")
yearmod += 1;
}
else
{
if (type=="LFYTD" || type=="TFYTD")
{
modifier = "-,-,";
endmodifier = "N,N,-";
}
else
{
modifier = "1,"+fm+",";
endmodifier = "N,Y,-";
}
if (type=="TFYTD")
yearmod = 0;
else if (type=="LFY")
yearmod += 0;
else if (type=="LFYTD")
yearmod += -1;
else if (type=="TFY")
yearmod += 1;
else if (type=="NFY")
yearmod += 2;
}
if (yearmod < 0)
modifier += yearmod+",";
else if (yearmod == 0)
modifier += "-,";
else if (yearmod > 0)
modifier += "+"+yearmod+",";
modifier += endmodifier;
}
else
return "";
return modifydate(curdate, modifier,mmyyyy);
}
function nlTestDrivePopup(taskid,usertype)
{
var dest = '/core/help/testdrivepopup.nl?taskid='+taskid+'&seqnum=0&usertype='+usertype;
createTDWindow(dest);
}
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 displayHelpSearch(sSearchString)
{
var searchwindow = window.open('/core/help/helpindex.nl?searchstring='+sSearchString,'helpSearch','');
searchwindow.focus();
return false;
}
function nlCustomHelp(id)
{
var customwindow = window.open('/core/help/customhelp.nl?htext='+id,'customhelp','scrollbars=no,width=350,height=150');
customwindow.focus();
return false;
}
function nlPopupHelp(taskId, usertype, anchor, seqnum)
{
var dest;
if (usertype == null)
dest = '/core/help/helpindex.nl?key='+taskId;
else
{
dest = '/core/help/helpindex.nl?taskid='+taskId;
if(anchor != null && anchor.length>0)
dest += '&anchor='+anchor;
if(seqnum != null)
dest += '&seqnum='+seqnum;
}
var newWin = window.open(dest,'popuphelp','toolbar=yes,menubar=yes,scrollbars=yes,location=yes,resizable=yes,height=400,width=800');
newWin.focus();
}
function nlPopupHelpEdit(taskId)
{
var dest = '/core/help/helpadmin.nl?taskid='+taskId;
var newWin = window.open(dest,'helpedit','toolbar=yes,menubar=yes,scrollbars=yes,location=yes,resizable=yes');
newWin.focus();
}
function nlFieldHelp(db,p,f,fld)
{
nlOpenWindow('/core/help/fieldhelp.nl?fld='+f+'&perm='+p,'fieldhelp',350,150,fld);
return false;
}
function nlFieldHelpEdit(db,p,f,fld)
{
nlOpenWindow('/core/help/admin/helpfieldeditform.nl?perm='+p+'&field='+f,'fieldhelpedit',450,250,fld);
return false;
}
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 setTextUnderline(val, bSet)
{
var n = val.className.indexOf('hover');
if(n >= 0 && bSet == false)
{
val.className = val.className.substring(0,n);
}
else if(n < 0 && bSet == true)
{
val.className += 'hover';
}
return true;
}
function clearMultiSelect(sel)
{
if ( isNLMultiDropDown(sel) )
getMultiDropdown(sel.name).removeAll();
else
{
for ( i=sel.length-1; i >=0 ; i-- )
sel.options[i].selected = false;
}
}
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 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)
{
list.form.elements[list.name+"_display"].value = getnamevaluelisttext(list.value,"\n", true);
}
function synclist(list,val,makedefault)
{
if (list.className == 'nldropdown')
{
var dd = getDropdown(list);
var idx = dd.getIndexForValue(val);
dd.setIndex(idx, true );
if (makedefault)
dd.setDefaultIndex(idx);
}
else
{
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;
}
}
}
}
function syncpopup(list,val,name)
{
var i;
if (list.className == 'nldropdown')
{
var dd = getDropdown(list);
var idx = dd.getIndexForValue(val);
dd.setIndex(idx, true );
}
else if (isNLMultiDropDown(list))
{
var dd = getMultiDropdown(list.name);
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
break;
}
}
else
{
list.value = val;
var dispfld = list.form.elements[list.name+"_display"];
if (val.length > 0 || (name != null && name.length > 0))
dispfld.value = name;
else
dispfld.value = dispfld.type == 'text' ? _popup_help : _mult_popup_help;
}
}
function syncmultiselectlist(list,val)
{
clearMultiSelect(list);
if (isNLMultiDropDown(list))
{
var dd = getMultiDropdown(list.name);
dd.setValues(val);
}
else if (list.type != "select-multiple")
{
list.form.elements[list.name].value = val;
}
else
{
var selvals = val.split(String.fromCharCode(5));
for (i=0; i < selvals.length; i++)
{
for (j=0; j < list.length; j++)
{
if (list.options[j].value == selvals[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.name).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 getFieldSetSpan( fldset )
{
return fldset.document.getElementById( fldset.id + "_slct" );
}
function getFieldSetValue( fldset, mach )
{
var encodedData = new Array();
if ( mach != null )
{
var types = mach.getFieldSetSelectedTypes( fldset );
var fields = mach.getFieldSetSelectedFields( fldset );
var delimData = new Array();
for ( var i = 0; i < fields.length - 1 ; i++ )
{
var inpField = getFormElement(mach.miniform,fields[i]);
var val = '';
if (inpField != null)
{
var spanName = (fields[i].indexOf( '_display' ) == -1 ? fields[i] : fields[i].substring(0,fields[i].indexOf('_display'))) + '_fs';
var inpSpan = document.getElementById( spanName );
if (inpSpan == null || inpSpan.style.display != 'none')
{
if ( types[i] == 'checkbox' )
val = inpField.checked ? 'T' : 'F';
else
val = inpField.value;
}
}
delimData[i] = val;
}
encodedData.push( mach.getFieldSetSelected( fldset ) );
encodedData.push( fields.join(String.fromCharCode( 8) ) );
encodedData.push( types.join(String.fromCharCode( 8 ) ) );
encodedData.push( mach.getFieldSetSelectedLabels( fldset ).join(String.fromCharCode( 8 ) ) );
encodedData.push( delimData.join( String.fromCharCode( 7 ) ) );
}
return encodedData.join( String.fromCharCode(6) );
}
function getFieldSetText( fldset, data, mach, nohtml )
{
var sOutput = "";
if ( nohtml == null )
nohtml = false;
if ( data != null && data.length > 0)
{
var dataFields = data.split(String.fromCharCode(6) );
var slct = dataFields[0];
var fields = dataFields[1].split(String.fromCharCode(8) );
var types = dataFields[2].split(String.fromCharCode(8) );
var labels = dataFields[3].split(String.fromCharCode(8) ) ;
var dataContent = dataFields[4].split(String.fromCharCode(7) );
var inpField = null;
var nCount = 0;
for( var i=0; i < fields.length; i++ )
{
if ( dataContent[i] && dataContent[i].length > 0 && curType != 'checkbox' )
{
nCount ++;
}
}
for (var i = 0; i < fields.length; i++)
{
if ( dataContent[i] && dataContent[i].length > 0)
{
var curType = types[i];
var bCheckBox = curType == 'checkbox';
var bWriteLabel = labels[i].length > 0 && ( (!bCheckBox && nCount>1) || dataContent[i] == 'T');
if ( bWriteLabel )
{
sOutput += labels[i];
if ( !bCheckBox )
sOutput += ": ";
}
if ( !bCheckBox )
{
var dataCell = dataContent[i];
var curName = fields[i];
var curElement = mach.miniform.elements[curName];
var pos = curName.indexOf("_display");
if ( getFieldSetDisplayField(curName, fields) != null )
{
if ( pos != -1 && !isValEmpty(dataCell) )
sOutput += dataCell.replace(/\n/g, nohtml ? ' ' : '
');
}
else if ( curType == "select" || curType == "slaveselect")
{
if ( isMultiSelect( curElement ) )
sOutput += getmultiselectlisttext( curElement ,dataCell );
else
sOutput += getlisttext( curElement, dataCell ) ;
}
else if (curType == "currency")
sOutput += format_currency( parseFloat( dataCell ) );
else if (curType == "radio")
sOutput += getradiotext( curElement, dataCell );
else if (curType == "namevaluelist")
sOutput += getnamevaluelisttext( dataCell , nohtml ? " " : "
" );
else if (curType == "fieldset")
sOutput += getFieldSetText( curName, dataCell, mach );
else
sOutput += dataCell.replace(/\n/g, nohtml ? ' ' : '
');
}
if ( i + 1 != fields.length && bWriteLabel )
sOutput += nohtml ? " " : "
";
}
}
}
return sOutput;
}
function getFieldSetDisplayField(field, fields)
{
var returnMe = null;
if ( field.indexOf('_display') != -1 )
returnMe = field;
else
{
for (var i = 0; i < fields.length; i++ )
{
if ( fields[i] == field+'_display' )
returnMe = fields[i];
}
}
return returnMe;
}
function syncFieldSet( mach, data )
{
var dataFields = data.split(String.fromCharCode(6) );
var slct = dataFields[0];
var fields = dataFields[1].split(String.fromCharCode(8) );
var types = dataFields[2].split(String.fromCharCode(8) );
var labels = dataFields[3].split(String.fromCharCode(8) ) ;
var dataContent = dataFields[4].split(String.fromCharCode(7) );
var sOutput = "";
var inpField = null;
for (var i = 0; i < fields.length; i++)
{
if ( dataContent[i] )
{
var curType = types[i];
var curName = fields[i];
var curElement = mach.miniform.elements[curName];
if (curType == "select" || curType == "slaveselect")
{
if ( isMultiSelect(curElement) )
syncmultiselectlist( curElement ,dataContent[i] );
else
synclist( curElement,dataContent[i], false );
}
else if ( curType == "radio" )
syncradio( curElement,dataContent[i], false );
else if (curType == "currency")
curElement.value = format_currency( parseFloat(dataContent[i]) );
else if ( curType == "checkbox" )
curElement.checked = (dataContent[i] == "T");
else if ( curType == "fieldset" )
curElement.value = syncFieldSet( mach, dataContent[i] );
else if ( curType == "namevaluelist" )
{
curElement.value = dataContent[i];
syncnamevaluelist( curElement );
}
else
curElement.value = dataContent[i];
}
}
}
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 (sel.className == 'nldropdown')
returnMe = getDropdown(sel).getValue();
else if (isNLMultiDropDown(sel))
returnMe = getMultiDropdown(sel.name).getSelectedValues();
else
returnMe = sel.value;
return returnMe;
}
function getSelectValueArray(sel)
{
var returnMe;
if (sel.type == "select-one")
{
returnMe = new Array(sel.length);
var i = 0;
for ( 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.name).valueArray;
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")
{
returnMe = new Array(sel.length);
var i = 0;
for ( 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.name).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 (isNLMultiDropDown(sel))
return getMultiDropdown(sel.name).getSelectedText();
else if (sel.type == "hidden" && sel.form != null && getFormElement(sel.form,sel.name+'_display') != null)
return getFormElement(sel.form,sel.name+'_display').value;
else
return sel.text;
}
function setSelectValue(sel, val)
{
if (sel.className == 'nldropdown')
{
var dd = getDropdown(sel);
var idx = dd.getIndexForValue(val);
dd.setIndex(idx, true );
}
else if (isNLMultiDropDown(sel))
{
var dd = getMultiDropdown(sel.name);
var idx = dd.getIndexForValue(val);
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;
break;
}
}
}
else
sel.value = val;
}
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.name, win).deleteAllOptions();
}
else if (sel.type == 'select-one' || sel.type == 'select-multiple')
{
sel.options.length = 0;
}
else
{
sel.form.elements[sel.name+"_display"].value = "";
sel.value = "";
}
}
function deleteOneSelectOption(sel, value)
{
if (sel.className == 'nldropdown')
{
getDropdown(sel).deleteOneOption(value);
}
else if (isNLMultiDropDown(sel))
{
getMultiDropdown(sel.name).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
{
sel.form.elements[sel.name+"_display"].value = "";
sel.value = "";
}
}
function getSelectIndex(sel,win)
{
if (sel.className == 'nldropdown')
{
return getDropdown(sel,win).getIndex();
}
else
{
sel.selectedIndex;
}
}
function setSelectIndex(sel, val)
{
if (sel.className == 'nldropdown')
{
return getDropdown(sel).setIndex(val, true );
}
else if (isNLMultiDropDown(sel))
{
return getMultiDropdown(sel.name).setIndex(val);
}
else
{
sel.selectedIndex = val;
}
}
function getMultiSelectValues(sel)
{
if (isMultiSelect(sel))
{
var val = '';
if ( isNLMultiDropDown(sel) )
val = getMultiDropdown(sel.name).getSelectedValues();
else
{
var i;
var numParams = 0;
for (i=0; i < sel.length; i++)
{
if (sel.options[i].selected)
val += ((numParams++ ==0 ? '' : String.fromCharCode(5)) + sel.options[i].value);
}
}
return val;
}
else
return sel.value;
}
function getMultiSelectText(sel)
{
if ( isMultiSelect(sel) )
{
var val = '';
if ( isNLMultiDropDown(sel) )
val = getMultiDropdown(sel.name).getSelectedText();
else
{
var i;
for (i=0; i < sel.length; i++)
{
if (sel.options[i].selected)
val += ((numParams++ == 0 ? '' : ', ') + sel.options[i].text);
}
}
return val;
}
else if (sel.type == "hidden" && sel.form != null && getFormElement(sel.form,sel.name+'_display') != null )
return getFormElement(sel.form,sel.name+'_display').value;
else
return sel.text;
}
function updateMultiSelectValue(fld,displayfld,val,displayval)
{
fld.value = val;
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.name,win);
dd.addOption(text, value, selected);
}
else
{
var opt = doc.createElement('OPTION');
opt.text= text;
opt.value= value;
if (selected !== false)
{
opt.selected = true;
if (isIE)
sel.selectedIndex = sel.length;
}
sel[sel.length] = opt;
}
}
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 = value;
}
}
function isMultiSelect(sel)
{
return sel != null && (isNLMultiDropDown(sel) || sel.multiple || sel.type == 'select-multiple');
}
function isNLMultiDropDown(el)
{
return el != null && (el.isddmultiselect || el.className == '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.name).resetDropDown();
}
else
sel.value = sel.defaultValue;
}
}
function setSelectFocus(sel,win)
{
if ( sel != null )
{
if (sel.type == "select-one" || sel.type == "select-multiple")
sel.focus();
else if (sel.className == 'nldropdown')
getDropdown(sel,win).setFocus();
else if (isNLMultiDropDown(sel))
getMultiDropdown(sel.name,win).setFocus();
else
sel.form.elements[sel.name+"_display"].focus();
}
}
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.name, win).setDisabled(val);
else
{
sel.form.elements[sel.name+"_display"].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 = doc.getElementById(sel.name+"_popup_new");
if (newlink != null)
newlink.style.visibility = val ? "hidden" : "inherit";
var linklink = doc.getElementById(sel.name+"_popup_link");
if (linklink != null)
linklink.style.visibility = val ? "hidden" : "inherit";
}
}
function hideSelect(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.style.display = val ? "none" : "";
else if (sel.className == 'nldropdown')
getDropdown(sel, win).setHidden(val);
else if (isNLMultiDropDown(sel))
getMultiDropdown(sel.name, win).setHidden(val);
else
{
sel.form.elements[sel.name+"_display"].style.display=val ? "none" : "";
var listlink = doc.getElementById(sel.name+"_popup_list");
if(listlink != null)
listlink.style.display = val ? "none" : "";
var searchlink = doc.getElementById(sel.name+"_popup_search");
if (searchlink != null)
searchlink.style.display = val ? "none" : "";
var alllink = doc.getElementById(sel.name+"_popup_all");
if (alllink != null)
alllink.style.display = val ? "none" : "";
}
var newlink = doc.getElementById(sel.name+"_popup_new");
if (newlink != null)
newlink.style.display = val ? "none" : "";
var linklink = doc.getElementById(sel.name+"_popup_link");
if (linklink != null)
linklink.style.display = val ? "none" : "";
}
}
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.name).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.name).getText(idx);
}
}
}
function setRequired(fld,required)
{
if ( fld.className == 'nldropdown' )
getDropdown(fld).setRequired(required);
else
fld.className='input' + (required ? 'req' : '');
}
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
fld.disabled = val;
}
window.linearrayArray = new Array();
function getLineArray(machine_name)
{
if( window.linearrayArray[machine_name] == null )
{
window.linearrayArray[machine_name] = splitIntoRows( document.forms[0].elements[machine_name+'data'].value );
}
return window.linearrayArray[machine_name];
}
window.fieldnamesArray = new Array();
function getFieldNamesArray(machine_name)
{
if( window.fieldnamesArray[machine_name] == null )
{
window.fieldnamesArray[machine_name] = splitIntoCells( document.forms[0].elements[machine_name+'fields'].value );
}
return window.fieldnamesArray[machine_name];
}
function getLineCount(machine_name)
{
return getLineArray(machine_name).length;
}
function hasEncodedField(machine_name, fieldname)
{
var fieldnames = getFieldNamesArray(machine_name);
for (var i=0; i < fieldnames.length; i++)
if (fieldnames[i] == fieldname)
return true;
return false;
}
function getEncodedValue(machine_name, linenum, fieldname)
{
var linearray = getLineArray(machine_name);
if( linearray[linenum - 1] == null )
return null;
var linedata = splitIntoCells( linearray[linenum-1] );
var fieldnames = getFieldNamesArray(machine_name);
for (var i=0; i < fieldnames.length; i++)
if (fieldnames[i] == fieldname)
return linedata[i];
return '';
}
function findEncodedValue(machine_name, fieldname, value)
{
var linearray = getLineArray(machine_name);
var i;
var fieldnames = getFieldNamesArray(machine_name);
for (i=0; i < fieldnames.length; i++)
if (fieldnames[i] == fieldname)
break;
if (i == fieldnames.length)
return -1;
for (linenum=0;linenum 0 ? url.substr(endIndex) : "");
}
return url;
}
function previewMedia(mediaid, href, document)
{
if (href)
mediaid = mediaid.substr(mediaid.lastIndexOf('/')+1);
var url = '/core/media/previewmedia.nl?id='+mediaid;
preview(url, 'prevmedia');
}
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)
return getCookieVal (j);
i = document.cookie.indexOf(' ', i) + 1;
if (i == 0) break;
}
return null;
}
function getStickyTag(tagName)
{
var cbody = GetCookie('stickytags');
if (cbody != null)
{
var b=cbody.indexOf(tagName+':');
if (b>=0)
return unescape(cbody.substring(b+tagName.length+1, cbody.indexOf(',',b)));
}
return null;
}
function getLmtPage(url, cookieName)
{
return url + (url.indexOf('?') >= 0 ? '&t=' : '?t=') + getStickyTag(cookieName);
}
function gotoLmtPage(url,cookieName,framed)
{
var newUrl = getLmtPage(url, cookieName);
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 (sorted)
{
keyString = String.fromCharCode (window.event.keyCode).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 (SelectKeyPressTypedString);
else
option = SelectKeyPressLookupNext (SelectKeyPressTypedString);
}
else
option = SelectKeyPressLookupLinear (SelectKeyPressTypedString);
window.event.returnValue = false;
if (option != -1)
{
window.event.srcElement.selectedIndex = option;
window.event.srcElement.onchange();
}
return false;
}
var SelectKeyPressTypedString = "";
SelectKeyPressTimeoutID = null;
function SelectKeyPressTimeout ()
{
SelectKeyPressTypedString = "";
SelectKeyPressTimeoutID = null;
}
function SelectKeyPressLookupFirst (str)
{
select = window.event.srcElement;
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 (str)
{
select = window.event.srcElement;
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 (str)
{
select = window.event.srcElement;
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 openMapWindow(address)
{
address = trim(address);
if (address.length == 0)
{
alert("You must enter an address before you can view a map.");
return;
}
var lines = address.split("\n");
var line, streetAddress, cityStateZip;
var i = 0;
for (; i < lines.length; i++)
{
line = trim(lines[i]);
if (line.length == 0)
continue;
if (/^\d/.exec(line))
{
streetAddress = escape(line);
break;
}
}
if (i >= lines.length)
{
alert("Cannot find a street address.");
return;
}
var j = lines.length - 1;
var ukaddress = false;
cityStatezip = " ";
for (; j >= 0; j--)
{
line = trim(lines[j]);
if (line.length == 0)
continue;
if ( (/\d{5}/.exec(line)) || (/\s/.exec(line) && !/United\s*States/i.exec(line)))
{
cityStateZip = escape(line);
break;
}
}
var mapUrl;
if (j <= i)
{
alert("Cannot find a line containing city, state, and zip.");
return;
}
mapUrl = "http://maps.yahoo.com/py/maps.py?Pyt=Tmap&GET%A0Map=Get+Map&addr="+streetAddress+"&csz="+cityStateZip;
window.open(mapUrl);
}
function setDateComponents(theDate, monthsToAdd, theDay)
{
var newDate = new Date(theDate);
addmonths(newDate,monthsToAdd);
newDate.setDate(theDay);
return newDate;
}
function setDisabledState(elementid,enable)
{
var childnodes=document.getElementById(elementid).getElementsByTagName('INPUT');
for(var i=0;i>> 16) + (y >>> 16) + (lsw >>> 16);
return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
}
function leftCircShift(value, numbits)
{
var top = (value << numbits) & 0xFFFFFFFF;
var bottom = (value >>> (32 - numbits));
return top | bottom;
}
function unsignedToHex(x)
{
var lsw = x & 0xFFFF;
var msw = (x >>> 16) & 0xFFFF;
return msw.toString(16)+lsw.toString(16);
}