var fabricDivSize;
var version;
var dheight;
var shpelements;
var cartDivHeight;
var testArray;
var testArray2;
var shipping=0;
var shiptype="";
var shiplink="";
var qty=0;
var cemail="";
		var lname="";
		var fname="";
		var address="";
		var city="";
		var prov="";
		var pcode="";
		var night_phone_a="";
		var night_phone_b="";
		var night_phone_c="";

var subtotal=0;
var shipping=0;
var gTotal=0;
var shipsubtotal=0;

var globalIndex=1*(readCookie("arrayindex"));
//alert(globalIndex);
if(globalIndex==null)
globalIndex=0;



Xoffset=350;    // modify these values to ...
Yoffset=400;    // change the popup position.

var old,skn,iex=(document.all),yyy=-1000,xxx=-1000;

var ns4=document.layers;
var ns6=document.getElementById&&!document.all;
var ie4=document.all;
var gdiv='';



function popup(divname,maindivName){

gdiv=divname;
document.getElementById(divname).style.visibility="visible";
if(version >= 5.5)
document.getElementById(divname).style.filter="Alpha(Opacity='95')";
else
document.getElementById(divname).style.opacity=95/100;
document.getElementById(maindivName).onmousemove=get_mouse;

}

function get_mouse(e){
var posx = 0;
var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
/*alert(posx);*/
if(gdiv!='')
{
	
document.getElementById(gdiv).style.left=(posx-40)+"px";
document.getElementById(gdiv).style.top=(posy-300)+"px";
}
}


function kill(divname){

document.getElementById(divname).style.visibility="hidden";

gdiv="";
}

function loadDiv(divname)
{
if(version >= 5.5)
document.getElementById(divname).style.filter="Alpha(Opacity='50')";
else
{
document.getElementById(divname).style.opacity=50/100;	
document.getElementById(divname).style.visibility="visible";
}

document.getElementById(divname).style.zIndex="100";
}

function setopenDiv(divname,divname2){
if(version >= 5.5)
document.getElementById(divname).style.filter="Alpha(Opacity='80')";
else
document.getElementById(divname).style.opacity=80/100;	
document.getElementById(divname).style.visibility="visible";

if(divname=="CartDiv")
{
document.getElementById(divname).style.zIndex="100";
document.getElementById(divname2).style.zIndex="120";
document.getElementById(divname2).style.height="500px";
document.getElementById("ShopCartList").style.height="400px";
document.getElementById("ConfirmDiv").style.visibility="visible";
}

setopeninnerDiv(divname2);
}


/*function openDiv(divname,divname2,dim){


	if(dim<80)
	{
	
		
			dim+=10;
			
				if(version >= 5.5)
				document.getElementById(divname).style.filter="Alpha(Opacity='"+dim+"')";
				else
				document.getElementById(divname).style.opacity=dim/100;
				
				window.setTimeout("openDiv('"+divname+"','"+divname2+"',"+dim+")",50);
			
	}
	else
	{
		alert(divname2);	
		setopeninnerDiv(divname2);
	}
				
}*/

function setopeninnerDiv(divname){
if(version >= 5.5)
document.getElementById(divname).style.filter="Alpha(Opacity='95')";
else
document.getElementById(divname).style.opacity=95/100;	
document.getElementById(divname).style.visibility="visible";	
//openinnerDiv(divname,10);
}


/*function openinnerDiv(divname,dim){


	if(dim<=100)
	{
	
		
			dim+=10;
			//alert(dim);
				if(version >= 5.5)
				document.getElementById(divname).style.filter="Alpha(Opacity='"+dim+"')";
				else
				document.getElementById(divname).style.opacity=dim/100;
				
				window.setTimeout("openinnerDiv('"+divname+"',"+dim+")",50);
	}
}*/

function closeDiv(divname,divname2)
{
document.getElementById(divname).style.visibility="hidden";

document.getElementById(divname2).style.visibility="hidden";

if(divname=="CartDiv")
{
	document.getElementById(divname).style.zIndex="1";
	document.getElementById(divname2).style.zIndex="2";
document.getElementById(divname2).style.height="10px";
document.getElementById("ShopCartList").style.height="10px";
document.getElementById("ConfirmDiv").style.visibility="hidden";

}
}

function closeDiv2(divname)
{
document.getElementById(divname).style.visibility="hidden";
}

function fireAction(formName,actionURL)
{
var JavaCommand1="document."+formName+".action='http://www.esewingfabric.com/FText.php?Director="+actionURL+"';";
//alert( JavaCommand1);
var JavaCommand3="document."+formName+".submit();";
eval(JavaCommand1);
eval(JavaCommand3);
}

function goTo(actionURL)
{
var JavaCommand1="window.location='http://www.esewingfabric.com/FText.php?Director="+actionURL+"';";
eval(JavaCommand1);

}

function goTo2(actionURL)
{
var JavaCommand1="window.location='"+actionURL+"';";
eval(JavaCommand1);

}


function fireAction2(formName1,formName2,detail1,detail2,actionURL,divName)
{
	var JavaCommand4="document."+formName1+"."+detail1+".value;";
	if (eval(JavaCommand4)!='')
	{
	var JavaCommand1="document."+formName1+".action='FText.php?Director="+actionURL+"';";
	var JavaCommand3="document."+formName1+".submit();";
	eval(JavaCommand1);
	eval(JavaCommand3);
	deflateDiv(divName,formName2,detail2);
	var JavaCommand2="document."+formName2+"."+detail2+".options[0].text=document."+formName1+"."+detail1+".value;";
	eval(JavaCommand2)
	var JavaCommand2="document."+formName2+"."+detail2+".options[0].value=document."+formName1+"."+detail1+".value;";
	eval(JavaCommand2)
	}
	else
	alert('Nothing was entered.');
}

function validateSearch(formName,actionURL)
{
if(document.frmSearch.wsearch.value=="")
alert("You entered nothing to search.");
else
fireAction(formName,actionURL);
}

function validateJoin(formName,actionURL)
{
var emailGood='false';
if(document.frmJoin.cjoin.value=="")
	{
		alert("Please enter a valid email address.");
		emailGood="empty";
	}
else
{
	
	for(i=0;i<=document.frmJoin.cjoin.value.length && emailGood=='false';i++)
	{
		if(document.frmJoin.cjoin.value.charAt(i)=='@')
		{
			for(j=0;j<=document.frmJoin.cjoin.value.length && emailGood=='false';j++)
			{
				if(document.frmJoin.cjoin.value.charAt(j)=='.')
				{
				emailGood='true';
				break;
				}
			}
		}
	
	}
}
	if (emailGood=='false')
	{
		alert("Email does not seem right");
	}
	else if(emailGood=="true")
	{
		fireAction(formName,actionURL);
	}
}

function validateLogin(formName,actionURL)
{
if(document.frmUserLogin.email.value=="")
alert("Please enter you email adddress.");
if(document.frmUserLogin.password.value=="")
alert("Please enter you password.");
else
fireAction(formName,actionURL);
}

function validateFP(formName,actionURL)
{
if(document.frmFP.email.value=="")
alert("Please enter you email adddress.");
else
fireAction(formName,actionURL);
}


function validateCart(frmname,divname,sindex,items,evalindex)
{
if(document.forms[frmname].quant.value=="")
alert("Please enter how many yards you want to buy.");
else
setupdateCookieArray(divname,sindex,items,evalindex);
}

