function getMatBottom(){
	this.baseURL = "";
	var that = this;

	this.getFirmwareMatBottom = function(){
		$('a.firmware, td.more').click(
				function(){
					var jq = $(this);
					var firmware = jq.attr('firmwareid');
					if(firmware){
					$.ajax(
							{
								url:that.baseURL+'/ajax/firmware/get-firmware-info/firmware_id/'+firmware,
								type:'GET',
								dataType:'html',
								success:function(data){
									MB_bottom.addContent(jq.attr('title'),data,function(){
										$('.matbox .additional_detail').load(that.baseURL+'/ajax/firmware/get-firmware-coverage/firmware_id/'+firmware);
										});
									
								},
				                error : function(xhr) {
				                	ErrorMessage(xhr);
								}
							}
						);
					}
				}
			);
	};
	this.getFeatureMatBottom = function(){
		$('td.table_bull').click(
				function(){
				var jq = $(this);
				var modelid = jq.attr('modelid');
				var product_id = $("tr.vehicle_list").attr('productid');
				var ss_product_id = $("tr.vehicle_list").attr('ssproductid');
				if(product_id)
					uri = '/product_id/'+product_id;
				else if(ss_product_id)
					uri = '/store_id/'+ss_product_id;
				else return ErrorMessage('No product id was specified');
				if(modelid){
				$.ajax(
						{
							url:that.baseURL+'/ajax/product/get-vehicle-product-feature/lan/En/model/'+modelid+uri,
							type:'GET',
							dataType:'html',
							success:function(data){
								MB_bottom.addContent("",data,function(){});
							},
				            error : function(xhr) {
				               	ErrorMessage(xhr);
							}
						}
					);
				}
			}
		);
	};
	this.getSearchFeatureMatBottom = function(){
		$('a.details').click(
				function(){
				var jq = $(this);
				var modelid = jq.attr('vehicleid');
				var product_id = jq.attr('productid');;
				uri = '/product_id/'+product_id;
				if(modelid){
				$.ajax(
						{
							url:that.baseURL+'/ajax/product/get-vehicle-product-feature/lan/En/model/'+modelid+uri,
							type:'GET',
							dataType:'html',
							success:function(data){
								MB_bottom.addContent("",data,function(){});
							},
				            error : function(xhr) {
				               	ErrorMessage(xhr);
							}
						}
					);
				}
			}
		);
	};
}
var getMB = new getMatBottom();
var productSearchResult = {
		mode : false,
		init : function(){
			if( false &&
					$('tr th.feature.fname').size()>25
				|| ($('tr th.accessory').size()!=0 && $('tr th.feature.fname').size()>20)
				|| ($('tr th.price').size()!=0 && $('tr th.feature.fname').size()>22)
				|| ($('tr th.price').size()!=0 && $('tr th.accessory').size()!=0 && $('tr th.feature.fname').size()>18)
					){
						$('div#search_result').addClass('wide');
						$('div#search_result').wrap('<div class="search-shadow"></div>');
					}
			productSearchResult.displayMode();
			$('div#search_result').hide().show();
			$('#switch_mode').click(
				productSearchResult.switchMode
		    	);
			getMB.getFirmwareMatBottom();
			getMB.getSearchFeatureMatBottom();
			$('td.feature.fcategory a[fcategoryid]').mouseover(function(){
				if(!$(this).attr('title')){
					var fcategoryid = $(this).attr('fcategoryid');
					var arr = new Array();
					var jq = $(this).parents('tr[productid]');
					jq = jq.children('td.feature.fname');
					jq = jq.children('a[featureid]');
					jq.each(
							function(){
								if($(this).attr('fcategoryid')!=fcategoryid) return;//
								arr.push($('th.feature.fname[featureid='+$(this).attr('featureid')+'] img').attr('alt'));
							});
					arr.sort();
					$(this).attr('title',arr.join(", "));
				}		
				
			});
			
			},
		switchMode : function(){
			productSearchResult.mode = !productSearchResult.mode;
			productSearchResult.displayMode();
 			},
 		displayMode : function(){
 				if(productSearchResult.mode){
 		    		$('.fname').hide();
 		    		$('.fcategory,.empty').show();
 		    		var src = $('#switch_mode img').attr('src');
 		    		if ($('#switch_mode img').length)
 		    			$('#switch_mode img').attr('src',src.replace('overview','detailed-view'));
 		    	} else {
 		    		$('.fname').show();
 		    		$('.fcategory,.empty').hide();
 		    		var src = $('#switch_mode img').attr('src');
 		    		if ($('#switch_mode img').length) 		    		
 		    			$('#switch_mode img').attr('src',src.replace('detailed-view','overview'));
 		    	}
 			}
 }