
function ChangeCheckList(hidCheckBox, arrayName, e, fn) {

var hidControl = document.getElementById(hidCheckBox);
var srcControl;
var strID;
var astrID;
var myArray = eval(arrayName);
var intIndex = 0;
var astrValues;
var intValuesLength;

if (!e) {
e = window.event;
}
srcControl = e.srcElement ? e.srcElement : e.target;
strID = srcControl.id;
astrID = strID.split('_');
strID = astrID[astrID.length - 1];
intIndex = parseInt(strID)
var strValue = myArray[intIndex];
astrValues = hidControl.value.split(',');
astrValues = ChangeCheckListArray(astrValues, strValue, srcControl.checked);
hidControl.value = astrValues.toString();
if ((typeof (fn) != 'undefined') && (typeof (fn) == 'string') && (fn != '')) {
eval(fn);
}
};
function ChangeCheckListArray(astrValues, value, add) {
var astrNewValues = [];
var intCount = astrValues.length;
var blnFound = false;
value = value.toLowerCase();
for (intIndex = 0; intIndex < intCount; intIndex++) {
if (astrValues[intIndex].toLowerCase() == value) {
blnFound = true;
if (add == true) {
astrNewValues.push(astrValues[intIndex]);
}
}
else {
astrNewValues.push(astrValues[intIndex]);
}
}
if ((add == true) && (blnFound == false)) {
astrNewValues.push(value);
}
return astrNewValues;
};
function TreeView_ChangeCheckList(hidCheckBox, arrayName, e, treeNodeId) {
var treeNode = document.getElementById(treeNodeId);
var children = null;
var childCount = 0;
var childIndex = 0;
var chkBox = null;
var hidControl = document.getElementById(hidCheckBox);
var myArray = eval(arrayName);
var strID;
var astrID;
var intIndex;
if (treeNode != null) {
chkBox = treeNode.getElementsByTagName('input');
if (chkBox[0].checked == true) {
children = ob_getChildrenList(treeNode);
childCount = children.length;
for (childIndex = 0; childIndex < childCount; childIndex++) {
chkBox = children[childIndex].getElementsByTagName('input');
if (chkBox[0].checked == false) {
chkBox[0].checked = true;

strID = chkBox[0].id;
astrID = strID.split('_');
strID = astrID[astrID.length - 1];
intIndex = parseInt(strID)
var strValue = myArray[intIndex];

astrValues = hidControl.value.split(',');
astrValues = ChangeCheckListArray(astrValues, strValue, chkBox[0].checked);
hidControl.value = astrValues.toString();
}
TreeView_ChangeCheckList(hidCheckBox, arrayName, e, children[childIndex].id);
}
}
else {
children = ob_getChildrenList(treeNode);
childCount = children.length;
for (childIndex = 0; childIndex < childCount; childIndex++) {
chkBox = children[childIndex].getElementsByTagName('input');
if (chkBox[0].checked == true) {
chkBox[0].checked = false;

strID = chkBox[0].id;
astrID = strID.split('_');
strID = astrID[astrID.length - 1];
intIndex = parseInt(strID)
var strValue = myArray[intIndex];

astrValues = hidControl.value.split(',');
astrValues = ChangeCheckListArray(astrValues, strValue, chkBox[0].checked);
hidControl.value = astrValues.toString();
}
TreeView_ChangeCheckList(hidCheckBox, arrayName, e, children[childIndex].id);
}
}
}
};

