    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }

    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
      var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }

    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
      d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
      if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }

    function previewWindow(file, title, width, height, name)
    {
      win = window.open('', name, 'left=100,top=100,width=' + width + ',height=' + height + ',location=0,toolbar=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,channelmode=0,fullscreen=0');
      win.document.write('<html><title>' + title + '</title><body style="margin:0px"><img src="' + file + '" width="' + width + '" height="' + height + '" border="0" alt="' + title + '"><body></html>');
      win.document.close();
      win.focus();
      return false;
    }

    function checkDeliveryDate(object,offset)
    {
      if (!object.value)
      {
        alert("Please select a shipping date.");
        return false;
      }
      var data_array = object.value.split("/");

      data_array[0] --;
      var today = new Date();
      var mon_day = [31,28,31,30,31,30,31,31,30,31,30,31];
      if (today.getFullYear() == 2008 || today.getFullYear() == 2012 || today.getFullYear() == 2016)
      {
          mon_day[1] ++;
      }
      if (data_array[1] > mon_day[parseFloat(data_array[0])])
      {
        alert("Please select a correct shipping date.");
        return false;
      }
      var from = new Date(data_array[2], data_array[0], data_array[1]);

      if (Math.floor(((from.getTime() - (86400000 * (offset))) - today.getTime()) / 86400000) < -1)
      {
          alert("The shipping date is earlier than is possible from the farm.  Click the calendar icon to select the possible dates.");
          return false;
      }
      // not currently used
      //if (Math.floor((from.getTime()  - today.getTime() +(86400000*2)) / 86400000) > 21)
      //{
      //    alert("The shipping date is is greater than 20 days from today.  We can ship no more than 20 days from today. Click the calendar icon to select the possible dates.");
      //    return false;
      //}
      if (from.getDay() == 0)
      {
          alert("We do not ship on Sundays.");
          return false;
      }
      if (check_holiday (from))
      {
      	  alert("We do not ship on a date which you have chosen.   Please select another date.");
          return false;
      }
      return true;
    }

