function typeList()
{
	this.length=4;
	this[0]=new Option("Top","b1");
  this[1]=new Option("Skirt","b2");
  this[2]=new Option("Accessories","b3");
	this[3]=new Option("Decor","b4");
	return this;
}
function subTypeList()
{
	this.length=4;
	this[0] = new Array(4);
	this[0][0]=new Option("Sweater/jacket","0");
	this[0][1]=new Option("Tank top/vest/camisole","1");
	this[0][2]=new Option("Tee shirt","2");
	this[0][3]=new Option("Tunic/coat","3");
	this[1] = new Array(3);
	this[1][0]=new Option("Straight","4");
	this[1][1]=new Option("A-line","5");
	this[1][2]=new Option("Flared","6");
	this[2] = new Array(4);
	this[2][0]=new Option("Hat","0");
	this[2][1]=new Option("Scarf","1");
	this[2][2]=new Option("Shawl","2");
	this[2][3]=new Option("Poncho","3");
	this[3] = new Array(3);
	this[3][0]=new Option("Blanket/throw/afghan","4");
	this[3][1]=new Option("Pillow","5");
	this[3][2]=new Option("Place mat","6");
	return this;
}

function sizeList()
{
	this.length=4;
	this[0] = new Array(10);
	this[0][0]=new Option("30\" - Chest",".7");
	this[0][1]=new Option("32\"",".75");
	this[0][2]=new Option("34\"",".8");
	this[0][3]=new Option("36\"",".85");
	this[0][4]=new Option("38\"",".9");
	this[0][5]=new Option("40\"",".95");
	this[0][6]=new Option("42\"","1.0");
	this[0][7]=new Option("44\"","1.05");
	this[0][8]=new Option("46\"","1.1");
	this[0][9]=new Option("48\"","1.15");
	this[1] = new Array(10);
	this[1][0]=new Option("33\" - Hip",".8");
	this[1][1]=new Option("35\"",".85");
	this[1][2]=new Option("36\"",".9");
	this[1][3]=new Option("38\"",".95");
	this[1][4]=new Option("40\"","1.0");
	this[1][5]=new Option("41\"","1.05");
	this[1][6]=new Option("43\"","1.1");
	this[1][7]=new Option("45\"","1.15");
	this[1][8]=new Option("47\"","1.2");
	this[1][9]=new Option("49\"","1.25");
	this[2] = new Array(3);
	this[2][0]=new Option("Small","0");
	this[2][1]=new Option("Medium","1");
	this[2][2]=new Option("Large","2");
	this[3] = new Array(3);
	this[3][0]=new Option("Small","0");
	this[3][1]=new Option("Medium","1");
	this[3][2]=new Option("Large","2");
	return this;
}

typeOp = new typeList();
subTypeOp = new subTypeList();
sizeOp = new sizeList();

function addsub(ptype,subtype,loc)
{
	var i = ptype.selectedIndex;
	for(j=0;j<loc[i].length;j++)
	{
	try
		{
		subtype.add(loc[i][j],null);
		}
	  	catch(ex)
		{
		subtype.add(loc[i][j]);
		}
	}
}

function delsub(subtype)
{
	var len = subtype.length;
	for(i=0;i<len;i++)
	{
		subtype.remove(0);
	}
}

function type_onchange(ptype,subtype)
{
	delsub(subtype);
	addsub(ptype,subtype,subTypeOp);
	delsub(document.f1.size1)
  addsub(ptype, document.f1.size1, sizeOp);
  document.f1.stmenu.selectedIndex=0
	if(document.f1.ptype.value=="b3")
	{
	  document.f1.length.disabled  = true;
		document.f1.fit.disabled  = true;
		document.f1.human.disabled  = true;
    subtype.selectedIndex=1;
	}
	else if(document.f1.ptype.value=="b4")
	{
	  document.f1.length.disabled  = true;
		document.f1.fit.disabled  = true;
		document.f1.human.disabled  = true
		subtype.selectedIndex=0;
	}
	else
	{
	  document.f1.length.disabled  = false;
		document.f1.human.disabled  = false;
		document.f1.fit.disabled  = false;
		subtype.selectedIndex=0;
		document.f1.fit.selectedIndex=1;
    document.f1.human.selectedIndex=0;
		document.f1.size1.selectedIndex=2;
	}
}

function calcprice(yprice, uprice) {
	var skein = document.f2.skein.value;
	var yarn = document.f2.c250.value;
	var skeinprice = skein*uprice;
	yprice = yprice*((100-curcloseout)*.01);
	var yarnprice = yarn*yprice.toFixed(2);
	if(skein<100 && skein > 0){
		skeinprice += 2;
	}
	if (yarn<100 && yarn > 0) {
		yarnprice += 2;
	}
	var price = skeinprice+yarnprice;
	document.f2.submit.value = 'Add to Cart > $'+price.toFixed(2)+' ';
}


function calculateYarn() {
	document.f1.order.value=document.f1.ptype.selectedIndex+'|'+document.f1.subtype.selectedIndex+'|'+document.f1.size1.selectedIndex+'|'+document.f1.length.selectedIndex+'|'+document.f1.stmenu.selectedIndex+'|'+document.f1.fit.selectedIndex+'|'+document.f1.human.selectedIndex;
	document.f1.submit();
 }
window.onload = function() {type_onchange(document.f1.ptype, document.f1.subtype);if(typeof reorder=='function'){reorder();}}