function captchaPlayAudio(strSrc) 
{
var soundPluginSpan = document.getElementById('spanPlayAudio');
var param;
var isIE = (navigator.appName == 'Microsoft Internet Explorer');
if(soundPluginSpan == null)
{
soundPluginSpan = document.createElement('div');
soundPluginSpan.id = 'spanPlayAudio';
var bodyRef = document.getElementsByTagName('body').item(0);
bodyRef.appendChild(soundPluginSpan);


}

var soundPlugin = document.getElementById('objPlayAudio');
if (soundPlugin != null)
{
soundPluginSpan.removeChild(soundPlugin);
}
if(isIE)
{
soundPlugin = document.createElement('bgsound');
soundPlugin.id = 'objPlayAudio';
soundPlugin.setAttribute('type','audio/wav');
soundPlugin.setAttribute('src',strSrc + '&b=0&refresh=' + new Date().getTime());
soundPluginSpan.appendChild(soundPlugin);
}
else
{
soundPlugin = document.createElement('embed');
soundPlugin.id = 'objPlayAudio';
soundPlugin.setAttribute('type','audio/wav');
soundPlugin.setAttribute('src',strSrc + '&b=1&refresh=' + new Date().getTime());
soundPlugin.setAttribute('autostart','true');
soundPlugin.setAttribute('loop','false');
soundPlugin.setAttribute('height','0');
soundPlugin.setAttribute('width','0');
soundPlugin.setAttribute('enablejavascript','true');
soundPluginSpan.appendChild(soundPlugin);
}




};

function captchaRefresh(strId, strSrc, intAudio) 
{
var imgCaptcha = document.getElementById(strId);
imgCaptcha.src = strSrc + '&refresh=' + new Date().getTime();

};


var bValidateOverride = false;
var bValidateItemOverride = false;

function CheckPage(validationGroup, useStatusArea) {
if (typeof (Validate) != 'undefined') {
return Validate.Check(validationGroup, useStatusArea);
}
else {
return true;
}
};
var Validator = Class.create();
Validator.prototype = {
items: [],
initialize: function()
{ },
Add: function(control, conditions, messages, runOnCheckAll, runOnBlur, runOnClick, addToBlur, addToMouseOut) {
if (control != null) {
this.items.push(new ValidatorItem(control, conditions, messages, runOnCheckAll, runOnBlur, runOnClick, false));
if (addToMouseOut == true) {
control.onmouseout = function() { Validate.CheckThis(this, event) };
}
if (addToBlur == true) {
control.onblur = function() { Validate.CheckThis(this, event) };
}
}
},
AddById: function(controlId, conditions, messages, runOnCheckAll, runOnBlur, runOnClick, addToBlur, addToMouseOut) {
if (controlId != null) {
this.items.push(new ValidatorItem(controlId, conditions, messages, runOnCheckAll, runOnBlur, runOnClick, true));
}
},

Check: function(validationGroup, useStatusArea) {
if ((typeof (validationGroup) == 'undefined') || (validationGroup == null)) {
validationGroup = '';
}
return this.CheckThis(null, null, validationGroup, useStatusArea);
},
CheckThis: function(checkcontrol, e, validationGroup, useStatusArea) {
var focusId;
var eventType = '';
var itemCount;
if ((e) && (e != null)) {
eventType = e.type;
}
alternativeFocusId = null;
if (bValidateOverride) {
return true;
}
else if ((bValidateItemOverride) && (checkcontrol != null)) {
return false;
}
else if ((messageArea) && (messageArea.messageRaised)) {
return false;
}
if ((typeof (useStatusArea) == 'undefined') || (useStatusArea == null)) {
useStatusArea = false;
}
itemCount = this.items.length;
for (var iLoop = 0; iLoop < itemCount; iLoop++) {
if (this.items[iLoop].control != null) {
if ((checkcontrol == null) || (this.items[iLoop].control.id == checkcontrol.id)) {
for (var iCondition = 0; iCondition < this.items[iLoop].rules.length; iCondition++) {
var that = this.items[iLoop].control;
if (this.items[iLoop].isId) {
that = document.getElementById(that);
}
if ((that != null) && (this.items[iLoop].rules[iCondition].condition.validationGroup == validationGroup) && (this.isDisabled(that) == false) && (this.isReadOnly(that) == false)) {
if ((checkcontrol != null) || (this.items[iLoop].rules[iCondition].runOnCheckAll == 'true')) {
if (!eval(this.items[iLoop].rules[iCondition].condition.rule)) {
if (typeof (this.items[iLoop].rules[iCondition].message) != 'undefined') {
if (alternativeFocusId != null) {
focusId = alternativeFocusId;
}
else {
focusId = this.items[iLoop].control.id;
}
if (useStatusArea == true) {
StatusArea.clear();
StatusArea.add('Fatal', this.items[iLoop].rules[iCondition].message);
}
else {
var msgShown = raiseMessage('validation', this.items[iLoop].rules[iCondition].message, focusId);
}
return false;
break;
}
}
}
}
}
}
}
}
return true;
},
isDisabled: function(that) {
if (typeof (that.disabled) == 'boolean') {
return that.disabled;
}
else {
return false;
}
},
isReadOnly: function(that) {
if (typeof (that.readOnly) == 'boolean') {
return that.readOnly;
}
else {
return false;
}
}
};
var ValidatorItem = Class.create();
ValidatorItem.prototype = {
control: null,
rules: null,
isId: false,
initialize: function(control, conditions, messages, runOnCheckAll, runOnBlur, runOnClick, isId) {
this.control = control;
this.rules = [];
this.isId = isId;
for (var ruleIndex = 0; ruleIndex < conditions.length; ruleIndex++) {
this.rules.push(new ValidatorRule(conditions[ruleIndex], messages[ruleIndex], runOnCheckAll[ruleIndex], runOnBlur[ruleIndex], runOnClick[ruleIndex]));
}
}
};
var ValidatorRule = Class.create();
ValidatorRule.prototype = {
condition: null,
message: null,
runOnCheckAll: false,
runOnBlur: false,
runOnClick: false,
initialize: function(condition, message, runOnCheckAll, runOnBlur, runOnClick) {
this.condition = condition;
this.message = message;
this.runOnCheckAll = runOnCheckAll;
this.runOnBlur = runOnBlur;
this.runOnClick = runOnClick;
}
};


