var aBoxName = new Array('Book Box','Linen Box','China Box','Picture Box','Wardrobe Box','File Box','Packing Tape','Packing Paper','Shrink Wrap');
	var aBoxPrice = new Array('3','4','7','6','15','5','2','25','75');
	var BoxQuantity ={'Book Box':0,'Linen Box':0,'China Box':0,'Picture Box':0,'Wardrobe Box':0,'File Box':0,'Packing Tape':0,'Packing Paper':0,'Shrink Wrap':0};
	var BoxExplanation ={'Book Box':'Perfect for books, CDs.&nbsp; Ideal for small, and heavier items.<BR><BR>Measurement: 17" x 12" x 12"<BR><BR><SPAN class="bold">Price: $3.00/ea</SPAN>','Linen Box':'Ideal for all linens and great all-purpose box.<BR><BR>Measurement: 18" x 18" x 16"<BR><BR><SPAN class="bold">Price: $4.00/ea</SPAN>','China Box':'Double corrugated for extra strength: best for dishware, glasses, and fragile/breakable items.<BR><BR>Measurement: 28" x 18" x 18"<BR><BR><SPAN class="bold">Price: $7.00/ea</SPAN>','Picture Box':'The box for all your framed pictures and small mirrors.<BR><BR>Measurement: 40" x 32" x 4"<BR><BR><SPAN class="bold">Price: $6.00/ea</SPAN>','Wardrobe Box':'For all items hanging in your closet.<BR><BR>Measurement: 25" x 21" x 48"<BR><BR><SPAN class="bold">Rent: $6.00<BR>Purchase: $15.00/ea</SPAN>','File Box':'Great for storing your important documents.<BR><BR>Measurement: 26" x 16" x 13"<BR><BR><SPAN class="bold">Price: $5.00/ea</SPAN>','Packing Tape':'<SPAN class="bold">Price: $2.00/ea</SPAN>','Packing Paper':'<SPAN class="bold">Price: $25.00/20 lbs.</SPAN>','Shrink Wrap':'<SPAN class="bold">Price: $75.00/roll</SPAN>'};
	var BoxImage ={'Book Box':'/images/boxes/book_box.jpg','Linen Box':'/images/boxes/linen_box.jpg','China Box':'/images/boxes/china_box.jpg','Picture Box':'/images/boxes/picture_box.jpg','Wardrobe Box':'/images/boxes/wardrobe_box.jpg','File Box':'/images/boxes/file_box.jpg','Packing Tape':'/images/boxes/misc.jpg','Packing Paper':'/images/boxes/packingpaper.jpg','Shrink Wrap':'/images/boxes/shrinkwrap.jpg'}
	
	function Body_onLoad() {
		document.getElementById('txtQTY').value = '1';
		document.getElementById('DisplayTotal').innerHTML = '<TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD class="Caption" style="WIDTH: 5%"><CENTER><INPUT type="checkbox" id="cbxAll" name="cbxAll" value="-1" disabled="true"></CENTER></TD><TD class="Caption" style="WIDTH: 45%">Type of Box</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">Quantity</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">SubTotal</TD></TR><TR><TD class="Display">&nbsp;</TD><TD class="Display">&nbsp;</TD><TD class="Display">&nbsp;</TD><TD class="Display" style="TEXT-ALIGN: right">$0.00</TD></TR><TR><TD class="Caption" style="WIDTH: 5%">&nbsp;</TD><TD class="Caption" style="WIDTH: 45%">&nbsp;</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">&nbsp;</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">Total:&nbsp;&nbsp;$0.00</TD></TR></TABLE>';
	}
	
	function frmOrderBoxes_onSubmit() {
		var aTitles, iCounter, bReturnValue
			
		//initialize all elements
		window.lblEmail.style.color = '#000000';
		window.lblMove_Date.style.color = '#000000';
		window.lblFirst_Name.style.color = '#000000';
		window.lblLast_Name.style.color = '#000000';
		window.lblAddress.style.color = '#000000';
		window.lblCity.style.color = '#000000';
		window.lblState.style.color = '#000000';
		window.lblZip.style.color = '#000000';
		window.lblHome_Phone.style.color = '#000000';
		window.lblWork_Phone.style.color = '#000000';
		window.lblDelivered_Time_Preference.style.color = '#000000';
			
		bReturnValue = IsEmpty('Email','your E-Mail address','txt');
			
		if(bReturnValue)
			bReturnValue = IsGoodExp('Email','a valid E-Mail address','txt','.(.*)@.(.*)\.(.*).');
			
		if(bReturnValue)
			bReturnValue = IsEmpty('Move_Date','your move date','txt');
			
		if(bReturnValue)
			bReturnValue = IsGoodExp('Move_Date','a date like: mm/dd/yyyy','txt','[0-9]{2}\/[0-9]{2}\/[0-9]{4}');
			
		if(bReturnValue)
			bReturnValue = IsEmpty('First_Name','your first name','txt');
			
		if(bReturnValue)
			bReturnValue = IsGoodExp('First_Name','your first name','txt','[a-z]');
				
		if(bReturnValue)
			bReturnValue = IsEmpty('Last_Name','your last name','txt');
			
		if(bReturnValue)
			bReturnValue = IsGoodExp('Last_Name','your last name','txt','[a-z]');
				
		if(bReturnValue)
			bReturnValue = IsEmpty('Address','your stree address','txt');
			
		if(bReturnValue)
			bReturnValue = IsEmpty('City','your city','txt');
			
		if(bReturnValue)
			bReturnValue = IsEmpty('State','your state','txt');
				
		if(bReturnValue)
			bReturnValue = IsEmpty('Zip','your zip code','txt');
			
		if(bReturnValue)
			bReturnValue = IsGoodExp('Zip','a valid zip code: 12345','txt','[0-9]{5}')
			
		if(bReturnValue)
			bReturnValue = IsEmpty('Home_Phone','a contact phone number','txt')
					
		if(bReturnValue)
			bReturnValue = IsGoodExp('Home_Phone','a valid phone number like: 123-456-7890','txt','[0-9]{3}\-[0-9]{3}\-[0-9]{4}');
		
		if(bReturnValue) {
			var frmOrderBoxes = document.forms["frmOrderBoxes"];
			
			frmOrderBoxes.strBookBox.value = BoxQuantity['Book Box'];
			frmOrderBoxes.strLinenBox.value = BoxQuantity['Linen Box'];
			frmOrderBoxes.strChinaBox.value = BoxQuantity['China Box'];
			frmOrderBoxes.strPictureBox.value = BoxQuantity['Picture Box'];
			frmOrderBoxes.strWardrobeBox.value = BoxQuantity['Wardrobe Box'];
			frmOrderBoxes.strFileBox.value = BoxQuantity['File Box'];
			frmOrderBoxes.strPackingTape.value = BoxQuantity['Packing Tape'];
			frmOrderBoxes.strPackingPaper.value = BoxQuantity['Packing Paper'];
			frmOrderBoxes.strShrinkWrap.value = BoxQuantity['Shrink Wrap'];
			frmOrderBoxes.strTotal.value = CalcTotal();
		}				
		return bReturnValue;
	}
		
	function IsEmpty(sFieldName, sMessage, sType) {
		if (window.document.getElementById(sType + sFieldName).value == '') {
			DisplayError(sFieldName, 'Please enter ' + sMessage, sType);
			return false;
		}
		else 
			return true;
	}
		
	function IsGoodExp(sFieldName, sMessage, sType, sExp){
		var reGoodExp;
		var element;
		element = document.getElementById(sType + sFieldName);
		reGoodExp = new RegExp(sExp);
		if(!reGoodExp.test(element.value)){
			DisplayError(sFieldName, 'Please enter ' + sMessage, sType);
			return false;
		}
		else
			return true;
	}
		
	function DisplayError(sFieldName, sMessage, sType) {
		document.getElementById('lblErrorMessage1').innerText = sMessage; 
		window.document.location.href = '#location';
		window.document.getElementById(sType + sFieldName).focus();
		window.document.getElementById('lbl' + sFieldName).style.color = '#ff0000';
	}
		
	function ChangeBox() {
		document.getElementById('BoxInfo').innerHTML = BoxExplanation[document.forms["frmOrderBoxes"].selBoxType[window.document.forms["frmOrderBoxes"].selBoxType.selectedIndex].value];
		document.getElementById('BoxPicture').innerHTML = '<IMG src="' + BoxImage[window.document.forms["frmOrderBoxes"].selBoxType[window.document.forms["frmOrderBoxes"].selBoxType.selectedIndex].value] + '">';
	}
	function AddBox(){
		var iCounter;
		var sHtml = '<TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD class="Caption" style="WIDTH: 5%"><CENTER><INPUT type="checkbox" id="cbxAll" name="cbxAll" value="-1" onClick="javascript:SelectAll();"></CENTER></TD><TD class="Caption" style="WIDTH: 50%">Type of Box</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">Quantity</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">SubTotal</TD></TR>'
		var frmOrderBoxes = document.forms["frmOrderBoxes"];
		BoxQuantity[frmOrderBoxes.selBoxType[frmOrderBoxes.selBoxType.selectedIndex].value] = BoxQuantity[frmOrderBoxes.selBoxType[frmOrderBoxes.selBoxType.selectedIndex].value] + parseInt(document.getElementById('txtQTY').value);
		document.getElementById('txtQTY').value = '1';
		for(iCounter = 0; iCounter < aBoxName.length; iCounter++) {
			if(BoxQuantity[aBoxName[iCounter]] != 0)
				sHtml = sHtml + '<TR><TD class="Display"><CENTER><INPUT type="checkbox" id="cbx' + iCounter + '" name="cbx" value="' + iCounter + '"></CENTER><TD class="Display">' + aBoxName[iCounter] + '</TD><TD class="Display" style="TEXT-ALIGN: right;PADDING-RIGHT: 30px">' + BoxQuantity[aBoxName[iCounter]] + '</TD><TD class="Display" style="TEXT-ALIGN: right"><SPAN id="SubTotal" name="SubTotal">' + AddMoney(aBoxPrice[iCounter],BoxQuantity[aBoxName[iCounter]]) + '</SPAN></TD></TR>';
		}
		sHtml = sHtml + '<TR><TD class="Caption" style="WIDTH: 5%">&nbsp;</TD><TD class="Caption" style="WIDTH: 45%">&nbsp;</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">&nbsp;</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">Total:&nbsp;&nbsp;' + CalcTotal() + '</TD></TR></TABLE>';
		document.getElementById('DisplayTotal').innerHTML = sHtml;
	}
	
	function RemoveBoxes() {
		var iCounter, strID, aCkbx = document.getElementsByName('cbx');
		var sHtml = '<TABLE border="0" cellpadding="0" cellspacing="0" width="100%"><TR><TD class="Caption" style="WIDTH: 5%"><CENTER><INPUT type="checkbox" id="cbxAll" name="cbxAll" value="-1" onClick="javascript:SelectAll();"></CENTER></TD><TD class="Caption" style="WIDTH: 50%">Type of Box</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">Quantity</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">SubTotal</TD></TR>'
		for(iCounter = 0;iCounter < aCkbx.length; iCounter++)
			if(aCkbx[iCounter].checked) {
				strID = aCkbx[iCounter].id.slice(3);
				BoxQuantity[aBoxName[strID]] = 0;
			}
		for(iCounter = 0; iCounter < aBoxName.length; iCounter++)
			if(BoxQuantity[aBoxName[iCounter]] != 0)
				sHtml = sHtml + '<TR><TD class="Display"><CENTER><INPUT type="checkbox" id="cbx' + iCounter + '" name="cbx" value="' + iCounter + '"></CENTER><TD class="Display">' + aBoxName[iCounter] + '</TD><TD class="Display" style="TEXT-ALIGN: right;PADDING-RIGHT: 30px">' + BoxQuantity[aBoxName[iCounter]] + '</TD><TD class="Display" style="TEXT-ALIGN: right"><SPAN id="SubTotal" name="SubTotal">' + AddMoney(aBoxPrice[iCounter],BoxQuantity[aBoxName[iCounter]]) + '</SPAN></TD></TR>';
		sHtml = sHtml + '<TR><TD class="Caption" style="WIDTH: 5%">&nbsp;</TD><TD class="Caption" style="WIDTH: 45%">&nbsp;</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">&nbsp;</TD><TD class="Caption" style="WIDTH: 25%;TEXT-ALIGN: right">Total:&nbsp;&nbsp;' + CalcTotal() + '</TD></TR></TABLE>';
		document.getElementById('DisplayTotal').innerHTML = sHtml;
	}
	
	function AddMoney(sPrice,sQTY) {
		var sSubTotal = sPrice * sQTY;
		var sSubTotal = '$' + sSubTotal +'.00';
		return sSubTotal;
	}
	
	function CalcTotal() {
		var iCounter, sTotal = 0;
		for (iCounter = 0; iCounter < aBoxName.length; iCounter++)
			sTotal += 1 * AddMoney(aBoxPrice[iCounter],BoxQuantity[aBoxName[iCounter]]).substring(1,AddMoney(aBoxPrice[iCounter],BoxQuantity[aBoxName[iCounter]]).indexOf("."));
		sTotal = '$' + sTotal + '.00';
		return sTotal
	}
	
	function SelectAll() {
		var iCounter, aCkbx = document.getElementsByName('cbx');
		if (document.getElementById('cbxAll').checked)
			for(iCounter = 0;iCounter < aCkbx.length; iCounter++)
				aCkbx[iCounter].checked = true;
		else
			for(iCounter = 0;iCounter < aCkbx.length; iCounter++)
				aCkbx[iCounter].checked = false;
	}