// step 1 vars
var step1ItemText   = 'felt'; // this value will either be felt or tiled from the selection made on the calculator
var step1ChosenItem = 'Felt';
var calculateError  = true;

// delivery postcodes & prices
var deliveryPostCodes = new Array( 'AB', 'AL', 'B', 'BA', 'BB', 'BD', 'BH', 'BL', 'BN', 'BR', 'BS', 'CA', 'CB', 'CF', 'CH', 'CM', 'CO', 'CR', 'CT', 'CV', 'CW', 'DA', 'DD', 'DE', 'DG', 'DH', 'DL', 'DN', 'DT', 'DY', 'E', 'EC', 'EH', 'EN', 'EX', 'FK', 'FY', 'G', 'GL', 'GU', 'HA', 'HD', 'HG', 'HP', 'HR', 'HU', 'HX', 'IG', 'IP', 'IV', 'KA', 'KT', 'KY', 'L', 'LA', 'LD', 'LE', 'LL', 'LN', 'LS', 'LU', 'M', 'ME', 'MK', 'ML', 'N', 'NE', 'NG', 'NN', 'NP', 'NR', 'NW', 'OL', 'OX', 'PA', 'PE', 'PH', 'PL', 'PO', 'PR', 'RG', 'RH', 'RM', 'S', 'SA', 'SE', 'SG', 'SK', 'SL', 'SM', 'SN', 'SO', 'SP', 'SR', 'SS', 'ST', 'SW', 'SY', 'TA', 'TD', 'TF', 'TN', 'TQ', 'TR', 'TS', 'TW', 'UB', 'W', 'WA', 'WC', 'WD', 'WF', 'WN', 'WR', 'WS', 'WV', 'YO' );
var erectionZone 	  = new Array( '4', '2', '3', '3', '4', '4', '3', '4', '1', '1', '3', '4', '2', '3', '4', '1', '2', '1', '1', '3', '3', '1', '4', '3', '4', '4', '4', '3', '3', '3', '2', '2', '4', '1', '4', '4', '4', '4', '3', '1', '1', '3', '4', '2', '3', '3', '4', '1', '2', '4', '4', '1', '4', '4', '4', '4', '3', '4', '3', '4', '2', '4', '1', '2', '4', '2', '4', '3', '3', '3', '3', '2', '4', '3', '4', '3', '4', '4', '2', '4', '2', '1', '1', '3', '4', '2', '2', '3', '2', '1', '3', '2', '3', '4', '1', '3', '2', '4', '3', '4', '3', '1', '4', '4', '4', '1', '1', '2', '4', '2', '1', '4', '4', '3', '3', '3', '4' );
var postCodePrices    = new Array( '750', '50', '180', '200', '440', '410', '150', '410', '0', '0', '200', '580', '60', '260', '410', '0', '40', '0', '0', '140', '270', '0', '680', '210', '620', '480', '450', '270', '200', '200', '50', '50', '640', '0', '350', '650', '460', '650', '190', '0', '0', '300', '410', '50', '250', '280', '390', '0', '90', '780', '660', '0', '670', '400', '490', '390', '150', '460', '220', '370', '50', '390', '0', '80', '650', '50', '530', '210', '110', '250', '160', '50', '410', '120', '650', '120', '700', '450', '90', '430', '90', '0', '0', '260', '430', '50', '50', '280', '50', '0', '140', '110', '140', '490', '0', '250', '50', '360', '270', '620', '230', '0', '390', '530', '450', '0', '0', '50', '380', '50', '0', '370', '400', '230', '200', '200', '410' );


// step 2 vars
var step2Price           = 0;
var step2ChosenSize      = 'Single'; // this value will either be single or double
var step2ItemText        = '';

var step2SingleSizes     = new Array('Please Select','3.00m x 4.94m', '3.00m x 5.54m', '3.00m x 6.18m');
var step2SingleSizesText = new Array('','3.00m long x 4.94m wide', '3.00m long x 5.54m wide', '3.00m long x 6.18m wide');
var step2SingleWidths    = new Array('','4.94', '5.54', '6.18');
//single erect zone prices
var singleEZ1 			 = new Array('','230','230','380','');
var singleEZ2 			 = new Array('','251','251','401','');
var singleEZ3 			 = new Array('','283','283','433','');
var step2tiledSingleEZPrices  = new Array('',(singleEZ1), (singleEZ2), (singleEZ3) );

