
var product=["Keyboard (only)" , "Keyboard (with pointer)" , "Mouse Pointer" , "Analog Joystick - \"F\" series" , "Analog Joystick - \"H\" series" , "Trackball"]


var c=[["Desktop" , "OEM" , "Backlit" , "Custom/Other",""] , 
	   ["Desktop w/ Industrial Mouse" , "Desktop w/ Orbital Mouse" , "Desktop w/ Arrow Mouse" , "Desktop w/ Trackball" , "Panel Mount w/ Industrial Mouse" , "Rack Mount w/ Industrial Mouse" , "Rack Mount w/ Arrow Mouse" , "Rack Mount w/ Orbital Mouse" , "Rack Mount w/ Trackball" , "OEM w/ Orbital Mouse" , "OEM w/ Arrow Mouse" , "Backlit w/ Orbital Mouse" , "Backlit w/ Arrow Mouse" , "Backlit w/ Trackball" , "Custom/Other",""],
	   ["Desktop - Industrial Mouse" , "Desktop - Orbital Mouse" , "Desktop - Trackball" , "Panel Mount - Industrial Mouse" , "Panel Mount - Trackball" , "Handheld - Industrial Mouse" , "Handheld - Orbital Mouse" , "OEM - Industrial Mouse" , "OEM - Orbital Mouse" , "OEM - Arrow Mouse" , "Custom/Other",""],
	   ["Standard Industrial Joystick" , "Industrial Joystick w/ Push Button Switch" , "Industrial Joystick w/ 3 Axis" , "Custom/Other",""],
	   ["Full Size Joystick" , "Full Size Joystick w/ Push Button Switch" , "Full Size Joystick w/ 3 Axis",""],
	   ["Desktop" , "Panel Mount" , "OEM" , "Custom/Other",""]
	  ]

var b=[   [["Full Size" , "Compact Size",""] , ["Full Size" , "Compact Size",""] , ["Compact Size",""] , ["Full Size" , "Mid Size" , "Compact Size",""] ],
		  [["Full Size",""] , ["Full Size" , "Mid Size",""] , ["Full Size" , "Compact Size",""] , ["Full Size", "Compact Size",""] , ["Full Size",""] , ["Full Size",""] , ["Full Size",""] , ["Full Size",""] , ["Full Size",""] , ["Full Size" , "Mid Size",""] , ["Full Size" , "Compact Size",""] , ["Mid Size",""] , ["Compact Size",""] ,["Compact Size",""] , ["Custom - Fill Out Comment Section",""]],
		  [["Standard Joystick" , "Joystick w/ Push Button Switch" , "3 Axis Joystick",""] , ["Standard",""] , ["2.0\" Diameter Only",""] , ["Standard Joystick" , "Joystick w/ Push Button Switch" , "3 Axis Joystick",""] , ["1.5\" Diameter " , "2.0\" Diameter" , "3.0\" Diameter",""] , ["Standard Joystick" , "Joystick w/ Push Button Switch" , "3 Axis Joystick",""] , ["Standard",""] , ["Standard Joystick" , "Joystick w/ Push Button Switch" , "3 Axis Joystick",""] , ["Standard",""] , ["Standard",""] , ["Custom - Fill Out Comment Section",""]],
		  [["N2" , "N5" , "N24" , "N54",""] , ["N3 - Push Button Switch" , "N33 - Push Button Switch" , "N34 - 2 Push Button Switches" , "N63 - Push Button",""] , ["1850 - 3 Axis",""] , ["Custom - Fill Out Comment Section",""]],
		  [["N0" , "N04",""] , ["N32 - Push Button" , "N42 - Push Button" , "N62 - Push Button",""] , ["0800 - 3 Axis",""]],
		  [["2.0\" Diameter Only",""] , ["1.3\" Diameter" , "1.5\" Diameter" , "2.0\" Diameter" , "3.0\" Diameter",""] , ["1.3\" Diameter" , "1.5\" Diameter" , "2.0\" Diameter",""] , ["Custom - Fill Out Comment Section",""]]
		 ]

