var loc=document.location.href;

var baseUrl=window.location.host;

$(document).ready(function() {
	
	//check to see if we are on an ordering page
	if(loc.match(/(order)/ig)) {

			//replace the step 1 and step 2 text
			var s1=$("#step_one_phrase").html();
			var s2=$("#step_two_phrase").html();

			$("#step_one_phrase").html(s1.replace(/Step 1/,"Step 2"));
			$("#step_two_phrase").html(s2.replace(/Step 2/,"Step 3"));

			var htm="Step 1: Choose a flavor";
			var sel="<div style='font-size:12px; padding:5px; line-height:16px; text-indent:45px;'><strong>Flavors: </strong> <select id='flavor_select' >";


			//check for weight gainer or protein

			if(loc.match(/(Weight_Gainer)/ig)) {

				sel+="<option value='/muscle_advance_weight_gainer/order_chocolate.php'>Chocolate</option>";
				sel+="<option value='/muscle_advance_weight_gainer_vanilla/order_vanilla.php'>Vanilla</option>";


			} else if(loc.match(/(Whey_Protein)/ig)) {

				sel+="<option value='/muscle_advance_whey_protein/order_chocolate.php'>Chocolate</option>";
				sel+="<option value='/muscle_advance_whey_protein_vanilla/order_vanilla.php'>Vanilla</option>";

			}


			sel+="</select></div>";
			$("div[rel=extra_step]").html(htm+sel);

			var ind=0;
			//set the preselected flavor
			if(loc.match(/(vanilla)/ig)) {
				ind=1;
			}

			document.getElementById("flavor_select").selectedIndex=ind;

			$("#flavor_select").change(

				function() {

					var e=this;



					var val=e.options[e.selectedIndex].value;
					//setNoCoupon();

					var xtra='';

					if(baseUrl.match(/(healthbuy.com)/ig)) {

						xtra="/product/order";

					}

					document.location.href="http://"+baseUrl+xtra+val;

				}
			);


	}
});