    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)
    {
      if (!object.value)
      {
        alert("Please select a delivery 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() == 2004 || today.getFullYear() == 2008)
      {
          mon_day[1] ++;
      }
      if (data_array[1] > mon_day[parseFloat(data_array[0])])
      {
        alert("Please select a correct delivery date.");
        return false;
      }
      var from = new Date(data_array[2], data_array[0], data_array[1]);
      if (Math.floor((from.getTime() - today.getTime()) / 86400000) < -1)
      {
          alert("Delivery date earlier than current date");
          return false;
      }
      return true;
    }

    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)
    {
        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;
        objstyle.left = xPos - width + 20;
        objstyle.top = yPos - height + 20;
        objstyle.display = '';

    }

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

    function setData(form_name)
    {
        var form = eval(form_name);
        if (!form.delivery_date.value)
        {
            var today = new Date();
            date =  '0/0/' + today.getFullYear();
        }
        else
        {
            date = form.delivery_date.value
        }
        var data = date.split('/');
		var oDate = new Date();
        if (navigator.userAgent.toLowerCase().indexOf('opera') != -1)
        {
            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
        {
            form.delivery_date_month.options[parseFloat(data[0])].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 getData(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 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;
    }