function check_holiday (dt_date) {
      // check simple dates (month/date - no leading zeroes)
      // if this function is updated you must also update check_holiday in calendar.js
      var n_date = dt_date.getDate(),
      n_month = dt_date.getMonth() + 1;
      var s_date1 = n_month + '/' + n_date;

      if ( s_date1 == '1/1' // New Year's Day
      || s_date1 == '6/14' // Flag Day
      || s_date1 == '7/4' // Independence Day
      || s_date1 == '11/11' // Veterans Day
      || s_date1 == '12/25' // Christmas Day
      ) return true;

      // weekday from beginning of the month (month/num/day)
      var n_wday = dt_date.getDay(),
      n_wnum = Math.floor((n_date - 1) / 7) + 1;
      var s_date2 = n_month + '/' + n_wnum + '/' + n_wday;

      if ( s_date2 == '1/3/1' // Birthday of Martin Luther King, third Monday in January
      || s_date2 == '2/3/1' // Washington's Birthday, third Monday in February
      || s_date2 == '5/3/6' // Armed Forces Day, third Saturday in May
      || s_date2 == '9/1/1' // Labor Day, first Monday in September
      || s_date2 == '10/2/1' // Columbus Day, second Monday in October
      || s_date2 == '11/4/4' // Thanksgiving Day, fourth Thursday in November
      ) return true;

      // weekday number from end of the month (month/num/day)
      var dt_temp = new Date (dt_date);
      dt_temp.setDate(1);
      dt_temp.setMonth(dt_temp.getMonth() + 1);
      dt_temp.setDate(dt_temp.getDate() - 1);
      n_wnum = Math.floor((dt_temp.getDate() - n_date - 1) / 7) + 1;
      var s_date3 = n_month + '/' + n_wnum + '/' + n_wday;
      var check_last = new Date(dt_date);
      check_last.setDate(31);
      var num_num;
      if (check_last.getDay() == 1)
      {
         num_num = 0;
      }
      else
      {
       num_num = 1;
      }

      if ( s_date3 == '5/'+num_num+'/1' // Memorial Day, last Monday in May
      ) return true;

      // misc complex dates
      if (s_date1 == '1/20' && (((dt_date.getFullYear() - 1937) % 4) == 0)
      // Inauguration Day, January 20th every four years, starting in 1937.
      ) return true;

      if (n_month == 11 && n_date >= 2 && n_date < 9 && n_wday == 2
      // Election Day, Tuesday on or after November 2.
      ) return true;

      return false;
    }

    function checkQuantity(object)
    {
        if (!checkAllowed(object.value, digits))
        {
           alert("Field 'Qty' should be an integer number.");
           object.value = 1;
           object.focus();
        }
    }

    function checkBorough(sform, state_id, object)
    {
        object.style.display = "none";

        if (sform.state_id.value == state_id && sform.country[0].value == '218' && !sform.international.checked)
        {
            var zip_code = parseInt(sform.zip.value);
            var city = sform.city.value.toLowerCase();
            for (var i in zip)
            {
                if (zip_code == zip[i] && (city == 'new york' || city == 'manhattan'))
                {
                    object.style.display = "";
                    break;
                }
            }
        }
    }

    function submitEmptyForm(url)
    {
        var sform = document.search;
        sform.action = url;
        sform.submit();
    }

    function showEnlargedImage(linkobj, name, width, height, left, top)
    {
        //var xPos, yPos;
        //xPos = eval(linkobj).offsetLeft;
        //tempEl = eval(linkobj).offsetParent;
        //while (tempEl != null)
        //{
	//		xPos += tempEl.offsetLeft;
        //    tempEl = tempEl.offsetParent;
        //}
        //yPos = eval(linkobj).offsetTop;
        //tempEl = eval(linkobj).offsetParent;
        //while (tempEl != null)
        //{
	//		yPos += tempEl.offsetTop;
	//		tempEl = tempEl.offsetParent;
	//	}
        var objstyle = window.document.getElementById(name).style;
        //var target = document.getElementById(name);
        //var coors = findPos(linkobj);  //alert(coors[0]+" "+coors[1]); return;
        //objstyle.left = xPos - width + 20;
        objstyle.left = left;
        //objstyle.top = yPos - height + 20;
        objstyle.top = top;
        objstyle.display = '';

    }

    function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
    }

    function hideEnlargedImage(name)
    {
        window.document.getElementById(name).style.display = 'none';
    }

    function setData(form_name,cnt)
    {
        var delivery_date = window.document.getElementById('delivery_date'+cnt);
        var form = eval(form_name);
        if (!delivery_date.value)
        {
            var today = new Date();
            date =  '0/0/' + today.getFullYear();
        }
        else
        {   
            date = delivery_date.value;
            //date = form.delivery_date+count.value;
        }

        var data = date.split('/');
		var oDate = new Date();
        if (navigator.userAgent.toLowerCase().indexOf('zzzzzzzzzzzz') != -1)
        {   // was for earlier versions of opera
            form.delivery_date_month.selectedIndex = parseFloat(data[0]);
            form.delivery_date_day.selectedIndex = parseFloat(data[1]);
            form.delivery_date_year.selectedIndex = parseFloat(data[2]) - oDate.getFullYear();
        }
        else
        {   
            var day_select = 'delivery_date_day'+cnt;
            //form.delivery_date_month.options[parseFloat(data[0])].selected = true;
            window.document.getElementById('delivery_date_month'+cnt).options[parseFloat(data[0])].selected = true;
            window.document.getElementById('delivery_date_day'+cnt).options[parseFloat(data[1])].selected = true;
            window.document.getElementById('delivery_date_year'+cnt).options[parseFloat(data[2]) - oDate.getFullYear()].selected = true;
            //form.delivery_date_day.options[parseFloat(data[1])].selected = true;
            //form.delivery_date_year.options[parseFloat(data[2]) - oDate.getFullYear()].selected = true;
        }
        if (typeof(items) != 'undefined') changePrice(form);
        if (typeof(carditem) != 'undefined') changeBasketPrice(form, carditem);
    }

    function setDataMaster(form_name,cnt)
    {
        
        for (x=0;x<=cnt;x++)
        {    
          var delivery_date = window.document.getElementById('delivery_date'+x);
          var form = eval(form_name);
          if (!delivery_date.value)
          {
            var today = new Date();
            date =  '0/0/' + today.getFullYear();
          }
          else
          {
            date = delivery_date.value;
            //date = form.delivery_date+count.value;
          }

          var data = date.split('/');
	  var oDate = new Date();
          if (navigator.userAgent.toLowerCase().indexOf('zzzzzzzzzzzz') != -1)
          {   // was for earlier versions of opera
            form.delivery_date_month.selectedIndex = parseFloat(data[0]);
            form.delivery_date_day.selectedIndex = parseFloat(data[1]);
            form.delivery_date_year.selectedIndex = parseFloat(data[2]) - oDate.getFullYear();
          }
          else
          {
            var day_select = 'delivery_date_day'+x;
            //form.delivery_date_month.options[parseFloat(data[0])].selected = true;
            window.document.getElementById('delivery_date_month'+x).options[parseFloat(data[0])].selected = true;
            window.document.getElementById('delivery_date_day'+x).options[parseFloat(data[1])].selected = true;
            window.document.getElementById('delivery_date_year'+x).options[parseFloat(data[2]) - oDate.getFullYear()].selected = true;
            //form.delivery_date_day.options[parseFloat(data[1])].selected = true;
            //form.delivery_date_year.options[parseFloat(data[2]) - oDate.getFullYear()].selected = true;
          }
          if (typeof(items) != 'undefined') changePrice(form);
          if (typeof(carditem) != 'undefined') changeBasketPrice(form, carditem);
        }
    }

    function changePrice(form)
    {
        var month = form.delivery_date_month.options[form.delivery_date_month.selectedIndex].value;
        if (!month) month = '0';
        if (month < 10) month = '0' + month;
        var day = form.delivery_date_day.options[form.delivery_date_day.selectedIndex].value;
        if (!day) day = '0';
        if (day < 10) day = '0' + day;
        var now = month + day + form.delivery_date_year.value;
        var prefix = (scenario_date.indexOf(' ' + now + ' ') != -1) ? 'spr_' : 'pr_';
        for (var i = 1; i < items; i++) document.getElementById('price_title_'+i).innerHTML = form.elements[prefix + i].value;
    }
    
    function changeDate(form)
    {
        var month = form.delivery_date_month.options[form.delivery_date_month.selectedIndex].value;
        if (!month) month = '0';
        if (month < 10) month = '0' + month;
        var day = form.delivery_date_day.options[form.delivery_date_day.selectedIndex].value;
        if (!day) day = '0';
        if (day < 10) day = '0' + day;
        var now = month + '/' + day + '/' + form.delivery_date_year.value;
        form.delivery_date.value = now;
    }

    function changeBasketPrice(form, item)
    {
        var month = form.delivery_date_month.options[form.delivery_date_month.selectedIndex].value;
        if (!month) month = '0';
        if (month < 10) month = '0' + month;
        var day = form.delivery_date_day.options[form.delivery_date_day.selectedIndex].value;
        if (!day) day = '0';
        if (day < 10) day = '0' + day;
        var now = month + day + form.delivery_date_year.value;
        var sc = eval('scenario_date_' + item);
        var prefix = (sc.indexOf(' ' + now + ' ') != -1) ? 'spr' : 'pr';
        document.getElementById('price_title_' + item).innerHTML = form.elements[prefix].value;
        total = form.elements[prefix].value * form.quantity.value;
        if (total - parseInt(total) == 0) total += '.00';
        document.getElementById('total_title_' + item).innerHTML = total;
        if (typeof(loaded) == 'undefined') return;
        var subtotal = 0;
        for (var i = 0; i < itemcount; i++) subtotal += parseFloat(document.getElementById('total_title_' + i).innerHTML);
        if (subtotal - parseInt(subtotal) == 0) subtotal += '.00';
        document.getElementById('subtotal_title').innerHTML = subtotal;
    }

    function getDataOLD(form)
    {
        var m = form.delivery_date_month;
        var d = form.delivery_date_day;
        var y = form.delivery_date_year;
        if (m.value && d.value && y.value)
        {
            form.delivery_date.value = ((parseFloat(m.value) < 10) ? "0": "") + m.value + "/" + ((parseFloat(d.value) < 10) ? "0" : "") + d.value + "/" + y.value;
        }
    }
    function getData(form,m,d,y,c)
    {
        var m = document.getElementById(m); 
        var d = document.getElementById(d);
        var y = document.getElementById(y);  
        var field = "delivery_date"+c;      
        if (m.value && d.value && y.value)
        {
            //form.field.value = ((parseFloat(m.value) < 10) ? "0": "") + m.value + "/" + ((parseFloat(d.value) < 10) ? "0" : "") + d.value + "/" + y.value;
            form.value = ((parseFloat(m.value) < 10) ? "0": "") + m.value + "/" + ((parseFloat(d.value) < 10) ? "0" : "") + d.value + "/" + y.value;
        }
    }
	function processPhone(form)
	{
		form.phone.value=form.ph1.value+'-'+form.ph2.value+'-'+form.ph3.value;
	}
	function processPhone2(form)
	{
		form.phone2.value=form.phn1.value+'-'+form.phn2.value+'-'+form.phn3.value;
	}
	function restorePhone(form,ph1,ph2,ph3)
	{
		form.ph1.value=ph1;
		form.ph2.value=ph2;
		form.ph3.value=ph3;
	}
	function restorePhone2(form,phn1,phn2,phn3)
	{
		form.phn1.value=phn1;
		form.phn2.value=phn2;
		form.phn3.value=phn3;
	}
	function checkPhone2Filled(oForm)
	{
	    if ( (oForm.phn1.value && (isEmpty(oForm.phn2.value) || isEmpty(oForm.phn3.value))) || 
	         (oForm.phn2.value && (isEmpty(oForm.phn1.value) || isEmpty(oForm.phn3.value))) ||
	         (oForm.phn3.value && (isEmpty(oForm.phn2.value) || isEmpty(oForm.phn1.value)))   )
	    {
	       alert("Field 'Phone2' needed to fill completely")
	       if (isEmpty(oForm.phn1.value))
	           oForm.phn1.focus();
	       else if (isEmpty(oForm.phn2.value))
	           oForm.phn2.focus();
	       else
	           oForm.phn3.focus();
	           
	       return false;
	    }
	    
	    return true;
	}

    function internationalOrder2(doc, sform, checked, ny_ny_state_id)
    {
        sform.state.style.display = "none";
        sform.state_id.style.display = "none";
        doc.getElementById('country_usa').style.display = 'none';
        doc.getElementById('country_other').style.display = 'none';
        if (checked)
        {
            sform.state.style.display = "";
            doc.getElementById('country_other').disabled = false;
            doc.getElementById('country_usa').disabled = true;
            doc.getElementById('country_other').style.display = '';
            doc.getElementById('phone_simple').style.display = 'block';
            doc.getElementById('phone5').style.display = 'none';
        }
        else
        {
            sform.state_id.style.display = "";
            doc.getElementById('country_other').disabled = true;
            doc.getElementById('country_usa').disabled = false;
            doc.getElementById('country_usa').style.display = '';
            checkZip(sform.country[0].value);
            doc.getElementById('phone_simple').style.display = 'none';
            doc.getElementById('phone5').style.display = 'block';
        }
    }
    
    function internationalOrder(doc, sform, checked, ny_ny_state_id)
    {
        sform.state.style.display = "none";
        sform.state_id.style.display = "none";
        doc.getElementById('country_usa').style.display = 'none';
        doc.getElementById('country_other').style.display = 'none';
        if (checked)
        {
            sform.state.style.display = "";
            doc.getElementById('country_other').disabled = false;
            doc.getElementById('country_usa').disabled = true;
            doc.getElementById('country_other').style.display = '';
            doc.getElementById('phone_simple').style.display = 'block';
            doc.getElementById('phone5').style.display = 'none';
            
            //var mandatory = mandatory2;
        }
        else
        {
            sform.state_id.style.display = "";
            doc.getElementById('country_other').disabled = true;
            doc.getElementById('country_usa').disabled = false;
            doc.getElementById('country_usa').style.display = '';
            checkZip(sform.country[0].value);
            doc.getElementById('phone_simple').style.display = 'none';
            doc.getElementById('phone5').style.display = 'block';
            //var mandatory = mandatory1;
        }
        checkBorough(sform, ny_ny_state_id, doc.getElementById('borough1'));
    }
    
    function checkMinLengthPhone(minimum, oField, sName)
    {
      //if (document.getElementById('international1').checked)
      //{
     //   return true;
      //}  
      if (isEmpty(oField.value)) return true;
    
      if (oField.value.length < minimum)
      {
        alert("Field '" + sName + "' has " + oField.value.length + " symbols (minimum required length is " + minimum + ').\n');
        oField.focus();
        return false;
      }
      else
      {
        return true;
      }
    }

    function internationalOrderUser(checked)
    {
        document.regform.state.style.display = "none";
        document.regform.state_id.style.display = "none";
        document.getElementById('country_usa').style.display = 'none';
        document.getElementById('country_other').style.display = 'none';
        if (checked)
        {
            document.regform.state.style.display = "";
            document.getElementById('country_other').disabled = false;
            document.getElementById('country_usa').disabled = true;
            document.getElementById('country_other').style.display = '';
        }
        else
        {
            document.regform.state_id.style.display = "";
            document.getElementById('country_other').disabled = true;
            document.getElementById('country_usa').disabled = false;
            document.getElementById('country_usa').style.display = '';
            checkZip(document.regform.country[0].value);
        }
    }

    function getKeyCode(e)
    {
        return (navigator.userAgent.indexOf('MSIE') != -1) ? event.keyCode : e.which;
    }
    
    function checkPrice(oVal)
    {
        if (oVal.price.value<0)
        {
            alert("Please fill correct field 'Price'");
            oVal.price.focus();
            return false;
        }
        return true;
    }
