<!--
  /*  ------------------------------------------------------  */
  /*                        TRIM methods                      */
  /*  ------------------------------------------------------  */
	function trim(Str) {
		var sTrimmed = Str.replace(/(^\s*)|(\s*$)/g, "");
		//var sTrimmed = Str.replace(/^\s*$/g, "");
		return sTrimmed;
  }
  
	function strip_commas(Str) {
	  // Ignore if found "1,,1" or trailing comma
	  if ( Str.match(/,,+/g)  || Str.match(/,$/g) )
	    return Str;
	    
		var sStrippedCommas = Str.replace(/,*/g, "");
		return sStrippedCommas ;
  }
  /*  ------------------------------------------------------  */


  /*  ------------------------------------------------------  */
  /*           Input validation  methods                      */
  /*  ------------------------------------------------------  */
	function is_empty(Str) {
    var sTrimmed = trim(Str);
		return ( sTrimmed.length == 0 ) ;
  }


	function is_nbr(Str, bStripCommasFl) {
		if (is_empty(Str) ) 
			return false;      
		else {
			if (bStripCommasFl) {
				Str = strip_commas(Str); 
			}
		
			if (Str == parseInt(Str,10))
				return true
			else
				return false
				
			//return ! isNaN(Str); 
		}
 }


	function is_zero(Str, bStripCommasFl) {
		if (! is_nbr(Str, bStripCommasFl) )
			return false;      
    else
		  return  (parseFloat(Str) == 0) ;
  }


	function is_greater_than_zero(Str, bStripCommasFl) {
		var bRC;
		//alert("Str:" + Str); 
		
		if (! is_nbr(Str, bStripCommasFl) )
		  bRC =  false;
			//return false;      
    else
      bRC =  (parseFloat(Str) > 0) ;
		  //return  (parseFloat(Str) > 0) ;
		
		//alert("bRC:" + bRC); 
		return bRC;
  }

  /*  ------------------------------------------------------  */
  /*           Match Array                                    */
  /*  ------------------------------------------------------  */
    function IsMatchArray(Array1, Array2, bTrim){
      var sMsg = "", bMatch = true;
      Str1 = new String;
      Str2 = new String;
      
      for (i = 0; i < Array1.length ; i++) {
        
        if  (bTrim) {
          Str1 = trim(Array1[i]);
          Str2 = trim(Array2[i]);
        }
        else {          
          Str1 = Array1[i];
          Str2 = Array2[i];
        }          
        
        if (Str1 != Str2) {
//          // test only
//          sMsg += "Array1[" + i + "]: >" + Str1 + "<";
//          sMsg += "\tArray2[" + i + "]: >" + Str2 + "<\n\r";
          bMatch = false;
          break;
        }
      }
      
//      // test only      
//      if (is_empty(sMsg)) 
//        sMsg = "No changes Made";
//      sMsg += "\r\nbMatch:" + bMatch;
//      alert(sMsg);
      
      return bMatch;
    }


  /*  ------------------------------------------------------  */
  /*           Popup window                                   */
  /*  ------------------------------------------------------  */
  function popUp(url){
    sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=500,height=450');
    self.name = "mainWin"; 
    sealWin.focus()
  }

  function ValidChar(Field){
    var valid = 1                                       
    var GoodChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
    var i = 0

    if (Field==""){
      valid = 1
      return false;
    }
                           
    for (i =0; i <= Field.length -1; i++){
      if (GoodChars.indexOf(Field.charAt(i)) == -1){
        return false;
      } 
    } 
    return true;         
  }
  
function AllwBckOrdMsg(QtyLimit)
{
 alert("You have exceeded the available amount for this product.  Currently, we only have " + QtyLimit + " gift certificates/gift cards available for this product and then it will be discontinued.  Please select this available amount OR chose another product and/or merchant.  We apologize for any inconvenience.")
}    
//-->

