function productDetail(pars){
	
	var that=this;
	if(typeof(pars)!=="object" && (typeof(pars)==='string' || typeof(pars)==='number')){
		this.product_id = pars;
	}
	else{
		if(pars.id !=="undefined"){
			this.product_id = pars.id;
		}
		if(pars.ss_products_id !=='undefined'){
			this.ss_products_id = pars.ss_products_id;
		}
	}
	this.baseUrl="";
	this.getMB = new getMatBottom();
	
    if(typeof(that.ss_products_id) != "undefined"){
		this.uri = 'store_id/'+that.ss_products_id;
	} else if(typeof(that.product_id) != "undefined") {
		this.uri = 'product_id/'+that.product_id;
	} else return ErrorMessage('No product id was specified');
	
	this.getProductDetail = function(){
		if (!$("#results_box").length)
		{
			$("#update_box").attr('id', 'results_box');
		};		
        $("#results_box").html('<div id="results_white"></div>');
		$.ajax({
            url: that.baseUrl+'/ajax/product/get-product-detail/'+that.uri,
            type:'GET',
            dataType:'html',
            success : function(data) {
                $("#results_white").html(data);
                //$("#results_white").prepend('<div id="loader_box"></div>');
                that.initDetail();
            },
            
            error : function(xhr) {
            	ErrorMessage(xhr);
            }
        });
	};
	this.initDetail = function(){
		$('#results_white > div.buttons').append('<table><tr class="buttons"></tr></table>');
        $('tr.buttons').append('<td valign="top" align="left"><div class="domtab" style="width: 565px; padding-top: 20px;"><ul class="domtabs"></ul></div></tr>');
        $('ul.domtabs').html('<li class="button" id="getVehicleCoverage"><a href="#">'+_getText('product-detail-button-car-coverage')+'</a></li><li id="getFeatureCoverage" class="button"><a href="#">'+_getText('product-detail-button-features')+'</a></li><li id="getFirmwareCoverage" class="button"><a href="#">'+_getText('product-detail-button-firmware')+'</a></li><li id="getInstallGuides" class="button"><a href="#">'+_getText('product-detail-button-install-guides')+'</a></li>');
       
        $('li.button').click(
        		function(){
        				if(typeof(that[$(this).attr('id')])=='function'){
        					that[$(this).attr('id')]();
        				}
        				return false;
        			}
        		);
        that.getVehicleCoverage();
	}
	this.getVehicleCoverage = function(){
		$("#results_white > div.additional_detail").empty();
		showLoader();
		$("#results_white > div.additional_detail").html('<table class="vehicle-list" width="100%" cellspacing="0" cellpadding="0" border="0" ></table>');
		$("#results_white > div.additional_detail > table.vehicle-list").html('<tr><td class="product_name"  colspan="<?=count($this->years)/2?>"></td></tr>');
		$.ajax(
				{	url:that.baseUrl+'/ajax/product/get-vehicle-make-coverage/'+that.uri,
					data:{},
					type:'GET',
					dataType:'html',
					success : function(data){
						hideLoader();
						$("#results_white > div.additional_detail td.product_name").html(_getText('product-detail-current-coverage')+$("div.product_txt").html());
						$("#results_white > div.additional_detail td.product_name").after(data);
						$(".vehicleName > select").bind('change', function(){
							if($(this).val()!=0)
								that.getVehicleCoverageDetail($(this).val());
							
						});
						$(".vehicleName > select").after('<a class="all-makes">'+_getText('product-detail-see-complete')+'</a>');
						$(".vehicleName a.all-makes").click(
								function(){
									that.getVehicleCoverageDetail("all-makes");
								});
						$("td.vehicleName > select").attr('selectedIndex',1);
						$("td.vehicleName > select").change();
						
						
					},
	                error : function(xhr) {
	                	ErrorMessage(xhr);
					}
			});
		showLoader();
		
	};
	this.getVehicleCoverageDetail = function(id){
		$("div.additional_detail > table.vehicle-coverage").empty();
		showLoader();
		$.ajax(
				{	url:that.baseUrl+'/ajax/product/get-vehicle-coverage/'+that.uri+(id!="all-makes"?"/vehicleMake_id/"+id:""),
					data:{},
					type:'GET',
					dataType:'html',
					success : function(data){
						hideLoader();
						$('#results_white > div.additional_detail table.vehicle-coverage').remove();
						
						$("#results_white > div.additional_detail table.vehicle-list").after(''+data+'');
						$('#results_white tr').each(function(){$(this).children('td.table_bull:even, td.table_year:even').addClass('odd');})
	                    $('.button_on').addClass('button');
	                    $('li.button').removeClass('button_on');
	                    $('#getVehicleCoverage').addClass('button_on');
	                    $('#getVehicleCoverage').removeClass('button');
	                    that.getMB.getFeatureMatBottom();
					},
	                error : function(xhr) {
	                	ErrorMessage(xhr);
					}
			});
	};
	
	this.getFeatureCoverage = function(){
		$("#results_white > div.additional_detail").empty();
		showLoader();
		$.ajax(
				{	url: that.baseUrl+'/ajax/product/get-feature-coverage/'+that.uri,
					data:{},
					type:'GET',
					dataType:'html',
					success : function(data){
						hideLoader();
						$("#results_white > div.additional_detail").html(data);
						$("#results_white > div.additional_detail td.product_name").html("Available feature for the product: "+$("div.product_txt").html());
                        $('.button_on').addClass('button');
                        $('li.button').removeClass('button_on');
                        $('#getFeatureCoverage').addClass('button_on');
                        $('#getFeatureCoverage').removeClass('button');
					},
	                error : function(xhr) {
	                	ErrorMessage(xhr);
					}
				});
	};
	this.getFirmwareCoverage = function(){
		$("#results_white > div.additional_detail").empty();
		showLoader();
		$.ajax(
				{	url:that.baseUrl+'/ajax/product/get-firmware-coverage/'+that.uri,
					data:{},
					type:'GET',
					dataType:'html',
					success : function(data){
						hideLoader();
						$("#results_white > div.additional_detail").html(data);
						$("#results_white > div.additional_detail td.product_name").html("Available firmware for the product: "+$("div.product_txt").html());
                        $('.button_on').addClass('button');
                        $('li.button').removeClass('button_on');
                        $('#getFirmwareCoverage').addClass('button_on');
                        $('#getFirmwareCoverage').removeClass('button');
                        that.getMB.getFirmwareMatBottom();
					},
	                error : function(xhr) {
	                	ErrorMessage(xhr);
					}
				});
		
	};
	
	this.getInstallGuides = function(){
		$("#results_white > div.additional_detail").empty();
		showLoader();
		$.ajax(
				{	url:that.baseUrl+'/ajax/product/get-install-guides/'+that.uri,
					data:{},
					type:'GET',
					dataType:'html',
					success : function(data){
                        hideLoader();
                        $("#results_white > div.additional_detail").html(data);
						$("#results_white > div.additional_detail td.product_name").html("Available install guides for the product: "+$("div.product_txt").html());
                        $('.button_on').addClass('button');
                        $('li.button').removeClass('button_on');
                        $('#getInstallGuides').addClass('button_on');
                        $('#getInstallGuides').removeClass('button');
					},
	                error : function(xhr) {
	                	ErrorMessage(xhr);
					}
				});
	}
	
}