function scanForm(formName,actionURL)
{
answer = checkCustomerForm();
if (answer!=false)
{
var JavaCommand1="document."+formName+".action='FText.php?Director="+actionURL+"';"
var JavaCommand3="document."+formName+".submit();";
eval(JavaCommand1);
eval(JavaCommand3);
}
}


function checkCustomerForm()
{
//Check for Blank Text Boxes
	for(i=0;i<=25;i++)
	{
		//alert(i);
		if(!(i==3) && !(i==5) && !(i==10) && !(i==12) && !(i==20) && !(i==21) && !(i==22))
		{
		if(document.frmAddCustomer.elements[i].value=='')
		{
			document.frmAddCustomer.elements[i].focus();
			alert('Please fill in the hightlighted Box.');
			return false;
			break;
		}
		}
	}

/*var TextArray=[9];
	for(i=0;i<TextArray.length;i++)
	{
		var textlength = 10;
		if (document.frmAddCustomer.elements[TextArray[i]].value.length<textlength)
		{
			document.frmAddCustomer.elements[TextArray[i]].focus();
			alert("HightLighted Box has to have atleast "+textlength+" digits.");
			return false;
			break;
		}
	}*/

if(!(document.frmAddCustomer.password.value == document.frmAddCustomer.cpassword.value))
{
alert('Passwords do not match.');
return false;
}
//Check for certain textboxes that must be numerical
var TextArray=[17,18,19];
var ValidChars = '0123456789.';
var Char;
	for(i=0;i<TextArray.length;i++)
	{

	for(j=0;(j<=document.frmAddCustomer.elements[TextArray[i]].value.length);j++)
	{
	  Char = document.frmAddCustomer.elements[TextArray[i]].value.charAt(j);
	  if (ValidChars.indexOf(Char) == -1)
		 {
			 document.frmAddCustomer.elements[TextArray[i]].focus();
			 alert('HightLighted Box must me a number.');
			 return false;
			 break;
		 }
	 }
	}

//check for postal code is in right format (L8L8L8)
/*if(document.frmAddCustomer.postal.value.length==6)
{
	for(i=0;i<=5;i++)
	{
		if ((i % 2)==1)//if postion is odd..is a number
		{
			var ichar=document.frmAddCustomer.postal.value.charCodeAt(i);
			if((ichar<48) || (ichar>57))
			{
				document.frmAddCustomer.postal.focus();
				alert('Postal Code does not seem correct');
				return false;
				break;
			}

		}
		else //position is even
		{
			var ichar=document.frmAddCustomer.postal.value.charCodeAt(i);
			if((ichar<65) || (ichar>122))
			{
			document.frmAddCustomer.postal.focus();
			alert('Postal Code does not seem correct');
			return false;
			break;
			}

		}

	}
}
else
{
	alert('Postal code is too short');
	return false;
}*/


//Checks for the @ and . in an email address
var emailGood='false';
for(i=0;i<=document.frmAddCustomer.email.value.length && emailGood=='false';i++)
{
	if(document.frmAddCustomer.email.value.charAt(i)=='@')
	{
		for(j=0;j<=document.frmAddCustomer.email.value.length && emailGood=='false';j++)
		{
			if(document.frmAddCustomer.email.value.charAt(j)=='.')
			{
			emailGood='true';
			break;
			}
		}
	}

}
if (emailGood=='false')
{
	document.frmAddCustomer.email.focus();
	alert("Email does not seem right");
	return false;
}
 

}

function setupProv(optionName,label,dropBox)
{
document.getElementById(dropBox).innerHTML="";
sindex = window.document.frmAddCustomer.elements[optionName].options.selectedIndex;
myVal = window.document.frmAddCustomer.elements[optionName].options[sindex].value;
if(myVal=="US")
{
strState="";
document.getElementById(label).innerHTML="State:";
strState+="<select id='istate' name='istate'>";
strState+="<option value='AL'>Alabama</option>";
strState+="<option value='AK'>Alaska</option>";
strState+="<option value='AS'>American Samoa</option>";
strState+="<option value='AZ'>Arizona</option>";
strState+="<option value='AR'>Arkansas</option>";
strState+="<option value='CA'>California</option>";
strState+="<option value='CO'>Colorado</option>";
strState+="<option value='CT'>Connecticut</option>";
strState+="<option value='DE'>Delaware</option>";
strState+="<option value='DC'>District of Columbia</option>";
strState+="<option value='FL'>Florida</option>";
strState+="<option value='GA'>Georgia</option>";
strState+="<option value='GU'>Guam</option>";
strState+="<option value='HI'>Hawaii</option>";
strState+="<option value='ID'>Idaho</option>";
strState+="<option value='IL'>Illinois</option>";
strState+="<option value='IN'>Indiana</option>";
strState+="<option value='IA'>Iowa</option>";
strState+="<option value='KS'>Kansas</option>";
strState+="<option value='KY'>Kentucky</option>";
strState+="<option value='LA'>Louisiana</option>";
strState+="<option value='ME'>Maine</option>";
strState+="<option value='MD'>Maryland</option>";
strState+="<option value='MH'>Marshall Islands</option>";
strState+="<option value='MA'>Massachusetts</option>";
strState+="<option value='MI'>Michigan</option>";
strState+="<option value='MN'>Minnesota</option>";
strState+="<option value='MS'>Mississipi</option>";
strState+="<option value='MO'>Missouri</option>";
strState+="<option value='MT'>Montana</option>";
strState+="<option value='NE'>Nebraska</option>";
strState+="<option value='NV'>Nevada</option>";
strState+="<option value='NH'>New Hampshire</option>";
strState+="<option value='NJ'>New Jersey</option>";
strState+="<option value='NM'>New Mexico</option>";
strState+="<option value='NY'>New York</option>";
strState+="<option value='NC'>North Carolina</option>";
strState+="<option value='ND'>North Dakota</option>";
strState+="<option value='MP'>Northern Marianas</option>";
strState+="<option value='OH'>Ohio</option>";
strState+="<option value='OK'>Oklahoma</option>";
strState+="<option value='OR'>Oregon</option>";
strState+="<option value='PW'>Palau</option>";
strState+="<option value='PA'>Pennsylvania</option>";
strState+="<option value='PR'>Puerto Rico</option>";
strState+="<option value='RI'>Rhode Island</option>";
strState+="<option value='SC'>South Carolina</option>";
strState+="<option value='SD'>South Dakota</option>";
strState+="<option value='TN'>Tennessee</option>";
strState+="<option value='TX'>Texas</option>";
strState+="<option value='UT'>Utah</option>";
strState+="<option value='VT'>Vermont</option>";
strState+="<option value='VA'>Virginia</option>";
strState+="<option value='VI'>Virgin Islands</option>";
strState+="<option value='WA'>Washington</option>";
strState+="<option value='WV'>West Virginia</option>";
strState+="<option value='WI'>Winconsin</option>";
strState+="<option value='WY'>Wyoming</option>";
strState+="</select>";
document.getElementById(dropBox).innerHTML=strState;
}
else
{
strState="";
document.getElementById(label).innerHTML="Province:";
strState+="<select id='istate' name='istate'>";
strState+="<option value='AB'>Alberta</option>";
strState+="<option value='BC'>British Columbia</option>";
strState+="<option value='MB'>Manitoba</option>";
strState+="<option value='NB'>New Brunswick</option>";
strState+="<option value='NL'>Newfoundland and Labrador</option>";
strState+="<option value='NT'>Northwest Territories</option>";
strState+="<option value='NS'>Mova Scotia</option>";
strState+="<option value='NU'>Nunavut</option>";
strState+="<option value='ON'>Ontario</option>";
strState+="<option value='PE'>Prince Edward Island</option>";
strState+="<option value='QC'>Quebec</option>";
strState+="<option value='SK'>Saskatchewan</option>";
strState+="<option value='YT'>Yukon</option>";
strState+="</select>";
document.getElementById(dropBox).innerHTML=strState;
}
}

