
	//Function to confirm an action.
	function confirmAction (theMsg,theUrl){
	
		var yesNo = confirm (theMsg);
		
		if (yesNo){
		
			window.location = theUrl;
		
		}
	
	}
	
	//Function to grey out options.
	function paymentChange (theBox){
	
		var deets = document.getElementById ("payment_details");
		
		if (deets){
		
			if (theBox.value == "1"){
			
				deets.className = "vis";
			
			} else {
			
				deets.className = "invis";
			
			}
		
		}
	
	}

	//Function to filter the products.
	function filterProds (theVal,catId,filterType,otherFilter,productFeature){
	
		if (filterType == "tog"){
		
			otherFilter = "&size="+otherFilter;
		
		} else {
		
			otherFilter = "&tog="+otherFilter;
		
		}
	
		window.location = "index.php?op=products&cat_id="+catId+"&"+filterType+"="+theVal+otherFilter+"&product_feature="+productFeature;
	
	}
	
	//Function to filter by product features.
	function filterReg (theVal,catId,tog,size){
	
		window.location = "index.php?op=products&cat_id="+catId+"&product_feature="+theVal+"&tog="+tog+"&size="+size;
	
	}

	//Function to change the number of items per page.
	function changeNumPages (theVal,catId,tog,size,searchq,id,productFeature){
	
		window.location = "process.php?op=change_num&num="+theVal+"&cat_id="+catId+"&tog="+tog+"&size="+size+"&searchq="+searchq+"&id="+id+"&product_feature="+productFeature;
	
	}

	//Function to change up the price.
	function updatePrice (opId,prodId,catCheck,catId){
	
		if (catId){
		
			var proceed = true;
			
			var catSplit = catCheck.split ("-");
		
			//Make sure the others are filled in.
			for (var i = 0; i < catSplit.length; i++){
		
				if (catSplit[i] != catId){
				
					var tObj = document.getElementById("category_"+catSplit[i]);
				
					if (tObj){
					
						if (tObj.value == "0"){
						
							proceed = false;
						
						} else {
						
							var checkId = tObj.value;
						
						}
					
					}
				
				}
				
			}
			
		}
		
		var proceed = true;
			
		if (!proceed){
		
			var curPrice = document.getElementById("price_"+prodId);
			
			if (curPrice){
			
				curPrice.innerHTML = "select an option";
			
			}
			
			//Reset the box
			var curBox = document.getElementById("category_"+catId);
			
			if (curBox){
		
				curBox.value = "0";
			
			}
		
		} else {
		
			//Get the price.
			var price = getPrice (opId);
			
			var curPrice = document.getElementById("price_"+prodId);
			
			if (curPrice){
			
				curPrice.innerHTML = "$"+price;
			
			}
			
		
		}
	
	}
	
	function getPrice (priceId){
	
		xmlhttp = getXmlHttp();
		xmlhttp.open("GET","ajax.php?op=get_price&op_id="+priceId,false);
		xmlhttp.send("");
		var price = xmlhttp.responseText;
		
		return price;
	
	}

	//Function to reload the category box.
	function filterNewOptions (catCheck,catId,opId){
	
		var catSplit = catCheck.split ("-");
		
		for (var i = 0; i < catSplit.length; i++){
		
			if (catSplit[i] != catId){
			
				var tObj = document.getElementById("category_"+catSplit[i]);
				
				if (tObj){

					var curSel = document.getElementById("category_"+catId);
					
					if (curSel){
				
						var cur = curSel.selectedIndex;
				
						var curText = curSel.options[cur].text;
						
					}
					
					var curVal = tObj.value;
		
					tObj.options.length = 0;
				
					//Repopulate the box.
					var optn = document.createElement("OPTION");
					optn.text = " -- ";
					optn.value = 0;
					tObj.options.add(optn);
					
					//Get the available options.
					xmlhttp = getXmlHttp();
					xmlhttp.open("GET","ajax.php?op=filter_options&cat_id="+catSplit[i]+"&op_id="+opId+"&val="+curText+"&cur_cat="+catId,false);
					xmlhttp.send("");
					var jsonString = xmlhttp.responseText;
					
					var myObject = eval ("(" + jsonString + ")");
					
					for (var j = 0; j < myObject.length; j++){
					
						if (myObject[j].prod_to_option_id){
						
							var optn = document.createElement("OPTION");
							optn.text = myObject[j].value + " - " + "$" + myObject[j].price_price;
							optn.value = myObject[j].prod_to_option_id;
							
							if (curVal == myObject[j].prod_to_option_id){
							
								optn.selected = "selected";
							
							}
							
							tObj.options.add(optn);
						
						}
						
					}
				
				}
			
			}
		
		}
	
	}
	
	function orderItem (prodId,catCheck){
	
		var catSplit = catCheck.split ("-");
		var proceed = true;
		
		for (var i = 0; i < catSplit.length; i++){
		
			var tObj = document.getElementById ("category_"+catSplit[i]);
			
			if (tObj){
			
				if (tObj.value == "0"){
				
					proceed = false;
				
				}
			
			}
		
		}
		
		if (proceed){
		
			//Get the values, pass them along to the ajax.
			var curForm = document.getElementById ("product_"+prodId);
			
			if (curForm){
			
				var qty = parseInt (curForm.qty.value);
			
				if (parseInt (curForm.qty.value) <= 0 || isNaN (qty)){
				
					alert ("Please enter a quantity.");
					proceed = false;
				
				}
				
				if (proceed){
			
					var theVars = getFormVars (curForm);
					
					xmlhttp = getXmlHttp();
					xmlhttp.open("POST","ajax.php?op=add_item",false);
					xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
					xmlhttp.send("&prod_id="+prodId+theVars);
					
					var topCart = document.getElementById("cur_cart");
					
					if (topCart){
					
						topCart.innerHTML = xmlhttp.responseText;
					
					}
					
					xmlhttp = getXmlHttp();
					xmlhttp.open("GET","ajax.php?op=reload_cart",false);
					xmlhttp.send("");
					
					var miniCart = document.getElementById("mini_cart");
					
					if (miniCart){
					
						miniCart.innerHTML = xmlhttp.responseText;
					
					}
					
					//Reset all form fields.
					for (var i = 0; i < catSplit.length; i++){
		
						var tObj = document.getElementById ("category_"+catSplit[i]);
						
						if (tObj){
						
							tObj.value = "0";
						
						}
					
					}
					
					curForm.qty.value = "";
					
					//Show the check mark.
					var check = document.getElementById("add_check_"+prodId);
					
					if (check){
					
						check.style.visibility = "visible";
						
						//Remove it after 5 seconds.
						setTimeout("removeCheck('"+prodId+"')", 3000);
					
					}
					
				}
				
				/*
				processAjax ("ajax.php?op=add_item",document.getElementById("cur_cart"),"post","&prod_id="+prodId+theVars,null,true);
				
				//Re-load the mini-cart.
				processAjax ("ajax.php?op=reload_cart",document.getElementById("mini_cart"),"post","",null,true);
				
				*/
				
			}
		
		} else {
		
			alert ("Please select your options.");
		
		}
	
	}
	
	//Function to remove the check mark.
	function removeCheck (prodId){
	
		var tObj = document.getElementById("add_check_"+prodId);
		
		if (tObj){
		
			tObj.style.visibility = "hidden";
		
		}
	
	}
	
	//Function to return a list of form vars.
	function getFormVars (theForm){
		var endStr = "";
		if (theForm){
			for (var i = 0; i < theForm.elements.length; i++){
				switch (theForm.elements[i].type){
					case "radio":
						if (theForm.elements[i].checked){
							endStr += "&"+theForm.elements[i].name + "=" + theForm.elements[i].value;
						}
						break;
					case "select-one":
						endStr += "&"+theForm.elements[i].name+"="+theForm.elements[i][theForm.elements[i].selectedIndex].value;
						break;
					case "checkbox":
						if (theForm.elements[i].checked){
							endStr += "&"+theForm.elements[i].name+"=1";
						} else {
							endStr += "&"+theForm.elements[i].name+"=0";
						}
						break;
					case "password":
					case "text":
					case "textarea":
					case "hidden":
						endStr += "&"+theForm.elements[i].name+"="+encodeURIComponent(theForm.elements[i].value);
						break;
				}
			}
		}
		return endStr;
	}
	
	//Function to stop a user from resubmitting the same order.
	function stopRe (){
	
		var payButton = document.getElementById("payment_button");
		
		if (payButton){
		
			payButton.disabled = true;
		
		}
	
	}
