//if user select a bandage type then disable product combo
function disableProduct(){
	if (document.getElementById("bandage").selectedIndex != 0){
		document.getElementById("product").disabled = true;
	} else {
		document.getElementById("product").disabled = false;
	}
}

//if user select a product then disable bandage type combo
function disableBandage(){
	if (document.getElementById("product").selectedIndex != 0){
		document.getElementById("bandage").disabled = true;
	} else {
		document.getElementById("bandage").disabled = false;
	}
}

var wound = new Array("Select One","Cuts, Scrapes & Burns","Blisters");
var bandage_all = new Array("Select One","Plastic","Just for Kids","Fabric","Foam","Waterproof","Advanced Protection","Cleanse","Variety Pack");
var bandage_cuts = new Array("Select One","Plastic","Just for Kids","Fabric","Foam","Waterproof","Advanced Protection","Cleanse","Variety Pack");
var bandage_blisters = new Array("Select One","Advanced Protection","Cleanse","Variety Pack");
var product_all = new Array("Select One","COMFORT-FLEX%AE","Decorated","PERFECT FIT%u2122","Flexible Fabric","TOUGH-STRIPS%AE","%20%20%20%20%20- Regular","%20%20%20%20%20- Waterproof","WET-FLEX%AE","Advanced Healing","SINGLE STEP%u2122","Cleanse");
var product_cuts = new Array("Select One","COMFORT-FLEX%AE","Decorated","PERFECT FIT%u2122","Flexible Fabric","TOUGH-STRIPS%AE","%20%20%20%20%20- Regular","%20%20%20%20%20- Waterproof","WET-FLEX%AE","Advanced Healing","SINGLE STEP%u2122");
var product_blisters = new Array("Select One","Advanced Healing","ANTI-BLISTER stick");

//populate combos when the page is started
function initializeSelects() {
	wound_options = eval(wound);
	num_wound_options = wound_options.length;
	document.getElementById("wound").length = num_wound_options;
	for(i=0;i<num_wound_options;i++){
	   document.getElementById("wound").options[i].value=i;
	   document.getElementById("wound").options[i].text=wound_options[i];
	}
	bandage_options = eval(bandage_all);
	num_bandage_options = bandage_options.length;
	document.getElementById("bandage").length = num_bandage_options;
	for(i=0;i<num_bandage_options;i++){
	   document.getElementById("bandage").options[i].value=i;
	   document.getElementById("bandage").options[i].text=bandage_options[i];
	}
	product_options = eval(product_all);
	num_product_options = product_options.length;
	document.getElementById("product").length = num_product_options;
	for(i=0;i<num_product_options;i++){
	   document.getElementById("product").options[i].value=i;
	   document.getElementById("product").options[i].text=unescape(product_options[i]);
	}
}

//if user select a wound then populate bandage type and product combos
function loadSelects(){
	
	var wound = document.getElementById("wound").selectedIndex;
	
    if (wound != 0) {
		if (wound == 1){
			bandage_options = eval(bandage_cuts);
			product_options = eval(product_cuts);
		}
		if (wound == 2){
			bandage_options = eval(bandage_blisters);
			product_options = eval(product_blisters);
		}
		num_bandage_options = bandage_options.length;
		document.getElementById("bandage").length = num_bandage_options;
		for(i=0;i<num_bandage_options;i++){
		   document.getElementById("bandage").options[i].value=i;
		   document.getElementById("bandage").options[i].text=unescape(bandage_options[i]);
		}
		num_product_options = product_options.length;
		document.getElementById("product").length = num_product_options;
		for(i=0;i<num_product_options;i++){
		   document.getElementById("product").options[i].value=i;
		   document.getElementById("product").options[i].text=unescape(product_options[i]);
		}
    }else{
		bandage_options = eval(bandage_all);
		num_bandage_options = bandage_options.length;
		document.getElementById("bandage").length = num_bandage_options;
		for(i=0;i<num_bandage_options;i++){
		   document.getElementById("bandage").options[i].value=i;
		   document.getElementById("bandage").options[i].text=unescape(bandage_options[i]);
		}
		product_options = eval(product_all);
		num_product_options = product_options.length;
		document.getElementById("product").length = num_product_options;
		for(i=0;i<num_product_options;i++){
		   document.getElementById("product").options[i].value=i;
		   document.getElementById("product").options[i].text=unescape(product_options[i]);
		}
    }
    document.getElementById("bandage").options[0].selected = true;
    document.getElementById("product").options[0].selected = true;
    document.getElementById("bandage").disabled = false;
    document.getElementById("product").disabled = false;	 	
}

//if user clicks on go to search
function submitSearch(){
	if (document.getElementById("product").selectedIndex == 0 && document.getElementById("bandage").selectedIndex == 0){
		alert("Please select a product or a type.");
	} else {
		if (document.getElementById("product").selectedIndex == 0){
			if (document.getElementById("wound").selectedIndex == 1 || document.getElementById("wound").selectedIndex == 0){
				switch(document.getElementById("bandage").selectedIndex)
				{
				case 1:
				  window.location = "productlist.asp?typeId=1";
				  break;
				case 2:
				  window.location = "productlist.asp?typeId=2";
				  break;
				case 3:
				  window.location = "productlist.asp?typeId=3";
				  break;
				case 4:
				  window.location = "productlist.asp?typeId=4";
				  break;
				case 5:
				  window.location = "productlist.asp?typeId=5";
				  break;
				case 6:
				  window.location = "productlist.asp?typeId=6";
				  break;
				case 7:
				  window.location = "productlist.asp?typeId=7";
				  break;
				case 8:
				  window.location = "productlist.asp?typeId=8";
				  break;
				}
			} else {
				switch(document.getElementById("bandage").selectedIndex)
				{
				case 1:
				  window.location = "productlist.asp?typeId=6";
				  break;
				case 2:
				  window.location = "productlist.asp?typeId=7";
				  break;
				case 3:
				  window.location = "productlist.asp?typeId=8";
				  break;
				}
			}			
		} else {
			if (document.getElementById("wound").selectedIndex == 1 || document.getElementById("wound").selectedIndex == 0){
				switch(document.getElementById("product").selectedIndex)
				{
				case 1:
				  window.location = "productlist.asp?typeId=1#a1";
				  break;
				case 2:
				  window.location = "productlist.asp?typeId=2";
				  break;
				case 3:
				  window.location = "productlist.asp?typeId=3#a4";
				  break;
				case 4:
				  window.location = "productlist.asp?typeId=3#a5";
				  break;
				case 5:
				  window.location = "productlist.asp?typeId=5#a9";
				  break;
				case 6:
				  window.location = "productlist.asp?typeId=3#a6";
				  break;
				case 7:
				  window.location = "productlist.asp?typeId=5#a9";
				  break;
				case 8:
				  window.location = "productlist.asp?typeId=4";
				  break;
				case 9:
				  window.location = "productlist.asp?typeId=6#a10";
				  break;
				case 10:
				  window.location = "productlist.asp?typeId=6#a12";
				  break;
				case 11:
				  window.location = "productlist.asp?typeId=7#a13";
				  break;
				case 12:
				  window.location = "productlist.asp?typeId=7#a15";
				  break;
				}
			} else {
				switch(document.getElementById("product").selectedIndex)
				{
				case 1:
				  window.location = "productlist.asp?typeId=6#a10";
				  break;
				case 2:
				  window.location = "productlist.asp?typeId=7#a16";
				  break;
				}
			}
		}
	}
}