function setupProv2(optionName,label,dropBox)
{
document.getElementById(dropBox).innerHTML="";
sindex = window.document.frmAddCustomer.elements[optionName].options.selectedIndex;
myVal = window.document.frmAddCustomer.elements[optionName].options[sindex].value;
if(myVal=="US")
{
strState="";
document.getElementById(label).innerHTML="State:";
strState+="<select id='sistate' name='sistate'>";
strState+="<option value='AL'>Alabama</option>";
strState+="<option value='AK'>Alaska</option>";
strState+="<option value='AS'>American Samoa</option>";
strState+="<option value='AZ'>Arizona</option>";
strState+="<option value='AR'>Arkansas</option>";
strState+="<option value='CA'>California</option>";
strState+="<option value='CO'>Colorado</option>";
strState+="<option value='CT'>Connecticut</option>";
strState+="<option value='DE'>Delaware</option>";
strState+="<option value='DC'>District of Columbia</option>";
strState+="<option value='FL'>Florida</option>";
strState+="<option value='GA'>Georgia</option>";
strState+="<option value='GU'>Guam</option>";
strState+="<option value='HI'>Hawaii</option>";
strState+="<option value='ID'>Idaho</option>";
strState+="<option value='IL'>Illinois</option>";
strState+="<option value='IN'>Indiana</option>";
strState+="<option value='IA'>Iowa</option>";
strState+="<option value='KS'>Kansas</option>";
strState+="<option value='KY'>Kentucky</option>";
strState+="<option value='LA'>Louisiana</option>";
strState+="<option value='ME'>Maine</option>";
strState+="<option value='MD'>Maryland</option>";
strState+="<option value='MH'>Marshall Islands</option>";
strState+="<option value='MA'>Massachusetts</option>";
strState+="<option value='MI'>Michigan</option>";
strState+="<option value='MN'>Minnesota</option>";
strState+="<option value='MS'>Mississipi</option>";
strState+="<option value='MO'>Missouri</option>";
strState+="<option value='MT'>Montana</option>";
strState+="<option value='NE'>Nebraska</option>";
strState+="<option value='NV'>Nevada</option>";
strState+="<option value='NH'>New Hampshire</option>";
strState+="<option value='NJ'>New Jersey</option>";
strState+="<option value='NM'>New Mexico</option>";
strState+="<option value='NY'>New York</option>";
strState+="<option value='NC'>North Carolina</option>";
strState+="<option value='ND'>North Dakota</option>";
strState+="<option value='MP'>Northern Marianas</option>";
strState+="<option value='OH'>Ohio</option>";
strState+="<option value='OK'>Oklahoma</option>";
strState+="<option value='OR'>Oregon</option>";
strState+="<option value='PW'>Palau</option>";
strState+="<option value='PA'>Pennsylvania</option>";
strState+="<option value='PR'>Puerto Rico</option>";
strState+="<option value='RI'>Rhode Island</option>";
strState+="<option value='SC'>South Carolina</option>";
strState+="<option value='SD'>South Dakota</option>";
strState+="<option value='TN'>Tennessee</option>";
strState+="<option value='TX'>Texas</option>";
strState+="<option value='UT'>Utah</option>";
strState+="<option value='VT'>Vermont</option>";
strState+="<option value='VA'>Virginia</option>";
strState+="<option value='VI'>Virgin Islands</option>";
strState+="<option value='WA'>Washington</option>";
strState+="<option value='WV'>West Virginia</option>";
strState+="<option value='WI'>Winconsin</option>";
strState+="<option value='WY'>Wyoming</option>";
strState+="</select>";
document.getElementById(dropBox).innerHTML=strState;
}
else
{
strState="";
document.getElementById(label).innerHTML="Province:";
strState+="<select id='sistate' name='sistate'>";
strState+="<option value='AB'>Alberta</option>";
strState+="<option value='BC'>British Columbia</option>";
strState+="<option value='MB'>Manitoba</option>";
strState+="<option value='NB'>New Brunswick</option>";
strState+="<option value='NL'>Newfoundland and Labrador</option>";
strState+="<option value='NT'>Northwest Territories</option>";
strState+="<option value='NS'>Mova Scotia</option>";
strState+="<option value='NU'>Nunavut</option>";
strState+="<option value='ON'>Ontario</option>";
strState+="<option value='PE'>Prince Edward Island</option>";
strState+="<option value='QC'>Quebec</option>";
strState+="<option value='SK'>Saskatchewan</option>";
strState+="<option value='YT'>Yukon</option>";
strState+="</select>";
document.getElementById(dropBox).innerHTML=strState;
}
}

