
function compare_boroughs() {

	var ajax = get_ajax();
	
	var boroughs = document.getElementById('boroughs');
	var borough_1 = document.getElementById('borough_1');
	var borough_2 = document.getElementById('borough_2');
	var borough_3 = document.getElementById('borough_3');
	var borough_4 = document.getElementById('borough_4');
	var borough_5 = document.getElementById('borough_5');

  	var type      = document.getElementById('type');
	var compare   = document.getElementById('compare_graph');
	compare.style.display = 'block';

	var embed = document.getElementById('embed');

    switch(type.value) {
       	case 'sales': // compare numSold / sales
    		document.getElementById('compare_graph').src = '/graph-compare-borough-sales.php?b1=' + borough_1.value + '&b2=' + borough_2.value + '&b3=' + borough_3.value + '&b4=' + borough_4.value + '&b5=' + borough_5.value;
       	break;
       	case 'price': // compare avPrice
			document.getElementById('compare_graph').src = '/graph-compare-borough-price.php?b1=' + borough_1.value + '&b2=' + borough_2.value + '&b3=' + borough_3.value + '&b4=' + borough_4.value + '&b5=' + borough_5.value;
       	break;
       	case 'monthly-change': // compare avPrice
			document.getElementById('compare_graph').src = '/graph-compare-borough-monthly-change.php?b1=' + borough_1.value + '&b2=' + borough_2.value + '&b3=' + borough_3.value + '&b4=' + borough_4.value + '&b5=' + borough_5.value;
       	break;

	}
			
    embed.innerHTML = embed.innerHTML.replace(/(sales|price|monthly-sales)\.php/, type.value + '.php');
	embed.innerHTML = embed.innerHTML.replace(/b1=([^&]+)/, 'b1=' + borough_1.value);
	embed.innerHTML = embed.innerHTML.replace(/b2=([^&]+)/, 'b2=' + borough_2.value);
	embed.innerHTML = embed.innerHTML.replace(/b3=([^&]+)/, 'b3=' + borough_3.value);
	embed.innerHTML = embed.innerHTML.replace(/b4=([^&]+)/, 'b4=' + borough_4.value);
	embed.innerHTML = embed.innerHTML.replace(/b5=([^"]+)/, 'b5=' + borough_5.value);

}