// JavaScript Document

// Planner scripts for ucoatit.com 2007 site
// Authored for UCoat It America, LLC - SPB 05/04/07

//------------------------------------------------------------------------------BEGIN FUNCTION
function getList(){
	var thelist = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	
	for (i=0; i<pairs.length; i++){
		var pos=pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0, pos);
		var value = pairs[i].substring(pos+1);
		thelist[argname]=unescape(value);
		}
	return thelist;
}//-----------------------------------------------------------------------------END OF FUNCTION

//-------------------------------------------------------------------------------------TEMPORARY SCRIPTS
function getHelp(a){alert('Help me with ' + a);}
//-------------------------------------------------------------------------------------END TEMPORARY

//-------------------------------------------------------------------------------------TEMPORARY SCRIPTS
function tryDealer(a){
	document.cookie='dealerid=00000;';
	var zip = document.getElementById('zipinput');
	document.cookie='zipcode='+zip.value+';';
	if (a=='31'){document.plannerinventory.submit();}
	if (a=='99'){parent.frames['topFrame'].usercart.submit();}
}//-------------------------------------------------------------------------------------END TEMPORARY

//-----------------------------------------------------------------------------------BEGIN FUNCTION
function getDescription(pcode){
	var itemnum = String(pcode); itemnum=itemnum.substring(1,5);
	var identifier = itemnum.substring(0,2);
	var numthree = itemnum.substring(2,3);
	var sizer = itemnum.substring(3,4);
		
	var name = ''; var size = ''; var clr = ''; var price=0; var swatch='ucoatpics/none';
	
	var coatcolors = new Array("","Light Gray","Medium Gray", "Beige", "Medium Blue", "Tile Red", "Black", "Antique White", "Safety Yellow", "Safety Red");
	
	var glosscolors = new Array("","Light Gray","Medium Gray", "Beige", "Medium Blue", "Tile Red", "Black", "Bright White", "Clear", "Safety Red", "Safety Yellow");
	var flekcolors = new Array("","Granite","Colonial", "Heritage", "Deco", "Dove", "Pacific", "Turf", "Venetian", "Canyon");
	var cladcolors = new Array("","Light Gray","Medium Gray", "Beige", "Medium Blue", "Tile Red", "Black", "Antique White", "Safety Yellow", "Safety Red");
	
	var colorswatch = new Array('','ltgray','mdgray','beige','mdblue','tilered','black','white','clear');

	if(identifier=='00'){name='UCoat It Product Info Kit'; size=''; price=19.95; clr='N/A'}

	if (identifier=='20'){name='UCoat';
		if (sizer=='0'){size='Complete Kit'; price=249.95;} if (sizer=='1'){size='Single Pack'; price=124.95;} if (sizer=='2'){size='Double Pack'; price=229.95;}
		clr=coatcolors[numthree];
		swatch='ucoatpics/'+colorswatch[numthree];}
	
	if (identifier=='30'){name='UGloss-AF';
		if (sizer=='0'){size='Complete Kit'; price=209.95;} if (sizer=='1'){size='Single Pack'; price=104.95;} if (sizer=='2'){size='Double Pack'; price=194.95;}
		clr=glosscolors[numthree];
		swatch='ucoatpics/'+colorswatch[numthree];
	}
	
	if (identifier=='23'){name='UGloss';
		if (numthree=='2'){size='Complete Kit'; price=169.95;} if (numthree=='4'){size='Double Pack'; price=144.95;}
		clr='Clear'; swatch='ucoatpics/'+colorswatch[8];
	}
	
	if (identifier=='60'){name='UFlek';
		if (sizer=='0'){size='Complete Kit'; price=194.95;} if (sizer=='2'){size='Double Pack'; price=169.95;}
		clr=flekcolors[numthree]; swatch='flekpics/'+flekcolors[numthree];
		if (sizer=='5'){name='UFlek Flakes'; size ='3.5 lb Jug'; clr=flekcolors[numthree]; price=25; swatch='flekpics/'+flekcolors[numthree];}
	}
	
	if (identifier=='40'){
		if (sizer=='5'){name='UFlek Flakes'; size ='3.5 lb Jug'; clr=flekcolors[numthree]; price=25; swatch='flekpics/'+flekcolors[numthree];}
		else{name='UFlek-AF';
			if (sizer=='0'){size='Complete Kit'; price=234.95;} if (sizer=='1'){size='Single Pack'; price=104.95;} if (sizer=='2'){size='Double Pack'; price=219.95;}clr=flekcolors[numthree]; swatch='flekpics/'+flekcolors[numthree];
		}
	}
	
	if (identifier=='70'){
		if (numthree=='1'){
			name='UPrep'; size='Complete Kit'; price=59.95;
			if (sizer=='0'){clr='Light Gray'; swatch='ucoatpics/'+colorswatch[2];}
			if (sizer=='1'){clr='Beige'; swatch='ucoatpics/'+colorswatch[4];}
		}
		if (numthree=='2'){
			name='UPatch'; 
			if (sizer=='0'){size='2-Quart Kit'; clr='Light Gray'; price=44.95; swatch='ucoatpics/'+colorswatch[1];}
			if (sizer=='1'){size='2-Gallon Kit'; clr='Light Gray'; price=164.95; swatch='ucoatpics/'+colorswatch[1];}
			if (sizer=='2'){size='2-Quart Kit'; clr='Beige'; price=44.95; swatch='ucoatpics/'+colorswatch[3];}
		}
		if (numthree=='3'){
			name='USolv'; clr='';
			if (sizer=='0'){size='1 qt. bottle'; price=5.95;}
			if (sizer=='1'){size='Case Quart Bottles (12)'; price=59.95;}
		}
		if (numthree=='4'){
			name='UClean'; clr='';
			if (sizer=='0'){size='1 qt. bottle'; price=4.95;}
			if (sizer=='1'){size='Case Quart Bottles (12)'; price=47.95;}
		}
		if (numthree=='5'){
			name='UDegrease'; clr='';
			if (sizer=='0'){size='1 Gallon Jug'; price=7.95;}
			if (sizer=='1'){size='5-Gallon Pail'; price=44.95;}
		}
		if (numthree=='7'){
			name='UFill'; clr='';
			if (sizer=='0'){clr='Gray'; size='11 oz. tube'; price=6.95; swatch='ucoatpics/'+colorswatch[2];}
			if (sizer=='1'){clr='Gray'; size='Case'; price=71.40; swatch='ucoatpics/'+colorswatch[2];}
			if (sizer=='2'){clr='Beige'; size='11 oz. tube'; price=6.95; swatch='ucoatpics/'+colorswatch[3];}
			if (sizer=='3'){clr='Beige'; size='Case'; price=71.40; swatch='ucoatpics/'+colorswatch[3];}
		}
		if (numthree=='8'){
			name='UPrep-CLC'; clr='';
			if (sizer=='0'){size='1 qt. bottle'; price=10.95;}
			if (sizer=='1'){size='Case'; price=131.40;}
		}
	}
	
	if (identifier=='80' || identifier=='81'){
		if (numthree=='9'){
			name='UGlaze'; clr='Clear';
			if (sizer=='0'){size='Complete Kit'; swatch='ucoatpics/'+colorswatch[8];} 
			if (sizer=='1'){size='Single Pack'; swatch='ucoatpics/'+colorswatch[8];}
			if (sizer=='2'){size='Double Pack'; swatch='ucoatpics/'+colorswatch[8];}
		}else{
			name='UClad';
			if (sizer=='0'){size='Complete Kit'; price=459.95; swatch='ucoatpics/'+colorswatch[numthree];}
			if (sizer=='1'){size='Single Pack'; price=224.95; swatch='ucoatpics/'+colorswatch[numthree];}
			if (sizer=='2'){size='Double Pack'; price=439.95; swatch='ucoatpics/'+colorswatch[numthree];}
			clr=cladcolors[numthree];}
	}
	
	if (identifier=='90'){name='URock';
		if(sizer=='0' || sizer=='1'){size='10 lb. Pail';} if(sizer=='5' || sizer=='6'){size='25 lb. Pail';}
		clr = rockcolors[numthree];
		if(sizer=='1' || sizer=='6'){clr=clr+'/White';}
	}
	
	return {name:name, size:size, clr:clr, price:price, swatch:swatch}
}//----------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function passProducts(){
	var query = location.search.substring(1);
	var pairs = query.split("&");
	return pairs;
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getList(){
	var thelist = new Object();
	var query = location.search.substring(1);
	var pairs = query.split("&");
	
	for (i=0; i<pairs.length; i++){
		var pos=pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0, pos);
		var value = pairs[i].substring(pos+1);
		thelist[argname]=unescape(value);
		}
	return thelist;
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getColornames(a){
	a=parseFloat(a);
	var colornames=new Array();
	if(a==1){colornames=Array('','Light Gray','Medium Gray','Beige','Medium Blue','Tile Red','Black', 'Antique White');}
	if(a==2){colornames=Array('','Light Gray','Medium Gray','Beige','Medium Blue','Tile Red','Black','Bright White');}
	if(a==3 || a==4){colornames=Array('','Granite','Colonial','Heritage','Deco','Dove','Pacific','Turf','Venetian','Canyon');}
	return colornames;
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function resetColors(a){
	if(a=='all' || a=='coat'){
		for (i=0; i<document.userinput.ucoatcolor.length; i++){document.userinput.ucoatcolor[i].checked=false;}}
	if(a=='all' || a=='gloss'){
		for (i=0; i<document.userinput.uglossafcolor.length; i++){document.userinput.uglossafcolor[i].checked=false;}}
	if(a=='all' || a=='flake'){
		for (i=0; i<document.userinput.uflekcolor.length; i++){document.userinput.uflekcolor[i].checked=false;}}
	
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getColorid(){
	var id1='0'; var id2='0'; var id3='0'; var idstring='';
	id1=document.userinput.finishtype.value;
	
	if(id1=='1'){
	for (i=0; i<document.userinput.ucoatcolor.length; i++){
		if(document.userinput.ucoatcolor[i].checked){id2=document.userinput.ucoatcolor[i].value;}}
	}
	
	if(id1=='2'){
	for (i=0; i<document.userinput.uglossafcolor.length; i++){
		if(document.userinput.uglossafcolor[i].checked){id2=document.userinput.uglossafcolor[i].value;}}
	}
	
	if(id1=='3' || id1=='4'){
	for (i=0; i<document.userinput.ucoatcolor.length; i++){
		if(document.userinput.ucoatcolor[i].checked){id2=document.userinput.ucoatcolor[i].value;}}
	for (i=0; i<document.userinput.uflekcolor.length; i++){
		if(document.userinput.uflekcolor[i].checked){id3=document.userinput.uflekcolor[i].value;}}
	}
	
	idstring=id1+id2+id3;
	return idstring;
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getFloortype(a){
	var floorstring='';
	if (a==0){floorstring='';}
	if (a==1){floorstring='Automotive';}
	if (a==2){floorstring='Non-Automotive';}
	return floorstring;
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function floorColor(){
	var colorstring='';
	var colorid=getColorid(); var id1=colorid.substring(0,1); id1=parseFloat(id1);
	if (id1==2){var basecolor=getColornames(2);}else{var basecolor=getColornames(1);}
	var id2=colorid.substring(1,2); id2=parseFloat(id2);
	colorstring=basecolor[id2];
	if(colorstring==undefined || id2 == 0){colorstring='';}
	else{
		if (id1=='3'){var id3=colorid.substring(2,3); id3=parseFloat(id3); var flakecolor=getColornames(id1); colorstring=basecolor[id2]+' with '+flakecolor[id3]+' flake';}
		if (id1=='4'){var id3=colorid.substring(2,3); id3=parseFloat(id3); var flakecolor=getColornames(id1); colorstring=flakecolor[id3]+' flake with '+basecolor[id2]+' base';}
	getPic(colorid);
	}
	return colorstring;
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getFinishtype(a, b){
	if(isNaN(a)){a=0;} if(isNaN(b)){b=0;}
	var finishstring='';
	if (a==0 || b==0){finishstring='';}
	if (a==1){
		if(b==1){finishstring='UCoat';}
		if(b==2){finishstring='UCoat with UGloss-AF';}
		if(b==3){finishstring='UCoat with UFlek-AF';}
		if(b==4){finishstring='UCoat It UltraLife';}
	}
	if (a==2){
		if(b==1){finishstring='UCoat';}
		if(b==2){finishstring='UCoat with UGloss';}
		if(b==3){finishstring='UCoat with UFlek';}
		if(b==4){finishstring='UCoat It UltraLife';}
	}
	return finishstring;
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function displaySwatches(a){
	var color_ucoat=document.getElementById('ucoatcolors');
	var color_gloss=document.getElementById('uglossafcolors');
	var color_flake=document.getElementById('uflekcolors');
	if(a=='none'){color_ucoat.style.display=''; color_gloss.style.display='none'; color_flake.style.display='none';}
	if(a=='coat'){color_ucoat.style.display=''; color_gloss.style.display='none'; color_flake.style.display='none';}
	if(a=='gloss'){color_ucoat.style.display='none'; color_gloss.style.display=''; color_flake.style.display='none';}
	if(a=='flake'){color_ucoat.style.display=''; color_gloss.style.display='none'; color_flake.style.display='';}
	
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function setColors(a){
	if (a==0){displaySwatches('none'); resetColors('all');}//no finish
	if (a==1){displaySwatches('coat'); resetColors('gloss'); resetColors('flake');}//satin finish
	if (a==2){displaySwatches('gloss'); resetColors('coat'); resetColors('flake');}//gloss finish
	if (a==3 || a==4){displaySwatches('coat'); displaySwatches('flake'); resetColors('gloss');}//terrazzo finish or ultralife
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function findPos(obj) {
	var curleft = 0;
	var curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return {curleft:curleft, curtop:curtop}
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function itemCost(qty, pcode){
	var itemtotal=0;
	qty=parseFloat(qty);
	var myitem=getDescription(pcode);
	itemtotal=qty * myitem.price;
	return itemtotal;
}//----------------------------------------------------------------------------------------------------------END FUNCTION


//function to set prices...SHOULD BE UPDATED AS NECESSARY!---------------------------------------------------BEGIN FUNCTION
function getPrices(){
	
	var ucoat_kit = 249.95;
	var ucoat_sp = 124.95;
	var ucoat_dp = 229.95;
	var ugloss_kit = 169.95;
	var ugloss_dp = 144.95;
	var uflek_kit = 194.95;
	var uflek_dp = 169.95;
	var uglossaf_kit = 209.95;
	var uglossaf_sp = 104.95;
	var uglossaf_dp = 194.95;
	var uflekaf_kit = 234.95;
	var uflekaf_sp = 104.95;
	var uflekaf_dp = 219.95;
	var uflek_jug = 25;
	var uprep_kit = 59.95;
	var upatch_2qt = 44.95;
	var upatch_2gal = 164.95;
	var uclad_kit = 459.95;
	var uclad_sp = 224.95;
	var uclad_dp = 439.95;
	var usolv_qt = 5.95;
	var usolv_case = 59.95;
	var uclean_qt = 4.95;
	var uclean_case = 47.95;
	var udegrease_gal = 7.95;
	var udegrease_case = 44.95;
	var ufill_tube = 6.95;
	var ufill_case = 71.40;
	
	return {ucoat_kit:ucoat_kit, ucoat_sp:ucoat_sp, ucoat_dp:ucoat_dp, ugloss_kit:ugloss_kit, ugloss_dp:ugloss_dp, uflek_kit:uflek_kit, uflek_dp:uflek_dp, uglossaf_kit:uglossaf_kit, uglossaf_sp:uglossaf_sp, uglossaf_dp:uglossaf_dp, uflekaf_kit:uflekaf_kit, uflekaf_sp:uflekaf_sp, uflekaf_dp:uflekaf_dp, uflek_jug:uflek_jug, uprep_kit:uprep_kit, upatch_2qt:upatch_2qt, upatch_2gal:upatch_2gal, uclad_kit:uclad_kit, uclad_sp:uclad_sp, uclad_dp:uclad_dp, usolv_qt:usolv_case, uclean_qt:uclean_case, udegrease_gal:udegrease_gal, udegrease_case:udegrease_case, ufill_tube:ufill_tube, ufill_case:ufill_case}
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//FUNCTION TO DETERMINE MIN NUMBER OF KITS/SINGLES/DOUBLES/FLEKJUGS & MAX S/F COVERAGE-----------------------BEGIN FUNCTION
function getkits(sqft, floortype, finishtype){
	//alert('calling getkits: sqft=' + sqft + '; floortype='+floortype+'; finishtype='+finishtype);
	var k=1; var s=0; var d=0; var j=1;
	
	if (sqft<=576 && sqft>0){var s=0; var d=0; var j=1; var maxcover = 576;}
	else{
		var remainder = sqft-576;
		var units = remainder/288;
		if (units == Math.floor(units)){var rndunits = Math.floor(units);}else{var rndunits = Math.floor(units)+1;}
		var doubles = rndunits/2;
		if (doubles == Math.floor(doubles)){var s=0;}else{var s=1;}
		var d = Math.floor(doubles);
		var maxcover=(k*576)+(s*288)+(d*576);
		}

	var j=parseInt(k)+parseInt(d); 
	
	var gls=s; var gld=d;
	if (floortype==1){gls=s; gld=d;}else{if (gls>0){gld=d+1;} gls=0;} //figure qty for AF vs. waterbase
	
	var flekdensity = document.userinput.flekdensity.value;
	if (finishtype==4){
		if (s==1){var addl = 2; var addlflake=4;}else{var addl = 1; var addlflake=0;}
		var gld=(d*2)+addl; var j=(j*8)+addlflake; gls=0;}
	
	if (finishtype==3){if (flekdensity==3){var j=j;}else{var j=0;}}
	
	if (finishtype==1 || finishtype==2){var j=0;}
	
	document.plannerinventory.usermax.value=maxcover;
	return {k:k, s:s, d:d, j:j, gls:gls, gld:gld};
}//-----------------------------------------------------------------------------END OF FUNCTION

//
function getEstimate(){
	var estimate = 0;
	var areachk=false; var floorchk=false; var finishchk=false; 
	var areainput=document.userinput.areainput.value; areainput=parseFloat(areainput);
	if(areainput == 0 || isNaN(areainput)){areachk=false;}else{areachk=true;}
	var floorinput=document.userinput.floortype.value; floorinput=parseFloat(floorinput);
	if(floorinput == 0 || isNaN(floorinput)){floorchk=false;}else{floorchk=true;}
	var finishinput=document.userinput.finishtype.value; finishinput=parseFloat(finishinput);
	if(finishinput == 0 || isNaN(finishinput)){finishchk=false;}else{finishchk=true;}
	
	
	if(areachk && floorchk && finishchk){

		var price$ = getPrices();

	// set the list variables
		var totalcoat = 0;
		var totalgloss = 0;
		var totalflek = 0;
		var totalcost = 0;
	
		var num = getkits(areainput,floorinput,finishinput); //builds object based on called function, returns values 'k'(number of kits), 's'(number of singlepacks), 'd'(number of doublepacks, 'j'(number of uflek jugs)
																																						
//determine cost based on finish type
		//UCoat standard finish
		if (finishinput == 1){
			totalcoat = (num.k*price$.ucoat_kit) + (num.s*price$.ucoat_sp) + (num.d*price$.ucoat_dp);
			totalcost = totalcoat;
			}
	
		//High Gloss finish
		if (finishinput == 2){
			if (floorinput == 1){
				totalcoat = (num.k*price$.ucoat_kit) + (num.s*price$.ucoat_sp) + (num.d*price$.ucoat_dp);
				totalgloss = (num.k*price$.uglossaf_kit) + (num.gls*price$.uglossaf_sp) + (num.gld*price$.uglossaf_dp);
				totalcost = totalcoat + totalgloss;}
			else{
				totalcoat = (num.k*price$.ucoat_kit) + (num.s*price$.ucoat_sp) + (num.d*price$.ucoat_dp);
				totalgloss = (num.k*price$.ugloss_kit) + (num.gld*price$.ugloss_dp);
				totalcost = totalcoat + totalgloss;}
		}
	
		//Terrazzo finish
		if (finishinput == 3){
			if (floorinput == 1){
				totalcoat = (num.k*price$.ucoat_kit) + (num.s*price$.ucoat_sp) + (num.d*price$.ucoat_dp);
				totalgloss = (num.k*price$.uflekaf_kit) + (num.gls*price$.uflekaf_sp) + (num.gld*price$.uflekaf_dp);
				totalflek = price$.uflek_jug*num.j;
				totalcost = totalcoat + totalgloss + totalflek;}
			else{
				totalcoat = (num.k*price$.ucoat_kit) + (num.s*price$.ucoat_sp) + (num.d*price$.ucoat_dp);
				totalgloss = (num.k*price$.uflek_kit) + (num.gld*price$.uflek_dp);
				totalflek = price$.uflek_jug*num.j;
				totalcost = totalcoat + totalgloss + totalflek;}
			}
	
		//UltraLife finish
		if (finishinput == 4){
			totalcoat = (num.k*price$.ucoat_kit) + (num.s*price$.ucoat_sp) + (num.d*price$.ucoat_dp);
			totalgloss = (num.k*price$.uglossaf_kit) + (num.gld*price$.uglossaf_dp);
			totalflek = price$.uflek_jug*num.j;
			totalcost = totalcoat + totalgloss + totalflek;
			}
	
		estimate=totalcost;
		}

	return estimate;
}//----------------------------------------------------------------------------------------------------------END OF FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function formatMoney(a){
	if (isNaN(a)||a==''){a=0; var amt='$0.00'; return amt;}
	var amt=a; 
	amt=parseFloat(amt); amt=amt.toFixed(2);
	amt=amt.toString(); 
	
	var pos=amt.indexOf('.');
	var tester=amt.substring(0,pos);
	if (tester.length>3 && tester.length<7){ //thousands
		amt=amt.substring(0,pos-3)+','+amt.substring(pos-3, pos)+'.'+amt.substring(pos+1, pos+3);}
	if (tester.length>6){ //millions
		amt=amt.substring(0,pos-6)+','+amt.substring(pos-6,pos-3)+','+amt.substring(pos-3, pos)+'.'+amt.substring(pos+1, pos+3);}
	
	amt='$ '+amt;
	return amt;
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getPic(){
	var mysrc='imgs/sampletiles/000.jpg';
	var colorid=getColorid();
	var id2 = colorid.substring(1,2); var id3=colorid.substring(2,3);
	var finishtype=document.userinput.finishtype.value;
	if(id2!='0'){
		if (finishtype=='3' || finishtype=='4'){
			if(id2=='0' || id3=='0'){mysrc='imgs/sampletiles/000.jpg';}else{mysrc='imgs/sampletiles/'+colorid+'.jpg';}
			}
		else{
			mysrc='imgs/sampletiles/'+colorid+'.jpg';}
	}
	return mysrc;
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getSwatch(){
	var mysrc='';
	var colorid=getColorid();
	var id2 = colorid.substring(1,2); var id3=colorid.substring(2,3);
	var finishtype=document.userinput.finishtype.value;
	if(colorid!='000'){
		if (finishtype=='3' || finishtype=='4'){
			if(id2=='0' || id3=='0'){mysrc='imgs/enlarged/000.jpg';}else{mysrc='imgs/enlarged/'+colorid+'.jpg';}
			}
		else{
			mysrc='imgs/enlarged/'+colorid+'.jpg';}
	}
	return mysrc;
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function writeCaution(){
	var cautionstring='<ul class="cautionlist">'; var basecolor='0';
	var floortype = document.userinput.floortype.value;
	var finishtype=document.userinput.finishtype.value;
	for (i=0; i<document.userinput.ucoatcolor.length; i++){
		if(document.userinput.ucoatcolor[i].checked){basecolor=document.userinput.ucoatcolor[i].value;}}
	if(finishtype!='2'){
		if(basecolor=='7'){cautionstring=cautionstring+'<li>When using white as a standalone finish or as a base color for one of our decorative flake topcoat systems, a finish coat of white-tinted UGloss-AF is strongly recommended for a consistent, bright white finish.</li>';}
	}else{
		if(basecolor=='7' && floortype=='2'){cautionstring=cautionstring+'<li>When using white as a base color for one of our interior topcoat systems, a third coat of UCoat epoxy may be desireable to achieve a solid, color antique white base. To achieve a bright white base color, use of our automotive topcoat, solvent based (-AF) white-tinted UGloss-AF is necessary for a bright white finish.</li>';}
		}
	cautionstring=cautionstring+'</ul>';
	return cautionstring;
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function resetForms(){
	hideStats();
	document.userinput.reset();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getUserConditions(){
	var condstring='';
	for (x=1; x<11; x++){
		var thischeck=document.getElementById('checkbox'+x);
		if(thischeck.checked){condstring=condstring+'1';}else{condstring=condstring+'0';}
	}
	return condstring;
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function buildInventory(){
	var userinput = document.getElementById('userinput');
	var areainput=userinput.areainput.value; areainput=parseFloat(areainput);
	var floorinput=userinput.floortype.value; floorinput=parseFloat(floorinput);
	var finishinput=userinput.finishtype.value; finishinput=parseFloat(finishinput);
	var num = getkits(areainput,floorinput,finishinput);
	var basecolor=''; var flakecolor='';
	
	if(finishinput==1){//SATIN FINISH
		for (i=0; i<userinput.ucoatcolor.length; i++){
			if(userinput.ucoatcolor[i].checked){basecolor=userinput.ucoatcolor[i].value;}}
		var ucoatkit=document.getElementById('i20'+basecolor+'0'); ucoatkit.value=num.k;
		var ucoatdp=document.getElementById('i20'+basecolor+'2'); ucoatdp.value=num.d;
		var ucoatsp=document.getElementById('i20'+basecolor+'1'); ucoatsp.value=num.s;
	}
	
	if(finishinput==2){//HIGH-GLOSS FINISH
		var pid='';
		for (i=0; i<userinput.uglossafcolor.length; i++){
			if(userinput.uglossafcolor[i].checked){basecolor=userinput.uglossafcolor[i].value;}}
		var ucoatkit=document.getElementById('i20'+basecolor+'0'); ucoatkit.value=num.k;
		var ucoatdp=document.getElementById('i20'+basecolor+'2'); ucoatdp.value=num.d;
		var ucoatsp=document.getElementById('i20'+basecolor+'1'); ucoatsp.value=num.s;
		
		if (floorinput==2){
			var glosskit=document.getElementById('i2320'); glosskit.value=num.k;
			var glossdp=document.getElementById('i2340'); glossdp.value=num.gld;}
		else{
			var glosskit=document.getElementById('i30'+basecolor+'0'); glosskit.value=num.k;
			var glossdp=document.getElementById('i30'+basecolor+'2'); glossdp.value=num.gld;
			var glosssp=document.getElementById('i30'+basecolor+'1'); glosssp.value=num.gls;}
	}
	
	if(finishinput==3){//FLAKE FINISH
		var pid='';
		for (i=0; i<userinput.ucoatcolor.length; i++){
			if(userinput.ucoatcolor[i].checked){basecolor=userinput.ucoatcolor[i].value;}}
		var ucoatkit=document.getElementById('i20'+basecolor+'0'); ucoatkit.value=num.k;
		var ucoatdp=document.getElementById('i20'+basecolor+'2'); ucoatdp.value=num.d;
		var ucoatsp=document.getElementById('i20'+basecolor+'1'); ucoatsp.value=num.s;
		
		for (i=0; i<userinput.uflekcolor.length; i++){
			if(userinput.uflekcolor[i].checked){flakecolor=userinput.uflekcolor[i].value;}}
		
		if (floorinput==2){pid='60';}else{pid='40';}
		var glosskit=document.getElementById('i'+pid+flakecolor+'0'); glosskit.value=num.k;
		var glossdp=document.getElementById('i'+pid+flakecolor+'2'); glossdp.value=num.gld;
		if (pid != '60'){var glosssp=document.getElementById('i'+pid+flakecolor+'1'); glosssp.value=num.gls;}
		var jugs=document.getElementById('i60'+flakecolor+'5'); jugs.value=num.j;
	}
	
	if(finishinput==4){//ULTRALIFE
		var pid='';
		for (i=0; i<userinput.ucoatcolor.length; i++){
			if(userinput.ucoatcolor[i].checked){basecolor=userinput.ucoatcolor[i].value;}}
		var ucoatkit=document.getElementById('i20'+basecolor+'0'); ucoatkit.value=num.k;
		var ucoatdp=document.getElementById('i20'+basecolor+'2'); ucoatdp.value=num.d;
		var ucoatsp=document.getElementById('i20'+basecolor+'1'); ucoatsp.value=num.s;
		
		for (i=0; i<userinput.uflekcolor.length; i++){
			if(userinput.uflekcolor[i].checked){flakecolor=userinput.uflekcolor[i].value;}}
		
		if (floorinput==2){
			var glosskit=document.getElementById('i2320'); glosskit.value=num.k;
			var glossdp=document.getElementById('i2340'); glossdp.value=num.gld;}
		else{
			var glosskit=document.getElementById('i3080'); glosskit.value=num.k;
			var glossdp=document.getElementById('i3082'); glossdp.value=num.gld;
			var glosssp=document.getElementById('i3081'); glosssp.value=num.gls;}
			
		var jugs=document.getElementById('i60'+flakecolor+'5'); jugs.value=num.j;
	}
	
	var plannerinventory = document.getElementById('plannerinventory');
	plannerinventory.userarea.value=areainput;
	plannerinventory.userfloor.value=floorinput;
	plannerinventory.usercolorid.value=getColorid();
	plannerinventory.usercond.value=getUserConditions();
	
	//if(navigator.family=="gecko"){alert('UCoat It admin: DEBUG Gecko Browser: plannerinventory='+plannerinventory.userarea.value);}
	
	plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function submitCart(){
	var userdealer=parent.document.getElementById('topFrame').contentWindow.document.getElementById('userdealer');
	var userinfo=parent.document.getElementById('topFrame').contentWindow.document.getElementById('userinfo');
	var usercart=parent.document.getElementById('topFrame').contentWindow.document.getElementById('usercart');
	var submitcart=parent.document.getElementById('topFrame').contentWindow.document.getElementById('submitcart');
	//------------------grab submitted zipcode...if available
	var zipinput = userdealer.userzip.value;
	document.plannerinventory.zipcode.value=zipinput;
	userinfo.usertotal.value=document.plannerinventory.usercost.value;

	//DO NOT REMOVE 
	for (i=0; i<submitcart.elements.length; i++){
		usercart.elements[i].value=document.plannerinventory.elements[i].value;}
	
	usercart.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function listProducts(){
 	var products=passProducts();
	var plannerinventory = document.getElementById('plannerinventory');
	
	/*if(navigator.family=="gecko"){//FIREFOX
		alert('UCoat It admin: DEBUG Gecko Browser: string:'+location.search);
	
	for(i=0; i<products.length; i++){
			var thisval=0; var itemnum='';
			var pos=products[i].indexOf('=');
			thisval=products[i].substring(pos+1);
			itemnum=products[i].substring(0, pos);
			var thisproduct=plannerinventory.elements[i];
			thisproduct.value=thisval;
		}
		
	}else{*/

	for(i=0; i<products.length; i++){// ALL OTHER BROWSER TYPES
			var thisval=0; var itemnum='';
			var pos=products[i].indexOf('=');
			thisval=products[i].substring(pos+1);
			itemnum=products[i].substring(0, pos);
			var thisproduct=document.getElementById(itemnum);
			thisproduct.value=thisval;}
	//}
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function writeList(){
	var runtotal=0;
	document.write('<tr><td class="listhead" style="text-align:right">Qty</td><td class="listhead" style="text-align:center">Id</td><td class="listhead">Description</td><td class="listhead">Color</td><td class="listhead" style="text-align:right">Price</td></tr>');
	for(i=0; i<document.plannerinventory.elements.length; i++){
		var itemnum=document.plannerinventory.elements[i].id;
		thisval=parseFloat(document.plannerinventory.elements[i].value);
		if(itemnum.substring(0,1) =='i'){
			if(thisval!=0){
				var thisitem=getDescription(itemnum); var thisitemcost=itemCost(thisval, itemnum);
				runtotal=runtotal+thisitemcost;
				document.write('<tr><td style="text-align:right">'+thisval+'</td><td style="text-align:center"><span style="font-size:9px;">'+itemnum.substring(1)+'</span></td><td>' + thisitem.name + ' ' + thisitem.size + '</td><td><img width=24 height=12 src="imgs/sampletiles/'+thisitem.swatch+'.jpg" style="margin-top:2px;"> '+thisitem.clr+'</td><td style="text-align:right">'+formatMoney(thisitemcost)+'</td></tr>');}
		}
	}
	document.plannerinventory.usercost.value=runtotal;
	document.write('<tr><td colspan="4" class="listbottom">&nbsp;</td><td class="listbottom" style="text-align:right">'+formatMoney(document.plannerinventory.usercost.value)+'</td></tr>');
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function writeCart(){
	var usercart=parent.document.getElementById('topFrame').contentWindow.document.getElementById('usercart');
	var userinfo=parent.document.getElementById('topFrame').contentWindow.document.getElementById('userinfo');
	//check for info kit or coatings in cart...i.e. shouldn't have both.
	var infokit=usercart.i0010.value;
	var hascoatings=false;
	var myitemcount = countItems(usercart);
	
	document.write('<tr><td class="listhead" style="text-align:right">Qty</td><td class="listhead" style="text-align:center">Id</td><td class="listhead">Description</td><td class="listhead">Color</td><td class="listhead">&nbsp;</td><td class="listhead" style="text-align:right">Price</td></tr>');
	for(i=0; i<usercart.elements.length; i++){
		var itemnum=usercart.elements[i].id;
		thisval=parseFloat(usercart.elements[i].value);
		if(itemnum.substring(0,1) =='i'){
			if(thisval!=0){
				if(itemnum!='i0010' && hascoatings==false){hascoatings=true;}
				var thisitem=getDescription(itemnum); var thisitemcost=itemCost(thisval, itemnum);
				
				document.write('<tr><td style="text-align:right">'+thisval+'</td><td style="text-align:center"><span style="font-size:9px;">'+itemnum.substring(1)+'</span></td><td>' + thisitem.name + ' ' + thisitem.size + '</td><td><img width=24 height=12 src="imgs/sampletiles/'+thisitem.swatch+'.jpg" style="margin-top:2px;"> '+thisitem.clr+'</td><td>'+getIcon(itemnum)+'</td><td style="text-align:right">'+formatMoney(thisitemcost)+'</td></tr>');}
		}
	}
	if(hascoatings==true && infokit!='0'){document.write('<tr><td colspan="6" class="listbottom">! Has info kit and coatings...this is not necessary. Remove info kit?</td></tr>');}
	document.write('<tr><td style="text-align:right;" class="listbottom">'+myitemcount+'</td><td colspan="4" class="listbottom">items in cart</td><td class="listbottom" style="text-align:right;">'+formatMoney(userinfo.usertotal.value)+'</td></tr>');
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getIcon(a){
	var icn_str='';
	var itemnum = String(a); itemnum=itemnum.substring(1,5);
	var identifier = itemnum.substring(0,2);
	if(identifier=='20'){icn_str='<img src="../imgs/cart/hidden.gif" height="12" width="16" />'}//UCoat Product (LOCK)
	if(identifier=='70'){icn_str='<img src="../imgs/cart/remove.gif" height="12" width="16" onmousedown=javascript:removeaddOn("'+a+'"); />'}//UCoat Product (EDITABLE)
	return icn_str;
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function buildDesc(){
	var sqft=document.plannerinventory.userarea.value; sqft=parseFloat(sqft);
	var floortype=document.plannerinventory.userfloor.value; floortype=parseFloat(floortype);
	var floorid=document.plannerinventory.usercolorid.value; var finishtype=floorid.substring(0,1); finishtype=parseFloat(finishtype);
	document.write('For your ' + getFloortype(floortype) + ' area of ' + sqft +' sq.ft. We would suggest the following to achieve a '+ getFinishtype(floortype, finishtype) +' finish.');
}//----------------------------------------------------------------------------------------------------------END FUNCTION


//----------------------------------------USER SUGGESTIONS FUNCTIONS-----------------------------------------------------//
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function checkMax(){
	var maxwarn='';
	var mymax=document.plannerinventory.usermax.value; mymax=parseFloat(mymax);
	var myarea=document.plannerinventory.userarea.value; myarea=parseFloat(myarea);
	var colorid=document.plannerinventory.usercolorid.value; var colorval=colorid.substring(1,2);
	var pctcover=0;
	var showwarn=false;
	if(colorval=='7'){showwarn=true; maxwarn='<tr valign="top"><td><img src="imgs/warnicns/coverage.gif"></td><td>When using white, more material than what is recommended here may be required for adequate color coverage due to the light pigmentation of the color.</td></tr>';}

	if(colorval=='3'){//BEIGE
		showwarn=true; maxwarn='<tr valign="top"><td><img src="imgs/warnicns/coverage.gif"></td><td>When using beige, more material than what is recommended here may be required for adequate color coverage due to the light pigmentation of the color.</td></tr>';}
		
	if(colorval!='3' && colorval!='7'){//ALL OTHER COLORS
		pctcover=mymax*0.95; pctcover=pctcover.toFixed(0);
		if(pctcover<=myarea){showwarn=true; maxwarn='<tr valign="top"><td><img src="imgs/warnicns/coverage.gif"></td><td>Your area is '+myarea+' sq.ft. which is within 95% of the maximum suggested coverage for this amount of material. Surface porosity and application technique may affect coverage rates. </td></tr>';}
	}
	
	if (showwarn==true){document.write('<table width="90%" cellspacing="0" cellpadding="0" align="center" class="warntables">'+maxwarn+'</table>');}
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function checkConditions(){
	var condstring=String(document.plannerinventory.usercond.value);
	var conditionwarn='';
	var floorcond=new Array();
	for(i=0; i<condstring.length; i++){floorcond[i]=condstring.substring(i,i+1);}
	if(floorcond[0]=='1'){//NEW CEMENT
		conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/fresh.gif"></td><td><strong>You indicated new concrete &mdash;</strong> New or freshly poured concrete will require a minimum of 30 days to cure. After 30 days, you may continue the application process by preparing your floor, including the muriatic acid wash, according to the UCoat Instruction Manual. The muriatic acid wash balances the pH level of the concrete surface and is required of all concrete floors, new or old.</td></tr>';}
	
	if(floorcond[1]=='1'){//ROUGH OR POROUS
		conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/rough.gif"></td><td><strong>You indicated a rough or porous surface &mdash;</strong> Surface wear, imperfections in finishing and pouring techniques may leave areas of the floor rough. UCoat will not necessarily fill in rough spots or provide a level surface when the substrate is irregular, but they are easily coated and present no special problem for the adhesion or performance of UCoat. If the area is porous, the substrate will absorb more material than what is usually expected and therefore may require additional material than is recommended here.</td></tr>';}
	
	if(floorcond[2]=='1'){//BRITTLE OR CHIPIING
		conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/rough.gif"></td><td><strong>You indicated a brittle surface or chipping &mdash;</strong> Brittle, soft or chalky concrete is not an ideal substrate for UCoat. To determine if your concrete is soft, perform a key test. Using a car or house key, or a flat-bladed screwdriver, scratch the surface of the floor. If the floor flakes, scratches or appears loose or dusty, do NOT coat the floor until this issue is resolved.</td></tr>';}
	
	if(floorcond[3]=='1' && floorcond[4]!='1'){//SOME OIL(MINOR), NO CRACKING
		var usolv_qty=document.plannerinventory.i7030.value; 
		if(usolv_qty>=1){conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/prep.gif"></td><td>You have added our industrial quality surface cleaner and degreaser, USolv. <a href="javascript:removeUSolv();">Click here</a> to remove this item.</td></tr>';}
		else{conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/prep.gif"></td><td><strong>You indicated some minor oil spots &mdash;</strong> Oil stains and residues must be dissolved and rendered water-soluble before applying UCoat. We recommend treating these areas with an industrial-grade degreaser such as <a href="../pgs/popups/info_usolv.htm" target=_blank>USolv&reg;</a>.</td></tr>';}
	}
	
	if(floorcond[4]=='1'){//SOME OIL(MAJOR)
		var udegrease_qty=parseFloat(document.plannerinventory.i7050.value)+parseFloat(document.plannerinventory.i7051.value);
		if(udegrease_qty>=1){conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/prep.gif"></td><td>You added UDegrease&reg; for heavy-duty cleaning and degreasing of your moderate-to-heavily soiled surface. <a href="javascript:removeUDegrease();">Click here</a> to remove this item.</td></tr>';}
		else
		{conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/prep.gif"></td><td><strong>You indicated a heavily soiled surface &mdash;</strong> Heavily soiled concrete should be cleaned thoroughly before applying UCoat. Consider using <a href="../pgs/popups/info_udegrease.htm" target=_blank>UDegrease&reg;</a> for heavy-duty cleaning and degreasing.</td></tr>';}
	}
		
	if(floorcond[5]=='1'){//SOME CRACKING OR VOIDS, NO OIL
		var upatch_qty=parseFloat(document.plannerinventory.i7020.value)+parseFloat(document.plannerinventory.i7021.value)+parseFloat(document.plannerinventory.i7022.value); 
		var ufill_qty=parseFloat(document.plannerinventory.i7070.value)+parseFloat(document.plannerinventory.i7071.value)+parseFloat(document.plannerinventory.i7072.value)+parseFloat(document.plannerinventory.i7073.value); 
		
		if(upatch_qty>=1){conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/cracks.gif"></td><td>You have added our industrial quality patching compound, UPatch. <a href="javascript:removeUPatch();">Click here</a> to remove this item.</td></tr>';}
		if(ufill_qty>=1){conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/cracks.gif"></td><td>You have added our industrial crack filling caulking compound, UFill. <a href="javascript:removeUFill();">Click here</a> to remove this item.</td></tr>';}
		
		if(ufill_qty<=0 && upatch_qty<=0){conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/cracks.gif"></td><td><strong>You indicated a some cracking and/or minor voids &mdash;</strong> You may consider repairing these with <a href="../pgs/popups/info_ufill.htm" target=_blank>UFill&trade;</a> for expansion joints and cracks smaller than 1/8" wide or  <a href="../pgs/popups/info_upatch.htm" target=_blank>UPatch&reg;</a> for wider cracks, minor pits and popouts..</td></tr>';}
	
	
	}
	
	/*if(floorcond[3]=='1' && floorcond[5]=='1'){//BOTH OIL AND CRACKING
		var uprep_qty=parseFloat(document.plannerinventory.i7010.value)+parseFloat(document.plannerinventory.i7011.value);
		if(uprep_qty>=1){conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/cracks.gif"></td><td>You have added our UPrep Kit which includes USolv citrus-based degreaser, UPatch our industrial epoxy floor patch and UClean our recommended floor cleaner to maintain your UCoat It finish. <a href="javascript:removeUPrep();">Click here</a> to remove this item.</td></tr>';}
		else
		{conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/cracks.gif"></td><td><strong>You indicated a surface with both oil stains and some cracking &mdash;</strong> With a concrete surface that requires both degreasing and crack repair, you may consider the <a href="../pgs/popups/info_uprep.htm" target=_blank>UPrep&reg; kit</a> which contains both UPatch epoxy crack repair compound and USolv citrus-based degreaser.</td></tr>';}
	} */
		
	if(floorcond[6]=='1'){//PITTING OR SPALLING
		var uclad_qty=getCladQty();
		if(uclad_qty>=1){conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/rough.gif"></td><td>You added UClad, our high-solids, self-leveling epoxy for surface repair. <a href=javascript:removeUClad();>Click here</a> to remove this item.</td></tr>';}
		else{conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/rough.gif"></td><td><strong>You indicated pitting and/or spalling &mdash;</strong> You may consider <a href="../pgs/popups/info_uclad.htm" target=_blank>UClad&reg;</a> for repair.</td></tr>';}
	}
		
	if(floorcond[7]=='1'){//CURRENTLY COATED (EPOXY OR PAINT)
		conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/prep.gif"></td><td><strong>You indicated that the surface is currently coated &mdash;</strong> When coating over previously coated concrete, we recommend removal of all previous coatings to ensure a tight bond with the concrete. However, previous coatings can be coated over if they are not failing. If previous coatings are worn through to the cement, or dull from wear and not peeling or flaking, scuff or sand the surface with 60-80 grit sandpaper to prepare for a mechanical bond. Chemically clean, rinse and proceed with UCoat application.</td></tr>';}
	if(floorcond[8]=='1'){//CURRENTLY SEALED
		conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/prep.gif"></td><td><strong>You indicated that the surface is currently sealed &mdash;</strong> Floors that have been sealed or treated with a waterproofing agent must be properly prepared prior to applying UCoat to ensure bonding with the substrate. Some water-based agents may be neutralized by performing a muriatic acid wash of the floor. Other agents may require grinding of the surface using an EDCO grinder to remove the upper-most layers of concrete. A freshly ground floor will be more porous and will absorb more material than what is usually expected and therefore may require additional material than is recommended here.</td></tr>';}
	if(floorcond[9]=='1'){//UNKNOWN STAINS
		conditionwarn=conditionwarn+'<tr valign="top"><td><img src="imgs/warnicns/prep.gif"></td><td><strong>You indicated stains of unknown origin &mdash;</strong> For floors with stains of unknown origin, always perform the water test to see if those stains will present a problem when applying UCoat. Contaminents that repel water (such as oils, grease, silicone, etc.) will prevent UCoat from penetrating the concrete and unless properly treated will prevent UCoat from bonding with those areas of the floor.</td></tr>';}
	
	if(conditionwarn!=''){document.write('<table width="90%" cellpadding="0" cellspacing="0" align="center" class="warntables">'+conditionwarn+'</table>');}
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function writeAdvice(){
	addonUPrepCLC();
	checkWhite();
	checkMax();
	checkGlossAF();
	checkConditions();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function highlightStep(a){
		a=parseFloat(a);
	for(i=1; i<6; i++){
		var thisstep=document.getElementById('step'+i);
		if (a==i){thisstep.className='activestep';}else{thisstep.className='inactivestep';}
	}
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function addonUPrepCLC(){
	var prepCLCqts=parseFloat(document.plannerinventory.i7080.value);
	var prepCLCcases=parseFloat(document.plannerinventory.i7081.value);
	var area = parseFloat(document.plannerinventory.userarea.value);
	var prepunits = area/150;
	if (prepunits > Math.floor(prepunits)){prepunits = Math.floor(prepunits)+1;}
	var qts=0;
	var cases=0;
	if (prepunits >= 12){cases=prepunits/12;}else{qts=prepunits;}
	if (Math.floor(cases) < cases){qts = prepunits-(Math.floor(cases)*12); cases=Math.floor(cases);}
	if (prepCLCqts == 0 && prepCLCcases == 0){
		
		var prepCLCadd='<table width="90%" cellpadding="0" cellspacing="0" align="center" class="warntables"><tr valign="top"><td><img src="imgs/warnicns/prep.gif"></td><td>Bare concrete surfaces will require a mild acid wash to properly prepare the cement for application. Consider using UPrep-CLC concentrated concrete preparation and pH balancing solution. <a href="javascript:addprepCLC('+qts+', '+cases+');">Click here</a> to add this material.</td></tr></table>';
		document.write(''+prepCLCadd+'');
	}else{
		
		var prepstring = '';
		var plural='';
		if (prepunits <= 12){
			if (prepunits > 1){plural='s';}
			prepstring = String(prepunits)+' quart' + plural;
		}else{
			
			if (cases > 1){plural='s';}
			prepstring = String(cases)+' case' + plural;
			if (qts > 0){
				if (qts > 1){plural='s';}
				prepstring = prepstring + ' and ' + String(qts)+' quart' + plural;
				
			}
		}
			
			
		var prepCLCadd='<table width="90%" cellpadding="0" cellspacing="0" align="center" class="warntables"><tr valign="top"><td><img src="imgs/warnicns/prep.gif"></td><td>You have added UPrep-CLC concentrated concrete preparation and pH balancing solution for your concrete surface. Each quart bottle will treat up to 150 square feet. For your area of '+area+' sq.ft., we recommend '+prepstring+'. <a href="javascript:removeprepCLC();">Click here</a> to remove this material.</td></tr></table>';
		document.write(''+prepCLCadd+'');
	}
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function addprepCLC(q, c){
	var qts=parseFloat(q); 
	var cases=parseFloat(c);
	document.plannerinventory.i7080.value=qts;
	document.plannerinventory.i7081.value=cases;
	document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function removeprepCLC(){
	document.plannerinventory.i7080.value=0; document.plannerinventory.i7081.value=0; document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function validateInputs(){
	var userinfo=document.getElementById('userinput');
	
	
	var userinput=userinfo.areainput.value; userinput=parseFloat(userinput);
	var userfloor=userinfo.floortype.value; userfloor=parseFloat(userfloor);
	var userfinish=userinfo.finishtype.value; userfinish=parseFloat(userfinish);
	var usercolor=userinfo.finishtype.value; userfinish=parseFloat(userfinish);
	for (i=0; i<userinfo.ucoatcolor.length; i++){
			if(userinfo.ucoatcolor[i].checked){var basecolor=userinfo.ucoatcolor[i].value;}}
	for (i=0; i<userinfo.uglossafcolor.length; i++){
			if(userinfo.uglossafcolor[i].checked){var glosscolor=userinfo.uglossafcolor[i].value;}}
	for (i=0; i<userinfo.uflekcolor.length; i++){
			if(userinfo.uflekcolor[i].checked){var flakecolor=userinfo.uflekcolor[i].value;}}
	
	
	
	/*var userinput=document.userinput.areainput.value; userinput=parseFloat(userinput);
	var userfloor=document.userinput.floortype.value; userfloor=parseFloat(userfloor);
	var userfinish=document.userinput.finishtype.value; userfinish=parseFloat(userfinish);
	var usercolor=document.userinput.finishtype.value; userfinish=parseFloat(userfinish);
	for (i=0; i<document.userinput.ucoatcolor.length; i++){
			if(document.userinput.ucoatcolor[i].checked){var basecolor=document.userinput.ucoatcolor[i].value;}}
	for (i=0; i<document.userinput.uglossafcolor.length; i++){
			if(document.userinput.uglossafcolor[i].checked){var glosscolor=document.userinput.uglossafcolor[i].value;}}
	for (i=0; i<document.userinput.uflekcolor.length; i++){
			if(document.userinput.uflekcolor[i].checked){var flakecolor=document.userinput.uflekcolor[i].value;}}*/
	
	if(isNaN(userinput) || userinput <=0){
		alert('Please enter a valid measurement for your square footage in Step 1.'); return;}
	else if(userfloor==0){alert('Please choose your floor type for Step 2.'); return;}
	else if(userfinish==0){alert('Please choose your finish type for Step 3.'); return;}
	else if(userfinish==1){if(!basecolor){alert('Please choose a UCoat color'); return;}}
	else if(userfinish==2){if(!glosscolor){alert('Please choose a color'); return;}}
	else if(userfinish==3 || userfinish==4){
		if(!basecolor || !flakecolor){alert('Please choose both a UCoat base color and UFlek flake color'); return;}}
	
	buildInventory();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function translateColorId(){
	var colorstring='';
	var floorid=document.plannerinventory.userfloor.value;
	var colorid=document.plannerinventory.usercolorid.value;
	var basecolors=getColornames(1);
	var glosscolors=getColornames(2);
	var flakecolors=getColornames(3);
	var id1=colorid.substring(0,1); id1=parseFloat(id1);
	var id2=colorid.substring(1,2); id2=parseFloat(id2);
	var id3=colorid.substring(2,3); id3=parseFloat(id3);
	if (id1==1){colorstring=basecolors[id2];}
	if (id1==2){if(floorid=='1'){colorstring=glosscolors[id2];}else{colorstring=basecolors[id2];}}
	if (id1==3 || id1==4){colorstring=basecolors[id2] + ' with ' +flakecolors[id3]+' flake';}
	return colorstring;
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function validateArea(a){
	if (isNaN(a) || a==0){document.userinput.areainput.value=''; document.userinput.areainput.focus();}else{updateStats();}
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function addwhiteGloss(){
	var k=document.plannerinventory.i2070.value;
	var s=document.plannerinventory.i2071.value;
	var d=document.plannerinventory.i2072.value;
	var mycost=parseFloat(document.plannerinventory.usercost.value);
	document.plannerinventory.i3070.value=parseFloat(document.plannerinventory.i3070.value)+k;
		var kitcost=getDescription('i3070'); mycost=mycost+kitcost.price*k;
	document.plannerinventory.i3071.value=parseFloat(document.plannerinventory.i3071.value)+s;
		var singlecost=getDescription('i3071'); mycost=mycost+singlecost.price*s;
	document.plannerinventory.i3072.value=parseFloat(document.plannerinventory.i3072.value)+d;
		var doublecost=getDescription('i3072'); mycost=mycost+doublecost.price*d;
	document.plannerinventory.userwhite.value=1;
	document.plannerinventory.usercost.value=mycost.toFixed(2);
	var prev_clr = String(document.plannerinventory.usercolorid.value);
	var fintype = prev_clr.substring(0,1);
	if (fintype=='1'){document.plannerinventory.usercolorid.value='270';}
	document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function removewhiteGloss(){
	var mycost=parseFloat(document.plannerinventory.usercost.value);
	var k=document.plannerinventory.i3070.value;
	var s=document.plannerinventory.i3071.value;
	var d=document.plannerinventory.i3072.value;
	document.plannerinventory.i3070.value=0;
	document.plannerinventory.i3071.value=0;
	document.plannerinventory.i3072.value=0;
	var kitcost=getDescription('i3070'); mycost=mycost-kitcost.price*k;
	var singlecost=getDescription('i3071'); mycost=mycost-singlecost.price*s;
	var doublecost=getDescription('i3072'); mycost=mycost-doublecost.price*d;
	document.plannerinventory.usercost.value=mycost.toFixed(2);
	document.plannerinventory.userwhite.value=0;
	document.plannerinventory.usercolorid.value='170'
	document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function checkWhite(){
	var colorid=document.plannerinventory.usercolorid.value;
	var finishid=colorid.substring(0,1);
	colorid=colorid.substring(1,2);
	var addedwhite=document.plannerinventory.userwhite.value;
	var whitewarn='';
	if(colorid=='7' && addedwhite=='0' && finishid!='2'){whitewarn='<tr valign="top"><td><img src="imgs/warnicns/white.gif"></td><td>When using white as a base color, an additional coat of white-tinted UGloss-AF is strongly recommended for an even, bright white finish. <a href="javascript:addwhiteGloss();">Click here</a> to add this material.</td></tr>';}
	if(colorid=='7' && addedwhite=='1' && finishid!='2'){whitewarn='<tr valign="top"><td><img src="imgs/warnicns/white.gif"></td><td>Since you are using white as a base color, we recommended an additional coat of white-tinted UGloss-AF for an even, bright white finish. <a href="javascript:removewhiteGloss();">Click here</a> to remove this material.</td></tr>';}
	if(colorid=='7' && finishid=='2'){whitewarn='<tr valign="top"><td><img src="imgs/warnicns/white.gif"></td><td>UCoat White will finish as an antique, or off-white color. To achieve a true, bright white the use of our white-tinted UGloss-AF (for automotive floors) is necessary.</td></tr>';}
	
	document.write('<table width="90%" cellpadding="0" cellspacing="0" align="center" class="warntables">'+whitewarn+'</table>');
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function checkGlossAF(){
	var floortype=document.plannerinventory.userfloor.value;
	var colorid=document.plannerinventory.usercolorid.value;
	var finishid=colorid.substring(0,1); var mycolor=colorid.substring(1,2);
	var tintedwarn='';
	
	if(finishid=='2' && floortype=='1' && mycolor !='7'){//High-gloss, no flake, not white - Automotive
		var clearcheck=document.plannerinventory.i3080.value; clearcheck=parseFloat(clearcheck);
		if(!clearcheck || clearcheck==0 || isNaN(clearcheck)){tintedwarn='<tr valign="top"><td><img src="imgs/warnicns/tinted.gif"></td><td><strong>When a solid color, high-gloss finish is desired</strong>, we recommend the use of UGloss-AF tinted to your UCoat base color for ease of application and coverage. If you plan on embedding floor graphics (such as a logo) during your application, you will need UGloss-AF "Clear". <a href=javascript:switchAF("clear");>Click here</a> to switch UGloss-AF from "tinted" to "clear".</td></tr>';}
	
		if(clearcheck >= 1){tintedwarn='<tr valign="top"><td><img src="imgs/warnicns/tinted.gif"></td><td><strong>You elected to switch UGloss-AF to "Clear".</strong> Unless you are applying floor graphics (such as a logo) we recommend the use of UGloss-AF tinted to your UCoat base color for ease of application and coverage, when a solid color, high-gloss finish is desired. <a href=javascript:switchAF("tint");>Click here</a> to switch UGloss-AF back to "tinted" from "clear".</td></tr>';}
		
		document.write('<table width="90%" cellpadding="0" cellspacing="0" align="center" class="warntables">'+tintedwarn+'</table>');
	}
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function switchAF(a){
	var colorid=document.plannerinventory.usercolorid.value;
	colorid=colorid.substring(1,2);
	
	var tintedkit=document.getElementById('i30'+colorid+'0');
	var tintedsp=document.getElementById('i30'+colorid+'1');
	var tinteddp=document.getElementById('i30'+colorid+'2');
	var clearkit=document.getElementById('i3080');
	var clearsp=document.getElementById('i3081');
	var cleardp=document.getElementById('i3082');
	
	if (a=='clear'){
		clearkit.value=tintedkit.value; tintedkit.value=0;
		clearsp.value=tintedsp.value; tintedsp.value=0;
		cleardp.value=tinteddp.value; tinteddp.value=0;}
	if (a=='tint'){
		tintedkit.value=clearkit.value; clearkit.value=0;
		tintedsp.value=clearsp.value; clearsp.value=0;
		tinteddp.value=cleardp.value; cleardp.value=0;}
	
	document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function countItems(a){
	var mycount=0;
	for (i=1; i<a.length; i++){
		var thisitem = parseFloat(a.elements[i].value); if(isNaN(thisitem)){thisitem=0;}
		mycount=mycount+thisitem;
	}
	return mycount;
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function showpurchaseDiv(){
	document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-top:24px;"><tr><td width="10" style="padding-top:7px;"><img src="../imgs/tablering/upperleft.gif" width="10" height="10" /></td><td class="ringtable_top"><span class="ringtable_title">WHAT ARE YOU LOOKING TO PURCHASE?</span></td><td width="10" style="padding-top:7px;"><img src="../imgs/tablering/upperright.gif" width="10" height="10" /></td></tr><tr><td width="10" class="ringtable_left">&nbsp;</td><td style="padding:4px; padding-top:12px;"><table border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" align="left" cellpadding="0" cellspacing="0"><tr><td><div align="center"><a href="products.htm"><img src="../imgs/trithumbs/products.jpg" width="120" height="100" border="0" /></a></div></td></tr><tr><td class="jumptabletd"><a href="products.htm">Floor Coating Products</a></td></tr></table></td><td><table border="0" align="center" cellpadding="0" cellspacing="0"><tr><td><div align="center"><a href="infokit.htm"><img src="../imgs/trithumbs/infokit.jpg" width="120" height="100" border="0" /></a></div></td></tr><tr><td class="jumptabletd"><a href="infokit.htm">UCoat It Product Info Kit</a></td></tr></table></td><td><table border="0" align="right" cellpadding="0" cellspacing="0"><tr><td><div align="center"><a href="giftcards.htm"><img src="../imgs/trithumbs/giftcard.jpg" width="120" height="100" border="0" /></a></div></td></tr><tr><td class="jumptabletd"><a href="giftcards.htm">UCoat It Gift Cards</a></td></tr></table></td></tr></table></td><td width="10" class="ringtable_right">&nbsp;</td></tr><tr><td width="10" style="padding-bottom:4px;"><img src="../imgs/tablering/lowerleft.gif" width="10" height="10" /></td><td class="ringtable_bottom">&nbsp;</td><td width="10" style="padding-bottom:4px;"><img src="../imgs/tablering/lowerright.gif" width="10" height="10" /></td></tr></table>');
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function purchasecartInfo(){
	var usercart=parent.document.getElementById('topFrame').contentWindow.document.getElementById('usercart');
	var userdealer=parent.document.getElementById('topFrame').contentWindow.document.getElementById('userdealer');
	var dealerid=userdealer.dealerid.value;
	var myzip=userdealer.userzip.value;
	var mydealer=userdealer.companyname.value;
	var mydealerphone=userdealer.phone1.value;
	var myitemcount = countItems(usercart);
	
	if (myitemcount<=0){
		userdealer.usertotal.value=0;
		document.write('<p class="maintext">Your cart is currently empty. If you are ready to purchase a UCoat It floor coating system, please use our <a href="estimator.htm">Material Estimator</a> to load your cart. Otherwise, you may choose from one of the options below.</p>');
		showpurchaseDiv();}
		
	else{/*
	document.write('<p class="dealerprompt"><b>PLEASE NOTE: </b>We are currently upgrading our web server and internet ordering will be disabled for approximately 48-72 hours beginning April 1, 2008. We anticipate online ordering services will be back online by this weekend. If you wish to place this order, call 1-800-UCoat-It (800-826-2848) and speak with a UCoat It representative directly. We thank you for your patience.</p>');
	document.write('<p><input type="submit" name="Submit" value="Empty Cart" onClick="javascript:resetCart();"></p>');*/
	if(dealerid=='0' || !dealerid || dealerid==''){//has NOT searched for a dealer
		document.write('<form name="searchdata2" action="finddealer.asp" method="post" style="display:none;"><input name="zip" type="hidden" id="zip"><input name="refer" type="hidden" id="refer" value="dealerinfo"></form><p class="dealerprompt"><strong>Ready to purchase?</strong><br>We may have a local dealer in your area.</p><form name="dealersearch2" method="get" action="javascript:searchDealer2();" onSubmit="javascript:searchDealer2();">Enter Zip Code: <input id="zipinput2" maxLength="6" size="10" name="zipinput2"><input type="button" value="Search" name="Button" onClick="javascript:searchDealer2();" ></form>');}
	else if(dealerid=='102'){//has searched for a dealer, none located
		document.write('<p class="dealerprompt"><strong>Ready to purchase?</strong><br>Currently, we do not have an Authorized Stocking dealer in or near to the ' + myzip + ' zipcode. However, you may purchase online using our secure server. Click the button below to confirm product availability and proceed to checkout</p>');
		document.write('<p><input type="button" name="Button" value="Checkout via web" onClick="javascript:submitSecure();"><input type="submit" name="Submit" value="Empty Cart" onClick="javascript:resetCart();"></p>');}
	else {//has a local dealer
		//document.write('<p class="dealerprompt"><strong>Ready to purchase?</strong><br>We have a dealer in your area:<strong> '+mydealer+'</strong>. Click the checkout button below to confirm product availability and proceed.');
		document.write('<p class="dealerprompt"><strong>Ready to purchase?</strong><br>We have a dealer in your area: <strong><a href="dealerinfo.htm">'+mydealer+'</a></strong>. Whenever possible, we recommend purchasing from a local Authorized Dealer. Please call '+mydealer+' at '+mydealerphone+' to confirm product availablity. If you do not wish to use your local dealer, you may still choose to order online by continuing below.</p><p class="dealerprompt" style="color:#CC0000;"> Online orders are shipped direct to your location from our warehouse in Michigan. Additional shipping charges may apply. Use the button below to order online.</p>');
		document.write('<p><input type="button" name="Button" value="Order Online" onClick="javascript:submitSecure();"><input type="submit" name="Submit" value="Empty Cart" onClick="javascript:resetCart();"></p>');}
	
	}	

}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function resetCart(){
	var usercart=parent.document.getElementById('topFrame').contentWindow.document.getElementById('usercart');
	var userinfo=parent.document.getElementById('topFrame').contentWindow.document.getElementById('userinfo');
	userinfo.usertotal.value=0;
	if(navigator.family=="gecko"){for (i=0; i<usercart.elements.length; i++){usercart.elements[i].value=0;}}else{usercart.reset();}
	usercart.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function returntoEstimator(){
	var usercart=parent.document.getElementById('topFrame').contentWindow.document.getElementById('usercart');
	usercart.reset();
	parent.frames['mainFrame'].location='estimator.htm';
}//----------------------------------------------------------------------------------------------------------END FUNCTION
//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function submitSecure(){
	var usercart=parent.document.getElementById('topFrame').contentWindow.document.getElementById('usercart');
	var userdealer=parent.document.getElementById('topFrame').contentWindow.document.getElementById('userdealer');
	var submitcart=parent.document.getElementById('topFrame').contentWindow.document.getElementById('submitcart');
	usercart.zipcode.value=userdealer.userzip.value;
	
	for (i=0; i<submitcart.elements.length; i++){submitcart.elements[i].value=usercart.elements[i].value;}
	submitcart.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function catchfromSim(){
	if(location.search){
		var stats=getList();
		document.userinput.floortype.value="1";
		document.userinput.finishtype.value=stats.fin;
		
		if (stats.flk!="0"){//convert flek numbers to corresponding imgs for products
			var flk = parseFloat(stats.flk);
			var colornames= new Array('','2','4','5','1','3','6','7','9','8');
			stats.flk=colornames[flk];
		}
		
		for(i=0; i<document.userinput.ucoatcolor.length; i++){
			if(stats.clr==document.userinput.ucoatcolor[i].value){document.userinput.ucoatcolor[i].checked=true;}else{document.userinput.ucoatcolor[i].checked=false;}
		}
		
		if(stats.fin=="2"){
			var hidetable=document.getElementById('ucoatcolors');
			hidetable.style.display='none';
			var showtable=document.getElementById('uglossafcolors');
			showtable.style.display='';
			for(i=0; i<document.userinput.uglossafcolor.length; i++){
				if(stats.clr==document.userinput.uglossafcolor[i].value){
					document.userinput.uglossafcolor[i].checked=true;}
				else{
					document.userinput.uglossafcolor[i].checked=false;}
			}
		}
		
		if(stats.fin=="3"){
			var showtable=document.getElementById('uflekcolors');
			showtable.style.display='';
			for(i=0; i<document.userinput.uflekcolor.length; i++){
				if(stats.flk==document.userinput.uflekcolor[i].value){
					document.userinput.uflekcolor[i].checked=true;}
				else{
					document.userinput.uflekcolor[i].checked=false;}
			}
		}
		
		
		
		updateStats();
		alert('Please enter your square footage in step one.');
		}
	
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getCladQty(){
	var totqty=parseFloat(document.plannerinventory.i8010.value) + parseFloat(document.plannerinventory.i8011.value) + parseFloat(document.plannerinventory.i8012.value) + parseFloat(document.plannerinventory.i8020.value) + parseFloat(document.plannerinventory.i8021.value) + parseFloat(document.plannerinventory.i8022.value) + parseFloat(document.plannerinventory.i8030.value) + parseFloat(document.plannerinventory.i8031.value) + parseFloat(document.plannerinventory.i8032.value) + parseFloat(document.plannerinventory.i8040.value) + parseFloat(document.plannerinventory.i8041.value) + parseFloat(document.plannerinventory.i8042.value) + parseFloat(document.plannerinventory.i8050.value) + parseFloat(document.plannerinventory.i8051.value) + parseFloat(document.plannerinventory.i8052.value) + parseFloat(document.plannerinventory.i8060.value) + parseFloat(document.plannerinventory.i8061.value) + parseFloat(document.plannerinventory.i8062.value) + parseFloat(document.plannerinventory.i8070.value) + parseFloat(document.plannerinventory.i8071.value) + parseFloat(document.plannerinventory.i8072.value);
	return totqty;
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function removeUSolv(){
	document.plannerinventory.i7030.value=0; document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function removeUPrep(){
	document.plannerinventory.i7010.value=0; document.plannerinventory.i7011.value=0; document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function removeUDegrease(){
	document.plannerinventory.i7050.value=0; document.plannerinventory.i7051.value=0; document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function removeUClad(){
	document.plannerinventory.i8010.value=0; document.plannerinventory.i8011.value=0; document.plannerinventory.i8012.value=0;
	document.plannerinventory.i8020.value=0; document.plannerinventory.i8021.value=0; document.plannerinventory.i8022.value=0;
	document.plannerinventory.i8030.value=0; document.plannerinventory.i8031.value=0; document.plannerinventory.i8032.value=0;
	document.plannerinventory.i8040.value=0; document.plannerinventory.i8041.value=0; document.plannerinventory.i8042.value=0;
	document.plannerinventory.i8050.value=0; document.plannerinventory.i8051.value=0; document.plannerinventory.i8052.value=0;
	document.plannerinventory.i8060.value=0; document.plannerinventory.i8061.value=0; document.plannerinventory.i8062.value=0;
	document.plannerinventory.i8070.value=0; document.plannerinventory.i8071.value=0; document.plannerinventory.i8072.value=0;
	
	document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function removeUPatch(){
	document.plannerinventory.i7020.value=0;
	document.plannerinventory.i7021.value=0;
	document.plannerinventory.i7022.value=0;
	//document.plannerinventory.i7023.value=0; UPATCH 2GAL BEIGE
	
	document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function removeUFill(){
	document.plannerinventory.i7070.value=0;
	document.plannerinventory.i7071.value=0;
	document.plannerinventory.i7072.value=0;
	document.plannerinventory.i7073.value=0;
	
	document.plannerinventory.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION

/*//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function buildDoubles(a){
	var sp=0;
	var dp=0;
	a=parseFloat(a);
	if (a>1){
		for (i=0; a>1; i++){
			dp=dp+1;
			a=a-2;
		}
	}
	if (a>0){sp=1;}
	return {sp:sp, dp:dp}
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function addRecommendation(clr,sqft,maxsqft){
	var variant = 0.95; //STANDARD COLORS
	var rec_string = 'this is calling addRecommendation '+clr+' '+sqft+', '+maxsqft;
	if(clr=='7'){var variant = 0.7;}//WHITE
	if(clr=='3'){var variant = 0.8;}//BEIGE
	maxsqft=parseFloat(maxsqft); sqft=parseFloat(sqft);
	var addl_cvr = 576 * variant; addl_cvr=addl_cvr.toFixed(0);
	var probsqft=maxsqft*variant; probsqft=probsqft.toFixed(0);
	var overrun = sqft-probsqft; overrun=overrun.toFixed(0);
	var addl_unit=0;
	
	if (overrun>288 && overrun<addl_cvr){addl_unit=1;}
	if (overrun>addl_cvr){addl_unit=overrun/288;}
	addl_unit=buildDoubles(addl_unit);
	alert('Users actual sqft:'+sqft+'\nMaximum sqft:'+maxsqft+'\nProbable sqft:'+probsqft+'\nPotential Short:'+overrun+'\nRecommended additional material\nSingles:'+addl_unit.sp+'\nDoubles:'+addl_unit.dp);
	
	return rec_string;
}//----------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function addMaterial(clr,sqft,maxsqft){
	alert('this is calling addMaterial '+clr+' '+sqft+', '+maxsqft);
}//----------------------------------------------------------------------------------------------------------END FUNCTION*/
//---------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function getCart(){
	var cart = parent.document.getElementById('topFrame').contentWindow.document.getElementById('usercart');
	return cart;
}//--------------------------------------------------------------------------------------------------------END FUNCTION

//-----------------------------------------------------------------------------------------------------------BEGIN FUNCTION
function removeaddOn(a){
	var cart=getCart();
	var userinfo=parent.document.getElementById('topFrame').contentWindow.document.getElementById('userinfo');
	var prev_val=parseFloat(cart.elements[a].value);
	var prev_cost=parseFloat(userinfo.usertotal.value); prev_cost=prev_cost.toFixed(2);
	
	var product=getDescription(a);
	var thiscost = prev_val * product.price; thiscost=thiscost.toFixed(2);
	userinfo.usertotal.value=prev_cost-thiscost;
	cart.elements[a].value=0;
	cart.submit();
}//----------------------------------------------------------------------------------------------------------END FUNCTION


