function getCompare(f) {
	var R = '';
	var cnt = 0;
	for(var n=0; n<50; n++) {

		var e = document.getElementById("comp"+n);
		if(e != null) {
			if(e.checked) {
				R += e.value + ' ';
				cnt++;
			}
		}
	}

	if(cnt < 2) {
		alert("Please Select at least (2) two products for comparision");
		return false;
	}

	if(R.length > 0) {
		f.R.value = R;
		return true;
	} else {
		return false;
	}
}

function validateChecks(f) {

	var R = '';
	var chkCnt = 0;
	for(var n=0; n<50; n++) {

		var e = document.getElementById("comp"+n);
		if(e != null) {
			if(e.checked) {
				chkCnt++;
			}
		}

		if(chkCnt > 4) {
			alert("You may select up to (4) four products to compare");
			f.checked = false;
			break;
		}
	}


}

$(function() {
	$("form.price").each(function() {

		var el_id = this.id.value;

		$("#show_all_link_" + el_id).toggle(function(){
		  $("#show_all_ul_" + el_id).slideDown();
		  $("#show_all_link_" + el_id).text("Hide");
		  $("#show_all_plus_" + el_id).text("-");
		},function(){
		  $("#show_all_ul_" + el_id).slideUp();
		  $("#show_all_link_" + el_id).text("Show All Fits");
		  $("#show_all_plus_" + el_id).text("+");
		});

	});

	$("form.price").each(function() {

		var el_id 		= this.id.value;
		var el_pnum 	= this.part_number.value;
		var el_bc 		= this.brand_code.value;
		var el_price 	= this.price.value;
		var el_core 	= this.core.value;

			if (parts[el_pnum + "Ç" + el_bc] != undefined) {
				el_price 				= parts[el_pnum + "Ç" + el_bc].price;
				el_core 				= parts[el_pnum + "Ç" + el_bc].core;
				this.bpp.value 	= parts[el_pnum + "Ç" + el_bc].key;
				this.price.value = el_price;
				this.core.value	 = el_core;

			}

		$("#price_" + el_id).html('$' + fmtMoney(el_price,2,'.',','));
		if (el_core > 0) {
			$("#core_" + el_id).append('$' + fmtMoney(el_core,2,'.',','));
			$("#core_" + el_id).css('display', 'block');
		}
	});

	var cat_id = 0;

	$("div.cat_li_toggle").each(function() {

		cat_id++;
		var cat_id_id = cat_id;

		$(this).click(function() {

			var el_li 		= document.getElementById("cat_li_id_" + cat_id_id);
			var el_img_li = document.getElementById("img_li_id_" + cat_id_id);

			if (el_li.style.display == 'none') {
				$(el_li).slideDown();
				el_img_li.src = 'images/minus.png';
			} else {
				$(el_li).slideUp();
				el_img_li.src = 'images/plus2.png';
			}

		});

	});


});

var parts = [];