	function totalTheForm() {
			var rmTotal = 0;
			var rmCount = '';
			var rmTypes = [];
			var rmRates = [];
			var estTotal = 0;			
		// Room and Spaces Count
			$('table#tbl_room tbody tr[class!="note"]:first').each(function(){
				var explode = $(this).find('option:selected').val().split(':');
				if ($(this).find('td.rmSize').hasClass("markedup")) { var firstprice = 105; }
				else { var firstprice = 85; }
				$(this).find('option:selected').val(explode[0]+':'+rndNum(firstprice,2));
				$('tr.note').remove();
				$('<tr class="note"><td colspan="6"><span><!--<span class="noteClose"><a href="#">Close</a></span>-->The first room always starts at $85.00, but not because we don\'t like you. It\'s just our policy.</span></td></tr>').insertAfter(this);			
			});
			var tC = 1;
			$('table#tbl_room tbody tr[class!="note"]').each(function(){
				$(this).children('td.rmCount').text(tC);
				$(this).find('td.rmDesc input').attr('name','rmDesc_'+tC).attr('id','rmDesc_'+tC);
				$(this).find('td.rmType select').attr('name','rmType_'+tC).attr('id','rmType_'+tC);				
				$(this).find('td.rmSize input').attr('name','rmSize_'+tC).attr('id','rmSize_'+tC);		
				tC++;
				});													
			$('table#tbl_room td.markedup').each(function(){
					var explode = $(this).parents('tr').find('option:selected').val().split(':');
					$(this).parents('tr').find('option:selected').val(explode[0]+':'+rndNum((explode[1]*1)-20.00,2));
					$(this).removeClass('markedup');			
				});										
			$('table#tbl_room td[class!="markedup"] input.overage:checkbox:checked').each(function(){
				var explode = $(this).parents('tr').find('td option:selected').val().split(':');
				var newValue = explode[0]+':'+rndNum((explode[1]*1)+20.00,2).toString();
				$(this).parents('tr').find('td option:selected').val(newValue);
				$(this).parent('td').addClass('markedup');			
				});							
			$('table#tbl_room select.roomType:first option').each(function(){ 
				var explode = $(this).val().split(':'); 
				rmTypes.push(explode[0]);
				});				
			if ($('table#tbl_room').length > 0) {
				$('li#rmBlank').hide();
				for(i=0; i < rmTypes.length; i++) {
					var q = 0; 
					var r = 0;
					var value = rmTypes[i]; 
					$('table#tbl_room option[value^="'+value+':"]').each(function(){
						if ($(this).attr('selected') ) {
							var explode = $(this).val().split(':');						
							$(this).parents('tr').children('td.rmPrice').text('$'+explode[1]); q++; r += (explode[1]*1);						
							}
						});				
					if (q > 0) {
						$('li#'+value+'_total').show(); $('li#'+value+'_total span.quant').text(q); 
						$('li#'+value+'_total span.summPrice').text('$'+rndNum(r,2)); 
						}
					else { 
						$('li#'+value+'_total').hide(); 
						}
					}				
				}
			else { 
				$('.formSummary li:not(:first)').each(function(){ if ($(this).hasClass('title')) { return false;} else {$(this).hide();} }); 
				$('li#rmBlank').show();
				}				
		// Room and Spaces Table Subtotal			
			$('.form tbody td.rmPrice').each(function(){ var rmCost = ($(this).text().replace('$',''))*1; rmTotal += rmCost; });
			$('#rmTblTotal').text('$'+rndNum(rmTotal,2)); $('#rmSubTotal_hid').val('$'+rndNum(rmTotal,2));
		// Packages
			var activePkg = $('.package input:checked').attr('id');
			var activeSubtotal = ($('#rmTblTotal').text().replace('$',''))*1;
			$('.package, .packageCon td').removeClass('selected'); 
			$('.package span.btn_status, .packageCon tfoot td:not(:first)').html('<input type="button" class="button" value="Select Package" />');
			
			var pkg_loc = $('#'+activePkg+'Box').parents('th').nextAll('th').length;
			switch (pkg_loc){
				case 2: var pkg_col = '2'; break;
				case 1: var pkg_col = '3'; break;
				case 0: var pkg_col = '4'; break;
				}
			$('#'+activePkg+'Box, #'+activePkg+'Foot, .packageCon tbody tr td:nth-child('+pkg_col+')').addClass('selected'); 
			$('#'+activePkg+'Box span.btn_status, #'+activePkg+'Foot').text('Selected');
			
			$('#pkgSlvr').val('pkgSlvr:'+rndNum(0,2)); $('#pkgSlvrTotal, #pkgSlvr_total span.summPrice').text('$'+rndNum(0,2));
			$('#pkgGld').val('pkgGld:'+rndNum((activeSubtotal*.30),2)); $('#pkgGldTotal, #pkgGld_total span.summPrice').text('$'+rndNum((activeSubtotal*.30),2));
			$('#pkgPltnm').val('pkgPltnm:'+rndNum((activeSubtotal*.80),2)); $('#pkgPltnmTotal, #pkgPltnm_total span.summPrice').text('$'+rndNum((activeSubtotal*.80),2));			
			$('.formSummary li[id^="pkg"]').hide(); $('.formSummary li[id="'+activePkg+'_total"]').show();			
		// Features		
			var activeFeat = $('.features input[name="ClnOpts"]:checked').attr('id');
			var pkgTtl_tmp = $('.package input:checked').val().split(':'); pkgTtl_tmp = pkgTtl_tmp[1];			
			var atmTotal = rndNum((($('#rmTblTotal').text().replace('$',''))*1) + (pkgTtl_tmp*1 ),2);
			//alert(atmTotal);
			$('#NoAddOn_rd').val('none:'+rndNum(0,2)); $('#NoAddOn').text('$'+rndNum(0,2)); 
			$('#HighTraffic_rd').val('ht:-'+rndNum((atmTotal*.2),2)); $('#HighTraffic, #HighTraffic_total .summPrice').text('-$'+rndNum((atmTotal*.2),2));
			$('#SpiffClean_rd').val('spiff:-'+rndNum((atmTotal*.4),2)); $('#SpiffClean, #SpiffClean_total .summPrice').text('-$'+rndNum((atmTotal*.4),2));			
			switch(activeFeat) {
				case 'NoAddOn_rd': $('#HighTraffic_total, #SpiffClean_total').hide(); break;
				case 'HighTraffic_rd': $('#HighTraffic_total').show(); $('#SpiffClean_total').hide(); break;
				case 'SpiffClean_rd': $('#SpiffClean_total').show(); $('#HighTraffic_total').hide(); break;
				}						
			if (pkg_col == '4') {
				$('#Deodor_rd').val(rndNum(0,2)).attr('checked','checked'); $('#Deodor, #Deodor_total .summPrice').text('Included');						
				$('#Protector_rd').val(rndNum(0,2)).attr('checked','checked'); $('#Protector, #Protector_total .summPrice').text('Included');					
				$('#PreVacuum_rd').val(rndNum(0,2)).attr('checked','checked'); $('#PreVacuum, #PreVacuum_total .summPrice').text('Included');									
				}
			else if (pkg_col == '3') {
				$('#Deodor_rd').val(rndNum(0,2)).attr('checked','checked'); $('#Deodor, #Deodor_total .summPrice').text('Included');						
				$('#Protector_rd').val(rndNum((atmTotal*.5),2)); $('#Protector, #Protector_total .summPrice').text('$'+rndNum((atmTotal*.5),2));					
				$('#PreVacuum_rd').val(rndNum(0,2)).attr('checked','checked'); $('#PreVacuum, #PreVacuum_total .summPrice').text('Included');									
				}
			else {
				$('#Deodor_rd').val(rndNum((atmTotal*.1),2)); $('#Deodor, #Deodor_total .summPrice').text('$'+rndNum((atmTotal*.1),2));						
				$('#Protector_rd').val(rndNum((atmTotal*.5),2)); $('#Protector, #Protector_total .summPrice').text('$'+rndNum((atmTotal*.5),2));					
				$('#PreVacuum_rd').val(rndNum((atmTotal*.2),2)); $('#PreVacuum, #PreVacuum_total .summPrice').text('$'+rndNum((atmTotal*.2),2));									
				}
			$('.features input:checkbox').each(function(){
				var id = $(this).attr('id').replace('_rd','');
				if ($(this).attr('checked')) { $('#'+id+'_total').show(); }
				else { $('#'+id+'_total').hide(); }	
			});
		// Estimate Summary Table
			$('.formSummary li:visible .summPrice').each(function(){ var liCost = ($(this).text().replace('$','').replace('Included',''))*1; estTotal += liCost; });
			$('#estTotal').text('$'+rndNum(estTotal,2)); $('#rmTotal_hid').val('$'+rndNum(estTotal,2));
		}
	function rndNum(num,dec) {
		var result = Math.round( Math.round( num * Math.pow( 10, dec + 1 ) ) / Math.pow( 10, 1 ) ) / Math.pow(10,dec);
		result = result.toFixed(2);
		return result;
		}	
	function windowSize(flag) {
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
			}
		if (flag == 'h') {
			return myHeight;
			}
		else {
			return myWidth;
			}			
		}
	function getPageSizeWithScroll(){
		var ScrollTop = document.body.scrollTop;
		if (ScrollTop == 0){
			if (window.pageYOffset)
				ScrollTop = window.pageYOffset;
			else
				ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
			}
		return ScrollTop;
		}
			
	function validateSaveForm() {
		var name = /[(\*\(\)\[\]\+\.\,\/\?\:\;\'\"\`\~\\#\$\%\^\&\<\>\s)+]/;
		var email  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if ($('#cust_name').val().match(name)) { $('#cust_name').parents('tr').find('td.valid span').hide(); }
		else { $('#cust_name').parents('tr').find('td.valid span').show(); }			
		
		if ($('#cust_email').val().match(email)) { $('#cust_email').parents('tr').find('td.valid span').hide(); }
		else { $('#cust_email').parents('tr').find('td.valid span').show(); }					
		
		if ($('td.valid span:visible').length == 0) {
			return true;			
			}
		}
	function modal_close(){
		$('#modalReturn').fadeOut('slow',function(){ $('#modalReturn').find('span.sysMsg').remove(); $('#modalReturn').find('input').val('');});
		}
	function createCookie(name,value,days) {if (days) {var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}
	function readCookie(name) {var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++) {var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}
	function eraseCookie(name) {createCookie(name,"",-1);}	
	function start_est_process(flag){
		$('.start_q').hide();
		$('#whereShitHappens').empty();		
		switch(flag){
			case 'srtFrsh': 
				$('#tbl_tmp_store table:first').clone(true).prependTo('#whereShitHappens').attr('id','tbl_room');				
				$('table#tbl_room tbody tr:not(:first)').remove(); 
				$('table#tbl_room tbody tr:first td.rmDesc input:text').val('New Room'); 
				$('table#tbl_room').show(); 
				break;
			case 'srtSmpl': 
				$('#tbl_tmp_store table:first').clone(true).prependTo('#whereShitHappens').attr('id','tbl_room').show();
				break; 
			case 'srtOver': $('table#tbl_room').hide(); $('.start_q').show(); break;
			default: $('table#tbl_room').hide(); $('.start_q').show(); break;
			}
		if ((flag == 'srtFrsh') || (flag == 'srtSmpl')) {createCookie('acc_est_flag',flag,90);} else {eraseCookie('acc_est_flag');}
		}
	$(document).ready(function(){
		$('.loadingForm').hide();
		$('#est_form').show();
		if ( readCookie('acc_est_flag') ) { start_est_process(readCookie('acc_est_flag')); }
		else { start_est_process('srtOver'); }
		$('.formOptions').append('<a href="#" id="print_est_form" title="Print This Estimate"><img src="http://www.albemarlecarpet.com/wp-content/themes/Theme-ACC/images/print.gif" alt="Print This Estimate" /> Print</a> <a href="#" id="srtOver" title="Restart This Estimate"><img src="http://www.albemarlecarpet.com/wp-content/themes/Theme-ACC/images/refresh.gif" alt="Restart This Estimate" /> Restart</a>');
		$('a[id^="srt"]').bind('click',function(){ start_est_process($(this).attr('id')); totalTheForm(); return false; });
		
		var msgCap = 'Wow! You must have a lot of rooms. Please call us at (252) 255-1477 and we\'ll talk about how to get all of them cleaned.';
		var msgMin = 'If you delete all the rooms, we won\'t be able to clean your home. We really want to clean your home, so let\'s leave that last room. OK?';
		$('td.rmDesc input:text').blur(function(){ $(this).addClass('disabled'); });
		$('td.rmDesc input:text').focus(function(){ $(this).removeClass('disabled'); });
		if ($('.package input:checkbox:checked').length == 0) {
			$('input#pkgSlvr').attr('checked','checked');			
			}

		$('.packageCon th:not(:first), .packageCon td:not(:first)')
			.mouseenter(function(){
				var pkgClk_loc = $(this).nextAll().length;
				switch (pkgClk_loc){
					case 2: pkgClk_col = '2'; break;
					case 1: pkgClk_col = '3'; break;
					case 0: pkgClk_col = '4'; break;
					}				
				$('.packageCon thead tr th:nth-child('+pkgClk_col+') .package, .packageCon tr td:nth-child('+pkgClk_col+')').addClass('hover');
				})
			.click(function(){
				$('.package input:checkbox').removeAttr('checked');
				$('.packageCon thead th:nth-child('+pkgClk_col+')').find('input:checkbox').attr('checked','checked');
				totalTheForm();
				})			
			.mouseleave(function(){
				$('.packageCon thead tr th:nth-child('+pkgClk_col+') .package, .packageCon tr td:nth-child('+pkgClk_col+')').removeClass('hover');
				});	

		$('.features input:radio, .features input:checkbox, input.overage').click(function(){ totalTheForm(); });						
		$('select.roomType').change(function(){ totalTheForm(); });								
		$('a[class^="tbl_room_"]').click(function(){
			var this_button = $(this).attr('class');
			switch(this_button) {
				case 'tbl_room_add':
					if ($('table#tbl_room tbody tr').length < 26) {
						$('table#tbl_room_alt tbody tr[class!="note"]:last').clone(true).insertAfter('table#tbl_room tbody tr:last');
						$('table#tbl_room tbody tr:last td.rmDesc input:text').removeClass('disabled').val('New Room').focus();						
						}
					else { alert(msgCap); }	
					break;
				case 'tbl_room_del':
					if ($(this).parents('tr').siblings('tr[class!="note"]').length > 0) { $(this).parents('tr').remove(); }
					else { alert(msgMin); }
					break;
				case 'tbl_room_dup':
					if ($('table#tbl_room tbody tr').length < 26) {					
						$(this).parents('tr').clone(true).insertAfter($(this).parents('tr'));					
						$(this).parents('tr').next('tr').find('td.rmDesc input:text').removeClass('disabled').focus();
						}
					else { alert(msgCap); }	
					break;
				}
			totalTheForm();
			return false;
			});			
		$('#save_est_form_start').click(function(){
			var width = windowSize();
			var height = getPageSizeWithScroll();			
			$('#modalReturn').css({'top' : (height+100)+'px', 'left' : ((width-660)/2)+'px'}).show();			
			$('#cancel_save').bind("click", function(e){
				modal_close();
				return false;
				});
			/*
			$(window).scroll(function(e){
				var height = getPageSizeWithScroll();							
				$('#modalReturn').css({'top' : (height+100)+'px'})
				});
			*/
			$(window).resize(function(e){
				var width = windowSize();
				var height = getPageSizeWithScroll();			
				$('#modalReturn').css({'top' : (height+100)+'px', 'left' : ((width-660)/2)+'px'}).show();			
				});
			
			$('#save_est_form').bind("click", function(e){
				if (validateSaveForm() == true) {
					subscribeMsg = '';
					$('form input:text').each(function(){
						var newValue = $(this).val().replace(/<(?:;.|\s)*?>/g,'');
						$(this).val(newValue);		
						});					
					if ($('#cust_newsletter:checked').length == 0) {
						var email = $('#cust_email').val().replace('@','%40');
						var name = $('#cust_name').val().replace(' ','%20');
						$.ajax({
							type: "POST",
							url: 'http://www.albemarlecarpet.com/data/create_contact.php',
							data: 'cust_name='+name+'&cust_email='+email,
							success: function(msg){
								if (msg == 'Success') {
									subscribeMsg += ' Thank you for subscribing to our newsletter.';
									return subscribeMsg;
									}
								}
							});																	
						}
					$('.modal .wrap').prepend('<div class="timeout"></div>');
					$('#printonly').val('false');
					var data = $('form#est_form').serialize();
					var url = $('form#est_form').attr('action');
					$.ajax({
						type: "POST",
						url: url,
						data: data,
						success: function(msg){ $('.modal .wrap .timeout').remove(); $('#modalReturn').prepend('<span class="sysMsg">'+ msg +'<br />' + subscribeMsg +'</span>'); setTimeout(function() {modal_close();},3000); },
						error: function(XMLHttpRequest, textStatus, errorThrown){ $('#modalReturn').prepend( '<span class="sysMsg">Error: '+textStatus +'</span>'); }	
						});					
					}
				return false;
				});			
			return false;
			});

		$('#print_est_form').click(function(){
			$('#printonly').val('true');			
			var url = $('form#est_form').attr('action');
			document.forms['est_form'].method = 'post';
			document.forms['est_form'].action = url;
			document.forms['est_form'].target = '_blank';
			document.forms['est_form'].submit();
			return false;
			});
		/*
		$('*:not(#modalReturn)').click(function(){
			
			if ($('#modalReturn:visible').length > 0) {
				$('#modalReturn:visible').hide();
				return false;
				}
			});
		*/
		totalTheForm();
		});