var singleEZ1f 			 = new Array('','230','230','380','');
var singleEZ2f 			 = new Array('','251','251','401','');
var singleEZ3f 			 = new Array('','283','283','433','');
var step2feltSingleEZPrices  = new Array('',(singleEZ1f), (singleEZ2f), (singleEZ3f) );

var step2DoubleSizes     = new Array('Please Select','5.40m x 4.94m', '6.00m x 4.94m', '5.40m x 5.54m', '6.00m x 5.54m', '5.40m x 6.18m', '6.00m x 6.18m');
var step2DoubleSizesText = new Array('','5.40m long x 4.94m wide', '6.00m long x 4.94m wide', '5.40m long x 5.54m wide', '6.00m long x 5.54m wide', '5.40m long x 6.18m wide', '6.00m long x 6.18m wide');
var step2DoubleWidths    = new Array('','4.94', '4.94', '5.54', '5.54', '6.18', '6.18');
//double erect zone prices
var doubleEZ1 			 = new Array('','402','402','627','');
var doubleEZ2 			 = new Array('','428','428','653','');
var doubleEZ3 			 = new Array('','436','436','661','');
var doubleEZ4 			 = new Array('','464','464','689','');
var doubleEZ5 			 = new Array('','499','499','724','');
var doubleEZ6 			 = new Array('','528','528','753','');
var step2tiledDoubleEZPrices  = new Array('',(doubleEZ1), (doubleEZ2), (doubleEZ3),(doubleEZ4), (doubleEZ5), (doubleEZ6) );

var doubleEZ1f 			 = new Array('','402','402','627','');
var doubleEZ2f 			 = new Array('','428','428','653','');
var doubleEZ3f 			 = new Array('','436','436','661','');
var doubleEZ4f			 = new Array('','464','464','689','');
var doubleEZ5f 			 = new Array('','499','499','724','');
var doubleEZ6f 			 = new Array('','528','528','753','');
var step2feltDoubleEZPrices  = new Array('',(doubleEZ1f), (doubleEZ2f), (doubleEZ3f),(doubleEZ4f), (doubleEZ5f), (doubleEZ6f) );

// step 2 felt prices
var step2SingleFeltPrices  = new Array('0','2089', '2285', '2575');
var step2DoubleFeltPrices  = new Array('0','3095', '3290', '3355', '3565', '3835', '4065');
// step 2 tile prices
var step2SingleTiledPrices = new Array('0','2424', '2704', '2860');
var step2DoubleTiledPrices = new Array('0','3542', '3765', '3866', '4099', '4192', '4440');

// step 3 (garage) vars
var step3Price        = 0;
var step3ItemText     = '';
var step3Direction    = 'L';
var step3BasketAdjust = true;
var step3Sizes        = new Array('Please Select', '3.00m x 4.94m', '3.60m x 4.94m', '3.00m x 5.54m', '3.60m x 5.54m', '3.00m x 6.18m', '3.60m x 6.18m');
var step3SizesText    = new Array('', '3.00m long x 4.94m wide', '3.60m long x 4.94m wide', '3.00m long x 5.54m wide', '3.60m long x 5.54m wide', '3.00m long x 6.18m wide', '3.60m long x 6.18m wide');
var step3Widths       = new Array('', '4.94', '4.94', '5.54', '5.54', '6.18', '6.18');

//garage erect zone prices
var garageEZ1 			 = new Array('','220','220','220','');
var garageEZ2 			 = new Array('','244','244','244','');
var garageEZ3 			 = new Array('','236','236','236','');
var garageEZ4 			 = new Array('','263','263','263','');
var garageEZ5 			 = new Array('','267','267','267','');
var garageEZ6 			 = new Array('','296','296','296','');
var step3EZtiledPrices  = new Array('',(garageEZ1), (garageEZ2), (garageEZ3),(garageEZ4), (garageEZ5), (garageEZ6) );

var garageEZ1f 			 = new Array('','220','220','220','');
var garageEZ2f 			 = new Array('','244','244','244','');
var garageEZ3f 			 = new Array('','236','236','236','');
var garageEZ4f 			 = new Array('','263','263','263','');
var garageEZ5f 			 = new Array('','267','267','267','');
var garageEZ6f 			 = new Array('','296','296','296','');
var step3EZfeltPrices  = new Array('',(garageEZ1f), (garageEZ2f), (garageEZ3f),(garageEZ4f), (garageEZ5f), (garageEZ6f) );


