$(document).ready(function() {
    var oldProductSelected = 0;
	$('#compare_selection > select').live('click', function(){
        if ($('#compare_selection option:selected').val() == oldProductSelected) return;        
        else oldProductSelected = $('#compare_selection option:selected').val();        
		var legacyid = $(this).val();
		if(legacyid=="") return;
        if (CheckIfUpdating()) return;		

		$.ajax({
            url:'/ajax/comparison/get-legacy-firmware/legacy_id/'+legacyid,
            type:'GET',
            dataType:'html',
            success : function(data) {
	    		if (!$("#results_box").length)
	    		{
	    			$("#update_box").attr('id', 'results_box');
	    		};
	            $("#results_box").html('<div id="compare_result"></div>');	    		
                $("#results_box > #compare_result").html(data);
            },
            error : function(xhr) {
            	ErrorMessage(xhr);
            }
        });
	});
});