function cloneBill(label,dropBox)
{
if(document.getElementById("checker").checked==1)
	{
	document.getElementById("saddress").value=document.frmAddCustomer.address.value;
	document.getElementById("saddress2").value=document.frmAddCustomer.address2.value;
	document.getElementById("sicountry").value=document.frmAddCustomer.icountry.value;
	document.getElementById("sistate").value=document.frmAddCustomer.istate.value;
	document.getElementById("scity").value=document.frmAddCustomer.city.value;
	document.getElementById("spostal").value=document.frmAddCustomer.postal.value;
	//alert(document.frmAddCustomer.icountry.value);
	if(document.frmAddCustomer.icountry.value=='US')
		{
		
			document.getElementById(dropBox).innerHTML="";
			var strState="";
			document.getElementById(label).innerHTML="State:";
			strState+="<select id='sistate' name='sistate'>";
			strState+="<option value='"+document.frmAddCustomer.istate.value+"'>"+document.frmAddCustomer.istate.value+"</option>";
			strState+="<option value='AL'>Alabama</option>";
			strState+="<option value='AK'>Alaska</option>";
			strState+="<option value='AS'>American Samoa</option>";
			strState+="<option value='AZ'>Arizona</option>";
			strState+="<option value='AR'>Arkansas</option>";
			strState+="<option value='CA'>California</option>";
			strState+="<option value='CO'>Colorado</option>";
			strState+="<option value='CT'>Connecticut</option>";
			strState+="<option value='DE'>Delaware</option>";
			strState+="<option value='DC'>District of Columbia</option>";
			strState+="<option value='FL'>Florida</option>";
			strState+="<option value='GA'>Georgia</option>";
			strState+="<option value='GU'>Guam</option>";
			strState+="<option value='HI'>Hawaii</option>";
			strState+="<option value='ID'>Idaho</option>";
			strState+="<option value='IL'>Illinois</option>";
			strState+="<option value='IN'>Indiana</option>";
			strState+="<option value='IA'>Iowa</option>";
			strState+="<option value='KS'>Kansas</option>";
			strState+="<option value='KY'>Kentucky</option>";
			strState+="<option value='LA'>Louisiana</option>";
			strState+="<option value='ME'>Maine</option>";
			strState+="<option value='MD'>Maryland</option>";
			strState+="<option value='MH'>Marshall Islands</option>";
			strState+="<option value='MA'>Massachusetts</option>";
			strState+="<option value='MI'>Michigan</option>";
			strState+="<option value='MN'>Minnesota</option>";
			strState+="<option value='MS'>Mississipi</option>";
			strState+="<option value='MO'>Missouri</option>";
			strState+="<option value='MT'>Montana</option>";
			strState+="<option value='NE'>Nebraska</option>";
			strState+="<option value='NV'>Nevada</option>";
			strState+="<option value='NH'>New Hampshire</option>";
			strState+="<option value='NJ'>New Jersey</option>";
			strState+="<option value='NM'>New Mexico</option>";
			strState+="<option value='NY'>New York</option>";
			strState+="<option value='NC'>North Carolina</option>";
			strState+="<option value='ND'>North Dakota</option>";
			strState+="<option value='MP'>Northern Marianas</option>";
			strState+="<option value='OH'>Ohio</option>";
			strState+="<option value='OK'>Oklahoma</option>";
			strState+="<option value='OR'>Oregon</option>";
			strState+="<option value='PW'>Palau</option>";
			strState+="<option value='PA'>Pennsylvania</option>";
			strState+="<option value='PR'>Puerto Rico</option>";
			strState+="<option value='RI'>Rhode Island</option>";
			strState+="<option value='SC'>South Carolina</option>";
			strState+="<option value='SD'>South Dakota</option>";
			strState+="<option value='TN'>Tennessee</option>";
			strState+="<option value='TX'>Texas</option>";
			strState+="<option value='UT'>Utah</option>";
			strState+="<option value='VT'>Vermont</option>";
			strState+="<option value='VA'>Virginia</option>";
			strState+="<option value='VI'>Virgin Islands</option>";
			strState+="<option value='WA'>Washington</option>";
			strState+="<option value='WV'>West Virginia</option>";
			strState+="<option value='WI'>Winconsin</option>";
			strState+="<option value='WY'>Wyoming</option>";
			strState+="</select>";
			document.getElementById(dropBox).innerHTML=strState;
		}
		else
		{
			document.getElementById(dropBox).innerHTML="";
			strState="";
			document.getElementById(label).innerHTML="Province:";
			strState+="<select id='sistate' name='sistate'>";
			strState+="<option value='"+document.frmAddCustomer.istate.value+"'>"+document.frmAddCustomer.istate.value+"</option>";
			strState+="<option value='AB'>Alberta</option>";
			strState+="<option value='BC'>British Columbia</option>";
			strState+="<option value='MB'>Manitoba</option>";
			strState+="<option value='NB'>New Brunswick</option>";
			strState+="<option value='NL'>Newfoundland and Labrador</option>";
			strState+="<option value='NT'>Northwest Territories</option>";
			strState+="<option value='NS'>Mova Scotia</option>";
			strState+="<option value='NU'>Nunavut</option>";
			strState+="<option value='ON'>Ontario</option>";
			strState+="<option value='PE'>Prince Edward Island</option>";
			strState+="<option value='QC'>Quebec</option>";
			strState+="<option value='SK'>Saskatchewan</option>";
			strState+="<option value='YT'>Yukon</option>";
			strState+="</select>";
			document.getElementById(dropBox).innerHTML=strState;
		}
	
	}
	else
	{
	document.getElementById("saddress").value="";
	document.getElementById("saddress2").value="";
	//document.getElementById("sicountry").value="";
	//document.getElementById("sistate").value="";
	document.getElementById("scity").value="";
	document.getElementById("spostal").value="";
	}
}




function scanFabricForm(formName,actionURL)
{
answer = checkFabricForm();
if (answer!=false)
{
var JavaCommand1="document."+formName+".action='FText.php?Director="+actionURL+"';"
var JavaCommand3="document."+formName+".submit();";
eval(JavaCommand1);
eval(JavaCommand3);
}
}


function checkFabricForm()
{
//Check for Blank Text Boxes
	/*for(i=0;i<=12;i++)
	{

		if(document.frmAddFabric.elements[i].value=='')
		{
			document.frmAddFabric.elements[i].focus();
			alert('Please fill in the hightlighted Box.');
			return false;
			break;
		}
	}*/
var TextArray=[0,6,7,9,10,11,17];
for(i=0;i<TextArray.length;i++)
	{

	for(j=0;(j<=document.frmAddFabric.elements[TextArray[i]].value.length);j++)
	{
	 
	  if (document.frmAddFabric.elements[TextArray[i]].value == "")
		 {
			document.frmAddFabric.elements[TextArray[i]].focus();
			alert('Please fill in the hightlighted Box.');
			return false;
			break;
		 }
	 }
	}


//Check for certain textboxes that must be numerical
var TextArray=[6,7,9,10,17,19];
var ValidChars = '0123456789.';
var Char;
	for(i=0;i<TextArray.length;i++)
	{

	for(j=0;(j<=document.frmAddFabric.elements[TextArray[i]].value.length);j++)
	{
	  Char = document.frmAddFabric.elements[TextArray[i]].value.charAt(j);
	  if (ValidChars.indexOf(Char) == -1)
		 {
			 document.frmAddFabric.elements[TextArray[i]].focus();
			 alert('HightLighted Box must me a number.');
			 return false;
			 break;
		 }
	 }
	}

}

function expandDiv(divName,frmName,textbox)
{
document.getElementById(divName).style.height="150px";
document.getElementById(divName).style.visibility="visible";
var JavaCommand2="document."+frmName+"."+textbox+".style.visibility='hidden';";
eval(JavaCommand2);

}

function deflateDiv(divName,frmName,textbox)
{
document.getElementById(divName).style.height="0px";
document.getElementById(divName).style.visibility="hidden";
var JavaCommand2="document."+frmName+"."+textbox+".style.visibility='visible';";
eval(JavaCommand2)
}

function deflate(divname,divHeader,height,headersize)
		{
		var dheight=document.getElementById(divname).offsetHeight-2;
			
			if(dheight<0)
			{
			dheight=40;	
			}
			
			if(dheight > 20)
			{
				dheight=dheight-20;
				//alert("deflate:"+dheight);
				document.getElementById(divname).style.height=dheight+"px";		
				window.setTimeout("deflate('"+divname+"','"+divHeader+"',"+height+","+headersize+")",15);	
			}
			else
				//alert("deflate:"+dheight);
				createCookie(divname,"close",1)	
				document.getElementById(divHeader).innerHTML="<div class='menuHeader' id='"+divHeader+"'>"+divHeader+"<div style='display:block;position:relative;background-image:url(\"http://www.esewingfabric.com/pics/web/menuArrowDown.gif\");height:10px;width:10px;margin-left:"+headersize+"px;margin-top:-14px;' onclick='inflate(\""+divname+"\",\""+divHeader+"\","+height+","+headersize+")'></div></div>";
				
		}
		
function inflate(divname,divHeader,height,headersize)
		{
		var dheight=document.getElementById(divname).offsetHeight-2;
			if(dheight < (height-2))
			{
				dheight=dheight+20;
				document.getElementById(divname).style.height=dheight+"px";		
				window.setTimeout("inflate('"+divname+"','"+divHeader+"',"+height+","+headersize+")",15);
			}
			else
				eraseCookie(divname);
				document.getElementById(divHeader).innerHTML="<div class='menuHeader'>"+divHeader+"<div style='display:block;position:relative;background-image:url(\"http://www.esewingfabric.com/pics/web/menuArrowUp.gif\");height:10px;width:10px;margin-left:"+headersize+"px;margin-top:-14px;' onclick='deflate(\""+divname+"\",\""+divHeader+"\","+height+","+headersize+")'></div></div>";
		}
		
