var sendForm=false;

function prepareSubmit(form) {
	if(!sendForm) validateComparisonLink(form);
return sendForm;
}

function validateComparisonLink(form) {

sendForm=true;
 if(comparisonLinkCount(form) == 0) {
 alert("Please select at least one product");
 sendForm=false;
 } 

 if(comparisonLinkCount(form) > 10) {
 alert("Please select up to 10 products only");
 sendForm=false;
 } 

}

function comparisonLinkCount(form) {
var numLinks=0;
var fieldName="";
var fieldtype="";
	for(i=0;i<form.elements.length;i++) {
	fieldName=form.elements[i].name;
	fieldType=form.elements[i].type;
		if(fieldType=="checkbox" && fieldName.toLowerCase().indexOf("compids")!=-1) {
		if(form.elements[i].checked) numLinks++;
		}
	}
return numLinks;
}
