
// VARIABLE DECLARATIONS
var defaultEmptyOK = false
var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// whitespace characters
var whitespace = " \t\n\r";

// decimal point character differs by language and culture
var decimalPointDelimiter = "."

// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";

// characters which are allowed in US phone numbers
var validUSPhoneChars = digits + phoneNumberDelimiters;

// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";


// U.S. phone numbers have 10 digits.
// They are formatted as 123 456 7890 or (123) 456-7890.
var digitsInUSPhoneNumber = 10;



// non-digit characters which are allowed in ZIP Codes
var ZIPCodeDelimiters = "-";



// our preferred delimiter for reformatting ZIP Codes
var ZIPCodeDelimeter = "-"
// U.S. ZIP codes have 5 or 9 digits.
// They are formatted as 12345 or 12345-6789.
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9



function Get_Cookie(name) {
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) 
		return null;
	if (start == -1) 
		return null;
	var end = document.cookie.indexOf(";",len)
	if (end == -1) 
		end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {
	//document.cookie = name + "=" +escape(value) +
	document.cookie = name + "=" + value +
		( (expires) ? ";expires=" + expires.toGMTString() : "") +
		( (path) ? ";path=" + path : "") +
		( (domain) ? ";domain=" + domain : "") +
		( (secure) ? ";secure" : "");
}

function Delete_Cookie(name,path,domain) {
	if (Get_Cookie(name)) document.cookie = name + "=" +
		( (path) ? ";path=" + path : "") +
		( (domain) ? ";domain=" + domain : "") +
		";expires=Thu, 01-Jan-70 00:00:01 GMT";
}

var delimitem = "|";
var delimdetail = "~";

var today = new Date();
var zero_date = new Date(0,0,0);
today.setTime(today.getTime() - zero_date.getTime());
//alert(today.getDate());

var todays_date = new Date(today.getFullYear(),today.getMonth(),today.getDate(),0,0,0);
//alert (todays_date)
var expires_date = new Date(todays_date.getTime() + (8 * 7 * 86400000));


function storeMasterCookie() {
	if (!Get_Cookie('MasterCookie'))
		Set_Cookie('MasterCookie','MasterCookie');
}

function addToCookie(name,value) {
	if (Get_Cookie('MasterCookie')) {
		var IntelligentCookie = Get_Cookie(name);
		//alert('IntelligentCookie = ' + IntelligentCookie);
		if (IntelligentCookie!=null){
			var cart_all = IntelligentCookie + delimitem + value
			//Set_Cookie(name, cart_all, expires_date);
			Set_Cookie(name, cart_all);
		}
		else {
			//Set_Cookie(name,value,expires_date);
			Set_Cookie(name,value);
			IntelligentCookie = Get_Cookie(name);
			if ((!IntelligentCookie) || (IntelligentCookie != value))
				Delete_Cookie('MasterCookie');
		}
	}
}

function updateCookie(name,value) {

	if (Get_Cookie('MasterCookie')) {
		var IntelligentCookie = Get_Cookie(name);

		Set_Cookie(name,value);
		IntelligentCookie = Get_Cookie(name);
		if ((!IntelligentCookie) || (IntelligentCookie != value))
			Delete_Cookie('MasterCookie');
	}
}


function display_cart() {
	location.href = 'shopping_cart.htm'
	//OrdWin = window.open('shopping_cart.htm','OrdWin');
}

function emptyCart(){
	var the_cart = Get_Cookie('Shopping Cart');
	if(the_cart != null){
		if(confirm('Are you sure you want to empty your shopping cart?')){
			Delete_Cookie('Shopping Cart');
			location.href = 'shopping_cart.htm';
		}
	}
	else{
		alert('The shopping cart is already empty');
	}
}

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function charInString (c, s)
{   for (i = 0; i < s.length; i++)
    {   if (s.charAt(i) == c) return true;
    }
    return false
}




function stripInitialWhitespace (s)

{   var i = 0;

    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    
    return s.substring (i, s.length);
}







// Returns true if character c is an English letter 
// (A .. Z, a..z).
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isLetter (c)
{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
}



// Returns true if character c is a digit 
// (0 .. 9).

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}



// Returns true if character c is a letter or digit.

function isLetterOrDigit (c)
{   return (isLetter(c) || isDigit(c))
}



// isInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters in string s are numbers.
//
// Accepts non-signed integers only. Does not accept floating 
// point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// By default, returns defaultEmptyOK if s is empty.
// There is an optional second argument called emptyOK.
// emptyOK is used to override for a single function call
//      the default behavior which is specified globally by
//      defaultEmptyOK.
// If emptyOK is false (or any value other than true), 
//      the function will return false if s is empty.
// If emptyOK is true, the function will return true if s is empty.
//
// EXAMPLE FUNCTION CALL:     RESULT:
// isInteger ("5")            true 
// isInteger ("")             defaultEmptyOK
// isInteger ("-5")           false
// isInteger ("", true)       true
// isInteger ("", false)      false
// isInteger ("5", false)     true

function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}







// isSignedInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters are numbers; 
// first character is allowed to be + or - as well.
//
// Does not accept floating point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// EXAMPLE FUNCTION CALL:          RESULT:
// isSignedInteger ("5")           true 
// isSignedInteger ("")            defaultEmptyOK
// isSignedInteger ("-5")          true
// isSignedInteger ("+5")          true
// isSignedInteger ("", false)     false
// isSignedInteger ("", true)      true

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}




// isPositiveInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is an integer > 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isPositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isPositiveInteger.arguments.length > 1)
        secondArg = isPositiveInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a positive, not negative, number

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) > 0) ) );
}






// isNonnegativeInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is an integer >= 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number >= 0

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}






// isNegativeInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is an integer < 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isNegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNegativeInteger.arguments.length > 1)
        secondArg = isNegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a negative, not positive, number

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) < 0) ) );
}






// isNonpositiveInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is an integer <= 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isNonpositiveInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonpositiveInteger.arguments.length > 1)
        secondArg = isNonpositiveInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number <= 0

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) <= 0) ) );
}





// isFloat (STRING s [, BOOLEAN emptyOK])
// 
// True if string s is an unsigned floating point (real) number. 
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isInteger, then call isFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isFloat (s)

{   var i;
    var seenDecimalPoint = false;

    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}







// isSignedFloat (STRING s [, BOOLEAN emptyOK])
// 
// True if string s is a signed or unsigned floating point 
// (real) number. First character is allowed to be + or -.
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isSignedInteger, then call isSignedFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isSignedFloat (s)

{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedFloat.arguments.length > 1)
            secondArg = isSignedFloat.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isFloat(s.substring(startPos, s.length), secondArg))
    }
}




// isAlphabetic (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is English letters 
// (A .. Z, a..z) only.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isAlphabetic (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphabetic character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;
    }

    // All characters are letters.
    return true;
}




// isAlphanumeric (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is English letters 
// (A .. Z, a..z) and numbers only.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isAlphanumeric (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphanumeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number or letter.
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    // All characters are numbers or letters.
    return true;
}




// reformat (TARGETSTRING, STRING, INTEGER, STRING, INTEGER ... )       
//
// Handy function for arbitrarily inserting formatting characters
// or delimiters of various kinds within TARGETSTRING.
//
// reformat takes one named argument, a string s, and any number
// of other arguments.  The other arguments must be integers or
// strings.  These other arguments specify how string s is to be
// reformatted and how and where other strings are to be inserted
// into it.
//
// reformat processes the other arguments in order one by one.
// * If the argument is an integer, reformat appends that number 
//   of sequential characters from s to the resultString.
// * If the argument is a string, reformat appends the string
//   to the resultString.
//
// NOTE: The first argument after TARGETSTRING must be a string.
// (It can be empty.)  The second argument must be an integer.
// Thereafter, integers and strings must alternate.  This is to
// provide backward compatibility to Navigator 2.0.2 JavaScript
// by avoiding use of the typeof operator.
//
// It is the caller's responsibility to make sure that we do not
// try to copy more characters from s than s.length.
//
// EXAMPLES:
//
// * To reformat a 10-digit U.S. phone number from "1234567890"
//   to "(123) 456-7890" make this function call:
//   reformat("1234567890", "(", 3, ") ", 3, "-", 4)
//
// * To reformat a 9-digit U.S. Social Security number from
//   "123456789" to "123-45-6789" make this function call:
//   reformat("123456789", "", 3, "-", 2, "-", 4)
//
// HINT:
//
// If you have a string which is already delimited in one way
// (example: a phone number delimited with spaces as "123 456 7890")
// and you want to delimit it in another way using function reformat,
// call function stripCharsNotInBag to remove the unwanted 
// characters, THEN call function reformat to delimit as desired.
//
// EXAMPLE:
//
// reformat (stripCharsNotInBag ("123 456 7890", digits),
//           "(", 3, ") ", 3, "-", 4)

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}