function deflateDiv(divName,frmName,textbox)
{
document.getElementById(divName).style.height="0px";
document.getElementById(divName).style.visibility="hidden";
var JavaCommand2="document."+frmName+"."+textbox+".style.visibility='visible';";
eval(JavaCommand2)
}

function deflateF(divname,divHeader,headersize)
		{
		var dheight=document.getElementById(divname).offsetHeight-2;
			
			if(dheight<0)
			{
			dheight=40;	
			}
			
			if(dheight > 20)
			{
				dheight=dheight-20;
				document.getElementById(divname).style.height=dheight+"px";		
				window.setTimeout("deflateF('"+divname+"','"+divHeader+"','"+headersize+"')",15);
				
			}
			else
				createCookie(divname,"close",1)	
				document.getElementById(divHeader).innerHTML="<div class='menuHeader' id='"+divHeader+"'>"+divHeader+"<div style='display:block;position:relative;background-image:url(\"http://www.esewingfabric.com/pics/web/menuArrowDown.gif\");height:17px;width:23px;margin-left:"+headersize+"px;margin-top:-18px;' onclick='inflateF(\""+divname+"\",\""+divHeader+"\",\""+headersize+"\")'></div></div>";
		}
		
function inflateF(divname,divHeader,headersize)
		{
		var dheight=document.getElementById(divname).offsetHeight-2;
		if(dheight < (fabricDivSize-2) )
			{
				dheight=dheight+20;
				document.getElementById(divname).style.height=dheight+"px";
				window.setTimeout("inflateF('"+divname+"','"+divHeader+"','"+headersize+"')",15);
			}
			else
				eraseCookie(divname);
				document.getElementById(divHeader).innerHTML="<div class='menuHeader'>"+divHeader+"<div style='display:block;position:relative;background-image:url(\"http://www.esewingfabric.com/pics/web/menuArrowUp.gif\");height:17px;width:23px;margin-left:"+headersize+"px;margin-top:-18px;' onclick='deflateF(\""+divname+"\",\""+divHeader+"\",\""+headersize+"\")'></div></div>";
		}
							
function deflateFabric(divname,divHeader,height,headersize,divtext)
		{
		var dheight=document.getElementById(divname).offsetHeight-2;
			
			
			
			if(dheight > 20)
			{
				//alert("deflate:"+dheight);
				dheight=dheight-20;
				fabricDivSize=fabricDivSize-20;
				document.getElementById(divname).style.height=dheight+"px";		
				document.getElementById("FabricDiv").style.height=fabricDivSize+"px";
				window.setTimeout("deflateFabric('"+divname+"','"+divHeader+"',"+height+","+headersize+",'"+divtext+"')",15);
				
			}
			else
				//alert("deflate out:"+dheight);
				eraseCookie(divname);
				document.getElementById(divHeader).innerHTML="<a href='http://www.esewingfabric.com/"+divtext+"-Fabric.html'>"+divtext+" Fabric</a><div style='display:block;position:relative;height:17px;width:23px;margin-left:175px;margin-top:-18px;cursor:pointer;' onclick='inflateFabric(\""+divname+"\",\""+divHeader+"\","+height+","+headersize+",\""+divtext+"\")'>+</div></div>";
				
		}
		
function setDivheight(divname,divHeader,height,headersize)
{
	 dheight=document.getElementById(divname).offsetHeight-2;
		
		if (dheight<0)
		{
		dheight=18;
		}
		deflate(divname,divHeader,height,headersize);
		
}		


function Fheight(divname,divHeader,height,headersize,divtext)
{
	 dheight=document.getElementById(divname).offsetHeight-2;
		
		if (dheight<0)
		{
		dheight=18;
		}
	
		inflateSFabric(divname,divHeader,height,headersize,divtext);
			
}
		
function inflateSFabric(divname,divHeader,height,headersize,divtext)
		{
		//alert("dheight:"+dheight+"\ninflate:"+height+"\n Divname:"+divname);
		if(dheight < (height-2))
			{
				dheight=dheight+20;
			
				fabricDivSize=fabricDivSize+20;
				document.getElementById("FabricDiv").style.height=fabricDivSize+"px";
				document.getElementById(divname).style.height=dheight+"px";		
				window.setTimeout("inflateSFabric(\""+divname+"\",\""+divHeader+"\","+height+","+headersize+",\""+divtext+"\")",15);
			}
			else
				
				createCookie(divname,"close",1)
				document.getElementById(divHeader).innerHTML="<a href='http://www.esewingfabric.com/"+divtext+"-Fabric.html'>"+divtext+" Fabric</a><div style='display:block;position:relative;height:17px;width:23px;margin-left:175px;margin-top:-18px;cursor:pointer;' onclick='deflateFabric(\""+divname+"\",\""+divHeader+"\","+height+","+headersize+",\""+divtext+"\")'>-</div></div>";
																	
		}
		
function inflateFabric(divname,divHeader,height,headersize,divtext)
		{
		var dheight=document.getElementById(divname).offsetHeight-2;
		
		if(dheight < (height-2))
			{
				dheight=dheight+20;
				fabricDivSize=fabricDivSize+20;
				document.getElementById(divname).style.height=dheight+"px";		
				document.getElementById("FabricDiv").style.height=fabricDivSize+"px";
				window.setTimeout("inflateFabric('"+divname+"','"+divHeader+"',"+height+","+headersize+",'"+divtext+"')",15);
			}
			else
				createCookie(divname,"close",1)	
				document.getElementById(divHeader).innerHTML="<a href='http://www.esewingfabric.com/"+divtext+"-Fabric.html'>"+divtext+" Fabric</a><div style='display:block;position:relative;height:17px;width:23px;margin-left:175px;margin-top:-18px;cursor:pointer;' onclick='deflateFabric(\""+divname+"\",\""+divHeader+"\","+height+","+headersize+",\""+divtext+"\")'>-</div></div>";														
		}
	
function setSCF(divname,height,width,margin,top)
		{
			document.getElementById(divname).style.visibility="visible";
			//inflateSCF(divname,height,width,margin,top);
		}
function inflateSCF(divname,height,width,margin,top)
		{
		
		var scfheight = document.getElementById(divname).offsetHeight;
		var scfwidth = document.getElementById(divname).offsetWidth;

		
		if(scfheight < height)
			{
				scfheight=scfheight+20;
				scfwidth=scfwidth+40;
				margin=margin-19;
				top=top-5;
				document.getElementById(divname).style.height=scfheight+"px";		
				document.getElementById(divname).style.width=scfwidth+"px";		
				document.getElementById(divname).style.left=margin+"px";
				document.getElementById(divname).style.top=top+"px";
				
				window.setTimeout("inflateSCF('"+divname+"',"+height+","+width+","+margin+","+top+")",10);
			}
														
		}	

function unsetSCF(divname)
		{
			
				document.getElementById(divname).style.height="14px";		
				document.getElementById(divname).style.width="0px";		
				document.getElementById(divname).style.left="200px";
				document.getElementById(divname).style.top="300px";
			    document.getElementById(divname).style.visibility="hidden";	
				if(version >= 5.5)
				document.getElementById(divname).style.filter="Alpha(Opacity='100')";
				else
				document.getElementById(divname).style.opacity=100/100;
				
		}

