function getstep2_VB(m) {
	$('step2').show();
	
	var m = $('option1').value;
	
	$('option1').disabled = true;
	$('option2').disabled = false;
	
	var option2 = new Array();
	var option2_values = new Array();
	var option2_text = new Array();
	
	if (m != 'VDB-LGSCREWS') {
	
		option2[0] = 'DuraTech Chimney Connector';
		option2_values[0] = 'VDB'+m+'CA-DURA';
		option2[1] = 'Selkirk MetalBest Chimney Connector';
		option2_values[1] = 'VDB'+m+'CA-META';
		option2[2] = 'ICC Excel Class-A Chimney';
		option2_values[2] = 'ICC';
		option2[3] = 'Secure Temp Class-A Chimney';
		option2_values[3] = 'Secure';
		option2[4] = 'Metal-Fab Temp Guard Class-A Chimney';
		option2_values[4] = 'Metal-Fab';
	}
	
	if (m == 'VDB-LGSCREWS') {
			
		option2[0] = 'DuraTech Chimney Connector - 6" diameter';
		option2_values[0] = 'VDB06CA-DURA';
		option2[1] = 'DuraTech Chimney Connector - 7" diameter';
		option2_values[1] = 'VDB07CA-DURA';
		option2[2] = 'DuraTech Chimney Connector - 8" diameter';
		option2_values[2] = 'VDB08CA-DURA';
		option2[3] = 'Selkirk MetalBest Chimney Connector - 6" diameter';
		option2_values[3] = 'VDB06CA-META';
		option2[4] = 'Selkirk MetalBest Chimney Connector - 7" diameter';
		option2_values[4] = 'VDB07CA-META';
		option2[5] = 'Selkirk MetalBest Chimney Connector - 8" diameter';
		option2_values[5] = 'VDB08CA-META';
		option2[6] = 'ICC Excel Class-A Chimney';
		option2_values[6] = 'ICC';
		option2[7] = 'Secure Temp Class-A Chimney';
		option2_values[7] = 'Secure';
		option2[8] = 'Metal-Fab Temp Guard Class-A Chimney';
		option2_values[8] = 'Metal-Fab';
	}
	
	var option2_dropdown = document.forms[1].option2;
	option2_dropdown.options[0] = new Option('Select Option 2', '');
	if (option2.length > 1) {
        for (i=0;i<option2.length;i++) {
        	option2_dropdown.options[i+1] = new Option(option2[i],option2_values[i]);
        }
    }
    
}

function calculatePrice() {
	var containerDiv = $('sized_pricing');
	containerDiv.innerHTML = '';
	
	var feet = $('feet').value;
	var shape = $('shape').value;
	
	if (shape == 'Oval') {
		var price = 1.50;
	}
	
	if (shape == 'Rectangle') {
		var price = 2.00;
	}
	
	if (shape == 'Square') {
		var price = 2.00;
	}
	
	total_price = price * feet;
	
	alert(total_price);
	
	total_price = total_price.toFixed(2);
	
	alert(total_price);
	
	var minor = $('minor').value;
	
	var html = '<p><strong>'+shape+ ' Liner</strong><br />';
	html+= '<strong>Number of Feet: </strong> ' + feet + '</br>';
	html+= '<strong>New Dimensions in Inches:</strong> ' + minor + '</p>';
	html+= '<p><strong>Price:</strong> $' + total_price + '</p>';
	
	containerDiv.innerHTML = html;
	
}

// Ajax Request
function buildList_VB(p) {
    
    // Parameters for request
    // p = parameters
    var loc = new String(window.parent.document.location);
	if (loc.indexOf("https://")!= -1)
	prefix = "https://";
	else
	prefix = "http://"; 
    
       
    var myAjax = new Ajax.Request(
        prefix+'www.olympiachimney.com/xml/cl_create_xml.php', 
        {method: 'post', parameters: p, onComplete: pushoptions_VB}
        );
    
}// end reqXML()

function pushoptions_VB(originalRequest) {
	
    var price_options = new Array();
    
    var xmlResponse = originalRequest.responseXML;

    var prices = xmlResponse.getElementsByTagName('prices');
    
    if (prices.length > 0) {
        
        
        var prices_array = '';
        var price = '';
        prices_array = xmlResponse.getElementsByTagName('price');
		price = prices_array[0].firstChild.data;
		feet = $('feet').value;
		
		
		total_price = price * feet;
		total_price = total_price.toFixed(2);
		
		
        $('price_per_foot').innerHTML = '<p><strong>Price per foot:</strong> $' + price + '<br /><strong>Estimated Total:</strong> $' + total_price + '</p>';
        
        
        $('price').value = total_price;
    
    } ///

	
}

