<!--
 //-----------------------------------------------------------
 // Select all elements on the form
 //-----------------------------------------------------------
 function selectDocumentAll(typeElement, formElement) {
 	var i;
		
 	if(formElement) {
 		if(typeElement == 'checkbox') {
 			if(formElement.length) {
 				 for (i = 0; i < formElement.length; i++) {
 				   formElement[i].checked = true;
 				}
 			}
 			else formElement.checked = true;
 		}
 	}
 }
	
 //-----------------------------------------------------------
 // email check
 //-----------------------------------------------------------
 function isValidEmail(addr)
 {
 	var re = /^[A-Za-z0-9_.%+-;]+@[A-Za-z0-9_.-]+(\.[A-Za-z0-9_.-;]+)+$/;

 	if (addr == "")
 	{
 		return false;
 	}
 	if (re.test(addr)) return true;
 	else
 	{
 		return false;
 	}
 }
 
 function isValidMultipleEmails(addr)
 {
	if(addr == '')
		return false;
	else
	{
		var arrAddr = addr.split(';');
		
		for(var i = 0; i < arrAddr.length; i++)
		{
			if(!isValidEmail(arrAddr[i]))
				return false;
		}
		
		return true;
	}		
 }
		
 //-----------------------------------------------------------
 // returns true if the variables passed is an 
 // integer or false if the variable is not a integer
 //-----------------------------------------------------------
 function isNotEmptyNumber(str)
 {
 	var n, c;

 	if (str == "")
 	{
 		return false;
 	}
 	for (n = 0; n < str.length; ++n)
 		{
 		c = str.charAt(n);
 		if (c > '9' || c < '0')
 			{
 				return false;
 				break;
 			}
 		}
 	return true;
 }
		
 //-----------------------------------------------------------
 // Trim() will return the variable passed without 
 // the leading and trailing spaces 
 //-----------------------------------------------------------
 function Trim(val)
 {
    return (LTrim(RTrim(val)));
 }

 //-----------------------------------------------------------
 // LTrim() will return the variable passed without 
 // the leading spaces 
 //-----------------------------------------------------------
 function LTrim(val)
 {
    var i;

    for (i = 0; i < val.length; i++) {
       if (val.charAt(i) != ' ') {
          break;
       }
    }
    return (val.substring(i, val.length));
 }

 //-----------------------------------------------------------
 // RTrim() will return the variable passed without 
 // the trailing spaces 
 //-----------------------------------------------------------
 function RTrim(val)
 {
    var i;

    for (i = val.length; i >= 0; i--) {
       if (val.charAt(i - 1) != ' ') {
          break;
       }
    }
    return (val.substring(0, i));
 }

 //-----------------------------------------------------------
 // isEmpty() returns true if the variable passed is empty
 // after the Trim() function, and returns false is the 
 // passed variable is not empty after the Trim() function.
 //-----------------------------------------------------------
 function isEmpty(val)
 {
    return (val == '')?true:false;
 }
		   
 //-----------------------------------------------------------
 // isInteger() returns true if the variables passed is an 
 // integer or false if the variable is not a integer
 //-----------------------------------------------------------
 function isInteger(val)
 {
    var integerList = '0123456789';
    var isInteger = false;

    for (var i = 0; i < val.length; i++) {
       isInteger = false;
       for (var j = 0; j < integerList.length; j++) {
          if (integerList.charAt(j) == val.charAt(i)) {
             isInteger = true;
             break;
          } 
       } 
       if (!isInteger) {
          break;
       } 
    } 
    return isInteger;
 }      

 function IsSignedReal(sText) 
 {
    var ValidChars = "0123456789.-";
    var IsNumber = true;
    var Char;
	var dashCount = 0;
	var dotCount = 0;
	
    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
       Char = sText.charAt(i); 
       if(Char == ".")
        dotCount++;
       if(Char == "-") 
        dashCount++;
       if(sText.indexOf(Char) > 0) {
         IsNUmber = false;
       }       
       if (ValidChars.indexOf(Char) == -1) 
         IsNumber = false;
    }
	
	if(dotCount > 1 || dashCount > 1)
	    IsNumber = false;
	    
    if (IsNumber == false) 
		alert('Please enter numeric value only');
		    
	return IsNumber;
 }

 function IsNumeric(sText)
 {	
    var ValidChars = "0123456789.";
    var IsNumber = true;
    var Char;
	 
    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
       Char = sText.charAt(i); 
       if (ValidChars.indexOf(Char) == -1) 
         IsNumber = false;
    }
	   
    if (IsNumber == false) 
		alert('Please enter numeric value only');
		
	return IsNumber;
}
    
