var availableSizes = new Object();
            availableSizes["rectangle"] = {"2 x 3 metal back":{"name":"2 x 3 inch metal back","prices":{1000000:"0.21",9999:"0.215",4999:"0.23",2499:"0.27",999:"0.335",499:"0.44",249:"0.79",0:"0"}}, "2 x 3 paper back":{"name":"2 x 3 inch paper back","prices":{1000000:"0.293",9999:"0.303",4999:"0.313",2499:"0.328",999:"0.413",499:"0.493",249:"0.848",0:"0"}}, "2 1/2 x 3 1/2":{"name":"2 1/2 x 3 1/2 inch","prices":{1000000:"0.234",9999:"0.239",4999:"0.249",2499:"0.274",999:"0.369",499:"0.554",249:"0.844",0:"0"}}, "1 x 1 1/2":{"name":"1 x 1 1/2 inch","prices":{1000000:"0.17",9999:"0.18",4999:"0.19",2499:"0.205",999:"0.265",499:"0.39",249:"0.715",0:"0"}}};
            availableSizes["square"] = {"2 metal back":{"name":"2 inch metal back","prices":{1000000:"0.196",9999:"0.201",4999:"0.216",2499:"0.251",999:"0.316",499:"0.416",249:"0.766",0:"0"}}, "2 paper back":{"name":"2 inch paper back","prices":{1000000:"0.29",9999:"0.30",4999:"0.31",2499:"0.325",999:"0.41",499:"0.49",249:"0.845",0:"0"}}};
            availableSizes["triangle"] = {"3":{"name":"3 inch","prices":{1000000:"0.224",9999:"0.229",4999:"0.239",2499:"0.284",999:"0.289",499:"0.469",249:"0.799",0:"0"}}};
            availableSizes["oval"] = {"1 7/8 x 2 7/8":{"name":"1 7/8 x 2 7/8 inch","prices":{1000000:"0.216",9999:"0.221",4999:"0.231",2499:"0.276",999:"0.281",499:"0.441",249:"0.786",0:"0"}}};
            availableSizes["oblong"] = {"1 3/4":{"name":"1 3/4 inch","prices":{1000000:"0.26",9999:"0.265",4999:"0.275",2499:"0.30",999:"0.395",499:"0.585",249:".87",0:"0"}}};
            availableSizes["round"] = {"1 1/4":{"name":"1 1/4 inch","prices":{1000000:"0.128",9999:"0.133",4999:"0.158",2499:"0.163",999:"0.248",499:"0.308",249:"0.543",0:"0"}}, "1 1/2":{"name":"1 1/2 inch","prices":{1000000:"0.134",9999:"0.144",4999:"0.164",2499:"0.174",999:"0.254",499:"0.319",249:"0.564",0:"0"}}, "1 3/4":{"name":"1 3/4 inch","prices":{1000000:"0.144",9999:"0.149",4999:"0.169",2499:"0.184",999:"0.259",499:"0.349",249:"0.574",0:"0"}}, "2 1/4":{"name":"2 1/4 inch","prices":{1000000:"0.151",9999:"0.156",4999:"0.176",2499:"0.196",999:"0.271",499:"0.391",249:"0.606",0:"0"}}, "2 1/4 2pc":{"name":"2 1/4 inch 2pc","prices":{1000000:"0.166",9999:"0.171",4999:"0.191",2499:"0.211",999:"0.286",499:"0.416",249:"0.68",0:"0"}}, "2 1/2":{"name":"2 1/2 inch","prices":{1000000:"0.166",9999:"0.171",4999:"0.196",2499:"0.216",999:"0.286",499:"0.606",249:"0.646",0:"0"}}, "3":{"name":"3 inch","prices":{1000000:"0.187",9999:"0.197",4999:"0.222",2499:"0.237",999:"0.307",499:"0.427",249:"0.692",0:"0"}},
			 "3 2pc":{"name":"3 inch 2pc","prices":{1000000:"0.212",9999:"0.222",4999:"0.242",2499:"0.252",999:"0.332",499:"0.452",249:"0.722",0:"0"}}, "3 1/2":{"name":"3 1/2 inch","prices":{1000000:"0.204",9999:"0.209",4999:"0.229",2499:"0.244",999:"0.374",499:"0.679",249:"0.724",0:"0"}}};
			  function getSizes(shapeElement){
                // get the selected shape:
                var selectedShape = shapeElement.options[shapeElement.selectedIndex].value;
                // find the correct sizes for this shape:
                var sizes = availableSizes[selectedShape];
                // now we put the available sizes in the second drop down:
                var dropDown2 = document.getElementById("size");
                dropDown2.options.length = 0; // remove existing information in the dropdown
                
                for(var size in sizes){
                    var option = document.createElement("option");
                    option.text = sizes[size]["name"];
                    option.value = size;
                    
                    try {
                        dropDown2.add(option,null); // standards compliant
                    } catch(ex) {
                        dropDown2.add(option); // IE only
                    }
                }
            }
            
            function doCalculation(){
                var selectedShape = document.getElementById("shape").options[document.getElementById("shape").selectedIndex].value;
                var selectedSize = document.getElementById("size").options[document.getElementById("size").selectedIndex].value;
                var selectedQuantity = document.getElementById("quantity").value;
                var doCalculation = true;
                
                // validate the data of the user:
                if (selectedQuantity == "") {
                    alert("Please select a quantity");
                    doCalculation = false;
                }
                
                // when the data is validated, do the calculation
                if (doCalculation){
                    // let's get all the available prices for the selcted shape & size:
                    var prices = availableSizes[selectedShape][selectedSize]["prices"];
                    
                    // get the correct price for the quantity
                    var previousPrice = 0;
                    for(price in prices){
                        if (selectedQuantity*1 > price){
                            // ok, we are 1 item too far; the end price should be calculated from the previousPrice:
                            alert(selectedQuantity + " x " + prices[previousPrice] + " = " + (selectedQuantity*prices[previousPrice]));
                            break; // we can stop going through the loop now
                        } else {
                            // the quantity is smaller than the maximum quantity for this price; no match found
                            previousPrice = price;
                        }
                    }
                }
            }