	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	  /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	  /**
	  * This is a place holder for common utilities used across the javascript validation
	  *
	  **/
	
	  /**
	   * Retreive the name of the form
	   * @param form The form validation is taking place on.
	   */
	  function jcv_retrieveFormName(form) {
	
	      // Please refer to Bugs 31534, 35127, 35294, 37315 & 38159
	      // for the history of the following code
	
	      var formName;
	
	      if (form.getAttributeNode) {
	          if (form.getAttributeNode("id") && form.getAttributeNode("id").value) {
	              formName = form.getAttributeNode("id").value;
	          } else {
	              formName = form.getAttributeNode("name").value;
	          }
	      } else if (form.getAttribute) {
	          if (form.getAttribute("id")) {
	              formName = form.getAttribute("id");
	          } else {
	              formName = form.attributes["name"];
	          }
	      } else {
	          if (form.id) {
	              formName = form.id;
	          } else {
	              formName = form.name;
	          }
	      }
	
	      return formName;
	
	  }  
	
	  /**
	   * Handle error messages.
	   * @param messages Array of error messages.
	   * @param focusField Field to set focus on.
	   */
	  function jcv_handleErrors(messages, focusField) {
	      if (focusField && focusField != null) {
	          var doFocus = true;
	          if (focusField.disabled || focusField.type == 'hidden') {
	              doFocus = false;
	          }
	          if (doFocus && 
	              focusField.style && 
	              focusField.style.visibility &&
	              focusField.style.visibility == 'hidden') {
	              doFocus = false;
	          }
	          if (doFocus) {
	              focusField.focus();
	          }
	      }
	      alert(messages.join('\n'));
	  }
	
	  /**
	   * Checks that the array element is a valid
	   * Commons Validator element and not one inserted by
	   * other JavaScript libraries (for example the
	   * prototype library inserts an "extends" into
	   * all objects, including Arrays).
	   * @param name The element name.
	   * @param value The element value.
	   */
	  function jcv_verifyArrayElement(name, element) {
	      if (element && element.length && element.length == 3) {
	          return true;
	      } else {
	          return false;
	      }
	  }
	
	  /**
	   * Checks whether the field is present on the form.
	   * @param field The form field.
	   */
	  function jcv_isFieldPresent(field) {
	      var fieldPresent = true;
	      if (field == null || (typeof field == 'undefined')) {
	          fieldPresent = false;
	      } else {
	          if (field.disabled) {
	              fieldPresent = false;
	          }
	      }
	      return fieldPresent;
	  }
	
	  /**
	   * Check a value only contains valid numeric digits
	   * @param argvalue The value to check.
	   */
	  function jcv_isAllDigits(argvalue) {
	      argvalue = argvalue.toString();
	      var validChars = "0123456789";
	      var startFrom = 0;
	      if (argvalue.substring(0, 2) == "0x") {
	         validChars = "0123456789abcdefABCDEF";
	         startFrom = 2;
	      } else if (argvalue.charAt(0) == "0") {
	         validChars = "01234567";
	         startFrom = 1;
	      } else if (argvalue.charAt(0) == "-") {
	          startFrom = 1;
	      }
	
	      for (var n = startFrom; n < argvalue.length; n++) {
	          if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
	      }
	      return true;
	  }
	
	  /**
	   * Check a value only contains valid decimal digits
	   * @param argvalue The value to check.
	   */
	  function jcv_isDecimalDigits(argvalue) {
	      argvalue = argvalue.toString();
	      var validChars = "0123456789";
	
	      var startFrom = 0;
	      if (argvalue.charAt(0) == "-") {
	          startFrom = 1;
	      }
	
	      for (var n = startFrom; n < argvalue.length; n++) {
	          if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
	      }
	      return true;
	  }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	   /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * Check to see if fields are in a valid float range.
	    * Fields are not checked if they are disabled.
	    * @param form The form validation is taking place on.
	    */
	    function validateFloatRange(form) {
	        var isValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	        
	        var oRange = eval('new ' + jcv_retrieveFormName(form) +  '_floatRange()');
	        for (var x in oRange) {
	            if (!jcv_verifyArrayElement(x, oRange[x])) {
	                continue;
	            }
	            var field = form[oRange[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	            
	            if ((field.type == 'hidden' ||
	                field.type == 'text' || field.type == 'textarea') &&
	                (field.value.length > 0)) {
	        
	                var fMin = parseFloat(oRange[x][2]("min"));
	                var fMax = parseFloat(oRange[x][2]("max"));
	                var fValue = parseFloat(field.value);
	                if (!(fValue >= fMin && fValue <= fMax)) {
	                    if (i == 0) {
	                        focusField = field;
	                    }
	                    fields[i++] = oRange[x][1];
	                    isValid = false;
	                }
	            }
	        }
	        if (fields.length > 0) {
	            jcv_handleErrors(fields, focusField);
	        }
	        return isValid;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * Check to see if fields are a valid using a regular expression.
	    * Fields are not checked if they are disabled.
	    * @param form The form validation is taking place on.
	    */
	    function validateMask(form) {
	        var isValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	 
	        var oMasked = eval('new ' + jcv_retrieveFormName(form) +  '_mask()');      
	        for (var x in oMasked) {
	            if (!jcv_verifyArrayElement(x, oMasked[x])) {
	                continue;
	            }
	            var field = form[oMasked[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	
	            if ((field.type == 'hidden' ||
		             field.type == 'text' ||
		             field.type == 'password' ||
	                 field.type == 'textarea' ||
					 field.type == 'file') &&
	                 (field.value.length > 0)) {
	
	                if (!jcv_matchPattern(field.value, oMasked[x][2]("mask"))) {
	                    if (i == 0) {
	                        focusField = field;
	                    }
	                    fields[i++] = oMasked[x][1];
	                    isValid = false;
	                }
	            }
	        }
	
	        if (fields.length > 0) {
	           jcv_handleErrors(fields, focusField);
	        }
	        return isValid;
	    }
	
	    function jcv_matchPattern(value, mask) {
	       return mask.exec(value);
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	   /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * Check to see if fields are a valid date.
	    * Fields are not checked if they are disabled.
	    * @param form The form validation is taking place on.
	    */
	    function validateDate(form) {
	       var bValid = true;
	       var focusField = null;
	       var i = 0;
	       var fields = new Array();
	 
	       var oDate = eval('new ' + jcv_retrieveFormName(form) +  '_DateValidations()');
	
	       for (var x in oDate) {
	            if (!jcv_verifyArrayElement(x, oDate[x])) {
	                continue;
	            }
	           var field = form[oDate[x][0]];
	           if (!jcv_isFieldPresent(field)) {
	             continue;
	           }
	           var value = field.value;
	           var isStrict = true;
	           var datePattern = oDate[x][2]("datePatternStrict");
	           // try loose pattern
	           if (datePattern == null) {
	               datePattern = oDate[x][2]("datePattern");
	               isStrict = false;
	           }    
	           if ((field.type == 'hidden' ||
	                field.type == 'text' ||
	                field.type == 'textarea') &&
	               (value.length > 0) && (datePattern.length > 0)) {
	                 var MONTH = "MM";
	                 var DAY = "dd";
	                 var YEAR = "yyyy";
	                 var orderMonth = datePattern.indexOf(MONTH);
	                 var orderDay = datePattern.indexOf(DAY);
	                 var orderYear = datePattern.indexOf(YEAR);
	                 if ((orderDay < orderYear && orderDay > orderMonth)) {
	                     var iDelim1 = orderMonth + MONTH.length;
	                     var iDelim2 = orderDay + DAY.length;
	                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
	                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
	                     if (iDelim1 == orderDay && iDelim2 == orderYear) {
	                        dateRegexp = isStrict 
	                             ? new RegExp("^(\\d{2})(\\d{2})(\\d{4})$") 
	                             : new RegExp("^(\\d{1,2})(\\d{1,2})(\\d{4})$");
	                     } else if (iDelim1 == orderDay) {
	                        dateRegexp = isStrict 
	                             ? new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$")
	                             : new RegExp("^(\\d{1,2})(\\d{1,2})[" + delim2 + "](\\d{4})$");
	                     } else if (iDelim2 == orderYear) {
	                        dateRegexp = isStrict
	                             ? new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$")
	                             : new RegExp("^(\\d{1,2})[" + delim1 + "](\\d{1,2})(\\d{4})$");
	                     } else {
	                        dateRegexp = isStrict
	                             ? new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$")
	                             : new RegExp("^(\\d{1,2})[" + delim1 + "](\\d{1,2})[" + delim2 + "](\\d{4})$");
	                     }
	                     var matched = dateRegexp.exec(value);
	                     if(matched != null) {
	                        if (!jcv_isValidDate(matched[2], matched[1], matched[3])) {
	                           if (i == 0) {
	                               focusField = field;
	                           }
	                           fields[i++] = oDate[x][1];
	                           bValid =  false;
	                        }
	                     } else {
	                        if (i == 0) {
	                            focusField = field;
	                        }
	                        fields[i++] = oDate[x][1];
	                        bValid =  false;
	                     }
	                 } else if ((orderMonth < orderYear && orderMonth > orderDay)) {
	                     var iDelim1 = orderDay + DAY.length;
	                     var iDelim2 = orderMonth + MONTH.length;
	                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
	                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
	                     if (iDelim1 == orderMonth && iDelim2 == orderYear) {
	                         dateRegexp = isStrict 
	                            ? new RegExp("^(\\d{2})(\\d{2})(\\d{4})$")
	                            : new RegExp("^(\\d{1,2})(\\d{1,2})(\\d{4})$");
	                     } else if (iDelim1 == orderMonth) {
	                         dateRegexp = isStrict
	                            ? new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$")
	                            : new RegExp("^(\\d{1,2})(\\d{1,2})[" + delim2 + "](\\d{4})$");
	                     } else if (iDelim2 == orderYear) {
	                         dateRegexp = isStrict
	                            ? new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$")
	                            : new RegExp("^(\\d{1,2})[" + delim1 + "](\\d{1,2})(\\d{4})$");
	                     } else {
	                         dateRegexp = isStrict
	                            ? new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$")
	                            : new RegExp("^(\\d{1,2})[" + delim1 + "](\\d{1,2})[" + delim2 + "](\\d{4})$");
	                     }
	                     var matched = dateRegexp.exec(value);
	                     if(matched != null) {
	                         if (!jcv_isValidDate(matched[1], matched[2], matched[3])) {
	                             if (i == 0) {
	                                  focusField = field;
	                             }
	                             fields[i++] = oDate[x][1];
	                             bValid =  false;
	                          }
	                     } else {
	                         if (i == 0) {
	                             focusField = field;
	                         }
	                         fields[i++] = oDate[x][1];
	                         bValid =  false;
	                     }
	                 } else if ((orderMonth > orderYear && orderMonth < orderDay)) {
	                     var iDelim1 = orderYear + YEAR.length;
	                     var iDelim2 = orderMonth + MONTH.length;
	                     var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
	                     var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
	                     if (iDelim1 == orderMonth && iDelim2 == orderDay) {
	                         dateRegexp = isStrict
	                            ? new RegExp("^(\\d{4})(\\d{2})(\\d{2})$")
	                            : new RegExp("^(\\d{4})(\\d{1,2})(\\d{1,2})$");
	                     } else if (iDelim1 == orderMonth) {
	                         dateRegexp = isStrict
	                            ? new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$")
	                            : new RegExp("^(\\d{4})(\\d{1,2})[" + delim2 + "](\\d{1,2})$");
	                     } else if (iDelim2 == orderDay) {
	                         dateRegexp = isStrict
	                            ? new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$")
	                            : new RegExp("^(\\d{4})[" + delim1 + "](\\d{1,2})(\\d{1,2})$");
	                     } else {
	                         dateRegexp = isStrict
	                            ? new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{2})$")
	                            : new RegExp("^(\\d{4})[" + delim1 + "](\\d{1,2})[" + delim2 + "](\\d{1,2})$");
	                     }
	                     var matched = dateRegexp.exec(value);
	                     if(matched != null) {
	                         if (!jcv_isValidDate(matched[3], matched[2], matched[1])) {
	                             if (i == 0) {
	                                 focusField = field;
	                             }
	                             fields[i++] = oDate[x][1];
	                             bValid =  false;
	                         }
	                     } else {
	                          if (i == 0) {
	                              focusField = field;
	                          }
	                          fields[i++] = oDate[x][1];
	                          bValid =  false;
	                     }
	                 } else {
	                     if (i == 0) {
	                         focusField = field;
	                     }
	                     fields[i++] = oDate[x][1];
	                     bValid =  false;
	                 }
	          }
	       }
	       if (fields.length > 0) {
	          jcv_handleErrors(fields, focusField);
	       }
	       return bValid;
	    }
	    
	    function jcv_isValidDate(day, month, year) {
		    if (month < 1 || month > 12) {
	            return false;
	        }
	        if (day < 1 || day > 31) {
	            return false;
	        }
	        if ((month == 4 || month == 6 || month == 9 || month == 11) &&
	            (day == 31)) {
	            return false;
	        }
	        if (month == 2) {
	            var leap = (year % 4 == 0 &&
	               (year % 100 != 0 || year % 400 == 0));
	            if (day>29 || (day == 29 && !leap)) {
	                return false;
	            }
	        }
	        return true;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * Check to see if fields are a valid float.
	    * Fields are not checked if they are disabled.
	    * @param form The form validation is taking place on.
	    */
	    function validateFloat(form) {
	        var bValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	 
	        var oFloat = eval('new ' + jcv_retrieveFormName(form) +  '_FloatValidations()');
	        for (var x in oFloat) {
	            if (!jcv_verifyArrayElement(x, oFloat[x])) {
	                continue;
	            }
	        	var field = form[oFloat[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	        	
	            if ((field.type == 'hidden' ||
	                field.type == 'text' ||
	                field.type == 'textarea' ||
	                field.type == 'select-one' ||
	                field.type == 'radio')) {
	        
	            	var value = '';
	                // get field's value
	                if (field.type == "select-one") {
	                    var si = field.selectedIndex;
	                    if (si >= 0) {
	                        value = field.options[si].value;
	                    }
	                } else {
	                    value = field.value;
	                }
	        
	                if (value.length > 0) {
	                    // remove '.' before checking digits
	                    var tempArray = value.split('.');
	                    //Strip off leading '0'
	                    var zeroIndex = 0;
	                    var joinedString= tempArray.join('');
	                    while (joinedString.charAt(zeroIndex) == '0') {
	                        zeroIndex++;
	                    }
	                    var noZeroString = joinedString.substring(zeroIndex,joinedString.length);
	
	                    if (!jcv_isAllDigits(noZeroString) || tempArray.length > 2) {
	                        bValid = false;
	                        if (i == 0) {
	                            focusField = field;
	                        }
	                        fields[i++] = oFloat[x][1];
	
	                    } else {
		                var iValue = parseFloat(value);
		                if (isNaN(iValue)) {
		                    if (i == 0) {
		                        focusField = field;
		                    }
		                    fields[i++] = oFloat[x][1];
		                    bValid = false;
		                }
	                    }
	                }
	            }
	        }
	        if (fields.length > 0) {
	           jcv_handleErrors(fields, focusField);
	        }
	        return bValid;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    *  Check to see if fields are a valid short.
	    * Fields are not checked if they are disabled.
	    *
	    * @param form The form validation is taking place on.
	    */
	    function validateShort(form) {
	        var bValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	 
	        var oShort = eval('new ' + jcv_retrieveFormName(form) +  '_ShortValidations()');
	
	        for (var x in oShort) {
	            if (!jcv_verifyArrayElement(x, oShort[x])) {
	                continue;
	            }
	            var field = form[oShort[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	
	            if ((field.type == 'hidden' ||
	                field.type == 'text' ||
	                field.type == 'textarea' ||
	                field.type == 'select-one' ||
	                field.type == 'radio')) {
	
	                var value = '';
	                // get field's value
	                if (field.type == "select-one") {
	                    var si = field.selectedIndex;
	                    if (si >= 0) {
	                        value = field.options[si].value;
	                    }
	                } else {
	                    value = field.value;
	                }
	
	                if (value.length > 0) {
	                    if (!jcv_isDecimalDigits(value)) {
	                        bValid = false;
	                        if (i == 0) {
	                            focusField = field;
	                        }
	                        fields[i++] = oShort[x][1];
	
	                    } else {
	
	                        var iValue = parseInt(value, 10);
	                        if (isNaN(iValue) || !(iValue >= -32768 && iValue <= 32767)) {
	                            if (i == 0) {
	                                focusField = field;
	                            }
	                            fields[i++] = oShort[x][1];
	                            bValid = false;
	                        }
	                   }
	               }
	            }
	        }
	        if (fields.length > 0) {
	           jcv_handleErrors(fields, focusField);
	        }
	        return bValid;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * A field is considered valid if less than the specified maximum.
	    * Fields are not checked if they are disabled.
	    *
	    *  Caution: Using validateMaxLength() on a password field in a 
	    *  login page gives unnecessary information away to hackers. While it only slightly
	    *  weakens security, we suggest using it only when modifying a password.
	    * @param form The form validation is taking place on.
	    */
	    function validateMaxLength(form) {
	        var isValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	 
	        var oMaxLength = eval('new ' + jcv_retrieveFormName(form) +  '_maxlength()');        
	        for (var x in oMaxLength) {
	            if (!jcv_verifyArrayElement(x, oMaxLength[x])) {
	                continue;
	            }
	            var field = form[oMaxLength[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	
	            if ((field.type == 'hidden' ||
	                field.type == 'text' ||
	                field.type == 'password' ||
	                field.type == 'textarea')) {
	
	                /* Adjust length for carriage returns - see Bug 37962 */
	                var lineEndLength = oMaxLength[x][2]("lineEndLength");
	                var adjustAmount = 0;
	                if (lineEndLength) {
	                    var rCount = 0;
	                    var nCount = 0;
	                    var crPos = 0;
	                    while (crPos < field.value.length) {
	                        var currChar = field.value.charAt(crPos);
	                        if (currChar == '\r') {
	                            rCount++;
	                        }
	                        if (currChar == '\n') {
	                            nCount++;
	                        }
	                        crPos++;
	                    }
	                    var endLength = parseInt(lineEndLength);
	                    adjustAmount = (nCount * endLength) - (rCount + nCount);
	                }
	
	                var iMax = parseInt(oMaxLength[x][2]("maxlength"));
	                if ((field.value.length + adjustAmount)  > iMax) {
	                    if (i == 0) {
	                        focusField = field;
	                    }
	                    fields[i++] = oMaxLength[x][1];
	                    isValid = false;
	                }
	            }
	        }
	        if (fields.length > 0) {
	           jcv_handleErrors(fields, focusField);
	        }
	        return isValid;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * Check to see if fields are a valid byte.
	    * Fields are not checked if they are disabled.
	    * @param form The form validation is taking place on.
	    */
	    function validateByte(form) {
	        var bValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	        
	        var oByte = eval('new ' + jcv_retrieveFormName(form) + '_ByteValidations()');
	
	        for (var x in oByte) {
	            if (!jcv_verifyArrayElement(x, oByte[x])) {
	                continue;
	            }
	            var field = form[oByte[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	
	            if ((field.type == 'hidden' ||
	                field.type == 'text' ||
	                field.type == 'textarea' ||
	                field.type == 'select-one' ||
	                field.type == 'radio')) {
	
	                var value = '';
	                // get field's value
	                if (field.type == "select-one") {
	                    var si = field.selectedIndex;
	                    if (si >= 0) {
	                        value = field.options[si].value;
	                    }
	                } else {
	                    value = field.value;
	                }
	
	                if (value.length > 0) {
	                    if (!jcv_isDecimalDigits(value)) {
	                        bValid = false;
	                        if (i == 0) {
	                            focusField = field;
	                        }
	                        fields[i++] = oByte[x][1];
	
	                    } else {
	
	                        var iValue = parseInt(value, 10);
	                        if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) {
	                            if (i == 0) {
	                                focusField = field;
	                            }
	                            fields[i++] = oByte[x][1];
	                            bValid = false;
	                        }
	                    }
	                }
	
	            }
	        }
	        if (fields.length > 0) {
	           jcv_handleErrors(fields, focusField);
	        }
	        return bValid;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    *  Check to see if fields must contain a value.
	    * Fields are not checked if they are disabled.
	    *
	    * @param form The form validation is taking place on.
	    */
	
	    function validateRequired(form) {
	        var isValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	
	        var oRequired = eval('new ' + jcv_retrieveFormName(form) +  '_required()');
	
	        for (var x in oRequired) {

	            var checkName = oRequired[x][0];
	            
	            if(checkName == 'equalsPassword'){
		            var field = form[oRequired[x][2]];
	            	var field1 = form[oRequired[x][2]];
	            	var field2 = form[oRequired[x][3]];
	            	if(trim(field1.value).length == 0 || trim(field2.value).length == 0){	      
			            fields[i++] = oRequired[x][1];      		
	            		isValid = false;
	            	}else{
	            		if(jcv_EqualsChk(field1,field2)){
	            			isValid = true;
	            		}else{	      
				            fields[i++] = oRequired[x][1];   
	            			isValid = false;
	            		}	
	            	}	            	
	            }else{
		            if (!jcv_verifyArrayElement(x, oRequired[x])) {
		                continue;
		            }		            
		            var field = form[oRequired[x][0]];
		
		            if (!jcv_isFieldPresent(field)) {
		                fields[i++] = oRequired[x][1];
		                isValid=false;
		            } else if ((field.type == 'hidden' ||
		                field.type == 'text' ||
		                field.type == 'textarea' ||
		                field.type == 'file' ||
		                field.type == 'radio' ||
		                field.type == 'checkbox' ||
		                field.type == 'select-one' ||
		                field.type == 'password')) {
		
		                var value = '';
		                // get field's value
		                if (field.type == "select-one") {
		                    var si = field.selectedIndex;
		                    if (si >= 0) {
		                        value = field.options[si].value;
		                    }
		                } else if (field.type == 'radio' || field.type == 'checkbox') {
		                    if (field.checked) {
		                        value = field.value;
		                    }
		                } else {
		                    value = field.value;
		                }
		
		                if (trim(value).length == 0) {
		
		                    if ((i == 0) && (field.type != 'hidden')) {
		                        focusField = field;
		                    }
		                    fields[i++] = oRequired[x][1];
		                    isValid = false;
		                }
		            } else if (field.type == "select-multiple") { 
		                var numOptions = field.options.length;
		                lastSelected=-1;
		                for(loop=numOptions-1;loop>=0;loop--) {
		                    if(field.options[loop].selected) {
		                        lastSelected = loop;
		                        value = field.options[loop].value;
		                        break;
		                    }
		                }
		                if(lastSelected < 0 || trim(value).length == 0) {
		                    if(i == 0) {
		                        focusField = field;
		                    }
		                    fields[i++] = oRequired[x][1];
		                    isValid=false;
		                }
		            } else if ((field.length > 0) && (field[0].type == 'radio' || field[0].type == 'checkbox')) {
		                isChecked=-1;
		                for (loop=0;loop < field.length;loop++) {
		                    if (field[loop].checked) {
		                        isChecked=loop;
		                        break; // only one needs to be checked
		                    }
		                }
		                if (isChecked < 0) {
		                    if (i == 0) {
		                        focusField = field[0];
		                    }
		                    fields[i++] = oRequired[x][1];
		                    isValid=false;
		                }
		            }   
	            }
	        }
	        if (fields.length > 0) {
	           jcv_handleErrors(fields, focusField);
	        }
	        return isValid;
	    }
	    
	    // Trim whitespace from left and right sides of s.
	    function trim(s) {
	        return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * A field is considered valid if greater than the specified minimum.
	    * Fields are not checked if they are disabled.
	    *
	    *  Caution: Using validateMinLength() on a password field in a 
	    *  login page gives unnecessary information away to hackers. While it only slightly
	    *  weakens security, we suggest using it only when modifying a password.
	    * @param form The form validation is taking place on.
	    */
	    function validateMinLength(form) {
	        var isValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	
	        var oMinLength = eval('new ' + jcv_retrieveFormName(form) +  '_minlength()');
	
	        for (var x in oMinLength) {
	            if (!jcv_verifyArrayElement(x, oMinLength[x])) {
	                continue;
	            }
	            var field = form[oMinLength[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	
	            if ((field.type == 'hidden' ||
	                field.type == 'text' ||
	                field.type == 'password' ||
	                field.type == 'textarea')) {
	
	                /* Adjust length for carriage returns - see Bug 37962 */
	                var lineEndLength = oMinLength[x][2]("lineEndLength");
	                var adjustAmount = 0;
	                if (lineEndLength) {
	                    var rCount = 0;
	                    var nCount = 0;
	                    var crPos = 0;
	                    while (crPos < field.value.length) {
	                        var currChar = field.value.charAt(crPos);
	                        if (currChar == '\r') {
	                            rCount++;
	                        }
	                        if (currChar == '\n') {
	                            nCount++;
	                        }
	                        crPos++;
	                    }
	                    var endLength = parseInt(lineEndLength);
	                    adjustAmount = (nCount * endLength) - (rCount + nCount);
	                }
	
	                var iMin = parseInt(oMinLength[x][2]("minlength"));
	                if ((trim(field.value).length > 0) && ((field.value.length + adjustAmount) < iMin)) {
	                    if (i == 0) {
	                        focusField = field;
	                    }
	                    fields[i++] = oMinLength[x][1];
	                    isValid = false;
	                }
	            }
	        }
	        if (fields.length > 0) {
	           jcv_handleErrors(fields, focusField);
	        }
	        return isValid;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * Check to see if fields is in a valid integer range.
	    * Fields are not checked if they are disabled.
	    * @param form The form validation is taking place on.
	    */
	    function validateIntRange(form) {
	        var isValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	 
	        var oRange = eval('new ' + jcv_retrieveFormName(form) +  '_intRange()');        
	        for (var x in oRange) {
	            if (!jcv_verifyArrayElement(x, oRange[x])) {
	                continue;
	            }
	            var field = form[oRange[x][0]];
	            if (jcv_isFieldPresent(field)) {
	                var value = '';
	                if (field.type == 'hidden' ||
	                    field.type == 'text' || field.type == 'textarea' ||
	                    field.type == 'radio' ) {
	                    value = field.value;
	                }
	                if (field.type == 'select-one') {
	                    var si = field.selectedIndex;
	                    if (si >= 0) {
	                        value = field.options[si].value;
	                    }
	                }
	                if (value.length > 0) {
	                    var iMin = parseInt(oRange[x][2]("min"));
	                    var iMax = parseInt(oRange[x][2]("max"));
	                    var iValue = parseInt(value, 10);
	                    if (!(iValue >= iMin && iValue <= iMax)) {
	                        if (i == 0) {
	                            focusField = field;
	                        }
	                        fields[i++] = oRange[x][1];
	                        isValid = false;
	                    }
	                }
	            }
	        }
	        if (fields.length > 0) {
	            jcv_handleErrors(fields, focusField);
	        }
	        return isValid;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * Check to see if fields are a valid integer.
	    * Fields are not checked if they are disabled.
	    * @param form The form validation is taking place on.
	    */
	    function validateInteger(form) {
	        var bValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	 
	        var oInteger = eval('new ' + jcv_retrieveFormName(form) +  '_IntegerValidations()');
	        for (var x in oInteger) {
	            if (!jcv_verifyArrayElement(x, oInteger[x])) {
	                continue;
	            }
	            var field = form[oInteger[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	
	            if ((field.type == 'hidden' ||
	                field.type == 'text' ||
	                field.type == 'textarea' ||
	                field.type == 'select-one' ||
	                field.type == 'radio')) {
	
	                var value = '';
	                // get field's value
	                if (field.type == "select-one") {
	                    var si = field.selectedIndex;
	                    if (si >= 0) {
	                        value = field.options[si].value;
	                    }
	                } else {
	                    value = field.value;
	                }
	
	                if (value.length > 0) {
	
	                    if (!jcv_isDecimalDigits(value)) {
	                        bValid = false;
	                        if (i == 0) {
	                            focusField = field;
	                        }
	                        fields[i++] = oInteger[x][1];
	
	                    } else {
	                        var iValue = parseInt(value, 10);
	                        if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
	                            if (i == 0) {
	                                focusField = field;
	                            }
	                            fields[i++] = oInteger[x][1];
	                            bValid = false;
	                       }
	                   }
	               }
	            }
	        }
	        if (fields.length > 0) {
	           jcv_handleErrors(fields, focusField);
	        }
	        return bValid;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * Check to see if fields are a valid creditcard number based on Luhn checksum.
	    * Fields are not checked if they are disabled.
	    * @param form The form validation is taking place on.
	    */
	    function validateCreditCard(form) {
	        var bValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	 
	        var oCreditCard = eval('new ' + jcv_retrieveFormName(form) +  '_creditCard()');
	
	        for (var x in oCreditCard) {
	            if (!jcv_verifyArrayElement(x, oCreditCard[x])) {
	                continue;
	            }
	            var field = form[oCreditCard[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	            if ((field.type == 'text' ||
	                 field.type == 'textarea') &&
	                (field.value.length > 0)) {
	                if (!jcv_luhnCheck(field.value)) {
	                    if (i == 0) {
	                        focusField = field;
	                    }
	                    fields[i++] = oCreditCard[x][1];
	                    bValid = false;
	                }
	            }
	        }
	        if (fields.length > 0) {
	            jcv_handleErrors(fields, focusField);
	        }
	        return bValid;
	    }
	
	    /**
	     * Checks whether a given credit card number has a valid Luhn checksum.
	     * This allows you to spot most randomly made-up or garbled credit card numbers immediately.
	     * Reference: http://www.speech.cs.cmu.edu/~sburke/pub/luhn_lib.html
	     */
	    function jcv_luhnCheck(cardNumber) {
	        if (jcv_isLuhnNum(cardNumber)) {
	            var no_digit = cardNumber.length;
	            var oddoeven = no_digit & 1;
	            var sum = 0;
	            for (var count = 0; count < no_digit; count++) {
	                var digit = parseInt(cardNumber.charAt(count));
	                if (!((count & 1) ^ oddoeven)) {
	                    digit *= 2;
	                    if (digit > 9) digit -= 9;
	                };
	                sum += digit;
	            };
	            if (sum == 0) return false;
	            if (sum % 10 == 0) return true;
	        };
	        return false;
	    }
	
	    function jcv_isLuhnNum(argvalue) {
	        argvalue = argvalue.toString();
	        if (argvalue.length == 0) {
	            return false;
	        }
	        for (var n = 0; n < argvalue.length; n++) {
	            if ((argvalue.substring(n, n+1) < "0") ||
	                (argvalue.substring(n,n+1) > "9")) {
	                return false;
	            }
	        }
	        return true;
	    }
	
	/*
	 * Licensed to the Apache Software Foundation (ASF) under one or more
	 * contributor license agreements.  See the NOTICE file distributed with
	 * this work for additional information regarding copyright ownership.
	 * The ASF licenses this file to You under the Apache License, Version 2.0
	 * (the "License"); you may not use this file except in compliance with
	 * the License.  You may obtain a copy of the License at
	 *
	 *    http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
	    /*$RCSfile: AnselmUtil.js,v $ $Rev: 478676 $ $Date: 2011/09/15 07:25:42 $ */
	    /**
	    * Check to see if fields are a valid email address.
	    * Fields are not checked if they are disabled.
	    * @param form The form validation is taking place on.
	    */
	    function validateEmail(form) {
	        var bValid = true;
	        var focusField = null;
	        var i = 0;
	        var fields = new Array();
	
	        var oEmail = eval('new ' + jcv_retrieveFormName(form) +  '_email()');
	
	        for (var x in oEmail) {
	            if (!jcv_verifyArrayElement(x, oEmail[x])) {
	                continue;
	            }
	            var field = form[oEmail[x][0]];
	            if (!jcv_isFieldPresent(field)) {
	              continue;
	            }
	            if ((field.type == 'hidden' || 
	                 field.type == 'text' ||
	                 field.type == 'textarea') &&
	                (field.value.length > 0)) {
	                if (!jcv_checkEmail(field.value)) {
	                    if (i == 0) {
	                        focusField = field;
	                    }
	                    fields[i++] = oEmail[x][1];
	                    bValid = false;
	                }
	            }
	        }
	        if (fields.length > 0) {
	            jcv_handleErrors(fields, focusField);
	        }
	        return bValid;
	    }
	
	    /**
	     * Reference: Sandeep V. Tamhankar (stamhankar@hotmail.com),
	     * http://javascript.internet.com
	     */
	    function jcv_checkEmail(emailStr) {
	        if (emailStr.length == 0) {
	            return true;
	        }
	        // TLD checking turned off by default
	        var checkTLD=0;
	        var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	        var emailPat=/^(.+)@(.+)$/;
	        var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	        var validChars="\[^\\s" + specialChars + "\]";
	        var quotedUser="(\"[^\"]*\")";
	        var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	        var atom=validChars + '+';
	        var word="(" + atom + "|" + quotedUser + ")";
	        var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	        var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	        var matchArray=emailStr.match(emailPat);
	        if (matchArray==null) {
	            return false;
	        }
	        var user=matchArray[1];
	        var domain=matchArray[2];
	        for (i=0; i<user.length; i++) {
	            if (user.charCodeAt(i)>127) {
	                return false;
	            }
	        }
	        for (i=0; i<domain.length; i++) {
	            if (domain.charCodeAt(i)>127) {
	                return false;
	            }
	        }
	        if (user.match(userPat)==null) {
	            return false;
	        }
	        var IPArray=domain.match(ipDomainPat);
	        if (IPArray!=null) {
	            for (var i=1;i<=4;i++) {
	                if (IPArray[i]>255) {
	                    return false;
	                }
	            }
	            return true;
	        }
	        var atomPat=new RegExp("^" + atom + "$");
	        var domArr=domain.split(".");
	        var len=domArr.length;
	        for (i=0;i<len;i++) {
	            if (domArr[i].search(atomPat)==-1) {
	                return false;
	            }
	        }
	        if (checkTLD && domArr[domArr.length-1].length!=2 && 
	            domArr[domArr.length-1].search(knownDomsPat)==-1) {
	            return false;
	        }
	        if (len<2) {
	            return false;
	        }
	        return true;
	    }
	

	    function jcv_EqualsChk(field1, field2) {
	  	  var bValid = true;
	  	  if (field1.value != field2.value){
	  		bValid = false;
	  	  }else{
	  		bValid = true;
	  	  }	  	 	  
	        return bValid;
	  }	

//-------------------------------------------------------------------
//hasOptions(obj)
//Utility function to determine if a select object has an options array
//-------------------------------------------------------------------
function hasOptions(obj) {
	if (obj!=null && obj.options!=null) { return true; }
	return false;
}

//-------------------------------------------------------------------
//selectUnselectMatchingOptions(select_object,regex,select/unselect,true/false)
//This is a general function used by the select functions below, to
//avoid code duplication
//-------------------------------------------------------------------
function selectUnselectMatchingOptions(obj,regex,which,only) {
	if (window.RegExp) {
		if (which == "select") {
			var selected1=true;
			var selected2=false;
		}
		else if (which == "unselect") {
			var selected1=false;
			var selected2=true;
		}
		else {
			return;
		}
		var re = new RegExp(regex);
		if (!hasOptions(obj)) { return; }
		for (var i=0; i<obj.options.length; i++) {
			if (re.test(obj.options[i].text)) {
				obj.options[i].selected = selected1;
			}
			else {
				if (only == true) {
					obj.options[i].selected = selected2;
				}
			}
		}
	}
}

//-------------------------------------------------------------------
//selectMatchingOptions(select_object,regex)
//This function selects all options that match the regular expression
//passed in. Currently-selected options will not be changed.
//-------------------------------------------------------------------
function selectMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"select",false);
}
//-------------------------------------------------------------------
//selectOnlyMatchingOptions(select_object,regex)
//This function selects all options that match the regular expression
//passed in. Selected options that don't match will be un-selected.
//-------------------------------------------------------------------
function selectOnlyMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"select",true);
}
//-------------------------------------------------------------------
//unSelectMatchingOptions(select_object,regex)
//This function Unselects all options that match the regular expression
//passed in. 
//-------------------------------------------------------------------
function unSelectMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"unselect",false);
}

//-------------------------------------------------------------------
//sortSelect(select_object)
//Pass this function a SELECT object and the options will be sorted
//by their text (display) values
//-------------------------------------------------------------------
function sortSelect(obj) {
	var o = new Array();
	if (!hasOptions(obj)) { return; }
	for (var i=0; i<obj.options.length; i++) {
		o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
	}
	if (o.length==0) { return; }
	o = o.sort( 
		function(a,b) { 
			if ((a.text+"") < (b.text+"")) { return -1; }
			if ((a.text+"") > (b.text+"")) { return 1; }
			return 0;
		} 
	);

	for (var i=0; i<o.length; i++) {
		obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	}
}

//-------------------------------------------------------------------
//selectAllOptions(select_object)
//This function takes a select box and selects all options (in a 
//multiple select object). This is used when passing values between
//two select boxes. Select all options in the right box before 
//submitting the form so the values will be sent to the server.
//-------------------------------------------------------------------
function selectAllOptions(obj) {
	if (!hasOptions(obj)) { return; }
	for (var i=0; i<obj.options.length; i++) {
		obj.options[i].selected = true;
	}
}

//-------------------------------------------------------------------
//unSelectAllOptions(select_object)
//This function takes a select box and selects all options (in a 
//multiple select object). This is used when passing values between
//two select boxes. Select all options in the right box before 
//submitting the form so the values will be sent to the server.
//-------------------------------------------------------------------
function unSelectAllOptions(obj) {
	if (!hasOptions(obj)) { return; }
	for (var i=0; i<obj.options.length; i++) {
		obj.options[i].selected = false;
	}
}

//-------------------------------------------------------------------
//moveSelectedOptions(select_object,select_object[,autosort(true/false)[,regex]])
//This function moves options between select boxes. Works best with
//multi-select boxes to create the common Windows control effect.
//Passes all selected values from the first object to the second
//object and re-sorts each box.
//If a third argument of 'false' is passed, then the lists are not
//sorted after the move.
//If a fourth string argument is passed, this will function as a
//Regular Expression to match against the TEXT or the options. If 
//the text of an option matches the pattern, it will NOT be moved.
//It will be treated as an unmoveable option.
//You can also put this into the <SELECT> object as follows:
// onDblClick="moveSelectedOptions(this,this.form.target)
//This way, when the user double-clicks on a value in one box, it
//will be transferred to the other (in browsers that support the 
//onDblClick() event handler).
//-------------------------------------------------------------------
function moveSelectedOptions(from,to) {
	//Unselect matching options, if required
	if (arguments.length>3) {
		var regex = arguments[3];
		if (regex != "") {
			unSelectMatchingOptions(from,regex);
		}
	
	}
	//Move them over
	if (!hasOptions(from)) { return; }
	
	for (var i=0; i<from.options.length; i++) {
		var o = from.options[i];
		if (o.selected) {
			if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
			to.options[index] = new Option( o.text, o.value, false, false);
		}
	}
	//Delete them from original
	for (var i=(from.options.length-1); i>=0; i--) {
		var o = from.options[i];
		if (o.selected) {
			from.options[i] = null;
		}
	}
	if ((arguments.length<3) || (arguments[2]==true)) {
		sortSelect(from);
		sortSelect(to);
	}
	from.selectedIndex = -1;
	to.selectedIndex = -1;
}

//-------------------------------------------------------------------
//copySelectedOptions(select_object,select_object[,autosort(true/false)])
//This function copies options between select boxes instead of 
//moving items. Duplicates in the target list are not allowed.
//-------------------------------------------------------------------
function copySelectedOptions(from,to) {
	var options = new Object();
	if (hasOptions(to)) {
		for (var i=0; i<to.options.length; i++) {
			options[to.options[i].value] = to.options[i].text;
		}
	}
	if (!hasOptions(from)) { return; }
	for (var i=0; i<from.options.length; i++) {
		var o = from.options[i];
		if (o.selected) {
			if (options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text) {
			if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
				to.options[index] = new Option( o.text, o.value, false, false);
			}
		}
	}
	if ((arguments.length<3) || (arguments[2]==true)) {
		sortSelect(to);
	}
	from.selectedIndex = -1;
	to.selectedIndex = -1;
}

//-------------------------------------------------------------------
//moveAllOptions(select_object,select_object[,autosort(true/false)[,regex]])
//Move all options from one select box to another.
//-------------------------------------------------------------------
function moveAllOptions(from,to) {
	selectAllOptions(from);
	if (arguments.length==2) {
		moveSelectedOptions(from,to);
	}
	else if (arguments.length==3) {
		moveSelectedOptions(from,to,arguments[2]);
	}
	else if (arguments.length==4) {
		moveSelectedOptions(from,to,arguments[2],arguments[3]);
	}
}

//-------------------------------------------------------------------
//copyAllOptions(select_object,select_object[,autosort(true/false)])
//Copy all options from one select box to another, instead of
//removing items. Duplicates in the target list are not allowed.
//-------------------------------------------------------------------
function copyAllOptions(from,to) {
	selectAllOptions(from);
	if (arguments.length==2) {
		copySelectedOptions(from,to);
	}
	else if (arguments.length==3) {
		copySelectedOptions(from,to,arguments[2]);
	}
}

//-------------------------------------------------------------------
//swapOptions(select_object,option1,option2)
//Swap positions of two options in a select list
//-------------------------------------------------------------------
function swapOptions(obj,i,j) {
	var o = obj.options;
	var i_selected = o[i].selected;
	var j_selected = o[j].selected;
	var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
	o[i] = temp2;
	o[j] = temp;
	o[i].selected = j_selected;
	o[j].selected = i_selected;
}

//-------------------------------------------------------------------
//moveOptionUp(select_object)
//Move selected option in a select list up one
//-------------------------------------------------------------------
function moveOptionUp(obj) {
	if (!hasOptions(obj)) { return; }
	for (i=0; i<obj.options.length; i++) {
		if (obj.options[i].selected) {
			if (i != 0 && !obj.options[i-1].selected) {
				swapOptions(obj,i,i-1);
				obj.options[i-1].selected = true;
			}
		}
	}
}

//-------------------------------------------------------------------
//moveOptionDown(select_object)
//Move selected option in a select list down one
//-------------------------------------------------------------------
function moveOptionDown(obj) {
	if (!hasOptions(obj)) { return; }
	for (i=obj.options.length-1; i>=0; i--) {
		if (obj.options[i].selected) {
			if (i != (obj.options.length-1) && ! obj.options[i+1].selected) {
				swapOptions(obj,i,i+1);
				obj.options[i+1].selected = true;
			}
		}
	}
}

//-------------------------------------------------------------------
//removeSelectedOptions(select_object)
//Remove all selected options from a list
//(Thanks to Gene Ninestein)
//-------------------------------------------------------------------
function removeSelectedOptions(from) { 
	if (!hasOptions(from)) { return; }
	if (from.type=="select-one") {
		from.options[from.selectedIndex] = null;
	}
	else {
		for (var i=(from.options.length-1); i>=0; i--) { 
			var o=from.options[i]; 
			if (o.selected) { 
				from.options[i] = null; 
			} 
		}
	}
	from.selectedIndex = -1; 
} 

//-------------------------------------------------------------------
//removeAllOptions(select_object)
//Remove all options from a list
//-------------------------------------------------------------------
function removeAllOptions(from) { 
	if (!hasOptions(from)) { return; }
	for (var i=(from.options.length-1); i>=0; i--) { 
		from.options[i] = null; 
	} 
	from.selectedIndex = -1; 
} 

//-------------------------------------------------------------------
//addOption(select_object,display_text,value,selected)
//Add an option to a list
//-------------------------------------------------------------------
function addOption(obj,text,value,selected) {
	try{
	if (obj!=null && obj.options!=null) {
		
		obj.options[obj.options.length] = new Option(text, value, false, selected);
	}
	}catch(e){alert(e.message);}
}
//-------------------------------------------------------------------
//match Check
//
//-------------------------------------------------------------------
function matchCheck(value){
  var re= new RegExp("^(?=[-_a-zA-Z0-9]*?[a-z])(?=[-_a-zA-Z0-9]*?[0-9])[-_a-zA-Z0-9]+$");
  if(value.match(re)){
	  return true;
  }else{
	  return false;
  }  
}

//Null Check Function
function fnNullChk(szInputType, szFormName, szInputName, szAlertMsg) {
  var objName = eval(szInputName);
  var blnRet = true;
  var nRadioChkCnt = 0;
  if (szInputType=='select-one' || szInputType=='radio' || szInputType=='checkbox' || szInputType=='file' ) {
    szAlertMsg += ' \uc120\ud0dd\ud574 \uc8fc\uc2ed\uc2dc\uc694.     ';
  }else if(szInputType=='equals'){
    szAlertMsg += ' \ub3d9\uc77c\ud55c \uac12\uc774 \ub4e4\uc5b4\uac00\uc57c \ud569\ub2c8\ub2e4..     ';
  }else{
    szAlertMsg += ' \uc785\ub825\ud574 \uc8fc\uc2ed\uc2dc\uc694.     ';
  }
  if (szInputType=='select-one'){
    if (objName.selectedIndex < 0)  {
      blnRet = false; 
    }else{
      if ( (objName.options[objName.selectedIndex].value)=='' ) { blnRet = false; } 
    }
  }else if (szInputType=='radio' || szInputType=='checkbox' ){
      
      if (objName.length == null || objName.length === undefined){
            if (objName.checked != false)
            {
                nRadioChkCnt++;
            }

      }else{
            for(var j=0; j < objName.length; j++) {
              if( objName[j].checked ) nRadioChkCnt++;
            }
      }

    if( nRadioChkCnt==0 ){ blnRet = false; } 
  }else if ( szInputType=='text' || szInputType=='file' || szInputType=='hidden' || szInputType=='textarea' || szInputType=='password' ){  
    if( fnTrim(objName.value) == '' ){ blnRet = false; }
  }
  if (szInputType=='file' && blnRet == true ) {
    if ( (objName.value.search(':') == -1) ){
      blnRet = false;
      szAlertMsg = '\ud30c\uc77c \ud615\uc2dd\uc774 \uc798\ubabb\ub418\uc5c8\uc2b5\ub2c8\ub2e4.     ';
    }
  } 
  if ( ! blnRet ){
    fnAlertFocus(szInputType, szFormName, szInputName, szAlertMsg) ;
    return false;
  }else{
	return true;
  }
}

function fnEqualsChk(szFormName, szInputName1,szInputName2, szAlertMsg) {
	  var objName1 = eval(szInputName1);
	  var objName2 = eval(szInputName2);
	  var blnRet = true;

	  szAlertMsg += ' \ub3d9\uc77c\ud55c \uac12\uc774 \ub4e4\uc5b4\uac00\uc57c \ud569\ub2c8\ub2e4..     ';

	  if (fnTrim(objName1.value) != fnTrim(objName2.value)){
	    fnAlertFocus('password', szFormName, szInputName1, szAlertMsg) ;
	    return false;
	  }else{
		  return true;
	  }
}

//Email Check Function
function fnEmailChk( objEmail ) {
  var objEmail = eval(objEmail) ;
  var szEmail = objEmail.value ;
  var regDoNot = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
  var regMust = /^[a-zA-Z0-9\-\.\_]+@[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3})$/;
  if ( !regDoNot.test(szEmail) && regMust.test(szEmail) ){
    return true;
  }else{
    alert('\uc798\ubabb\ub41c E-mail\uc785\ub2c8\ub2e4.     ');
    objEmail.focus() ;
    return false;
  }
}

//Jumin Number Check Function
function fnJuminChk( objJumin, szJumin ) {
  var objJumin = eval(objJumin) ;
  var nIDtot = 0;
  var szIDAdd = '234567892345';
  if (Number(szJumin)==0) {
    alert('\uc8fc\ubbfc\ub4f1\ub85d\ubc88\ud638\ub97c \uc785\ub825\ud574 \uc8fc\uc2ed\uc2dc\uc694.     ');
    objJumin.focus() ;
    return false;
  }
  for(var i=0; i < 12; i++) nIDtot = nIDtot + parseInt(szJumin.substring(i, i+1), 10) * parseInt(szIDAdd.substring(i, i+1), 10);
  nIDtot = 11 - ( nIDtot % 11);
  if ( nIDtot == 10) nIDtot = 0;
  else if ( nIDtot == 11) nIDtot = 1;
    if(parseInt(szJumin.substring(12, 13), 10) != nIDtot) {
      alert('\uc798\ubabb\ub41c \uc8fc\ubbfc\ub4f1\ub85d\ubc88\ud638\uc785\ub2c8\ub2e4.     ');
      objJumin.focus() ;
      return false;
    }else{
      return true;
    }
}

//Only Number Check Function
function fnOnlyNumChk( objNum , szAlertMsg ) {
  var objNum = eval(objNum);
  var szValue = objNum.value;
  szValue = szValue.toUpperCase();
  for(var i=0; i < szValue.length; i++) {
    if (szValue.charAt(i) == ' '){
      alert( szAlertMsg+' \uc22b\uc790\ub9cc \uc785\ub825\ud558\uc154\uc57c \ud569\ub2c8\ub2e4.     ' );
      objNum.focus();
      return false;
    }else if ((szValue.charAt(i) < '0') || (szValue.charAt(i) > '9'))	{
      alert( szAlertMsg+' \uc22b\uc790\ub9cc \uc785\ub825\ud558\uc154\uc57c \ud569\ub2c8\ub2e4.     ' );
      objNum.focus();
      return false;
    }
  }
}

//Message Length Check Function
function fnMsgLenChk( objMessage, nLimitLen, szAlertMsg ) {
  var nbytes = 0;
  var objMessage = eval(objMessage) ;
  var szMessage = objMessage.value ;
  for (var i=0; i < szMessage.length; i++) {
    var szChr = szMessage.charAt(i);
    if(escape( szChr ).length > 4) {
      nbytes += 2;
    } else if (szChr == '\n') {
      if (szMessage.charAt(i-1) != '\r')    nbytes += 1;
    } else if (szChr == '<' || szChr == '>' ) {
      nbytes += 4;
    } else if (szChr == "'") {
      nbytes += 2;
    } else {
      nbytes += 1;
    }
  }
  if ( nbytes > nLimitLen ){
    alert( szAlertMsg + ' \ub108\ubb34 \uae38\uac8c \uc785\ub825\ud558\uc168\uc2b5\ub2c8\ub2e4.     \n\uc601\ubb38/\uc22b\uc790\ub294 '+nLimitLen+'\uc790, \ud55c\uae00\uc740 '+nLimitLen/2+'\uc790 \uc774\ub0b4\ub85c \uc785\ub825\ud574 \uc8fc\uc2ed\uc2dc\uc694.     ');		
    objMessage.focus();
    return false;
  }
}

/** Summary_start ========================================================
\uc124\uba85 \u25b6 Object\uc758 \ucd5c\uc18c \ubb38\uc790 \uae38\uc774 \uccb4\ud06c (\ud55c\uae00/\uc601\ubb38)
\uc778\uc790 \u25b6 String objJumin,int nLimitLen(byte\uac12), String szJumin
\ubc18\ud658 \u25b6 boolean
\uc0ac\uc6a9 \u25b6 

        if( fnMsgLenChk('frm.member_id',4,'\ud68c\uc6d0\uc544\uc774\ub514\ub294' )==false ){return false;}
        
========================================================== Summary_end **/
function fnMsgLenChkMin( objMessage, nLimitLen, szAlertMsg ) {
  var nbytes = 0;
  var objMessage = eval(objMessage) ;
  var szMessage = objMessage.value ;
  for (var i=0; i < szMessage.length; i++) {
    var szChr = szMessage.charAt(i);
    if(escape( szChr ).length > 4) {
      nbytes += 2;
    } else if (szChr == '\n') {
      if (szMessage.charAt(i-1) != '\r')    nbytes += 1;
    } else if (szChr == '<' || szChr == '>' ) {
      nbytes += 4;
    } else if (szChr == "'") {
      nbytes += 2;
    } else {
      nbytes += 1;
    }
  }
  if ( nbytes < nLimitLen ){
    alert( szAlertMsg + ' \ub108\ubb34 \uc9e7\uac8c \uc785\ub825\ud558\uc168\uc2b5\ub2c8\ub2e4.     \n\uc601\ubb38/\uc22b\uc790\ub294 '+nLimitLen+'\uc790, \ud55c\uae00\uc740 '+nLimitLen/2+'\uc790 \uc774\uc0c1\uc73c\ub85c \uc785\ub825\ud574 \uc8fc\uc2ed\uc2dc\uc694.     ');       
    objMessage.focus();
    return false;
  }
}
/** Function_end **/

/** Summary_start ========================================================
\uc124\uba85 \u25b6 Object\uc758 \ucd5c\uc18c \ubb38\uc790 \uae38\uc774 \uccb4\ud06c (\uc601\ubb38)
\uc778\uc790 \u25b6 String objJumin,int nLimitLen(byte\uac12), String szJumin
\ubc18\ud658 \u25b6 boolean
\uc0ac\uc6a9 \u25b6 

        if( fnMsgLenChk('frm.member_id',4,'\ud68c\uc6d0\uc544\uc774\ub514\ub294' )==false ){return false;}
        
========================================================== Summary_end **/
function fnMsgLenChkMinEng(objMessage, nLimitLen, szAlertMsg ) {
  var nbytes = 0;
  var objMessage = eval(objMessage) ;
  var szMessage = objMessage.value ;
  for (var i=0; i < szMessage.length; i++) {
    var szChr = szMessage.charAt(i);
    if(escape( szChr ).length > 4) {
      nbytes += 2;
    } else if (szChr == '\n') {
      if (szMessage.charAt(i-1) != '\r')    nbytes += 1;
    } else if (szChr == '<' || szChr == '>' ) {
      nbytes += 4;
    } else if (szChr == "'") {
      nbytes += 2;
    } else {
      nbytes += 1;
    }
  }
  if ( nbytes < nLimitLen ){
    alert( szAlertMsg + ' \ub108\ubb34 \uc9e7\uac8c \uc785\ub825\ud558\uc168\uc2b5\ub2c8\ub2e4.     \n\uc601\ubb38/\uc22b\uc790 '+nLimitLen+'\uc790 \uc774\uc0c1\uc73c\ub85c \uc785\ub825\ud574 \uc8fc\uc2ed\uc2dc\uc694.     ');       
    objMessage.focus();
    return false;
  }else{
	return true;
  }
}
/** Function_end **/


/** Summary_start ========================================================
\uc124\uba85 \u25b6 Object\uc758 \ucd5c\uc18c \ubb38\uc790 \uae38\uc774 \uccb4\ud06c (\uc601\ubb38)
\uc778\uc790 \u25b6 String objJumin,int nLimitLen(byte\uac12), String szJumin
\ubc18\ud658 \u25b6 boolean
\uc0ac\uc6a9 \u25b6 

        if( fnMsgLenChk('frm.member_id',4,'\ud68c\uc6d0\uc544\uc774\ub514\ub294' )==false ){return false;}
        
========================================================== Summary_end **/
function fnMsgLenChkEng(objMessage, nLimitLen, szAlertMsg ) {
  var nbytes = 0;
  var objMessage = eval(objMessage) ;
  var szMessage = objMessage.value ;
  for (var i=0; i < szMessage.length; i++) {
    var szChr = szMessage.charAt(i);
    if(escape( szChr ).length > 4) {
      nbytes += 2;
    } else if (szChr == '\n') {
      if (szMessage.charAt(i-1) != '\r')    nbytes += 1;
    } else if (szChr == '<' || szChr == '>' ) {
      nbytes += 4;
    } else if (szChr == "'") {
      nbytes += 2;
    } else {
      nbytes += 1;
    }
  }
  if ( nbytes > nLimitLen ){
    alert( szAlertMsg + ' \ub108\ubb34 \uae38\uac8c \uc785\ub825\ud558\uc168\uc2b5\ub2c8\ub2e4.     \n\uc601\ubb38/\uc22b\uc790 '+nLimitLen+'\uc790 \uc774\ub0b4\uc73c\ub85c \uc785\ub825\ud574 \uc8fc\uc2ed\uc2dc\uc694.     ');       
    objMessage.focus();
    return false;
  }
}
/** Function_end **/


//Alert & focus Function
function fnAlertFocus(szInputType, szFormName, szInputName, szAlertMsg) {
  if(fnTrim(szAlertMsg)!='') { alert(szAlertMsg); }
  var objName = eval(szInputName);
  if ( (szInputType=='checkbox' || szInputType=='radio') && (objName.length > 0) ){
    objName = eval(szInputName+'[0]');
  }
  objName.focus();
}

//Trim Function
function fnTrim( szValue ) {
  var szRetVal = '';
  if( szValue == '' )  return false;
  for(var i=0;i<szValue.length;i++) {
    if(szValue.charAt(i) != ' ')    szRetVal = szRetVal + szValue.charAt(i);
  }
  return szRetVal;
}


function fnOpenWindow( sUrl, sName, iLeft, iTop, iWidth, iHeight,iScrollbar)
{
	
  window.open(sUrl, sName, 'left='+iLeft+',top='+iTop+',width='+iWidth+',height='+iHeight+',toolbar=no,menubar=no,status=no,scrollbars='+iScrollbar+',resizable=no');
		
}


function winResize(swidth,sheight){
    var Dwidth = parseInt(document.body.scrollWidth)+swidth;
    var Dheight = parseInt(document.body.scrollHeight)+sheight;
    var divEl = document.createElement("div");
    divEl.style.position = "absolute";
    divEl.style.left = "0px";
    divEl.style.top = "0px";
    divEl.style.width = "100%";
    divEl.style.height = "100%";

    document.body.appendChild(divEl);

    window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight);
    document.body.removeChild(divEl);


}