function deflateSCF(divname,dim)
		{
		document.getElementById(divname).style.visibility="hidden";	
		
		//unsetSCF(divname);
		
		}	

function chkQty()
{
		
			qty=0;
			for(var x=0;x<(globalIndex+1);x++)
				{
				//alert(globalIndex);
					testArray = new getCookieArray("shopCart"+x);
					if(testArray.length)
					{
						qty=qty+eval(testArray[2]);
						
					}
				}
				
				 return qty.toFixed(2);
				
}


function fillShopCart()
{
			document.getElementById("ShopCartList").innerHTML='';
			var shpstr='';
			shpelements=0;
			subtotal=0;
			shipsubtotal=0;
			qty=0;
			for(var x=0;x<(globalIndex+1);x++)
				{
				//alert(globalIndex);
				testArray = new getCookieArray("shopCart"+x);
				if(testArray.length)
				{
				shpstr+="\n<div class='menuFabricElement' style='background-image:url(\"http://www.esewingfabric.com/pics/web/shopCartListBack.gif\");border:1px dashed #EEEEEE;height:88px;width:575px;color:black;margin-top:0px;padding-right:2px;'>\n";
				shpstr+="<form  method='POST' id='frmShopList"+x+"' name='frmShopList"+x+"'>\n";
				shpstr+="<div style='display:block;position:absolute;width:75px;height:15px;margin-left:500px;cursor:pointer;' onclick='delCookieArray(\""+x+"\",7)'>Remove X</div>\n";
				
				
				
				var ftype=testArray[3];
				
				var ftypeL=ftype.length;
				
				for(var j=0;(j<=ftypeL);j++)
						{
						   
						ftype=ftype.replace(/-/," ");  
						
						}
				
				var fcat=testArray[5];
				var fcatL=fcat.length;
						for(var z=0;(z<=fcatL);z++)
						{
						   
						fcat=fcat.replace(/ /,"-");  
						}
						
						
				shpstr+="<div class='menuElement' style='display:block;position:absolute;width:75px;height:75px;margin-top:5px;margin-left:10px;'><a href='http://www.esewingfabric.com/"+fcat+"-Fabric/"+testArray[6]+"-Fabric/"+testArray[3]+"-"+testArray[1]+".html'><img class='saleimg' src='http://www.esewingfabric.com/pics/fabric/thumbnail/"+testArray[7]+"' height='75' width='75'></a></div>\n";				
				
				shpstr+="<div style='text-align:right;display:block;position:absolute;width:200px;height:auto;margin-top:15px;margin-left:100px;font-size:10px;'><a href='http://www.esewingfabric.com/"+fcat+"-Fabric/"+testArray[6]+"-Fabric/"+testArray[3]+"-"+testArray[1]+".html'>\n";
				shpstr+=ftype+" "+testArray[4]+"</a></div>";
				
				shpstr+="<div style='display:block;position:absolute;width:50px;height:20px;margin-top:25px;margin-left:400px;padding-left:0px;'>$"+testArray[8]+"   X </div>\n";
				shpstr+="<div style='display:block;position:absolute;background-image:url(\"http://www.esewingfabric.com/pics/web/UpdateButton.gif\");width:75px;height:25px;margin-left:460px;margin-top:55px;cursor:pointer;' onclick='validateCart(\"frmShopList"+x+"\",\"ShopTimer"+x+"\",\""+x+"\",1,1)'></div>\n";
				shpstr+="<div style='display:block;position:absolute;width:25px;height:20px;margin-top:20px;margin-left:450px;padding-left:0px;'><input type='text' id='quant' name='quant' size='2' value='"+testArray[2]+"' style='position:absolute;margin-left:0px;'></input></div>\n";
				
				var price =testArray[8]*testArray[2];
				subtotal+=price;
				if(testArray[4]=="(SWATCH)")
				shipsubtotal+=price;
				shpstr+="<div style='display:block;position:absolute;width:100px;height:20px;margin-top:25px;margin-left:500px;padding-left:0px;'>  =  $"+price.toFixed(2)+"</div>\n";
				
				shpstr+="<div id='ShopTimer"+x+"' name='ShopTimer"+x+"' style='display:block;position:absolute;width:25px;height:25px;margin-left:525px;margin-top:20px;visibility:hidden;' onclick=''>\n";
				shpstr+= "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='25' height='25' id='timer' align='middle'>\n";
				shpstr+= "<param name='allowScriptAccess' value='sameDomain' />\n";
				shpstr+= "<param name='movie' value='http://www.esewingfabric.com/Flash/timer.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><param name='bgcolor' value='#ffffff' /><embed src='http://www.esewingfabric.com/Flash/timer.swf' quality='high' wmode='transparent' bgcolor='#ffffff' width='25' height='25' name='timer' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\n";
				shpstr+= "</object>\n";
				
				shpstr+= "</div>\n";
				shpstr+="</form>\n";
				
			

				shpstr+="</div>\n";
				
				//shpstr+="<div class='menuFabricElement' style='height:48px;width:148px;color:black;'></div>";
				//sss=(document.getElementById("ShopCartList").offsetHeight++2)+"px";
//				alert("sss:"+sss);
//				document.getElementById("ShopCartList").style.height=sss;
				shpelements+=1;
				}
			
			}
				//document.getElementById("innerCheckout").innerHTML="<input type='hidden' name='amount' value='"+subtotal.toFixed(2)+"'>";
				//document.getElementById("innerCheckout").innerHTML=subtotal.toFixed(2);
				if(shpstr=='')
				{
				document.getElementById("ShopCartList").innerHTML="<div class='menuFabricElement' style='width:148px;color:black;'>Cart is empty</div>";
				createCookie("arrayindex",0,1);
				globalIndex=0;
				document.getElementById("itemCountDiv").innerHTML=shpelements+" Item(s)";
				calSub();
				}
				else
				{
					cartDivHeight=(shpelements*90)+40;
					document.getElementById("ShopCartList").innerHTML=shpstr;
					document.getElementById("itemCountDiv").innerHTML=shpelements+" Item(s)";
				calSub();
				
				}

}