function isMatch(strValue, strExpression) {
var rgMatch = new RegExp(strExpression);
return strValue.match(rgMatch)
}
function upperCase(that) {
that.value = that.value.toUpperCase();
return true;
}
function lowerCase(that) {
that.value = that.value.toLowerCase();
return true;
}
function normalCaseFirst(that) {
that.value = toNormalCase(that.value, ' ', false);
return true;
}
function normalCaseAll(that) {
that.value = toNormalCase(that.value, ' ', true);
return true;
}
function compareDate(strdate_1, strdate_2, strmode) {
var ret_val = false;
if (
typeof (strdate_1) != 'undefined' &&
typeof (strdate_2) != 'undefined' &&
strdate_1 != '' &&
strdate_2 != ''
) {
var new_date_1 = toDate(strdate_1);
var new_date_2 = toDate(strdate_2);
switch (strmode) {
case "greater":
ret_val = new_date_1 > new_date_2;
break;
case "less":
ret_val = new_date_1 < new_date_2;
break;
case "equal":
ret_val = new_date_1 == new_date_2;
break;
case "equgreater":
ret_val = new_date_1 >= new_date_2;
break;
case "equless":
ret_val = new_date_1 <= new_date_2;
break;
default:
ret_val = false;
break;
}
}
else {
return true;
}
return ret_val;
}
function toNormalCase(this_string, word_seperator, all_words) {

var first_letter = new String();
var other_letters = new String();
var temp_string = new String();
if (word_seperator == null) {
word_seperator = ' ';
}
if (all_words != true) {
all_words = false
}
this_string = this_string.toLowerCase();
if (all_words) {
var temp_words = new Array();
temp_words = this_string.split(word_seperator);
var word_num = 0;
for (word_num = 0; word_num < temp_words.length; word_num++) {
first_letter = temp_words[word_num].charAt(0);
other_letters = temp_words[word_num].substring(1, temp_words[word_num].length);
first_letter = first_letter.toUpperCase();
if (temp_string == '') {
temp_string += first_letter + other_letters
}
else {
temp_string += word_seperator + first_letter + other_letters
}
}
}
else {
first_letter = this_string.charAt(0);
other_letters = this_string.substring(1, this_string.length);
first_letter = first_letter.toUpperCase();
temp_string = first_letter + other_letters
}
return (temp_string);
}

