<h2>Quick Order</h2>
<img src="/skin/frontend/default/modern/images/example.jpg" alt="example" width="552" height="182"><br /><br />
<p>You arleady know what you want right?  Well then, use this quick order page to quickly order products using the manufacturer's item number. After an item number is entered and added to the cart, the form resets and is immediately ready for the next item.  Despite how it appears in the catalog, <strong>do not type the space between the manufacturer's three letter prefix and the remainder of the number. </strong> Please see the example above to see exactly how an item should be entered. If you enter an item, click "Add To Cart", and you don't see an item appear in the My Cart box on the upper left, it simply means the item number you used was incorrect.  Try again.</p>
<div class="quick-order">
	<form id="product_addtocart_form" action="" method="post">
	<input type="hidden" id="product" name="product" value="1010" /> 
	<p><strong>Item Number: </strong> <input class="input-text" type="text" name="sku-entry" id="sku-entry" onkeydown="if (event.keyCode == 13) { fireOnEnter(); return false; }" /> 
	<strong>Qty: </strong> <input type="text" class="input-text" name="qty" id="qty" onkeydown="if (event.keyCode == 13) { fireOnEnter(); return false; }" />

<a id="clickbtn" onclick="processMyForm(); return false;" href="#"><img style="margin: 0pt 0pt 0pt 5px;" class="v-middle" alt="Add to Cart" src="https://officebundle.com/skin/frontend/default/modern/images/btn_add_to_cart.gif"></a>
	</form>
</div>

<script type="text/javascript">
//<![CDATA[

function fireOnEnter()
{
	$('clickbtn').onclick();
	return false;
}

var productAddToCartForm = new VarienForm('product_addtocart_form');
productAddToCartForm.submit = function() {
    if(this.validator.validate()) {
        this.form.submit();
    }
}.bind(productAddToCartForm);

var processMyForm = function()
{
    var formdata = $('product_addtocart_form').serialize(true);
    var theform = $('product_addtocart_form');
    var input = theform['sku-entry'];
    var myqtyinput = theform['qty'];
    var itemnum = $(input).getValue();
    var prodinput = theform['product'];
    var myqty = $(myqtyinput).getValue();
    var winner = '';
    var response = '';
    var url = '';
    var pageback;
    new Ajax.Request('/scripts/add-sku-to-cart.php', {
			parameters: formdata,
			onSuccess: function(transport){
				response = transport.responseText;
				if (itemnum == response)
					alert('Product Not Added. The SKU you entered ('+itemnum+') was not found.');
				else
				{
			    url = response.substr(27);
					new Ajax.Request(url, {
				  	method: "get",
			    	onSuccess: function(resp){
				  	  var thehtml = resp.responseText;
			    		var myreg = /\/checkout\/cart\/add\/uenc\/[\,\/\w]+/gi;
			    		var prodIdReg = /\/(\d+)/gi;
			    		var match = myreg.exec(thehtml);
			      	winner = match[0];
			    		var prodId = prodIdReg.exec(winner);
							prodinput.setValue(prodId[0].substr(1));
							theform.setAttribute('action', winner+"qty/"+myqty);
					    myqtyinput.setValue('');
					    input.setValue('');
			    	},
			    	onComplete: function(trans){
					    productAddToCartForm.submit();        	
			    	}
			    });
				}
			}
		});
}

//]]>
</script>