function IsNumeric2(sText) {
	var ValidChars = "0123456789.";
	var DotCounter = 0;
	var IsNumber = true;
	var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++) { 
		Char = sText.charAt(i);
		if (Char == ".") DotCounter = DotCounter + 1;
		if (DotCounter > 1) {
			IsNumber = false;
			break;
		}
		if (!(Char == "-" && i == 0)) {
			if (ValidChars.indexOf(Char) == -1) {
				IsNumber = false;
				break;
			}
		}
	}
	   
	if (!IsNumber) alert('Please enter numeric value only');
	return IsNumber; 
}

function IsMoney(sText) {
	var ValidChars = "0123456789.$";
	var DotCounter = 0;
	var IsNumber = true;
	var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++) { 
		Char = sText.charAt(i);
		if (Char == ".") DotCounter = DotCounter + 1;
		if (DotCounter > 1) {
			IsNumber = false;
			break;
		}
		if (!(Char == "-" && i == 0)) {
			if (ValidChars.indexOf(Char) == -1) {
				IsNumber = false;
				break;
			}
		}
	}
	   
	if (!IsNumber) alert('Please enter numeric value only');
	return IsNumber; 
}

 //-----------------------------------------------------------
 // isDouble() returns true if the variables passed is an 
 // double or returns false if the variable is not a double
 //-----------------------------------------------------------
 function isDouble(val)
 {
    var decimalCtr = 0;
    var leftVal = '', rightVal = '';
		      
    for (var i = 0; i < val.length; i++) {
       if (val.charAt(i) == '.') {
          decimalCtr++;
       }
       else if (decimalCtr == 0) {
          leftVal += val.charAt(i);
       }
       else if (decimalCtr == 1) {
          rightVal += val.charAt(i);
       }
    }
    if (decimalCtr == 0 && !isInteger(leftVal)) {
       return false;
    }
    if (isEmpty(leftVal) || isEmpty(rightVal)) {
       return false;
    }
    else if ((leftVal.length > 0 && !isInteger(leftVal)) || 
       (rightVal.length > 0 && !isInteger(rightVal))) {
          return false;
    }
    else {
       return true;
    }
 }

 //-----------------------------------------------------------
 // isAlphabetic() returns true if the variables passed is  
 // alphabetic or returns false if the variable is not 
 // alphabetic
 //-----------------------------------------------------------
 function isAlphabetic(val)   
 {
    var upperCaseList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var lowerCaseList = "abcdefghijklmnopqrstuvwxyz";
    var isUpperCase = false, isLowerCase = false;

    for (var i = 0; i < val.length; i++) {
       isUpperCase = isLowerCase = false;
       for (var j = 0; j < lowerCaseList.length; j++) {
          if (val.charAt(i) == lowerCaseList.charAt(j)) {
             isLowerCase = true;
             break;
          }
       }
       if (!isLowerCase) {
          for (var j = 0; j < upperCaseList.length; j++) {
             if (val.charAt(i) == upperCaseList.charAt(j)) {
                isUpperCase = true;
                break;
             }
          }
          if (!isUpperCase) {
             break;
          }
       }
    }
    return (isLowerCase || isUpperCase)?true:false;
 }

 //-----------------------------------------------------------
 // isAlphaNumeric() returns true if the variables passed is  
 // alpha/numeric or returns false if the variable is not 
 // alpha/numeric
 //-----------------------------------------------------------
 function isAlphaNumeric(val)
 {
    var isAlphaNumeric = false;
		      
    for (var i = 0; i < val.length; i++) {
       isAlphaNumeric = false;
       if (!isInteger(val.charAt(i))) {
          if (!isAlphabetic(val.charAt(i))) {
             break;
          }
          else {
             isAlphaNumeric = true;
          }
       }
       else {
          isAlphaNumeric = true;
       }
    }
    return isAlphaNumeric;
 }
		   
 //-----------------------------------------------------------
 // isDate() returns true if the variables passed is in a 
 // valid date format or returns false if the variable is 
 // not in a valid date format
 //-----------------------------------------------------------
 function isDate(val) 
 {
    if (val.length != 8)
       return false;
    else if (val.charAt(2) != '/' || val.charAt(5) != '/' ||
       !isInteger(val.substring(0, 2)) || 
       !isInteger(val.substring(3, 5)) || 
       !isInteger(val.substring(6, 8)))
          return false;
    else
       return true;
 }
		   
 //-----------------------------------------------------------
 // isEmail() returns true if the variables passed is in a 
 // valid e-mail address format or returns false if the 
 // variable is not in a valid e-mail address format
 //-----------------------------------------------------------
 function isEmail(val) 
 {
    if (val.indexOf("@") == -1 || isEmpty(val))
       return false;
    else
       return true;
 }
		   
 //-----------------------------------------------------------
 // isImageFile() returns true if the file name passed does 
 // not have a ".jpg" or ".gif" file extension, and returns
 // true if is does have a ".jpg" or ".gif" file extension.
 //-----------------------------------------------------------
 function isImageFile(val)
 {
    if (val.length < 5)
       return false;
		         
    var imgExt = val.substring(val.length - 4, val.length).toUpperCase();
		      
    if (imgExt != ".JPG" && imgExt != ".GIF")
       return false;
    else
       return true;
 }
	   
 //-----------------------------------------------------------
 // isHtmlFile() returns true if the file name passed does 
 // not have a ".htm" or ".html" file extension, and returns
 // true if is does have a ".htm" or ".html" file extension.
 //-----------------------------------------------------------
 function isHtmlFile(val)
 {
    if (val.length < 5)
       return false;

    var htmExt = val.substring(val.length - 4, val.length).toUpperCase();
    var htmlExt = val.substring(val.length - 5, val.length).toUpperCase();

    if (htmExt != ".HTM" && htmlExt != ".HTML")
       return false;
    else
       return true;
 }
	   
 //-----------------------------------------------------------
 // getFileName() will return the file name only when given 
 // full path of the file.
 //-----------------------------------------------------------
 function getFileName(val)
 {
    if (isEmpty(val))
       return '';
    else if(val.indexOf("/") == -1)
       return val;
		         
    var i;

    for (i = val.length; i >= 0; i--) {
       if (val.charAt(i - 1) == '/' || 
          val.charAt(i - 1) == '\\') {
             break;
       }
    }
    return (val.substring(i, val.length));
 }
	   
 //-----------------------------------------------------------
 // sortArrayAsc() returns the array passed in ascending 
 // order.
 //-----------------------------------------------------------
 function sortArrayAsc(oldArray)
 {
    var limit = oldArray.length;
    var newArray = new Array(limit);
    var element = null;

    for (var i = 0; i < limit; i++) {
       element = oldArray[i];
       for (var j = 0; j < limit; j++) {
          if (newArray[j] == '' || newArray[j] == null) {
             newArray[j] = element;
             break;
          }
          else if (newArray[j] > element) {
             for (var k = limit; k > j - 1; k--)
                newArray[k] = newArray[k - 1];
             newArray[j] = element;
             break;
          }
       }
    }
    return newArray;
 }

 //-----------------------------------------------------------
 // sortArrayDesc() returns the array passed in descending 
 // order.
 //-----------------------------------------------------------
 function sortArrayDesc(oldArray)
 {
    var limit = oldArray.length;
    var newArray = new Array(limit);
    var element = null;

    for (var i = 0; i < limit; i++) {
       element = oldArray[i];
       for (var j = 0; j < limit; j++) {
          if (newArray[j] == '' || newArray[j] == null) {
             newArray[j] = element;
             break;
          }
          else if (newArray[j] < element) {
             for (var k = limit; k > j - 1; k--)
                newArray[k] = newArray[k - 1];
             newArray[j] = element;
             break;
          }
       }
    }
    return newArray;
 }
	      
 //-----------------------------------------------------------
 // FormatNumber() returns the formatted number passed to 
 // the precision value passed.  If the number is not valid 
 // then null will be returned.
 //-----------------------------------------------------------
 function FormatNumber(val, precision)
 {
    var decimalCtr = 0;
    var validZero = false;
    var prefix = '', suffix = '', extra = '';

    if (val.indexOf(".") == -1 && isInteger(val))
       val += ".";
    for (var i = 0; i < val.length; i++) {
       if (val.charAt(i) == '.') {
          decimalCtr++;
       }
       else if (decimalCtr == 0) {
          if (val.charAt(i) != '0' || validZero) {
             prefix += val.charAt(i);
             if (!validZero) {
                validZero = true;
             }
          }
       }
       else if (decimalCtr == 1 && suffix.length < precision) {
          suffix += val.charAt(i);
       }
       else {
          extra += val.charAt(i);
       }
    }
    if (prefix == '' && suffix == '') {
       return null;
    }
    else if ((prefix.length > 0 && !isInteger(prefix)) || 
       (suffix.length > 0 && !isInteger(suffix)) || 
       (extra.length > 0 && !isInteger(extra)) ||
       decimalCtr > 1) {
          return null;
    }
    else if ((suffix + suffix == 0) && prefix.length == 0) {
       return null;
    }
    else {   
       if (suffix.length < precision) {
          for (var j = suffix.length; j < precision; j++) {
             suffix += '0';
          }
       }
       if (prefix.length == 0) {
          prefix = '0';
       }
       if (precision == 0) {
          return (prefix);
       }
       else {
          return (prefix + '.' + suffix);
       }
    }
 }
	
 function FormatNumberStripZeros(valNum, leaveDecimals) {
    var strNum = valNum.toString();
    var iSuffix = 0;
    var decimalPoint = strNum.indexOf(".");
    
    if (decimalPoint == 0) return strNum;
	else {
		iSuffix = strNum.length - (decimalPoint + 1);
		if (iSuffix <= leaveDecimals) return strNum;
		else {
			for (var i = strNum.length - 1; i >= 0; i--) {
				if ((strNum.charAt(i) != '0') || iSuffix == leaveDecimals) break;
				iSuffix--;
			}
			return strNum.substr(0, i + 1);
		}
	}
 }	
	   
 //-----------------------------------------------------------
 // getUrlPath() will return the path of the current 
 // document/frame's URL
 //-----------------------------------------------------------
 function getUrlPath()
 {
    var url = document.location.toString();
    return url.substring(0, url.lastIndexOf("/"));
 }

 //-----------------------------------------------------------
 // setUrlParameter() will replace ' ' characters 
 // with the '+' character
 //-----------------------------------------------------------
 function setUrlParameter(val)
 {
    var param = '';
		      
    for (var i = 0; i < val.length; i++) {
       if (val.charAt(i) == ' ') {
          param += '+';
       }
       else {
          param += val.charAt(i);
       }
    }
    return param;
 }
	   
 function setDateNew(obj)
 {
    var date = obj.value;
    var month = '', day = '', year = '';
    var slashCtr = 0;
    var integer = true;

    if (isEmpty(date)) {
       alert('Date Required\nFormat: MM/DD/YY');
    } 
    else if (date.length < 6) {
       alert('Invalid Date\nFormat: MM/DD/YY');
    } 
    else {
       for (var i = 0; i < date.length; i++) {
          if (date.charAt(i) != '/') {
             number = false;
             if (!isInteger(date.charAt(i))) {
                integer = false;
                break;
             } 
             if (slashCtr == 0) {
                month += date.charAt(i);
             }
             else if (slashCtr == 1) {
                day += date.charAt(i);
             }
             else {
                year += date.charAt(i);
             }
          } 
          else {
             slashCtr++;
          } 
       } 
       if (day.length == 1) {
          day = "0" + day.toString()
       }
       if (month.length == 1) {
          month = "0" + month.toString()
       }
       if (!integer) {
          alert('No Characters Allowed in Date\nFormat: MM/DD/YY');
       } 
       else if (isEmpty(day) || isEmpty(year)) {
          alert('Invalid Date\nFormat: MM/DD/YY');
       } 
       else if (year.length < 2) {
          alert('Invalid Year\nFormat: MM/DD/YY');
       } 
       else { 
          if (month < 1 || month > 12 || day < 1) {
             alert('Invalid Date\nFormat: MM/DD/YY');
          } 
          else if ((month == 1 || month == 3 || month == 5 ||
             month == 7 || month == 8 || month == 10 || month == 12) && day > 31) {
                alert('Only 31 Days in Month\nFormat: MM/DD/YY');
          } 
          else if ((month == 4 || month == 6 || month == 9 ||
             month == 11) && day > 31) {
                alert('Only 30 Days in Month\nFormat: MM/DD/YY');
          }
          else if ((month == 2) && day > 29) {
             if (isLeapYear(year)) {
                alert('Only 29 Days in Month\nFormat: MM/DD/YY');
             } 
             else {
                alert('Only 28 Days in Month\nFormat: MM/DD/YY');
             } 
          } 
          else if ((month == 2) && day > 28 && !isLeapYear(year)) {
             if (day == 29) {
                alert('Not a Leap Year\nFormat: MM/DD/YY');
             } 
          } 
          else {
             obj.value = month + "/" + day + "/" + year
             return true;
          } 
       } 
    } 
    return false;
 } 
   
