	
// STORE 
	
	// Shipping Address - Different from Billing? or Same as Billing? Show/Hide block.
	function open_shippingaddress()
	   {
	   document.getElementById('account_shippingaddress').style.display = '';
	   document.getElementById('shipping_paragraph').innerHTML = '<input type="checkbox" id="ship2diff" name="ship2diff" value="Y" onclick="javascript: close_shippingaddress();" checked="checked" /> My shipping address is different from my billing address.';
	   window.location = "#shippingaddress";
	   }
	function close_shippingaddress()
	   {
	   document.getElementById('account_shippingaddress').style.display = 'none';
	   document.getElementById('shipping_paragraph').innerHTML = '<input type="checkbox" id="ship2diff" name="ship2diff" value="Y" onclick="javascript: open_shippingaddress();" /> My shipping address is different from my billing address.';
	   window.location = "#shippingaddress";
	   }

// EMBROIDERY 
    
    // Embroidery Section open/close
    function open_embroidery()
        {
        document.getElementById('embroidery').style.display = 'block';
        document.getElementById('embroideryflip').innerHTML = '<a href="#embroidery" onclick="close_embroidery();">No thanks, I’ll call you or skip embroidery at this time.</a>';
	    window.location = "#embroidery";
	    
	    // Set logo choice
	    embroidery_chooselogo(document.getElementById("embroidery_logo").value);
	    
	    // Price calculations - in case of refresh
	    embroidery_calculateprice();
        }
     function close_embroidery()
        {
        document.getElementById('embroidery').style.display = 'none';
        document.getElementById('embroideryflip').innerHTML = '<a href="#embroidery" onclick="open_embroidery();">Simple embroidery of your name and/or a stock logo on your order.</a>';
	    window.location = "#embroidery";
        }
        
     // Embroidery Samples open/close
    function open_embroiderysample()
        {
        document.getElementById('samples_box').style.display = 'block';
        document.getElementById('embroidery_samplelink').innerHTML = '<a href="#embroidery" onClick="close_embroiderysample();">Hide examples</a>';
        }
     function close_embroiderysample()
        {
        document.getElementById('samples_box').style.display = 'none';
        document.getElementById('embroidery_samplelink').innerHTML = '<a href="#embroidery" onClick="open_embroiderysample();">Show examples</a>';
        }
    
     // Embroidery Price Calculations
     function embroidery_calculateprice () 
        {
		var totalPrice = 0;
		var eachPrice = 0;
		var logo = document.getElementById("embroidery_logo");
		var line1 = document.getElementById("embroidery_line1_text");
		var line2 = document.getElementById("embroidery_line2_text");
		var quantity = document.getElementById("embroidery_quantity");
		var price = document.getElementById ("embroidery_price");
		var price_each = document.getElementById ("embroidery_price_each");
		var postPrice = document.getElementById("totalPrice");
		
		
		if (logo.value && logo.value != "embroidery_logo_none") totalPrice += 8.00;
		if (line1.value.length || line2.value.length) totalPrice += 5.00;
		if (line1.value.length && line2.value.length) totalPrice += 3.00;
		eachPrice = totalPrice;
		
		totalPrice = totalPrice * parseInt (quantity.value);
		price_each.innerHTML = eachPrice.toFixed (2);
		price.innerHTML = totalPrice.toFixed (2);
		postPrice.value = totalPrice.toFixed (2);
		}
	function embroidery_chooselogo(selection) 
	   {
	   var logo = document.getElementById("embroidery_logo");
	   logo.value = selection;
	   
	   document.getElementById("embroidery_logo_none").style["border"] = "1px dotted #e3ddd3";
	   document.getElementById("embroidery_logo_caduceus").style["border"] = "1px dotted #e3ddd3";
	   document.getElementById("embroidery_logo_chiropractic").style["border"] = "1px dotted #e3ddd3";
	   document.getElementById(selection).style["border"] = "1px solid #000";
	   
	   embroidery_calculateprice();
	   }
	function embroidery_changequantity(quantity, checkboxid) {
	   var quantity_all = document.getElementById("embroidery_quantity");
	   var checkboxquantity = document.getElementById("embroidery_item_" + checkboxid);
	   
	   if (checkboxquantity.checked) quantity_new = parseInt (quantity_all.value) + parseInt (quantity);
	   if (!checkboxquantity.checked) quantity_new = parseInt (quantity_all.value) - parseInt (quantity);
	   
	   quantity_all.value = quantity_new;
	   
	   embroidery_calculateprice();
	   }
	   
// PRODUCT DETAILS
    
    // Features Section open/close
    function open_features()
        {
        document.getElementById('product_features').style.display = 'block';
        document.getElementById('product_features_link').className = 'open';
        document.getElementById('product_features_link').onclick = close_features;
        }
     function close_features()
        {
        document.getElementById('product_features').style.display = 'none';
        document.getElementById('product_features_link').className = 'closed';
        document.getElementById('product_features_link').onclick = open_features;
        }

// ADMIN 

    // Process search input string for various searches
    function getorderdetails()
        {
        $inputvalue = document.getElementById('inputvalue').value;
        
        // If it's a number...
        if (IsNumeric($inputvalue)) {
            var orderrange = $inputvalue.split("-");
             // If it's a number range, list all orders in range
            if (orderrange[1]) {
                document.getElementById('ordernumberbegin').value = orderrange[0];
                document.getElementById('ordernumberend').value = orderrange[1];
                document.getElementById('inputvalue').value = "";
                document.searchform_mini.submit();
                }
             // If it's a single number, look up detailed order page for it
            else {
                document.location.href = "../admin/order.php?orderid=" + $inputvalue;
                }
            }
        // If not a number, submit form to search by name
        else {
            document.searchform_mini.submit();
            }
        }
    // Test to check if value is a number
    function IsNumeric(sText)
	   {
	   var ValidChars = "0123456789.-";
	   var IsNumber=true;
	   var Char;
	 
	   for (i = 0; i < sText.length && IsNumber == true; i++) 
	      { 
	      Char = sText.charAt(i); 
	      if (ValidChars.indexOf(Char) == -1) 
	         {
	         IsNumber = false;
	         }
	      }
	   return IsNumber;
	   }