var step3FeltPrices   = new Array('0', '1690', '1875', '1815', '2020', '2055', '2280');
var step3TiledPrices  = new Array('0', '1830', '2043', '1930', '2158', '2145', '2388');

// step 4 (workshop) vars
var step4Price        = 0;
var step4ItemText     = '';
var step4Direction    = 'L';
var step4BasketAdjust = true;
var step4Sizes        = new Array('Please Select', '2.40m x 4.94m', '3.00m x 4.94m', '2.40m x 5.54m', '3.00m x 5.54m', '2.40m x 6.18m', '3.00m x 6.18m');
var step4SizesText    = new Array('Please Select', '2.40m long x 4.94m wide', '3.00m long x 4.94m wide', '2.40m long x 5.54m wide', '3.00m long x 5.54m wide', '2.40m long x 6.18m wide', '3.00m long x 6.18m wide');
var step4Widths       = new Array('', '4.94', '4.94', '5.54', '5.54', '6.18', '6.18');


//workshop erect zone prices
var workshopEZ1 			 = new Array('','190','190','190','');
var workshopEZ2 			 = new Array('','214','214','214','');
var workshopEZ3 			 = new Array('','206','206','206','');
var workshopEZ4 			 = new Array('','231','231','231','');
var workshopEZ5 			 = new Array('','237','237','237','');
var workshopEZ6 			 = new Array('','265','265','265','');
var step4EZtiledPrices  = new Array('',(workshopEZ1), (workshopEZ2), (workshopEZ3),(workshopEZ4), (workshopEZ5), (workshopEZ6) );

var workshopEZ1f 			 = new Array('','190','190','190','');
var workshopEZ2f 			 = new Array('','214','214','214','');
var workshopEZ3f 			 = new Array('','206','206','206','');
var workshopEZ4f 			 = new Array('','231','231','231','');
var workshopEZ5f 			 = new Array('','237','237','237','');
var workshopEZ6f 			 = new Array('','265','265','265','');
var step4EZfeltPrices  = new Array('',(workshopEZ1f), (workshopEZ2f), (workshopEZ3f),(workshopEZ4f), (workshopEZ5f), (workshopEZ6f) );

var step4FeltPrices   = new Array('0', '1465', '1645', '1585', '1780', '1820', '2035');
var step4TiledPrices  = new Array('0', '1577', '1785', '1680', '1895', '1892', '2125');

// step 5 vars
var step5PostCodes = deliveryPostCodes;     //  "deliveryPostCodes" is defined in passmores.js
var step5Prices    = postCodePrices;        //  "postCodePrices" is defined in passmores.js
var step5Value     = step5PostCodes[0];
var step5Price     = step5Prices[0];
var erectionPrice  = 0;
var erection2SizeIndex  = 0;
var erection3SizeIndex  = 0;
var erection4SizeIndex  = 0;
var erectionPostCodeIndex  = 0;
var mainErectPrice = 0;
var garageErectPrice = 0;
var workshopErectPrice = 0;

// step 1 functions
function setStep1Choice(choice) {

	erection3SizeIndex = 0;
    $('step3Body').hide();
    step3Price = 0;
    step3ItemText = '';
    $('step3Size').options.selectedIndex = 0;
    $('workshopSelect').options.selectedIndex = 0;
    
    erection4SizeIndex = 0;
    $('step4Body').hide();
    step4Price = 0;
    step4ItemText = '';
    $('step4Size').options.selectedIndex = 0;
    $('garageSelect').options.selectedIndex = 0;
        
	
    step1ItemText   = choice;
    step1ChosenItem = step1ItemText.substr(0, 1).toUpperCase() + step1ItemText.substr(1);
    setStep2Price($('step2Size').options[$('step2Size').options.selectedIndex].value);
    if ($('step3Size').options.selectedIndex > 0) {
        setStep3Price($('step2Size').options[$('step2Size').options.selectedIndex].value);
    }
    if ($('step4Size').options.selectedIndex > 0) {
        setStep4Price($('step2Size').options[$('step2Size').options.selectedIndex].value);
    }
    
}