//-----------------------------------------------------------
// setDate() checks if the date value passed is
// a valid date; alerting the appropriate message
// if it is not a valid date.
//-----------------------------------------------------------
function setDate(obj)
{
   // date value of the object passed
   var date = obj.value
   // date parsed into month, day, & year variables 
   // using the '/' as a delimiter      
   var month = '', day = '', year = '';
   // date delimiter counter variable
   var slashCtr = 0;
   // boolean variable set whether date,
   // without slashes is numeric
   var integer = true;

   if (isEmpty(date)) {
      alert('Date Required\nFormat: MM/DD/YYYY');
   } 
   // END checking empty date
   else if (date.length <= 7) {
      alert('Invalid Date\nFormat: MM/DD/YYYY');
   } 
   // END checking for invalid date length
   else {
      for (var i = 0; i < date.length; i++) {
         if (date.charAt(i) != '/') {
            number = false;
            if (!isInteger(date.charAt(i))) {
               integer = false;
               break;
            } 
            // END if..then; break out of for loop if 
            // date isn't numeric
            if (slashCtr == 0) {
               month += date.charAt(i);
            }
            else if (slashCtr == 1) {
               day += date.charAt(i);
            }
            else {
               year += date.charAt(i);
            }
         } 
         // END if..then checking for '\' in date
         else {
            slashCtr++;
         } 
         // END if..then; increment slashCtr if a '/' is found
      } 
      // END for loop
      if (day.length == 1) {
         day = "0" + day.toString()
      }
      // append a zero to day if day length is 1
      if (month.length == 1) {
         month = "0" + month.toString()
      }
      // append a zero to month if month length is 1
      if (!integer) {
         alert('No Characters Allowed in Date\nFormat: MM/DD/YYYY');
      } 
      // END if; alert if date is not numeric
      else if (isEmpty(day) || isEmpty(year)) {
         alert('Invalid Date\nFormat: MM/DD/YYYY');
      } 
      // END else if; alert if day or year is empty
      else if (year.length != 4) {
         alert('Need 4 Digit Year\nFormat: MM/DD/YYYY');
      } 
      // END else if; alert if year is not 4 digits in length
      else { 
         if (month < 1 || month > 12 || day < 1) {
            alert('Invalid Date\nFormat: MM/DD/YYYY');
         } 
         // END if; alert if month is less than 1 or 
         // greater than 12 or the day is less than 1
         else if ((month == 1 || month == 3 || month == 5 ||
            month == 7 || month == 8 || month == 10 || month == 12) && day > 31) {
               alert('Only 31 Days in Month\nFormat: MM/DD/YYYY');
         } 
         // END else if; alert if the day is greater than 31 days 
         else if ((month == 4 || month == 6 || month == 9 ||
            month == 11) && day > 31) {
               alert('Only 30 Days in Month\nFormat: MM/DD/YYYY');
         } 
         // END else if; alert if the day is greater than 30 days 
         else if ((month == 2) && day > 29) {
            if (isLeapYear(year)) {
               alert('Only 29 Days in Month\nFormat: MM/DD/YYYY');
            } 
            // END if; alert if the day is greater than 29 days 
            // when a leap year
            else {
               alert('Only 28 Days in Month\nFormat: MM/DD/YYYY');
            } 
            // END if..then; alert if the day is greater than 28 days 
            // when not a leap year
         } 
         // END if..then checking for whether or not year is a leap year
         else if ((month == 2) && day > 28 && !isLeapYear(year)) {
            if (day == 29) {
               alert('Not a Leap Year\nFormat: MM/DD/YYYY');
            } 
            // END if; alert if the day equals 29 and 
            // the year is not a leap year 
         } 
         // END else if checking whether day entered is 29 
         else {
            obj.value = month + "/" + day + "/" + year
            return true;
         } 
         // END if..then; return true if date validation is OK
      } 
      // END if..then
   } 
      
      
   // END if..then validating the date 
   return false;
   // return false if date validation is not OK
} 
// END checkDate() function
    
 function isLeapYear(year) { 
 return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? true : false;
 }


 function validateNumbersOnly(field) {
 	var valid = "0123456789."
 	var ok = "yes";
 	var temp;
		
 	for (var i=0; i<field.value.length; i++) {
 		temp = "" + field.value.substring(i, i+1);
 		if (valid.indexOf(temp) == "-1") ok = "no";
 	}
 	if (ok == "no") {
 		alert("Value must be Numbers Only or blank.\nPlease,try again");
 		field.focus();
 		field.select();
    }
 }


 function validateShippingTableFrom_ToRange(frm){
 	var i=0;
 	var MinQty;
 	var MaxQty;
 	var nextMinQty;
 	var nextMaxQty;
 	var prevMinQty;
 	var prevMaxQty;
 	var QtyDiff;
		
 	for (i = 0; i < 12; i++){
 		MinQty = eval('frm.MinQty'+i+'.value' );
 		MaxQty = eval('frm.MaxQty'+i+'.value' );
			
 		if(MinQty!==''){
 			//checking the pair MinQty and MaxQty
 			if (MaxQty==''){
 				//alert('i='+i+ '\nMinQty='+MinQty+'\nMaxQty='+MaxQty);
 				alert('Please Enter Corresponding "To" Range');
 				eval('frm.MaxQty'+i+'.focus()' );
 				return false ;
 			}
 		}
 		if(MaxQty!==''){
 			//checking the pair MinQty and MaxQty
 			if (MinQty==''){
 				alert('Please Enter Corresponding "FROM" Range');
 				eval('frm.MinQty'+i+'.focus()' );
 				return false;
 			}		
 		}
 	}

		
 	for (i = 0; i < 12; i++){
 		MinQty = eval('frm.MinQty'+i+'.value' );
 		MaxQty = eval('frm.MaxQty'+i+'.value' );
 		MinQty = round(MinQty,2);
 		MaxQty = round(MaxQty,2);
 		//alert('i='+i+ '\nMinQty='+MinQty+'\nMaxQty='+MaxQty);
			
 		//checking GAPS and OVERLAPS
 		if (MinQty!=='' && MaxQty!=='') {
 			if (MinQty > MaxQty ) {
				
 				//alert('i='+i+ '\nMinQty='+MinQty+'\nMaxQty='+MaxQty);
						
				
 				alert('FROM Value in "FROM - TO range" must be less then TO value');
 				eval('frm.MaxQty'+i+'.focus();frm.MaxQty'+i+'.select();' );
 				return false;
 			}
				 
 			if(i>0  && MinQty!==0 && MaxQty!==0){
 				MinQty	   = eval('frm.MinQty'+i+'.value' );
 				prevMaxQty = eval('frm.MaxQty'+(i-1)+'.value' );
 				QtyDiff = MinQty - prevMaxQty
 				QtyDiff = round(QtyDiff,2)
 				//alert('QtyDiff='+QtyDiff);
					
 				if(QtyDiff>0.01){  //GAPs
 					//alert('i='+i+ '\nMinQty='+MinQty+'\nMaxQty='+MaxQty);
 					//alert('MinQty='+MinQty+'\nprevMaxQty='+prevMaxQty+'\nQtyDiff='+QtyDiff);
 					alert('Please do not leave GAPS in the "FROM" - "TO" ranges.\nThe "FROM" - "TO" ranges have 2 decimal places\nExample : "FROM 2.01" - "TO 5.00"');
 					eval('frm.MinQty'+i+'.focus();frm.MinQty'+i+'.select();' );
 					return false;
 				}
 				if(QtyDiff<= 0 && MinQty!==''){   //OVERLAPS
 					alert('Please do not OVERLAP values in the "FROM" - "TO" ranges.\nThe "FROM" - "TO" ranges have 2 decimal places\nExample : "FROM 2.01" - "TO 5.00"');
 					eval('frm.MinQty'+i+'.focus();frm.MinQty'+i+'.select();' );
 					return false;
 				}
			
 			}
         }	
 	}
		
 	//alert('success');
 	return true;
 }

 function round(number,X) { 
 // rounds number to X decimal places, defaults to 2
 X = (!X ? 2 : X);
 return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
 }

 function NewisValidEmail(addr)
 {
 	var re = /^[\\'A-Za-z0-9_.%@+-]+$/;

 	if (addr == "")
 	{
 		return false;
 	}
 	if (re.test(addr))
 		return true;
 	else
 	{
 		return false;
 	}
 }

 function NewisValidEmail(addr)
 {
 	var re = /^[\\'A-Za-z0-9_.%+-@ ]+$/;

 	if (addr == "")
 	{
 		return false;
 	}
 	if (re.test(addr)) return true;
 	else
 	{
 		return false;
 	}
 }

function isValidDate(dateStr) {
	// Checks for the following valid date formats:
	// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY

	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
	var matchArray = dateStr.match(datePat); // is the format ok?
	
	if (matchArray == null) {
		alert(dateStr + " Date is not in a valid format.")
		return false;
	}
	
	month = matchArray[1]; // parse date into variables
	day = matchArray[3];
	year = matchArray[4];
	
	if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
	}
	
	if (day < 1 || day > 31) {
		alert("Day must be between 1 and 31.");
		return false;
	}
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Month "+month+" doesn't have 31 days!")
		return false;
	}
	
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			alert("February " + year + " doesn't have " + day + " days!");
			return false;
	   }
	}
	
	return true;
}