var a=[		   [[["PS/2" , "USB" , "AT" , "Sun (5C)" , "RS232" , "Don't know",""],["PS/2" , "USB" , "AT" , "Don't know",""]],
				[["PS/2" , "USB" , "AT" , "Sun (5C)" , "RS232" , "Don't know",""],["PS/2" , "USB" , "AT" , "Don't know",""]],
				[["PS/2" , "USB" , "AT" , "Don't know",""]],
				[["PS/2" , "USB" , "AT" , "Sun (5C)" , "RS232" , "Don't know",""],["PS/2" , "USB" , "AT" , "Sun (5C)" , "RS232" , "Don't know",""],["PS/2" , "USB" , "AT" , "Sun (5C)" , "RS232" , "Don't know",""]]],
			   [[["PS/2" , "USB (mouse)" , "USB (flight stick)" , "AT" , "Sun (5C)" , "RS232" , "Don't know",""]],
				[["PS/2" , "USB" , "Don't know",""] , ["PS/2" , "USB" , "Don't know",""]],
				[["PS/2" , "USB" , "AT" , "Don't know",""] , ["PS/2" , "USB" , "AT" , "Don't know",""]],
				[["PS/2" , "USB" , "AT" , "Sun (5C)" , "Don't know",""],["PS/2" , "AT" , "Don't know",""]],
				[["PS/2" , "USB (mouse)" , "USB (flight stick)" , "AT" , "Sun (5C)" ,"Don't know",""]],
				[["PS/2" , "AT" , "Don't know",""]],
				[["PS/2" , "USB" , "AT" , "Don't know",""]],
				[["PS/2" , "USB" , "Don't know",""]],
				[["PS/2" , "USB" , "AT" , "Sun (5C)" , "Don't know",""]],
				[["PS/2" , "USB" , "Don't know",""] , ["PS/2" , "USB" , "Don't know",""]],
				[["PS/2" , "USB" , "AT" , "Sun (5C)" , "Don't know",""] , ["PS/2" , "USB" , "Don't know",""]],
				[["PS/2" , "USB" , "AT" , "Don't know",""]],
				[["USB Only",""]],
				[["PS/2 Only",""]],
				[["PS/2" , "USB" , "AT" , "Sun (5C)" , "RS232" , "Don't know",""]]],
			   [[["PS/2" , "USB (mouse)" , "USB (flight stick)" , "AT" , "RS232" ,"Don't know",""] , ["PS/2" , "USB (mouse)" , "USB (flight stick)" , "AT" , "RS232" ,"Don't know",""] , ["PS/2" , "USB (mouse)" , "USB (flight stick)" , "AT" , "RS232" ,"Don't know",""]],
				[["PS/2" , "USB" ,"Don't know",""]],
				[["PS/2" , "USB" ,"Don't know",""]],
				[["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""] , ["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""] , ["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""]],
				[["PS/2" , "USB" , "RS232" ,"Don't know",""] ,["PS/2" , "USB" , "RS232" ,"Don't know",""] ,["PS/2" , "USB" , "RS232" ,"Don't know",""]],
				[["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""] , ["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""] , ["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""]],
				[["PS/2" , "USB" ,"Don't know",""]],
				[["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""] , ["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""] , ["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""]],
				[["PS/2" , "USB" , "RS232" , "Don't know",""]],
				[["PS/2" , "USB" ,  "Don't know",""]],
				[["PS/2" , "USB (mouse)" , "USB (flight stick)" , "RS232" ,"Don't know",""]]],
			   [[["Voltage Input = +12" , "Voltage Input = +5" , "Voltage Input = +/-5" , "Voltage Input = +/-12" , "Don't Know",""] , ["Voltage Input = +12" , "Voltage Input = +5" , "Voltage Input = +/-5" , "Voltage Input = +/-12" , "Don't Know",""] ,["Voltage Input = +12" , "Voltage Input = +5" , "Voltage Input = +/-5" , "Voltage Input = +/-12" , "Don't Know",""] , ["Voltage Input = +12" , "Voltage Input = +5" , "Voltage Input = +/-5" , "Voltage Input = +/-12" , "Don't Know",""]],
				[["Voltage Input = +12" , "Voltage Input = +5" , "Voltage Input = +/-5" , "Voltage Input = +/-12" , "Don't Know",""] , ["Voltage Input = +12" , "Voltage Input = +5" , "Voltage Input = +/-5" , "Voltage Input = +/-12" , "Don't Know",""] ,["Voltage Input = +12" , "Voltage Input = +5" , "Voltage Input = +/-5" , "Voltage Input = +/-12" , "Don't Know",""] , ["Voltage Input = +12" , "Voltage Input = +5" , "Voltage Input = +/-5" , "Voltage Input = +/-12" , "Don't Know",""]],
				[["Voltage Input = +/-5" , "Voltage Input = +5" , "Don't Know",""]],
				[["Custom - Fill Out Comment Section",""]]],
			   [[["Voltage Input = +12" , "Voltage Input = +/-12" , "Voltage Input = +24" , "Voltage Input = +/-15" , "Voltage Input = +10" , "Voltage Input = +/-10" , "Don't Know",""] , ["Voltage Input = +12" , "Voltage Input = +/-12" , "Voltage Input = +24" , "Voltage Input = +/-15" , "Voltage Input = +10" , "Voltage Input = +/-10" , "Don't Know" ,""]],
				[["Voltage Input = +12" , "Voltage Input = +/-12" , "Voltage Input = +24" , "Voltage Input = +/-15" , "Voltage Input = +10" , "Voltage Input = +/-10" , "Don't Know",""] , ["Voltage Input = +12" , "Voltage Input = +/-12" , "Voltage Input = +24" , "Voltage Input = +/-15" , "Voltage Input = +10" , "Voltage Input = +/-10" , "Don't Know",""] , ["Voltage Input = +12" , "Voltage Input = +/-12" , "Voltage Input = +24" , "Voltage Input = +/-15" , "Voltage Input = +10" , "Voltage Input = +/-10" , "Don't Know",""]],
				[["Voltage Input = +12" , "Voltage Input = +/-12" , "Voltage Input = +24" , "Voltage Input = +/-15" , "Voltage Input = +10" , "Voltage Input = +/-10" , "Don't Know",""]]],
			   [[["PS/2" , "USB" , "RS232" , "Don't Know",""]],
				[["PS/2" , "USB" , "RS232" , "Quadrature Ribbon - Wire Output" , "Don't Know",""] , ["PS/2" , "USB" , "RS232" , "Quadrature Ribbon - Wire Output" , "Don't Know",""] , ["PS/2" , "USB" , "RS232" , "Quadrature Ribbon - Wire Output" , "Don't Know",""] , ["PS/2" , "USB" , "RS232" , "Quadrature Ribbon - Wire Output" , "Don't Know",""]],
				[["Quadrature Ribbon - Wire Output",""] , ["Quadrature Ribbon - Wire Output",""] , ["Quadrature Ribbon - Wire Output",""]],
				[["Custom - Fill Out Comment Section",""]]]
			  ]


function fillCategory(){ 
 // this function is used to fill the category list on load
 for(i=0;i<6;i++){addOption(document.getElementById('Category'),i, product[i])}
 for(i=0;i<6;i++){addOption(document.getElementById('Category2'),i, product[i])}
 for(i=0;i<6;i++){addOption(document.getElementById('Category3'),i, product[i])}
 }

function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}


function SelectSubCat(a){
// ON selection of category this function will work
switch(a){
case 1:  
	     document.getElementById('Category2').disabled=true;
		 removeAllOptions(document.drop_list.SubCat1);
		 removeAllOptions(document.drop_list.SubCat2);
		 removeAllOptions(document.drop_list.SubCat3);
         addOption(document.drop_list.SubCat1, "", "Select Style", "");
		 addOption(document.drop_list.SubCat2, "", "Select Size", "");
		 addOption(document.drop_list.SubCat3, "", "Select Interface", "");
		 var pr=document.drop_list.Category.value;
		 fillStyle(pr,a);
		 break;
case 2:
		document.getElementById('Category3').disabled=true;
		removeAllOptions(document.drop_list.SubCat12);
		removeAllOptions(document.drop_list.SubCat22);
		removeAllOptions(document.drop_list.SubCat32);
		addOption(document.drop_list.SubCat12, "", "Select Style", "");
		addOption(document.drop_list.SubCat22, "", "Select Size", "");
		addOption(document.drop_list.SubCat32, "", "Select Interface", "");
		var pr=document.drop_list.Category2.value;
		fillStyle(pr,a);
		break;
case 3:
		removeAllOptions(document.drop_list.SubCat13);
		removeAllOptions(document.drop_list.SubCat23);
		removeAllOptions(document.drop_list.SubCat33);
		addOption(document.drop_list.SubCat13, "", "Select Style", "");
		addOption(document.drop_list.SubCat23, "", "Select Size", "");
		addOption(document.drop_list.SubCat33, "", "Select Interface", "");
		var pr=document.drop_list.Category3.value;
		fillStyle(pr,a);
		break;
		}
}

function SelectSize(a){
// ON selection of category this function will work
switch(a){
case 1:
		 removeAllOptions(document.drop_list.SubCat2);
		 removeAllOptions(document.drop_list.SubCat3);
		 addOption(document.drop_list.SubCat2, "", "Select Size", "");
		 addOption(document.drop_list.SubCat3, "", "Select Interface", "");
		 var pr=document.drop_list.Category.value;
		 var st=document.drop_list.SubCat1.value;
		 fillSize(pr,st,a);
		 break;		 
case 2:
		removeAllOptions(document.drop_list.SubCat22);
		removeAllOptions(document.drop_list.SubCat32);
		addOption(document.drop_list.SubCat22, "", "Select Size", "");
		addOption(document.drop_list.SubCat32, "", "Select Interface", "");
		var pr=document.drop_list.Category2.value;
		var st=document.drop_list.SubCat12.value;
		fillSize(pr,st,a);
		break;
case 3:
		removeAllOptions(document.drop_list.SubCat23);
		removeAllOptions(document.drop_list.SubCat33);
		addOption(document.drop_list.SubCat23, "", "Select Size", "");
		addOption(document.drop_list.SubCat33, "", "Select Interface", "");
		var pr=document.drop_list.Category3.value;
		var st=document.drop_list.SubCat13.value;
		fillSize(pr,st,a);
		break;
		}
}

function SelectInterface(a){
// ON selection of category this function will work
switch(a){
case 1:
		removeAllOptions(document.drop_list.SubCat3);
		addOption(document.drop_list.SubCat3, "", "Select Interface", "");
		var pr=document.drop_list.Category.value;
		var st=document.drop_list.SubCat1.value;
		var sz=document.drop_list.SubCat2.value;
		fillInterface(pr,st,sz,1);
		break;		 
case 2:
		removeAllOptions(document.drop_list.SubCat32);
		addOption(document.drop_list.SubCat32, "", "Select Interface", "");
		var pr=document.drop_list.Category2.value;
		var st=document.drop_list.SubCat12.value;
		var sz=document.drop_list.SubCat22.value;
		fillInterface(pr,st,sz,a);
		document.getElementById('Category3').disabled=false;
		break;
case 3:
		removeAllOptions(document.drop_list.SubCat33);
		addOption(document.drop_list.SubCat33, "", "Select Interface", "");
		var pr=document.drop_list.Category3.value;
		var st=document.drop_list.SubCat13.value;
		var sz=document.drop_list.SubCat23.value;
		fillInterface(pr,st,sz,a);
		break;
		}
}

////////////////// 

////////////////////////////////////////

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}

function fillStyle(productCatagory,a){
	if(productCatagory !=""){
	switch(a){
		case 1:	i=parseInt(productCatagory);
		        j=0
					do{
						addOption(document.drop_list.SubCat1,j, c[i][j]);
						j++
					}while (c[i][j] !='')
				break;
		case 2:
				i=parseInt(productCatagory);
		        j=0
					do{
						addOption(document.drop_list.SubCat12,j, c[i][j]);
						j++
					}while (c[i][j] !='')
				break;
		case 3:
				i=parseInt(productCatagory);
				j=0
					do{
						addOption(document.drop_list.SubCat13,j, c[i][j]);
						j++
					}while (c[i][j] !='')
				break;
			}
	}
}

function fillSize(productCatagory,style,a){
    if(productCatagory !="" && style !=""){
	switch(a){
		case 1:
				 i=parseInt(productCatagory);
				 j=parseInt(style);
				 k=0
					do{
						addOption(document.drop_list.SubCat2,k, b[i][j][k]);
						k++
					}while (b[i][j][k] !='')
				break;
		case 2:
				 i=parseInt(productCatagory);
				 j=parseInt(style);
				 k=0
					do{
						addOption(document.drop_list.SubCat22,k, b[i][j][k]);
						k++
					}while (b[i][j][k] !='')
				break;
		case 3:
				 i=parseInt(productCatagory);
				 j=parseInt(style);
				 k=0
					do{
						addOption(document.drop_list.SubCat23,k, b[i][j][k]);
						k++
					}while (b[i][j][k] !='')
				break;
			}
	}
   }


function fillInterface(productCatagory,style,Interface,h){
		if(productCatagory != "" && style != "" && Interface != ""){
		switch(h){
		case 1:  i=parseInt(productCatagory);
		         j=parseInt(style);
	             k=parseInt(Interface);
				 l=0;
				 	do{
						addOption(document.drop_list.SubCat3,l, a[i][j][k][l]);
						l++
					}while (a[i][j][k][l] !='')
				break;
		case 2:
				 i=parseInt(productCatagory);
				 j=parseInt(style);
	             k=parseInt(Interface);
				 l=0
					do{
						addOption(document.drop_list.SubCat32,l, a[i][j][k][l]);
						l++
					}while (a[i][j][k][l] !='')
				break;
		case 3:
				i=parseInt(productCatagory);
				 j=parseInt(style);
	             k=parseInt(Interface);
				 l=0
					do{
						addOption(document.drop_list.SubCat33,l, a[i][j][k][l]);
						l++
					}while (a[i][j][k][l] !='')
				break;
			}	
		}
}

///  Enabling the other 2 catogory drop downs

function EnableCatagory(e){
	switch(e){
		case 1:	if (document.drop_list.SubCat3.value !=""){document.getElementById('Category2').disabled=false;}
		        break;
		case 2: if (document.drop_list.SubCat32.value !=""){document.getElementById('Category3').disabled=false;}
		        break;
	}
}

function DisableCatagory(e){
	switch(e){
		case 1:	if (!document.getElementById('Category2').disabled){
							document.getElementById('Category2').disabled=true;
							removeAllOptions(document.drop_list.SubCat12);
							removeAllOptions(document.drop_list.SubCat22);
							removeAllOptions(document.drop_list.SubCat32);
							addOption(document.drop_list.SubCat12, "", "Select Style", "");
							addOption(document.drop_list.SubCat22, "", "Select Size", "");
							addOption(document.drop_list.SubCat32, "", "Select Interface", "");
		            }
		        if (!document.getElementById('Category3').disabled){
							document.getElementById('Category3').disabled=true;
							removeAllOptions(document.drop_list.SubCat13);
							removeAllOptions(document.drop_list.SubCat23);
							removeAllOptions(document.drop_list.SubCat33);
							addOption(document.drop_list.SubCat13, "", "Select Style", "");
							addOption(document.drop_list.SubCat23, "", "Select Size", "");
							addOption(document.drop_list.SubCat33, "", "Select Interface", "");
					}
		        break;
		case 2: if (!document.getElementById('Category3').disabled){
							document.getElementById('Category3').disabled=true;
							removeAllOptions(document.drop_list.SubCat13);
							removeAllOptions(document.drop_list.SubCat23);
							removeAllOptions(document.drop_list.SubCat33);
							addOption(document.drop_list.SubCat13, "", "Select Style", "");
							addOption(document.drop_list.SubCat23, "", "Select Size", "");
							addOption(document.drop_list.SubCat33, "", "Select Interface", "");
					}
		        break;
	}
}

////// validate the form drop_list

//This is the javascript function that validates fields on the form. The form needs to be named 'drop_list'
//Validation happens on the author, title, and username fields. Validation on the Status field works only
//in Internet Explorer.
//The input name=value for fields on the form must match what is used in the javascript code.
function CheckTheForm()
{
if (document.drop_list.Name.value=="")
{
alert("Name is required!")
document.drop_list.Name.focus();return false
}

if (document.drop_list.Address.value=="")
{
alert("Address is required!")
document.drop_list.Address.focus();return false
}
if (document.drop_list.State.value=="")
{
alert("state is required!")
document.drop_list.State.focus();return false
}

if (document.drop_list.Phone.value=="" || !parseInt(document.drop_list.Phone.value))
{
alert("valid Phone Number is required!")
document.drop_list.Phone.focus();return false
}

if (document.drop_list.Title.value=="")
{
alert("Title/Dept is required!")
document.drop_list.Title.focus();return false
}

if (document.drop_list.Zip.value=="")
{
alert("Valid Postal Zip coid is required!")
document.drop_list.Zip.focus();return false
}
if (document.drop_list.Company.value=="")
{
alert("Company is required!")
document.drop_list.Company.focus();return false
}
if (document.drop_list.City.value=="")
{
alert("City is required!")
document.drop_list.City.focus();return false
}

if (document.drop_list.Country.value=="")
{
alert("Country is required!")
document.drop_list.Country.focus();return false
}

//This does validation of a valid email address... it cannot validate that the address works, but that it is 
//formatted like an email address should be (something@something.something)
if (document.drop_list.Email.value != "")
{
	if (document.drop_list.Email.value.indexOf("@") == -1 || document.drop_list.Email.value.length < 7)
		{
		alert("Sorry your Email address is not valid");
		document.drop_list.Email.focus();return false
		}
}

if (document.drop_list.Category.value=="")
{
alert("Product is required!")
document.drop_list.Category.focus();return false;
}
if (document.drop_list.SubCat1.value=="")
{
alert("Style is required!")
document.drop_list.SubCat1.focus();return false
}

if (document.drop_list.SubCat2.value=="")
{
alert("Size is required!")
document.drop_list.SubCat2.focus();return false
}

if (document.drop_list.SubCat3.value=="")
{
alert("Interface is required!")
document.drop_list.SubCat3.focus();return false
}

if (document.drop_list.hear_about.value=="")
{
alert("How did you hear about CTI? is required!")
document.drop_list.hear_about.focus();return false
}

if (document.drop_list.time_frame.value=="")
{
alert("Time Frame is required!")
document.drop_list.time_frame.focus();return false
}

if(!document.getElementById('Category2').disabled && document.getElementById('Category2').value!="" ){
		
			if (document.drop_list.Category2.value=="")
				{
					alert("Product is required!")
					document.drop_list.Category2.focus();return false
				}
			if (document.drop_list.SubCat12.value=="")
				{
					alert("Style is required!")
					document.drop_list.SubCat12.focus();return false
				}

			if (document.drop_list.SubCat22.value=="")
				{
					alert("Size is required!")
					document.drop_list.SubCat22.focus();return false
				}

			if (document.drop_list.SubCat32.value=="")
				{
					alert("Interface is required!")
					document.drop_list.SubCat32.focus();return false
				}
			
			
			if(!document.getElementById('Category3').disabled && document.getElementById('Category3').value!=""){
				if (document.drop_list.Category3.value=="")
				{
					alert("Product is required!")
					document.drop_list.Category3.focus();return false
				}
				if (document.drop_list.SubCat13.value=="")
				{
					alert("Style is required!")
					document.drop_list.SubCat13.focus();return false
				}

				if (document.drop_list.SubCat23.value=="")
				{
					alert("Size is required!")
					document.drop_list.SubCat23.focus();return false
				}

				if (document.drop_list.SubCat33.value=="")
				{
					alert("Interface is required!")
					document.drop_list.SubCat33.focus();return false
				}
			}
	}

}