// step 2 functions
function step2SizeChoice(sizeChoice) {
    step2ChosenSize = sizeChoice;
    sizeArray = eval('step2' + step2ChosenSize + 'Sizes');

    $('step2Size').options.length = 0;
    for (i=0; i<sizeArray.length; i++) {
        $('step2Size').options[i] = new Option(sizeArray[i], i);
    }  
    step2Price = 0;
    calculateError  = true;
    
    erection3SizeIndex = 0;
    $('step3Body').hide();
    step3Price = 0;
    step3ItemText = '';
    $('step3Size').options.selectedIndex = 0;
    $('workshopSelect').options.selectedIndex = 0;
    
    erection4SizeIndex = 0;
    $('step4Body').hide();
    step4Price = 0;
    step4ItemText = '';
    $('step4Size').options.selectedIndex = 0;
    $('garageSelect').options.selectedIndex = 0;
    
    garageErectPrice = 0;
	workshopErectPrice = 0;
    
    
}

function setStep2Details(index) {
    setStep2Price(index);
    setStep3Sizes(step2WidthArray[index]);
    setStep4Sizes(step2WidthArray[index]);
    
    erection2SizeIndex=index;
    if( erectionPostCodeIndex > 0 ){
    	mainErectPrice = eval('step2' + step1ItemText + step2ChosenSize + 'EZPrices[' + erection2SizeIndex + '][' + erectionZone[erectionPostCodeIndex] + ']');
    }
}

function setStep2Price(index) {
    chosenSizeArray  = eval('step2' + step2ChosenSize + 'SizesText');
    step2WidthArray  = eval('step2' + step2ChosenSize + 'Widths');
    step2ItemText    = chosenSizeArray[index] + ' ' + step2ChosenSize.toLowerCase() + ' bay carriage house with ' + step1ItemText + ' roof';
    chosenPriceArray = eval('step2' + step2ChosenSize + step1ChosenItem + 'Prices');
    step2Price       = chosenPriceArray[index];
}

// step 3 functions
function showStep3(show) {
	garageErectPrice = 0;
    if (show == 1) {
        $('step3Body').show();
    } else {
    	erection3SizeIndex = 0;
        $('step3Body').hide();
        step3Price = 0;
        step3ItemText = '';
        $('step3Size').options.selectedIndex = 0;
    }
}

function setStep3Sizes(step2Width) {
    $('step3Size').options.length = 0;
    var j = 0;
    for (i=0; i<step3Sizes.length; i++) {
        if (step3Widths[i] == step2Width || i < 1) {
            $('step3Size').options[j] = new Option(step3Sizes[i], i);
            j++;
        }
    }
}

function setStep3Direction(direction) {
    step3Direction = direction;
    setStep3Price($('step3Size').options[$('step3Size').options.selectedIndex].value);
}

function setStep3Price(index) {

	erection3SizeIndex = index;
	
    step3Price = eval('step3' + step1ChosenItem + 'Prices[index]');
    step3ItemText = step3SizesText[index] + ' integral garage with ' + step1ItemText + ' roof ' + step3Direction;
    

    
}

// step 4 functions
function showStep4(show) {
	workshopErectPrice = 0;
    if (show == 1) {
        $('step4Body').show();
    } else {
    	erection4SizeIndex = 0;
        $('step4Body').hide();
        step4Price = 0;
        step4ItemText = '';
        $('step4Size').options.selectedIndex = 0;
    }
}

function setStep4Sizes(step2Width) {
    $('step4Size').options.length = 0;
    var j = 0;
    for (i=0; i<step4Sizes.length; i++) {
        if (step4Widths[i] == step2Width || i < 1) {
            $('step4Size').options[j] = new Option(step4Sizes[i], i);
            j++;
        }
    }
}

function setStep4Direction(direction) {
    step4Direction = direction;
    setStep4Price($('step4Size').options[$('step4Size').options.selectedIndex].value);
}

function setStep4Price(index) {

	erection4SizeIndex = index;
	
    step4Price = eval('step4' + step1ChosenItem + 'Prices[index]');
    step4ItemText = step4SizesText[index] + ' integral workshop with ' + step1ItemText + ' roof ' + step4Direction;
    
//    if( erectionPostCodeIndex > 0 ){
//		workshopErectPrice = eval('step4EZ' + step1ItemText + 'Prices[' + erection4SizeIndex + '][' + erectionZone[erectionPostCodeIndex] + ']');
//		//alert(workshopErectPrice);
//	}
    
}

function setStep5PostCodes() {
	
    $('step5PostCodes').options.length = 0;
    $('step5PostCodes').options[0] = new Option("Please Select","");
    for (i=0; i<step5PostCodes.length; i++) {
        $('step5PostCodes').options[i+1] = new Option(step5PostCodes[i], i);
    }
}