function isValidTime(timeStr) {
	// Checks if time is in HH:MM:SS AM/PM format.
	// The seconds and AM/PM are optional.

	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
	var matchArray = timeStr.match(timePat);
	
	if (matchArray == null) {
		alert("Time is not in a valid format.");
		return false;
	}
	
	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];

	if (second=="") { second = null; }
	if (ampm=="") { ampm = null }

	if (hour < 0  || hour > 23) {
		alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
		return false;
	}
	
	if (hour <= 12 && ampm == null) {
		if (confirm("Please indicate which time format you are using.  OK = Standard Time, CANCEL = Military Time")) {
			alert("You must specify AM or PM.");
			return false;
	   }
	}
	
	if  (hour > 12 && ampm != null) {
		alert("You can't specify AM or PM for military time.");
		return false;
	}
	
	if (minute < 0 || minute > 59) {
		alert ("Minute must be between 0 and 59.");
		return false;
	}
	
	if (second != null && (second < 0 || second > 59)) {
		alert ("Second must be between 0 and 59.");
		return false;
	}
	
	return true;
}

function dateDiff(firstdate, seconddate) {
	if (isValidDate(firstdate)) { // Validates first date 
		var date1 = new Date(firstdate);
	}
	else return -1;

	if (isValidDate(seconddate)) { // Validates first date 
		var date2 = new Date(seconddate);
	}
	else return -1;

	var one_day = 1000*60*60*24; // Set 1 day in milliseconds
	return Math.floor((date2.getTime() - date1.getTime()) / one_day);
}

