﻿//script for compare functionality
// - 4/16/05 - Cy Huckaba - Springbox
			
function doCount(el){
	var count = 0;
	var maxcompare = 5;
	var cBoxes = document.getElementsByName("chkCompare");

	for (var i=0;i < cBoxes.length;i++){
		if (cBoxes[i].checked) {
			count++;
		}
	}
	if (count > maxcompare) {
		alert('You may compare up to ' + maxcompare + ' items at a time.\n\nThe last selection will be ignored.');
		el.checked = false;
	}
}

function doCompare(sectionid){
	var count = 0;
	var url = "/Find-Your-Home/Compare-Communities.aspx?";
	var strVars = "";
	var cBoxes = document.getElementsByName("chkCompare");
	for (var i=0;i < cBoxes.length;i++){
		if (cBoxes[i].checked) {
			count++;
			if (strVars != "") {
				strVars = strVars + "&";	
			}
			
			strVars = strVars + "c=" + cBoxes[i].value;
		}
	}
	
	if (count > 1) {
		//alert(url + strVars);
		window.location = url + strVars + "&s=" + sectionid;
	} else {
		alert('You have not selected more than one item to compare.\n\nPlease select up to ' + maxcompare + ' items to use this feature.');
	}
	
	//return false;
}