function setStep5Price(index) {
	
	erectionPostCodeIndex = index;
	if( erectionZone[erectionPostCodeIndex] == '4' ){
		
		var i;
        for(i = $('erectChange').options.length - 1 ; i >= 0 ; i-- ) {
            $('erectChange').remove(i);
        }
		$('erectChange').options[ 0 ] = new Option( 'N/A', 'N/A' );
		$('erectChange').options[0].selected = true;
		
		mainErectPrice = 0;
		garageErectPrice = 0;
		workshopErectPrice = 0;
		
	}else{
		var i;
        for(i = $('erectChange').options.length - 1 ; i >= 0 ; i-- ) {
            $('erectChange').remove(i);
        }
		$('erectChange').options[ 0 ] = new Option( 'Please Select', 'Please Select' );
		$('erectChange').options[ 1 ] = new Option( 'No', 'No' );
		$('erectChange').options[ 2 ] = new Option( 'Yes', 'Yes' );
		$('erectChange').options[0].selected = true;
	}
    step5Value = step5PostCodes[index];
    step5Price = step5Prices[index];
}

function setStep6Price(value) {
	
	if( value == 'Yes' ){
		
		mainErectPrice = eval('step2' + step1ItemText + step2ChosenSize + 'EZPrices[' + erection2SizeIndex + '][' + erectionZone[erectionPostCodeIndex] + ']');
		//alert(mainErectPrice);
		
		if( erection3SizeIndex > 0 ){
			garageErectPrice = eval('step3EZ' + step1ItemText + 'Prices[' + erection3SizeIndex + '][' + erectionZone[erectionPostCodeIndex] + ']');
			//alert(garageErectPrice);
		}
		
		if( erection4SizeIndex > 0 ){
			workshopErectPrice = eval('step4EZ' + step1ItemText + 'Prices[' + erection4SizeIndex + '][' + erectionZone[erectionPostCodeIndex] + ']');
			//alert(workshopErectPrice);
		}
	
	}else{
		mainErectPrice = 0;
		garageErectPrice = 0;
		workshopErectPrice = 0;
	}
	
}