function checkPassword(strng) {
     var error = "";
     if (strng == "") error = "You didn't enter a password.\n";
     else {
        if ((strng.length < 6) || (strng.length > 20)) error = "The password is the wrong length.\n";
        else {
            if (strng.match(/[a-zA-Z]+/) == null || strng.match(/[0-9]+/) == null) {
				error = "The password must contain at least one letter, and one numeral.\n";
			}
        }
    }
    if (error == "") return true;
    else {
        alert(error);
        return false;
	}
}
function checkPassword(strng,security) {
     var error = "";
     if (strng == "") error = "You didn't enter a password.\n";
     else {
        if ((strng.length < 6) || (strng.length > 20)) error = "The password is the wrong length.\n";
        else if (security) {
            if (strng.match(/[a-zA-Z]+/) == null || strng.match(/[0-9]+/) == null) {
				error = "The password must contain at least one letter, and one numeral.\n";
			}
        }
    }
    if (error == "") return true;
    else {
        alert(error);
        return false;
	}
}

function PopUpDetector(url, fwidth, fheight) {
	var mypopup=window.open("","PopUp",'width=+ fwidth +,height=+ fheight +');
	if (mypopup){
	  mypopup.close();
	  window.open(url,"PopUp",'width=+ fwidth +,height=+ fheight +');
	}
	else 
	  alert("You have unrequested popup blocking on!");
}
	ns4=document.layers
	ie4=document.all
	ns6=document.getElementById&&!document.all
	var xWin=null; var ticks=6;

	function ChangeLabel0(txt){
		if(ns4){document.layers.label0.innerHTML=txt}
		if(ie4){document.all.label0.innerHTML=txt}
		if(ns6){document.getElementById("label0").innerHTML=txt}
	}

	function StartT(url, fwidth, fheight){
		StartPopup(url, fwidth, fheight);
		window.focus();
		ChangeLabel0("<b>Popup window appears in "+ticks+" sec. Wait please...</b>");
	} 
	function StartPopup(url, fwidth, fheight){
		xWin=window.open(url);
		setTimeout("test_xWin(url, fwidth, fheight)",700);
	}
	function test_xWin(){
	//  alert("typeof(xWin)="+typeof(xWin));
	//  alert("typeof(xWin.location.href)="+typeof(xWin.location.href));
	//  alert("xWin="+xWin);
	//  alert("xWin.location.hash="+xWin.location.hash);
	  if ( (xWin==null)
	     ||(typeof(xWin)=="undefined")
	     ||(typeof(xWin.location.hash)!="string")
	//     ||(xWin.location.hash!="#abc")
	     ){alert('detect pop up blocker');}
	  else{alert('no pop up blocker');};
	//alert("xWin="+xWin+" type="+typeof(xWin)+" typeloc="+typeof(xWin.location.hash)+" hash="+xWin.location.hash);
	  window.focus();
	}
	/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


//-->