function isValidDecimalPercent(that, min, max) {

var return_value = true;
if (isNaN(that)) {
return_value = false;
}
else {
if (that > max || that < min) {
return_value = false;
}
if (that.indexOf('.') > -1) {
var this_value = that.toString();
var value_array = new Array();
value_array = this_value.split('.');
if (value_array.length > 0) {
var decimal_part = value_array[1].toString();
if (decimal_part.length > 2) {
return_value = false;
}
}
}
}
return return_value;
};

function isNumeric(expression) {
var validChars = "0123456789.";
var validSignChars = "-+";
var charValue;
var decimalPointCount = 0;
if ((expression != null) && (expression != 'undefined')) {
for (var charIndex = 0; charIndex < expression.length; charIndex++) {
charValue = expression.charAt(charIndex);
if (validChars.indexOf(charValue) == -1) {
if (!((charIndex == 0) && (validSignChars.indexOf(charValue) != -1))) {
return false;
}
}
if (charValue == '.') {
decimalPointCount++;
}
}
if (decimalPointCount < 2) {
return true;
}
return true;
}
else {
return false;
}
};
function isGenericPhoneNo(strPhone) {
rePhoneNumber = new RegExp(/^\+?\d[-\s\d]*\d$/);
if (strPhone == '') {
return true;
}
if (!rePhoneNumber.test(strPhone)) {
return false;
}
return true;
};
function isEmail(strEmail) {
var reExp;
if (strEmail == '') {
return true;
}
reExp = new RegExp(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
return reExp.test(strEmail);
};
function isDate(strDate) {


if (bValidateOverride) {
return true;
}
if ((strDate != null) && (typeof(strDate.getFullYear) != 'undefined'))
{
return true;
}

var iDay = 0;
var iMonth = 1;
var iYear = 2;
var splitChar = '';
var validformat;

if (strDate.indexOf('/') >= 0) {
validformat = new RegExp(/(0?[1-9]|[12][0-9]|3[01])(\/)(0?[1-9]|1[0-2])(\/)[129][0-9]{3}/);
splitChar = '/';
}
else if (strDate.indexOf('.') >= 0) {
validformat = new RegExp(/(0?[1-9]|[12][0-9]|3[01])(\.)(0?[1-9]|1[0-2])(\.)[129][0-9]{3}/);
splitChar = '.';
}
else if (strDate.indexOf('-') >= 0) {
validformat = new RegExp(/(0?[1-9]|[12][0-9]|3[01])(\-)(0?[1-9]|1[0-2])(\-)[129][0-9]{3}/);
splitChar = '-';
}
else if (strDate.indexOf('\\') >= 0) {
validformat = new RegExp(/(0?[1-9]|[12][0-9]|3[01])(\\)(0?[1-9]|1[0-2])(\\)[129][0-9]{3}/);
splitChar = '\\';
}
else {
return false;
}
if (!strDate.match(validformat)) {
return false;
}
else {
var dayfield = strDate.split(splitChar)[iDay]
var monthfield = strDate.split(splitChar)[iMonth]
var yearfield = strDate.split(splitChar)[iYear]
var dayobj = new Date(yearfield, monthfield - 1, dayfield)
if ((dayobj.getMonth() + 1 != monthfield) || (dayobj.getDate() != dayfield) || (dayobj.getFullYear() != yearfield)) {
return false;
}
else {
return true;
}
}
return true;
}
function toDate(expression) {

if ((typeof (expression) != 'undefined') && (typeof (expression.setYear) != 'undefined')) {
return expression;
}
else if ((typeof (expression) == 'string') && (expression.indexOf('new Date(') > 0)) {
return eval(expression);
}
else if (typeof (expression) == 'number') {
return new Date(expression);
}

var sStartDate = expression.split('/');
var day = 0;
var month = 0;
var year = 0;
if (sStartDate.length > 0) {
day = parseInt(sStartDate[0]);
}
if (sStartDate.length > 1) {
month = parseInt(sStartDate[1]);
}
if (sStartDate.length > 2) {
year = parseInt(sStartDate[2]);
}
if (day == 0) {
day = new Date().getDate();
}
if (month == 0) {
month = new Date().getMonth();
}
if (year == 0) {
year = new Date().getYear();
}
return new Date(year, month, day);
}
function numericComparisons(expression, compareValue, whichComparison) {
var value = null;
var blnComparison = false;
if (expression == '') {
return true;
}
if ((expression != null) && (expression != 'undefined')) {
switch (whichComparison.toLowerCase()) {
case 'numericgreaterthanorequalto':
value = getNumeric(expression, '-.+', true);
if (value >= compareValue) {
blnComparison = true;
}
break;
case 'numericlessthanorequalto':
value = getNumeric(expression, '-.+', true);
if (value <= compareValue) {
blnComparison = true;
}
break;
case 'numericlessthan':
value = getNumeric(expression, '-.+', true);
if (value < compareValue) {
blnComparison = true;
}
break;
case 'numericgreaterthan':
value = getNumeric(expression, '-.+', true);
if (value > compareValue) {
blnComparison = true;
}
break;
case 'numericnotlongerthan':
value = getNumeric(expression, '', true);
if (value.length <= compareValue) {
blnComparison = true;
}
break;
case 'numericnotshorterthan':
value = getNumeric(expression, '', true);
if (value.length >= compareValue) {
blnComparison = true;
}
break;
case 'numericlengthequalto':
value = getNumeric(expression, '', true);
if (value.length == compareValue) {
blnComparison = true;
}
break;
case 'numericnotblank':
value = getNumeric(expression, '', true);
if (value.length > 0) {
blnComparison = true;
}
break;
case 'numericbutnotdecimal':
value = getNumeric(expression, '+.-', true);
var intValue = parseInt(value);
if (value == intValue) {
blnComparison = true;
}
break;
default:
blnComparison = false;
}
}
else {
blnComparison = false;
}
return blnComparison;
};
function getNumericValue(that, allowTheseExtras, blnTreatAsANumber) {
that.value = getNumeric(that.value, allowTheseExtras, blnTreatAsANumber);
return true;
};

function getNumeric(expression, allowTheseExtras, blnTreatAsANumber) {
var blnDecimal = false;
var blnPositiveNegative = false;
var strExpression = '';
var chrAtIndex;
var numList = '0123456789';
var iCharIndex = 0;
if ((expression != null) && (expression != 'undefined')) {
for (iCharIndex = 0; iCharIndex < expression.length; iCharIndex++) {
chrAtIndex = expression.charAt(iCharIndex);
if ((!(numList.indexOf(chrAtIndex) == -1)) || (!(allowTheseExtras.indexOf(chrAtIndex) == -1))) {
if (blnTreatAsANumber) {
if ((chrAtIndex == '.') && (blnDecimal)) {
return false;
}
else if (chrAtIndex == '.') {
blnDecimal = true;
}
else if (((blnPositiveNegative) && (chrAtIndex == '-')) || ((chrAtIndex == '+') && (blnPositiveNegative))) {
return false;
}
else if ((chrAtIndex == '-') || (chrAtIndex == '+')) {
blnPositiveNegative = true;
}
}
strExpression = strExpression.concat(chrAtIndex);
}
}
return strExpression;
}
else {
return false;
}
};


