$(document).ready(function(){
    $('.compare-checkbox').click(function(){
        var count = 0; var p1, p2, p1val, p2val;
        $('.compare-checkbox').each(function(){
            if ($(this).attr('checked')) {
                if (count==0) {
					p1 = $(this);
				}
				else {
					p2 = $(this);
				}
                count++;
                if (count == 2) {
                    $('.compare-checkbox').each(function(){
                        $(this).attr('disabled','disabled');
                        $(this).next().css({color:'#c2928b'});
                    });
                    p1.removeAttr('disabled').next().css({color:'#DF321A'});
                    p2.removeAttr('disabled').next().css({color:'#DF321A'});
					
					$("a#myLink").attr('href','compare.aspx?p1=' + p1.val() + '&p2=' + p2.val());
//            		enable the compare button 
					$("a#myLink").css('background-image','url(_includes/images/global/compare-now-btn.gif)'); 
               		$("a#myLink").css('cursor','pointer');

                }
            }
        });
        if (count < 2) {
            $('.compare-checkbox').removeAttr('disabled','disabled');
            $('.compare-checkbox').each(function(){
                $(this).next().css({color:'#DF321A'});
//            		disable the compare button 
				$("a#myLink").attr('href','#');
				$("a#myLink").css('background-image','url(_includes/images/global/compare-now-btn-faded.gif)'); 
                $("a#myLink").css('cursor','default');
            });
       }

    });
});