// isUSPhoneNumber (STRING s [, BOOLEAN emptyOK])
// 
// isUSPhoneNumber returns true if string s is a valid U.S. Phone
// Number.  Must be 10 digits.
//
// NOTE: Strip out any delimiters (spaces, hyphens, parentheses, etc.)
// from string s before calling this function.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isUSPhoneNumber (s)
{   if (isEmpty(s)) 
       if (isUSPhoneNumber.arguments.length == 1) return defaultEmptyOK;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == digitsInUSPhoneNumber)
}


// isZIPCode (STRING s [, BOOLEAN emptyOK])
// 
// isZIPCode returns true if string s is a valid 
// U.S. ZIP code.  Must be 5 or 9 digits only.
//
// NOTE: Strip out any delimiters (spaces, hyphens, etc.)
// from string s before calling this function.  
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isZIPCode (s)
{  if (isEmpty(s)) 
       if (isZIPCode.arguments.length == 1) return defaultEmptyOK;
       else return (isZIPCode.arguments[1] == true);
   return (isInteger(s) && 
            ((s.length == digitsInZIPCode1) ||
             (s.length == digitsInZIPCode2)))
}


// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c -- in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

// takes ZIPString, a string of 5 or 9 digits;
// if 9 digits, inserts separator hyphen

function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}


// checkZIPCode (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid ZIP code.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkZIPCode (theField, emptyOK)
{   if (checkZIPCode.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    { var normalizedZIP = stripCharsInBag(theField.value, ZIPCodeDelimiters)
      if (!isZIPCode(normalizedZIP, false)) 
         return warnInvalid (theField, iZIPCode);
      else 
      {  // if you don't want to insert a hyphen, comment next line out
         theField.value = reformatZIPCode(normalizedZIP)
         return true;
      }
    }
}

// takes USPhone, a string of 10 digits
// and reformats as (123) 456-789

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "(", 3, ") ", 3, "-", 4))
}



// checkUSPhone (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid US Phone.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkUSPhone (theField, emptyOK)
{   if (checkUSPhone.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
       if (!isUSPhoneNumber(normalizedPhone, false)) 
          return warnInvalid (theField, iUSPhone);
       else 
       {  // if you don't want to reformat as (123) 456-789, comment next line out
          theField.value = reformatUSPhone(normalizedPhone)
          return true;
       }
    }
}



// checkInternationalPhone (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid International Phone.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkInternationalPhone (theField, emptyOK)
{   if (checkInternationalPhone.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  if (!isInternationalPhoneNumber(theField.value, false)) 
          return warnInvalid (theField, iWorldPhone);
       else return true;
    }
}



// checkEmail (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid Email.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkEmail (theField, emptyOK)
{   if (checkEmail.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isEmail(theField.value, false)) 
       return warnInvalid (theField, iEmail);
    else return true;
}


// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}



// Removes all characters which do NOT appear in string bag 
// from string s.

function stripCharsNotInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}



// Removes all whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.

function stripWhitespace (s)

{   return stripCharsInBag (s, whitespace)
}