function activate_VB(m) {

	var option2 = $('option2').value;	
	
	if (option2 == 'VDB06CA-DURA' || option2 == 'VDB07CA-DURA' || option2 == 'VDB08CA-DURA') {
		$('message').innerHTML = '<p><font color="red">You must purchase this item.</font> This part adapts DuraTech to Ventis&reg; Double Wall Black Stove Pipe. This part <strong>replaces</strong> the DuraTech Close Clearance Connector.</p>';
	}
	
	if (option2 == 'VDB06CA-META' || option2 == 'VDB07CA-META' || option2 == 'VDB08CA-META') {
		$('message').innerHTML = '<p><font color="red">You must purchase this item.</font> This part adapts MetalBest to Ventis&reg; Double Wall Black Stove Pipe. This part <strong>replaces</strong> the MetalBest Chimney Pipe Adapter.</p>';
	}
	
	if (option2 == 'ICC') {
		$('message').innerHTML = '<p>Simply use the Excel Brand Flue Extension.</p>';
	}
	
	if (option2 == 'Secure') {
		$('message').innerHTML = '<p>Simply use the Secure Temp Brand Flue Extension.</p>';
	}
	
	if (option2 == 'Metal-Fab') {
		$('message').innerHTML = '<p>Simply use the Metal-Fab Brand Ceiling Support or Double Wall Adapter.</p>';
	}

	var option1;
	var option2;
	
	$('option1').disabled = false;
	option1 = $('option1').value;	
	$('option1').disabled = true;
	
	$('option2').disabled = false;
	option2 = $('option2').value;
	
	if (option1 == 'VDB-LGSCREWS') {
		option1_price = 1.50;
		option1_id = '4541';
	} else {
		if (option1 == '06') {
			option1 = 'VDB06CA';
			option1_price = 19.35;
			option1_id = '4535';
		} else if (option1 == '07') {
			option1 = 'VDB07CA';
			option1_price = 19.80;
			option1_id = '4562';
		} else if (option1 == '08') {
			option1= 'VDB08CA';
			option1_price = 21.60;
			option1_id = '4534';
		}
	}
	
	if (option2 == 'VDB06CA-DURA') {
		option2_price = 5.99;
		option2_id = '4486';
	} else if (option2 == 'VDB07CA-DURA') {
		option2_price = 5.99;
		option2_id = '4560';
	} else if (option2 == 'VDB08CA-DURA') {
		option2_price = 5.99;
		option2_id = '4536';
	} else if (option2 == 'VDB06CA-META') {
		option2_price = 21.95;
		option2_id = '4487';
	} else if (option2 == 'VDB07CA-META') {
		option2_price = 24.79;
		option2_id = '4561';
	} else if (option2 == 'VDB08CA-META') {
		option2_price = 25.97;
		option2_id = '4537';
	} else {
		option2_id = '';
		option2_price = 0;
	}
	
	var total_price = option1_price + option2_price;
	
	total_price = total_price.toFixed(2);
	
	option1_price = parseFloat(option1_price);
	option2_price = parseFloat(option2_price);
	total_price = parseFloat(total_price);
	
	option1_price = option1_price.toFixed(2);
	option2_price = option2_price.toFixed(2);
	total_price = total_price.toFixed(2);
	
	var html = '<p><strong>Adapter Price:</strong> $' + option1_price + '<br />';
	if (option2_price > 0) {
		html+= '<strong>Connector Price</strong>: $' + option2_price + '<br />';
	}
	html+= '<strong>Total Price</strong>: $' + total_price + '</p>';
	$('price_per_foot').innerHTML = html;
	
	$('option1_item').value = option1;
	$('option1_price').value = option1_price;
	$('option1_id').value = option1_id;
	
	$('option2_item').value = option2;
	$('option2_price').value = option2_price;
	$('option2_id').value = option2_id;
	
	
	$('calculate').disabled = false;
	$('calculate').focus();
}

function redirectTo(url) {
	window.location(url);
}

function resetForm_VB() {
	$('price_per_foot').innerHTML = '';
	$('message').innerHTML = '';
	$('option1').disabled = false;
	$('option2').disabled = true;
	$('step2').hide();
}

function checkForm_VB() {
	
	var error = false;
	if ( $('thickness').value == "" || $('diameter').value == "" || $('feet').value == "" ) {
		error = true;
	}
	
	if (error == true) {
		alert("You are required to select a thickness, diameter, and feet.");
		return false;
	}
		
	$('thickness').disabled = false;
	$('diameter').disabled = false;
	$('feet').disabled = false;
	
	return true;	
}
