$(function(){


	$('.MoreInfoBox').hide();
	$('.SimilarBox').hide();
	
	if(!$('#criteria1').is(':checked'))
	{
		$('#vehicleClass').hide();
	}
	
	if(!$('#showvtype').is(':checked'))
	{
		$('#vehicleType').hide();
	}
	
	if(!$('#showfilter').is(':checked'))
	{
		$('#filters').hide();
	}
	
	if(!$('#showVEDbands').is(':checked'))
	{
		$('#vedbands').hide();
	}
	if(!$('#showMPGbands').is(':checked'))
	{
		$('#mpgbands').hide();
	}
	
	$('.moreinfo').live('click',function(event) {
	
		var index = $('.moreinfo').index(this);
		
		var sim = $('.similar')[index];
		sim.src = "/search_database/images/similar.png";
		
		//next bit of code use to make sure the right image is replaced
		//IE resets the image src when using Ajax !
		var src = $(this).attr("src");
		var strMatch = /moreinfo.png/;
		var matchPos = src.search(strMatch);
		
		if(matchPos != -1) {
			$(this).attr("src","/search_database/images/moreinfo-on.png");
		} else {
		
			$(this).attr("src","/search_database/images/moreinfo.png");
		}
		
		$('#SimilarBox' + index).hide('slow', function() {
			$('#MoreInfoBox' + index).slideToggle('slow');
			if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');
		});


	})
	
	$('.similar').live('click',function(event) {
	
		var index2 = $('.similar').index(this);
		
		var moreinfo = $('.moreinfo')[index2];
		moreinfo.src = "/search_database/images/moreinfo.png";
		
		//next bit of code use to make sure the right image is replaced
		//IE resets the image src when using Ajax !
		var src = $(this).attr("src");
		var strMatch = /similar.png/;
		var matchPos = src.search(strMatch);
		
		if(matchPos != -1) {
			$(this).attr("src","/search_database/images/similar-on.png");
		} else {
		
			$(this).attr("src","/search_database/images/similar.png");
		}
		
		$('#MoreInfoBox' + index2).hide('slow', function() {
			$("#SimilarBox" + index2).slideToggle("slow");
			if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');
		});
	})
	
	
	$('#showvtype').click(function(event) {
			 
			$("#vehicleType" ).slideToggle("slow");
	});
	
	$('#showfilter').click(function(event) {

			$("#filters" ).slideToggle("slow");
	});
	
	$('#criteria1').click(function(event) {

			$("#vehicleClass" ).slideToggle("slow");
	});
	
	$('#showVEDbands').click(function(event) {

			$("#vedbands" ).slideToggle("slow");
	});
	
	$('#showMPGbands').click(function(event) {

			$("#mpgbands").slideToggle("slow");
	});
	
	


});