function calculateTotal() {
	
    calculateError = false;

    if( step2Price > 0 ){
    
	    $('step2Text').update(step2ItemText);
	    $('step2Price').update( '&pound;' + addCommas(parseInt(step2Price).toFixed(2)) );
	    if (step2ItemText.length > 0) {
	        $('step2BasketDetails').show();
	    } else {
	        //alert('You must select a size of Carriage House before you can calculate a build price');
	        alert('No details entered. Please complete steps 1 to 6 on the Carriage House calculator.');
	        calculateError = true;
	    }
    }else{
    	alert('No details entered. Please complete steps 1 to 6 on the Carriage House calculator.');
	    calculateError = true;
    }

    $('step3Text').innerHTML = step3ItemText;
    $('step3Price').innerHTML = (step3Price > 0) ? '&pound;' + addCommas(parseInt(step3Price).toFixed(2)) : '';
    if (step3ItemText.length > 0) {
        $('step3BasketDetails').show();
        if (step3BasketAdjust) {
            floatingMenu.targetY -= 80;
            step3BasketAdjust = false;
        }
    } else if ($('step3Body').style.display != 'none') {
        //alert('You must select a size of garage that you want to join to your Carriage House before you can calculate a build price');
        alert('No details entered. Please complete steps 1 to 6 on the Carriage House calculator.');
        calculateError = true;
    }

    $('step4Text').innerHTML = step4ItemText;
    $('step4Price').innerHTML = (step4Price > 0) ? '&pound;' + addCommas(parseInt(step4Price).toFixed(2)) : '';
    if (step4ItemText.length > 0) {
        $('step4BasketDetails').show();
        if (step4BasketAdjust) {
            floatingMenu.targetY -= 80;
            step4BasketAdjust = false;
        }
    } else if ($('step4Body').style.display != 'none') {
        //alert('You must select a size of workshop that you want to join to your Carriage House before you can calculate a build price');
        alert('No details entered. Please complete steps 1 to 6 on the Carriage House calculator.');
        calculateError = true;
    }


    if (!calculateError) {
    	
    	
    	var mainPrice 			= parseFloat(step2Price) + parseFloat(step3Price) + parseFloat(step4Price);
    	
    	//  Show 10% saving for buying online
        var discount = Math.round(( mainPrice * 10 )  * 1.15) / 100 ;     //  Round to 2 decimal places
        discount     = discount.toString();

        //  Add
        switch ( discount.indexOf('.') ) {

            case -1:
                discount += '.00';
            break;

            case ( discount.length - 2 ) :
                discount += '0';
            break;

        }
    	
        if( $('erectChange').options[$('erectChange').options.selectedIndex].value == 'Yes' ){
			
			mainErectPrice = eval('step2' + step1ItemText + step2ChosenSize + 'EZPrices[' + erection2SizeIndex + '][' + erectionZone[erectionPostCodeIndex] + ']');
			//alert(mainErectPrice);
			
			if( erection3SizeIndex > 0 ){
				
				garageErectPrice = eval('step3EZ' + step1ItemText + 'Prices[' + erection3SizeIndex + '][' + erectionZone[erectionPostCodeIndex] + ']');
				//alert(garageErectPrice);
			}
			
			if( erection4SizeIndex > 0 ){
				
				workshopErectPrice = eval('step4EZ' + step1ItemText + 'Prices[' + erection4SizeIndex + '][' + erectionZone[erectionPostCodeIndex] + ']');
				//alert(workshopErectPrice);
			}
		
		}else{
			mainErectPrice = 0;
			garageErectPrice = 0;
			workshopErectPrice = 0;
		}
        
    	
    	var erectionCharge = (parseInt(mainErectPrice)) + (parseInt(garageErectPrice)) + (parseInt(workshopErectPrice));
        $('erectionCharge').innerHTML = '&pound;' + addCommas(parseFloat(erectionCharge).toFixed(2));
    	
        var deliveryCharge = step5Price;
        $('deliveryCharge').innerHTML = '&pound;' + addCommas(parseFloat(deliveryCharge).toFixed(2));

        var subTotal = parseFloat(erectionCharge) + parseFloat(deliveryCharge) + mainPrice;
        $('subTotal').innerHTML = '&pound;' + addCommas(parseFloat(subTotal).toFixed(2));   

        var vatAmount = parseFloat(subTotal) * 0.15;
        $('vatAmount').innerHTML = '&pound;' + addCommas(parseFloat(vatAmount).toFixed(2));

        var grossTotal = parseFloat(subTotal) + parseFloat(vatAmount);
        $('grossTotal').innerHTML = '&pound;' + addCommas(parseFloat(grossTotal).toFixed(2));

        

        $('save_5_percent').update( '\u00A3' + discount );

        $('step2Details').value          = step2ItemText;
        $('step2PriceDetails').value     = step2Price;
        $('step3Details').value          = step3ItemText;
        $('step3PriceDetails').value     = step3Price;
        $('step4Details').value          = step4ItemText;
        $('step4PriceDetails').value     = step4Price;
        $('deliveryPostCode').value      = step5Value;
        $('deliveryChargeDetails').value = deliveryCharge;
        $('subTotalDetails').value       = subTotal;
        $('vatAmountDetails').value      = vatAmount;
        $('grossTotalDetails').value     = grossTotal;
        $('discountDetails').value       = discount;
        $('postalLocation').innerHTML 	 = ' to postal area '+ step5Value;

    }

}

// thousand separator function
function addCommas( sValue ) {
    var sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
    while (sRegExp.test(sValue)) {
        sValue = sValue.replace(sRegExp, '$1,$2');
    }
    return sValue;
}


function submitBuyForm() {
    if (!calculateError) {
        $('buyOnlineForm').submit();
    } else {
        alert('No details entered. Please complete steps 1 to 6 on the Carriage House calculator.');
    }
}

function resetCalculator(step){
	
	switch(step){
		case'1':
			
			//reset initial
			
			calculateError  = true;
			sizeArray = eval('step2' + step2ChosenSize + 'Sizes');
		    $('step2Size').options.length = 0;
		    for (i=0; i<sizeArray.length; i++) {
		        $('step2Size').options[i] = new Option(sizeArray[i], i);
		    }  
		case'2':
			
		case'3':
		
			step3Price        = 0;
			
		case'4':
			step4Price        = 0;
		case'5':
		
			step5Value     = step5PostCodes[0];
			step5Price     = 0;
			erectionPrice  = 0;
			erection2SizeIndex  = 0;
			erection3SizeIndex  = 0;
			erection4SizeIndex  = 0;
			erectionPostCodeIndex  = 0;
			mainErectPrice = 0;
			garageErectPrice = 0;
			workshopErectPrice = 0;
	
		break;
	}
	
}



// init functions
step2SizeChoice(step2ChosenSize);
setStep5PostCodes();