function calSub()
		{
		/*var swatch_subtotal=subtotal-shipsubtotal;	
		var extra=1.10;	
		if(swatch_subtotal==0)
		shipping=0.00;
		else if(swatch_subtotal>1 && swatch_subtotal < 9.99)
		shipping=8.14 * extra;
		else if(swatch_subtotal>10 && swatch_subtotal < 14.99)
		shipping=10.74* extra;
		else if(swatch_subtotal>15 && swatch_subtotal < 29.99)
		shipping=12.04* extra;
		else if(swatch_subtotal>30 && swatch_subtotal < 49.99)
		shipping=13.34* extra;
		else if(swatch_subtotal>50 && swatch_subtotal < 74.99)
		shipping=15.94* extra;
		else if(swatch_subtotal>75 && swatch_subtotal < 99.99)
		shipping=17.54* extra;
		else if(swatch_subtotal>100 && swatch_subtotal < 125.99)
		shipping=22.14* extra;
		else if(swatch_subtotal>126 && swatch_subtotal < 150.99)
		shipping=22.44* extra;
		else if(swatch_subtotal>151 && swatch_subtotal < 175.99)
		shipping=23.04* extra;
		else if(swatch_subtotal>176 && swatch_subtotal < 200.99)
		shipping=23.34* extra;
		else if(swatch_subtotal>201 && swatch_subtotal < 250.99)
		shipping=24.64* extra;
		else if(swatch_subtotal>251 && swatch_subtotal < 300.99)
		shipping=29.54* extra;
		else if(swatch_subtotal>301 && swatch_subtotal < 350.99)
		shipping=34.74* extra;
		else if(swatch_subtotal>351 && swatch_subtotal < 400.99)
		shipping=39.94* extra;
		else if(swatch_subtotal>401 && swatch_subtotal < 450.99)
		shipping=45.14* extra;
		else if(swatch_subtotal>451 && swatch_subtotal < 500.99)
		shipping=50.34* extra;
		else if(swatch_subtotal>501 && swatch_subtotal < 600.99)
		shipping=55.54* extra;
		else if(swatch_subtotal>601 && swatch_subtotal < 700.99)
		shipping=68.54* extra;
		else if(swatch_subtotal>701 && swatch_subtotal < 800.99)
		shipping=81.54* extra;
		else if(swatch_subtotal>801 && swatch_subtotal < 900.99)
		shipping=94.54* extra;
		else if(swatch_subtotal>901)
		shipping=107.54* extra;
		shipping=shipping.toFixed(2)*1;*/
		//var total=(subtotal.toFixed(2)*1)+(shipping*1);
		document.getElementById("subTotal").innerHTML="Subtotal:    $"+subtotal.toFixed(2);
		document.getElementById("shpname").innerHTML= "Shipping Choice:<br>"+shiptype;
		document.getElementById("shpprice").innerHTML="Shipping/Handling Cost: $"+shipping.toFixed(2);
		document.getElementById("Gtotal").innerHTML="Total: $"+gTotal.toFixed(2);
		}
		
		function calSub2()
		{
		var tempship=document.Shpform.shipRates.options[document.Shpform.shipRates.selectedIndex].value;
		
		var temp = new Array();
		temp = tempship.split('@');
		document.getElementById("shpname").innerHTML="Method: "+temp[0];
		document.getElementById("shpprice").innerHTML="Price: "+temp[1];

		
		}

function calPP()
		{
			if(cemail)
		{
			var item_index=1;
			//alert("called");
		checkout_html="";
		checkout_html+="<form action='https://www.paypal.com/row/cgi-bin/webscr' method='post'>\n";
		//checkout_html+="<input type='hidden' name='cmd' value='_ext-enter'>";
		//checkout_html+="<input type='hidden' name='redirect_cmd' value='_xclick'>";
		
		
		checkout_html+="<input type='hidden' name='cmd' value='_cart'>\n";
		checkout_html+="<input type='hidden' name='upload' value='1'>\n";
		
		checkout_html+="<input type='hidden' name='custom' value='"+cid+"'>\n";
		checkout_html+="<input type='hidden' name='email' value='"+cemail+"'>\n";
		checkout_html+="<input type='hidden' name='first_name' value='"+fname+"'>\n";
		checkout_html+="<input type='hidden' name='last_name' value='"+lname+"'>\n";
		checkout_html+="<input type='hidden' name='address1' value='"+address+"'>\n";
		checkout_html+="<input type='hidden' name='city' value='"+city+"'>\n";
		checkout_html+="<input type='hidden' name='state' value='"+prov+"'>\n";
		checkout_html+="<input type='hidden' name='zip' value='"+pcode+"'>\n";
		checkout_html+="<input type='hidden' name='country' value='"+country+"'>\n";
		
		checkout_html+="<input type='hidden' name='night_phone_a' value='"+night_phone_a+"'>\n";
		checkout_html+="<input type='hidden' name='night_phone_b' value='"+night_phone_b+"'>\n";
		checkout_html+="<input type='hidden' name='night_phone_c' value='"+night_phone_c+"'>\n";
		checkout_html+="<input type='hidden' name='shipping_1' value='"+(shipping*1)+"'>\n";
		checkout_html+="<input type='hidden' name='on0' value='shipMethod'>\n";
		checkout_html+="<input type='hidden' name='os0' value='"+shiptype+"'>\n";
		for(var x=0;x<(globalIndex+1);x++)
				{
				//alert(globalIndex);
				testArray2 = new getCookieArray("shopCart"+x);
				if(testArray2.length)
				{
				var ftype=testArray2[3];
				var ftypeL=ftype.length;
				
				for(var j=0;(j<=ftypeL);j++)
						{
						   
						ftype=ftype.replace(/-/,"  ");  
						
						}
				checkout_html+="<input type='hidden' name='item_name_"+item_index+"' value='"+ftype+" "+testArray2[4]+"'>\n";
				checkout_html+="<input type='hidden' name='item_number_"+item_index+"' value='"+testArray2[1]+"'>\n";
				
				//var price2 =testArray[8]*testArray[2];
				checkout_html+="<input type='hidden' name='amount_"+item_index+"' value='"+testArray2[8]+"'>\n";
				checkout_html+="<input type='hidden' name='quantity_"+item_index+"' value='"+testArray2[2]+"'>\n";
				item_index+=1;
				}
		
				}
			
		checkout_html+="<input type='hidden' name='business' value='netcube.solutions@gmail.com'>\n";
		
		checkout_html+="<input type='hidden' name='currency_code' value='USD'>\n";
		//checkout_html+="<input type='hidden' name='amount' value='"+subtotal.toFixed(2)+"'>\n";
		checkout_html+="<input type='image' src='http://www.paypal.com/en_US/i/btn/x-click-but01.gif' name='submit' style='margin-left:25px;' alt='Make payments with PayPal - it's fast, free and secure!'>\n";
		checkout_html+="</form>\n";
		//alert(checkout_html);
		document.getElementById("Checkout").innerHTML=checkout_html;
		}
		}


function deflateShop(divname,divHeader,divname2,headersize)
		{
		 	xdheight=document.getElementById(divname).offsetHeight-2;
			xdheight2=document.getElementById(divname2).offsetHeight;
			//alert("deflate1:"+dheight2);
				if(dheight<0)
				{
				xdheight=150;	
				}
				//alert("deflate11:"+dheight2);
			if(xdheight > 40 && xdheight2 > 0)
			{
			
				xdheight=xdheight-45;
				xdheight2=xdheight2-45;
				//alert("deflate3:"+dheight2);
				
				document.getElementById(divname2).style.height=xdheight2+"px";		
				document.getElementById(divname).style.height=xdheight+"px";		
				window.setTimeout("deflateShop('"+divname+"','"+divHeader+"','"+divname2+"',"+headersize+")",15);
				
			}
			else
			
				//alert("deflate out:"+dheight);
				createCookie(divname,"close",1);
				document.getElementById(divHeader).innerHTML="<div class='menuHeader' id='"+divHeader+"'>Shopping Cart<div id='itemCountDiv' style='font-size:9px;display:block;position:relative;height:13px;width:55px;margin-left:100px;margin-top:-12px;'>"+globalIndex+" Item(s)</div><div style='display:block;position:relative;background-image:url(\"http://www.esewingfabric.com/pics/web/menuArrowDown.gif\");height:10px;width:10px;margin-left:"+headersize+"px;margin-top:-14px;' onclick='inflateShop(\""+divname+"\",\""+divHeader+"\",\""+divname2+"\","+headersize+")'></div></div>";
			
			}
		
		