function calculatePostalZone(zipcode) {
  var zone;
  
  if(zipcode == 5) zone = 5;
  else if(zipcode >= 6 && zipcode <= 9) zone = 7;
  else if(zipcode >= 10 && zipcode <= 37) zone = 5;
  else if(zipcode >= 38 && zipcode <= 49) zone = 6;
  else if(zipcode >= 50 && zipcode <= 149) zone = 5;
  else if(zipcode >= 150 && zipcode <= 157) zone = 4;
  else if(zipcode == 158) zone = 5;
  else if(zipcode >= 159 && zipcode <= 163) zone = 4;
  else if(zipcode >= 164 && zipcode <= 165) zone = 4;
  else if(zipcode == 166) zone = 4;
  else if(zipcode == 167) zone = 5;
  else if(zipcode == 168) zone = 4;
  else if(zipcode >= 169 && zipcode <= 199) zone = 5;
  else if(zipcode >= 200 && zipcode <= 209) zone = 4;
  else if(zipcode >= 210 && zipcode <= 212) zone = 5;
  else if(zipcode == 214) zone = 5;
  else if(zipcode == 215) zone = 4;
  else if(zipcode == 216) zone = 5;
  else if(zipcode == 217) zone = 4;
  else if(zipcode == 218 || zipcode == 219) zone = 5;
  else if(zipcode >= 220 && zipcode <= 241) zone = 4;
  else if(zipcode == 242) zone = 3;
  else if(zipcode >= 243 && zipcode <= 286) zone = 4;
  else if(zipcode >= 287 && zipcode <= 289) zone = 3;
  else if(zipcode >= 290 && zipcode <= 292) zone = 4;
  else if(zipcode == 293) zone = 3;
  else if(zipcode == 294 || zipcode == 295) zone = 4;
  else if(zipcode == 296) zone = 3;
  else if(zipcode == 297) zone = 4;
  else if(zipcode == 298) zone = 3;
  else if(zipcode == 299) zone = 4;
  else if(zipcode >= 300 && zipcode <= 303) zone = 2;
  else if(zipcode >= 304 && zipcode <= 306) zone = 3;
  else if(zipcode == 307) zone = 2;
  else if(zipcode >= 308 && zipcode <= 310) zone = 3;
  else if(zipcode == 311) zone = 2;
  else if(zipcode == 312) zone = 3;
  else if(zipcode >= 313 && zipcode <= 316) zone = 4;
  else if(zipcode >= 317 && zipcode <= 319) zone = 3;
  else if(zipcode >= 320 && zipcode <= 323) zone = 4;
  else if(zipcode == 324 || zipcode == 325) zone = 3;
  else if(zipcode >= 326 && zipcode <= 329) zone = 4;
  else if(zipcode >= 330 && zipcode <= 334) zone = 5;
  else if(zipcode >= 335 && zipcode <= 338) zone = 4;
  else if(zipcode >= 339 && zipcode <= 341) zone = 5;
  else if(zipcode == 342) zone = 4;
  else if(zipcode == 344) zone = 4;
  else if(zipcode == 346 || zipcode == 347) zone = 4;
  else if(zipcode == 349) zone = 5;
  else if(zipcode >= 350 && zipcode <= 352) zone = 2;
  else if(zipcode == 354 || zipcode == 355) zone = 2;
  else if(zipcode >= 356 && zipcode <= 358) zone = 2;
  else if(zipcode == 359) zone = 2;
  else if(zipcode == 360 || zipcode == 361) zone = 3;
  else if(zipcode == 362) zone = 2;
  else if(zipcode >= 363 && zipcode <= 369) zone = 3;
  else if(zipcode >= 370 && zipcode <= 372) zone = 2;
  else if(zipcode == 373 || zipcode == 374) zone = 2;
  else if(zipcode == 375 || zipcode == 376) zone = 3;
  else if(zipcode >= 377 && zipcode <= 381) zone = 3;
  else if(zipcode >= 382 && zipcode <= 385) zone = 2;
  else if(zipcode == 386 || zipcode == 387) zone = 3;
  else if(zipcode == 388) zone = 2;
  else if(zipcode >= 389 && zipcode <= 394) zone = 3;
  else if(zipcode == 395) zone = 4;
  else if(zipcode == 396) zone = 3;
  else if(zipcode == 397) zone = 2;
  else if(zipcode == 398) zone = 3;
  else if(zipcode == 399) zone = 2;
  else if(zipcode >= 400 && zipcode <= 409) zone = 3;
  else if(zipcode >= 410 && zipcode <= 412) zone = 4;
  else if(zipcode >= 413 && zipcode <= 418) zone = 3;
  else if(zipcode == 420) zone = 3;
  else if(zipcode == 421 || zipcode == 422) zone = 2;
  else if(zipcode >= 423 && zipcode <= 427) zone = 3;
  else if(zipcode >= 430 && zipcode <= 470) zone = 4;
  else if(zipcode == 471 || zipcode == 472) zone = 3; 
  else if(zipcode == 473) zone = 4;
  else if(zipcode >= 474 && zipcode <= 478) zone = 3;
  else if(zipcode >= 479 && zipcode <= 495) zone = 4;
  else if(zipcode >= 496 && zipcode <= 499) zone = 5;
  else if(zipcode >= 500 && zipcode <= 504) zone = 4;
  else if(zipcode == 505) zone = 5;
  else if(zipcode >= 506 && zipcode <= 509) zone = 4;
  else if(zipcode >= 510 && zipcode <= 516) zone = 5;
  else if(zipcode == 520) zone = 4;
  else if(zipcode == 521) zone = 5;
  else if(zipcode >= 522 && zipcode <= 538) zone = 4;
  else if(zipcode >= 539 && zipcode <= 566) zone = 4;
  else if(zipcode == 567) zone = 6;
  else if(zipcode >= 570 && zipcode <= 575) zone = 5;
  else if(zipcode == 576 || zipcode == 577) zone = 6;
  else if(zipcode == 580 || zipcode == 581) zone = 5;
  else if(zipcode >= 582 && zipcode <= 593) zone = 6;
  else if(zipcode >= 594 && zipcode <= 599) zone = 7;
  else if(zipcode >= 600 && zipcode <= 627) zone = 4;
  else if(zipcode == 628 || zipcode == 629) zone = 3;
  else if(zipcode >= 630 && zipcode <= 635) zone = 4;
  else if(zipcode >= 636 && zipcode <= 639) zone = 3;
  else if(zipcode >= 640 && zipcode <= 668) zone = 4;
  else if(zipcode >= 669 && zipcode <= 672) zone = 5;
  else if(zipcode == 673) zone = 4;
  else if(zipcode >= 674 && zipcode <= 693) zone = 5;
  else if(zipcode >= 700 && zipcode <= 714) zone = 4;
  else if(zipcode == 716) zone = 3;
  else if(zipcode >= 717 && zipcode <= 719) zone = 4;
  else if(zipcode >= 720 && zipcode <= 725) zone = 3;
  else if(zipcode >= 726 && zipcode <= 729) zone = 4;
  else if(zipcode == 730 || zipcode == 731) zone = 5;
  else if(zipcode == 733) zone = 5;
  else if(zipcode == 734) zone = 4;
  else if(zipcode >= 735 && zipcode <= 739) zone = 5;
  else if(zipcode >= 740 && zipcode <= 759) zone = 4;
  else if(zipcode >= 760 && zipcode <= 769) zone = 5;
  else if(zipcode >= 770 && zipcode <= 778) zone = 4;
  else if(zipcode >= 779 && zipcode <= 797) zone = 5;
  else if(zipcode >= 798 && zipcode <= 816) zone = 6;
  else if(zipcode >= 820 && zipcode <= 831) zone = 6;
  else if(zipcode >= 832 && zipcode <= 844) zone = 7;
  else if(zipcode >= 845 && zipcode <= 847) zone = 6;
  else if(zipcode == 850) zone = 7;
  else if(zipcode == 852 || zipcode == 853) zone = 7;
  else if(zipcode >= 855 && zipcode <= 860) zone = 6;
  else if(zipcode == 863 || zipcode == 864) zone = 7;
  else if(zipcode == 865) zone = 6;
  else if(zipcode >= 870 && zipcode <= 880) zone = 6;
  else if(zipcode == 881) zone = 5;
  else if(zipcode == 882 || zipcode == 883) zone = 6;
  else if(zipcode == 884) zone = 5;
  else if(zipcode == 885) zone = 6;
  else if(zipcode >= 889 && zipcode <= 891) zone = 7;
  else if(zipcode == 893) zone = 7;
  else if(zipcode == 894 || zipcode == 895) zone = 8;
  else if(zipcode == 897) zone = 8;
  else if(zipcode == 898) zone = 7;
  else if(zipcode >= 900 && zipcode <= 928) zone = 7;
  else if(zipcode >= 930 && zipcode <= 934) zone = 8;
  else if(zipcode == 935) zone = 7;
  else if(zipcode >= 936 && zipcode <= 978) zone = 8;
  else if(zipcode == 979) zone = 7;
  else if(zipcode >= 980 && zipcode <= 989) zone = 8;
  else if(zipcode >= 990 && zipcode <= 992) zone = 7;
  else if(zipcode == 993) zone = 8;
  else if(zipcode == 994) zone = 7;
  else if(zipcode >= 995 && zipcode <= 999) zone = 8;

  return zone;
}