function inflateShop(divname,divHeader,divname2,headersize)
		{
		var dheight=document.getElementById(divname).offsetHeight-2;
		//alert("inflate cart:"+dheight);
			if(dheight < (cartDivHeight-2))
			{
				
				dheight=dheight+45;
				//alert("inflate:"+dheight);
				document.getElementById(divname2).style.height=(dheight-40)+"px";	
				document.getElementById(divname).style.height=dheight+"px";		
				window.setTimeout("inflateShop('"+divname+"','"+divHeader+"','"+divname2+"',"+headersize+")",15);
			}
			else
				eraseCookie(divname);	
				document.getElementById(divHeader).innerHTML="<div class='menuHeader'>Shopping Cart<div id='itemCountDiv' style='font-size:9px;display:block;position:relative;height:13px;width:55px;margin-left:100px;margin-top:-12px;'>"+globalIndex+" Item(s)</div><div style='display:block;position:relative;background-image:url(\"http://www.esewingfabric.com/pics/web/menuArrowUp.gif\");height:10px;width:10px;margin-left:"+headersize+"px;margin-top:-14px;' onclick='deflateShop(\""+divname+"\",\""+divHeader+"\",\""+divname2+"\","+headersize+")'></div></div>";
		}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	//alert(name);
	createCookie(name,"",-1);
}



function setCookieArray(name){
    var alength = setCookieArray.arguments.length - 1;
	   for (var i = 0; i < alength; i++) {
        data = setCookieArray.arguments[i + 1]
        createCookie (name + i, data,1);
        }        
    }
	
	function ValidateBox(fid,fbname,swatch,category,type,pic,price)
	{
		var yards = document.frmShopCart.yards.value;
		var answer='true';
		if (yards=='')
			{
			alert('Nothing was entered');
			answer='false';
			
			}
		
		var ValidChars = '0123456789.';
		var Char;
	

	for(j=0;(j<=document.frmShopCart.yards.value.length);j++)
	{
	  Char = document.frmShopCart.yards.value.charAt(j);
	  if (ValidChars.indexOf(Char) == -1)
		 {
			 document.frmShopCart.yards.focus();
			 alert('HightLighted Box must me a number.');
			 answer='false';
			 break;
		 }
	 }
	
	if (answer=='true')
		setupCartCookie(fid,fbname,swatch,category,type,pic,price);
	}
	
	function setupCartCookie(fid,fbname,swatch,category,type,pic,price){
	var yards = document.frmShopCart.yards.value;
	var answer='true';
	for(var x=0;x<=globalIndex;x++)
				{
					testArray = new getCookieArray("shopCart"+x);					
					//alert(x);
					if(testArray.length)
						{
					if(testArray[1]==fid && testArray[4]=="Fabric")
						{
							updateCookieArray(x,"1",2)
							answer='false';
							break;
						}	
						}
				}
	if(answer=='true')
	{
	setCookieArray("shopCart"+globalIndex,fid,yards,fbname,swatch,category,type,pic,price);
	globalIndex=globalIndex+1;
	createCookie("arrayindex",globalIndex,1)
	}
	deflateSCF("ShopCartform",90);
	fillShopCart();
	
	
	}
	
	function setupCartCookie2(fid,fbname,swatch,category,type,pic,price){
	var yards = 1;
	var answer='true';
	for(var x=0;x<=globalIndex;x++)
				{
					testArray = new getCookieArray("shopCart"+x);					
					//alert(x);
					if(testArray.length)
						{
					if(testArray[1]==fid && testArray[4]=="(SWATCH)")
						{
							
							answer='false';
							break;
						}	
						}
				}
	if(answer=='true')
	{
	setCookieArray("shopCart"+globalIndex,fid,yards,fbname,swatch,category,type,pic,price);
	globalIndex=globalIndex+1;
	createCookie("arrayindex",globalIndex,1)
	document.getElementById("SwatchDivInfo").innerHTML="A "+fbname+" swatch has been added to your cart."
	document.getElementById("SwatchDiv").style.visibility="visible";
	}
	else
	{
	document.getElementById("SwatchDivInfo").innerHTML="A "+fbname+" swatch has already been added to your cart."
	document.getElementById("SwatchDiv").style.visibility="visible";
	}
	
	fillShopCart();
	
	
	}
	
	function getCookieArray(name){
		var i = 0;
        while (readCookie(name + i) != null) {
        this[i + 1] = readCookie(name + i);
        i++; this.length = i; 
        }
}


function delCookieArray(sindex,items){
		
		for(var x=0;x<items;x++)
		{
       eraseCookie("shopCart"+sindex+x);
        }
	
		
	

fillShopCart();
document.getElementById("shpname").innerHTML="";
	document.getElementById("shpprice").innerHTML="";
	document.getElementById("Gtotal").innerHTML="";
	document.getElementById("Checkout").innerHTML="<form id='ChkShp' method='POST' action='http://www.esewingfabric.com/FText.php?Director=SetShip&qty="+chkQty()+"'><input type='submit' value='Check Shipping'></form>";
}

function delCookieArray2(){
		
		for(var y=0;y<=globalIndex;y++)
		{
		for(var x=0;x<7;x++)
		{
       eraseCookie("shopCart"+y+x);
        }
		
		//document.write(globaIndex+"\n"+x);
		}
		
	

fillShopCart();
calPP();
}


function setupdateCookieArray(divname,sindex,items,evalindex){
document.getElementById(divname).style.visibility='visible';
updateCookieArray(sindex,items,evalindex);
}
function updateCookieArray(sindex,items,evalindex){
	if(evalindex==1)
	{
	var JavaCommand1="var value=document.frmShopList"+sindex+".quant.value";
	}
	else
	{
	var JavaCommand1="var value=document.frmShopCart.yards.value";
	}
	eval(JavaCommand1);
	//alert(value);
	createCookie("shopCart"+sindex+items,value,1);        
	fillShopCart();
	document.getElementById("shpname").innerHTML="";
	document.getElementById("shpprice").innerHTML="";
	document.getElementById("Gtotal").innerHTML="";
	document.getElementById("Checkout").innerHTML="<form id='ChkShp' method='POST' action='http://www.esewingfabric.com/FText.php?Director=SetShip&qty="+chkQty()+"'><input type='submit' value='Check Shipping'></form>";
	
	//calPP();
}
<!--New Fabric Design-->
function checkEnter(e,form1,preform1){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
if(form1=="frmJoin")
validateJoin(form1,preform1);//submit the form
else if(form1=="frmSearch")
validateSearch(form1,preform1);//submit the form
else if(form1=="frmUserLogin")
validateLogin(form1,preform1);//submit the form
else if(form1=="frmFP")
validateFP(form1,preform1);//submit the form
return false
}
else{
return true
}

}

function ShipChoice(){
	
var tempship=document.Shpform.shipRates.options[document.Shpform.shipRates.selectedIndex].value;

var temp = new Array();
temp = tempship.split('@');
//document.getElementById("shpname").innerHTML="Method: "+temp[0];
shipping=(temp[1]*1);
shiptype=temp[0];
gTotal=subtotal+shipping;

document.getElementById("ShipDiv").style.visibility="hidden";

fillShopCart();
calPP();
}
		

function chgBack(divname,bcol,fcol)
{
document.getElementById(divname).style.backgroundColor=bcol;
document.getElementById(divname).style.color=fcol;
	
}