$(document).ready(function() {
		//Tabs top
		$('#TabNav').idTabs();
		
		//$('.provicieField').parent('input').hide();
		$('#FormField_12').hide();
	
		//Add target blank to all links in topmenu
		$('#TopMenu #Menu .HasSubMenu a span').each(function () {
			if($(this).text() == 'Links'){
				$(this).parent('a').parent('li').addClass('LinksMenu');
				$('.LinksMenu').children('ul').children('li').children('a').attr('target', '_blank');
			}
		});
		
		//Give all (submit) buttons the mmSubmitButton class (temporary)
		$('input[type="submit"]').addClass('mmSubmitButton');
		$('input[type="button"]').addClass('mmSubmitButton');
		
		//Heightfix
		var a=$('#LayoutColumn1').height();
		var b=$('#LayoutColumn2').outerHeight();
		var c=$('#LayoutColumn3').height();
		var maxHeight=Math.max(a,b,c); 
		$('#Wrapper').css('height',maxHeight);
		
		//Productmain fix
		$('.PrimaryProductDetails .ProductMain').css('height', 'auto');
		
		//Tabs bottom
		$('#TabNavBottom').idTabs();
		
		//Footer fill fix
		footerPush ('#Footer');
		
		if($('#datepicker').length>0){
			$('#datepicker').datepicker();
		}
		
		//favoriet toevoegen
		$("#FavoFormSubmit").click(function() {
			  $("#frmWishList").submit();
		});

		/** Auto verkopen **/
			/** plusbox **/
		$('.plusbox').click(function(){
			$('.photouploadbutton:eq(0)').clone().appendTo('.uploadimgbox');
		});
		
		/** Start WPA **/
		handleWPA();
		
		//Scroll to top of the page
		$( 'html' ).animate( { scrollTop: 0 }, 0 );
		
		//Add active class to tab parent li's
		$('#TabNav .selected').parent('li').addClass('active');
		$('#TabNav > ul > li > a').click(function() {
			$('#TabNav > ul > li').removeClass('active');
			$(this).parent('li').addClass('active');
		});
		
		//Add active class to tab parent li's
		$('#TabNavBottom .selected').parent('li').addClass('active');
		$('#TabNavBottom > ul > li > a').click(function() {
			$('#TabNavBottom > ul > li').removeClass('active');
			$(this).parent('li').addClass('active');
		});
		
		if($('.AdvancedSearch #action').val()!='advancedsearch'){
			$('.mmAdvancedSearch').hide();
			$('.mmAdvancedSearchLink').text('Meer opties');
		}else{
			$('.mmAdvancedSearchLink').text('Minder opties');
		}
		$('.mmAdvancedSearchLink').click(function(){
			if($('.mmAdvancedSearch:hidden').length==1){
				$('.mmAdvancedSearch').show();
				$('.AdvancedSearch #action').val('advancedsearch');
				$('.mmAdvancedSearchLink').text('Minder opties');
			}else{
				$('.mmAdvancedSearch').hide();
				$('.AdvancedSearch #action').val('search');
				$('.mmAdvancedSearchLink').text('Meer opties');
			}
		});
		
		//getmmmodels
		$('.firstselect').change(function(){
			getCarModels($(this).val());
		});
		if($('.firstselect').val()!='Alle'){
			getCarModels($('.firstselect').val());
		}
		
		/* Price  */ 
		var priceFrom=$("#pricefrom").val();
		var priceTo=$("#priceto").val();
		var priceMax=$("#pricemax").val();
		$("#PriceSlider").slider({
			range: true,
			min: 0,
			max: priceMax,
			step: 100,
			values: [ priceFrom, priceTo ],
			slide: function( event, ui ) {
				$("#pricefrom").val(ui.values[ 0 ]);
				$("#priceto").val(ui.values[ 1 ]);
				$(".pricefromdis").text(addCommas(ui.values[ 0 ]));
				$(".pricetodis").text(addCommas(ui.values[ 1 ]));
			}
		});
		
		$("#pricefrom").val($("#PriceSlider").slider("values", 0));
		$("#priceto").val($("#PriceSlider").slider("values", 1));
		
		$(".pricefromdis").text(addCommas($("#PriceSlider").slider("values", 0)));
		$(".pricetodis").text(addCommas($("#PriceSlider").slider("values", 1)));
		
		
	
		/* DateOfManufactureSlider */
		
		var ManufactureDateFrom=parseInt($("#bouwjaarfrom").val());
		var ManufactureDateTo=parseInt($("#bouwjaarto").val());
		var ManufactureDateMin=parseInt($("#bouwjaarmin").val());
		var ManufactureDateMax=parseInt($("#bouwjaarmax").val());
		
		if(ManufactureDateMin>ManufactureDateFrom){
			ManufactureDateMin=ManufactureDateFrom;
		}
		if(ManufactureDateMax>ManufactureDateTo){
			//ManufactureDateMax=ManufactureDateTo;
		}
			
		//ManufactureDateMin=1995;
		//alert(ManufactureDateFrom+" - "+ManufactureDateTo+" - "+ManufactureDateMin+" - "+ManufactureDateMax);
			
		$("#DateOfManufactureSlider").slider({
			range: true,
			min: ManufactureDateMin,
			max: ManufactureDateMax,
			values: [ ManufactureDateFrom, ManufactureDateTo ],
			slide: function( event, ui ) {
				$("#bouwjaarfrom").val(ui.values[ 0 ]);
				$("#bouwjaarto").val(ui.values[ 1 ]);
				$(".bouwjaarDis").html(ui.values[ 0 ] + " - " + ui.values[ 1 ]);
			}
		});
		
		$(".bouwjaarDis").html($("#DateOfManufactureSlider").slider("values", 0) + " - " + $("#DateOfManufactureSlider").slider("values", 1));
		
		/* KMStandSlider */
		var kmStandFrom=$("#kilometerstandfrom").val();
		var kmStandTo=$("#kilometerstandto").val();
		var kmStandMax=$("#kilometerstandmax").val();
		
		$("#KMStandSlider").slider({
			range: true,
			min: 0,
			max: kmStandMax,
			step: 10000,
			values: [ kmStandFrom, kmStandTo ],
			slide: function( event, ui ) {
				$("#kilometerstandfrom").val(ui.values[ 0 ]);
				$("#kilometerstandto").val(ui.values[ 1 ]);
				
				var x=ui.values[ 0 ];
				var y=ui.values[ 1 ];
				
				$(".kilometerstandDis").html(addCommas(x)+ " - " + addCommas(y));
			}
		});
		
		$(".kilometerstandDis").html(addCommas($("#KMStandSlider").slider("values", 0)) + " - " + addCommas($("#KMStandSlider").slider("values", 1)));
		
		$('.mmResetSearchFields').click(function() {
			resetSearchForm();
			
			$("#PriceSlider" ).slider( "option", "values", [0, priceMax] );
			$("#pricefrom").val(0); 
			$("#priceto").val(priceMax);
			
			$(".pricefromdis").text(0);
			$(".pricetodis").text(priceMax);
			
			/*** bouwjaar***/
			$("#DateOfManufactureSlider").slider( "option", "values", [ManufactureDateMin, ManufactureDateMax] );
			$("#bouwjaarfrom").val(ManufactureDateMin);
			$("#bouwjaarto").val(ManufactureDateMax);
			
			/*** km stand ***/
			$("#KMStandSlider" ).slider( "option", "values", [0, kmStandMax] );
			$("#kilometerstandfrom").val(0);
			$("#kilometerstandto").val(kmStandMax);
			
			$(".kilometerstandDis").html(addCommas($("#KMStandSlider").slider("values", 0)) + " - " + addCommas($("#KMStandSlider").slider("values", 1)));

		});
		
		
		$('#mmPersoneel li .pboxopener').each(function(){
			var persbox=$(this).attr('rel');
			$(this).tooltip({ 
				delay: 250, 
			    showURL: false, 
			    positionLeft: true,
			    left:-15,
			    bodyHandler: function() { 
			        return $('#personeelBox_'+persbox).html(); 
			    } 
			});
		});
		
		$('#CarParts #send').click(function(){
			var val = $('#CarParts #prodnumber').val();
			if(val!=''){
				mmSearchForCarPart(val);
			}
		});
		
		homePagemmPersoneelSlider('Goes', 0, 5);
		homePagemmPersoneelSlider('Roosendaal', 0, 5);
		
		$('.mmPersoneelNav .mmPersDown').click(function(){
			GetHomePagemmPersoneelNumbers(5,1,'Goes');
			GetHomePagemmPersoneelNumbers(5,1,'Roosendaal')
		});
		$('.mmPersoneelNav .mmPersUp').click(function(){
			GetHomePagemmPersoneelNumbers(5,0,'Goes');
			GetHomePagemmPersoneelNumbers(5,0,'Roosendaal')
		});
		
		$('#mmCalculation #mmCalculate').click(function(){
			mmCarFinanceCalculation();
		});
		if($('#autoTrigger').val()==1){
			mmCarFinanceCalculation();
		}
		
		$('#mmTradeInCar #submit').attr('disabled','disabled');
		
		$('.TradeInBox .optionsbox input:radio').change(function(){
			$('#mmTradeInCar #submit').attr('disabled',true);
			var x=$(".TradeInBox .optionsbox input:radio:checked").val();
			if(x==1){
				$('#mmTradeInCar .FormContentBlock').hide();
				if($('#signedin').val()==1){
					$('#mmTradeInCar #submit').parent('.optionsbox').show();
					$('#mmTradeInCar #submit').removeAttr('disabled');
				}else{
					$('#mmTradeInCar .LoginBox').slideDown();
				}
			}
			if(x==2){
				$('#mmTradeInCar .LoginBox').hide();
				$('#mmTradeInCar .FormContentBlock').slideDown();
				$('#mmTradeInCar #submit').parent('.optionsbox').hide();
			}
		});
		
		$('.OfferPrint').click(function(){
			PrintOffer();
		});
		
		$('.OfferMail').click(function(){
			MailOffer();
		});
		
		$('.OccasionContact').click(function(){
			$('#dialog-question-form').dialog('open');
			$('.ui-dialog').center();
		});
		
		$('.mmHomeContent #ActionCarPart ul').cycle({ 
			delay: 0,
			speed: 1000,
			timeout: 6000
		});
		
		$('.mmHomeContent #ActionCar ul').cycle({
			delay: 0,
			speed: 1000,
			timeout: 6000
		});
		
		$('.Left #HomeNewProducts ul').cycle({
			delay: 0,
			speed: 1000,
			timeout: 6000
		});
		
		
		$('#dialog-form').dialog({ 
			autoOpen: false,
			height: 300,
			width: 350,
			modal: true,
			buttons: {
				"Verzenden": function() {
					var offername = $( "#name" ).val();
					var offeremail = $( "#email" ).val();
					if(offername!='' && offeremail!='') {
						$(this).dialog( "close" );
						MailSendOffer(offername,offeremail);
						//alert('Uw offerte is verzonden naar '+ offeremail);
					}else{
						$('#dialog-form .validateTips').html('Er is een fout opgetreden. Controleer uw gegevens en probeer het opnieuw.');
					}
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			},close: function() {
			}
		});
		
		$('#dialog-form-thanks').dialog({ 
			autoOpen: false,
			height: 200,
			width: 350,
			modal: true,
			buttons: {
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
			}
		});	
		
		$('#dialog-question-form').dialog({ 
			autoOpen: false,
			height: 400,
			width: 350,
			modal: true,
			buttons: {
				"Verzenden": function() {
					var name = $( "#question_name" ).val();
					var email = $( "#question_email" ).val();
					var phone = $( "#question_phone" ).val();
					var question = $( "#question_question" ).val();
					if(name!='' && email!='') {
						$(this).dialog( "close" );
						MailContact(name,email,phone,question);
						//alert('Uw offerte is verzonden naar '+ offeremail);
					}else{
						$('#dialog-question-form .validateTips').html('Er is een fout opgetreden. Controleer uw gegevens en probeer het opnieuw.');
					}
				},
				Cancel: function() {
					$( this ).dialog( "close" );
				}
			},close: function() {
			}
		});
		
		$('.FormContainer .hideme').parent('dd').hide().prev('dt').hide();
		
		
		 $('#mmwpa6 .ProceedToCheckout .confirmButton').click(function() {
			 if($('#mmwpa6 .stepform .confirmtextarea').val()!=''){
				 var textAreaContent=$('#mmwpa6 .stepform .confirmtextarea').val();
				 addDescriptionToCart(textAreaContent);
			 }
			 return true;
		 });
		 $('#mmwpa6 .stepform .confirmtextarea').blur(function() {
			 if($('#mmwpa6 .stepform .confirmtextarea').val()!=''){
				 var textAreaContent=$('#mmwpa6 .stepform .confirmtextarea').val();
				 addDescriptionToCart(textAreaContent);
			 }
			 return true;
		 });
		 
		 $('#mmwpa6 .ProceedToCheckout .confirmButton').mouseover(function() {
			 if($('#mmwpa6 .stepform .confirmtextarea').val()!=''){
				 var textAreaContent=$('#mmwpa6 .stepform .confirmtextarea').val();
				 addDescriptionToCart(textAreaContent);
			 }
			 return true;
		 });
		 
		 $("#mmwpa6 .stepform .confirmtextarea").mouseenter(function() {
		 }).mouseleave(function() {
			  if($('#mmwpa6 .stepform .confirmtextarea').val()!=''){
				 var textAreaContent=$('#mmwpa6 .stepform .confirmtextarea').val();
				 addDescriptionToCart(textAreaContent);
			  }
			  return true;
		 });
		 
		 $('.wplHRow').click(function(){
			 
			 if($(this).hasClass('open')){
				 $(this).removeClass('open')
			 }else{
				 $(this).addClass('open') 
			 }
			 
			 var num=$(this).attr('id');
			 if($('.'+num).length==1){
				 $('.'+num).toggle();
			 }
		 });
		 
		 $('.predictionSubmit').click(function(){
			 var kmPred=$('.kmPredictionVal').val();
			 if(kmPred!=''){
				 addToSession(kmPred,'prediction', 'kmstand');
			 }
		 });
		 $('.kmPredictionVal').keypress(function(e){
		     if(e.which == 13){
		    	 var kmPred=$(this).val();
				 if(kmPred!=''){
					 addToSession(kmPred,'prediction', 'kmstand');
				 }
				 return false;
		     } 
	     });
		 
		$('#sideWpa .SideSelectBrands').change(function(){
			getModelsForSide($(this).val());
		});
		
		if($('#sideWpa .SideSelectBrands').length>0){
			SideCarSelection.init();
		}
		 
	});

	function RemoveHelp() {
		$("#help").remove();
	}
	function CheckFormFields(formid) {
		var name = $('#'+formid+' input[name=name]').val();
		var email = $('#'+formid+' input[name=email]').val();
		var date = $('#'+formid+' input[name=date]').val();
		var phonenumber = $('#'+formid+' input[name=phonenumber]').val();
		var x=true;
		if(name.length==0){
			x=false;
		}
		if(email.length==0){
			x=false;
		}
		
		if(date=='00-00-0000'){
			x=false;
		}
		
		if(!x){
			$('div.TestDriveForm').html('Een van onderstaande velden is niet of niet correct ingevult.').slideDown();
			return false;
		}else{
			return true;
		}
	}
	
	
	function ShowHelp(img, title, desc)
	{
		img = document.getElementById(img);
		div = document.createElement('div');
		div.id = 'help';
	
		div.style.display = 'inline';
		div.style.position = 'absolute';
		div.style.width = '350';
	
		div.style.backgroundColor = '#FEFCD5';
		div.style.border = 'solid 1px #E7E3BE';
		div.style.padding = '10px';
		div.innerHTML = '<span class=helpTip><strong>' + title + '<\/strong><\/span><br /><img src=images/1x1.gif width=1 height=5><br /><div style="padding-left:10; padding-right:5;" class=helpTip>' + desc + '</div>';
	
		//img.parentNode.appendChild(div);
		var parent = img.parentNode;
		if(img.nextSibling)
			parent.insertBefore(div, img.nextSibling);
		else
			parent.appendChild(div)
	}
	
	function HideHelp(img)
	{
		if ($("#help").length) {
			$("#help").css('display','none');
			setTimeout('RemoveHelp()', 1);
		}
	}

	function updateTips( t ) {
		tips
			.text( t )
			.addClass( "ui-state-highlight" );
		setTimeout(function() {
			tips.removeClass( "ui-state-highlight", 1500 );
		}, 500 );
	}

	function PrintOffer(){ 
		window.print();
	}
	
	function MailOffer(){ 
		$('#dialog-form').dialog('open');
		$('#ui-dialog-title-dialog-form').text('E-mail deze pagina naar:');
		$('.ui-dialog').center();
	}
	
	//Center function
	//Usage: $('.ui-dialog').center();
    $.fn.center = function () {
        this.css("position","absolute");
        this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
        this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
        return this;
    }
	
	function MailSendOffer(name,email){ 
		$.post(config.ShopPath+"/remote.php", { w: "mmmailoffer", carid:$('#carid').val(),name:name,email:email }, function(data){
			if(data==1){
				$('#dialog-form .validateTips').html('Uw offerte is succesvol verzonden naar '+email);
				$('#dialog-form-thanks').dialog('open');
			}else if(data!=''){
				$('#dialog-form .validateTips').html(data);
				$('#dialog-form-thanks').dialog('open');
			}
		}, "html");
	}
	
	function MailContact(name,email,phone,question){ 
		$.post(config.ShopPath+"/remote.php", { w: "mmMailContact", carid:$('#carid').val(),name:name,email:email,phone:phone,question:question }, function(data){
			if(data==1){
				$('#dialog-question-form .validateTips').html('Uw vraag is succesvol verzonden naar '+email);
				$('#dialog-form-thanks').dialog('open');
			}else if(data!=''){
				$('#dialog-question-form .validateTips').html(data);
				$('#dialog-form-thanks').dialog('open');
			}
		}, "html");
	}

	function mmCarFinanceCalculation(){
		// get the basic details and put it in a function
		var calcTotalAmount=$('#totalAmount').val();
		var calcMinAmount=$('#minAmount').val();
		
		var calcFinalAmount=calcTotalAmount-calcMinAmount;
		$('#financialAmount').val(calcFinalAmount);
		var calcRestAmount=$('#amountEnding').val();
		var carid=$('#carid').val();
		
		if(calcFinalAmount!=''){
			$(".CalculationBlock").load( config.ShopPath+"/remote.php", {w: 'mmcalculate', finalamount: calcFinalAmount, amount:calcTotalAmount, minamount:calcMinAmount, restamount: calcRestAmount, prodid: carid });
			$('#mmCalculation #mmCalculate').val('');
		}
	}

	function GetHomePagemmPersoneelNumbers(num,plusmin,type){
		var start=$('.HomePersoneelList.'+type+' > li:visible:first').index();
		var end=$('.HomePersoneelList.'+type+' > li:visible:last').index();
		var total=$('.HomePersoneelList.'+type+' > li').length;
		total--;
		var maxStart=total-num;
		
		if(plusmin==1){
			start+=num;
			end+=num;
			if(start>maxStart){
				start=maxStart
			}
			if(end>total){
				end=total
			}
		}else{
			start-=num;
			end-=num;
			if(start<0){
				start=0;
			}
			if(end<num){
				end=num;
			}
		}
		homePagemmPersoneelSlider(type, start, end);
	}

	function homePagemmPersoneelSlider(type,start, end){
		$('.HomePersoneelList.'+type+' > li').each(function(){
			$(this).show();
		});
		if(start!=0){
			$('.HomePersoneelList.'+type+' > li:lt('+start+')').each(function(){
				$(this).hide();
			});
		}
		
		$('.HomePersoneelList.'+type+' > li:gt('+end+')').each(function(){
			$(this).hide();
		});
	}

	function mmPersoneelBox(id){
		return false;
		$('.PersoneelList li .pboxopener').each(function(){
			var persbox=$(this).attr('rel');
			$('#personeelBox_'+persbox).dialog("close");
		});
		$('#'+id).dialog("open");
	}
	
	function mmSearchForCarPart(search){
		$(".CarPartsResult").load( config.ShopPath+"/remote.php", {w: 'getcarparts', searchval: search });
	}
	
	function mmWerkplaatsShowCorrectAgenda(){
		var selected = $('.locationselect option:selected').val();
		if(selected=='goes'){
			$('.agenda').hide();
			$('.agenda.goes').show();
			$('.stepform .heading').hide();
			$('.stepform .heading.goes').show();
		}else{
			$('.agenda').hide();
			$('.agenda.rsd').show();
			$('.stepform .heading').hide();
			$('.stepform .heading.rsd').show();
		}
	}

	function mmWerkplaatsShowCorrectContent(){
		//Get active tab, hide other tab content and only display active tab content
		var activeId = $('.mmWerkplaatsagendaTabs .selected').attr('href');
		$('.mmProductMainTab').hide();
		$(activeId).show();
		$( 'html' ).animate( { scrollTop: 0 }, 0 );
	}

	function mmWerkplaatsBeurtenFormCheck(){
		var BeurtValue=$('input:radio[name=beurt]:checked').val();
		if(BeurtValue!=''){
			$('.nextbutton').removeAttr('disabled');
		}else{
			$('.nextbutton').attr('disabled', 'true');
		}
	}

	function mmWerkplaatsVervangendVervoerFormCheck(){
		if($('.vervangendvervoerradio:checked').length>0){
			$('.nextbutton').removeAttr('disabled');
		}else{
			$('.nextbutton').attr('disabled', 'true');
		}
	}

	function mmWerkplaatsVoertuigFormCheck(){
		var brand = $('.vehicleSelect.selectBrand');
		var model = $('.vehicleSelect.selectModel');
		var brandstof = $('.vehicleSelect.selectBrandstof');
		var transmissie = $('.vehicleSelect.selectTransmissie');
		var motorisering = $('.vehicleSelect.selectMotoriseringBouwjaar');
		var type = $('.vehicleSelect.selectType');
		
		//If the select boxes even exist
		if(brand.length > 0 && model.length > 0 && brandstof.length > 0 && transmissie.length > 0 && motorisering.length > 0 && type.length > 0){
			var selectedbrand = $('.vehicleSelect.selectBrand option:selected').val();
			var selectedmodel = $('.vehicleSelect.selectModel option:selected').val();
			var selectedbrandstof = $('.vehicleSelect.selectBrandstof option:selected').val();
			var selectedtransmissie = $('.vehicleSelect.selectTransmissie option:selected').val();
			var selectedmotorisering = $('.vehicleSelect.selectMotoriseringBouwjaar option:selected').val();
			var selectedtype = $('.vehicleSelect.selectType option:selected').val();
			var selectedTotalLength = selectedbrand + selectedmodel + selectedbrandstof + selectedtransmissie + selectedmotorisering;
			//Check the values of the selected options, if all are NOT empty, enable the next button
			if(selectedTotalLength > 0){
				$('#mmwpa1 .stepform .nextbutton').attr('disabled', false);
			}else{
				$('#mmwpa1 .stepform .nextbutton').attr('disabled', true);
			}
		}
	}
	
	function resetSearchForm(){
		$(".secondselect").load( config.ShopPath+"/remote.php", {w: 'getmmmodels', brand:0,model:0,nolabel:1});
		//getModelsByBrand(0);
		/*** color ***/
		// $("select option:selected").each(function () {
		$('select option:selected').each(function () {
			$(this).removeAttr('selected');
		});
		$('#searchfield').val('');
		if ( $.browser.msie ) { 
			$('select').each(function () {
				//$(this+':first-child').addAttr('selected',true);
				$(this+':first-child').attr('selected','selected');
			});
		}
	}
	
	function getCarModels(brandID){
		if(brandID==0){
			$(".secondselect").load( config.ShopPath+"/remote.php", {w: 'getmmmodels', brand:brandID,model:$('.secondselect').val(),nolabel:1});
		}else{
			$(".secondselect").load( config.ShopPath+"/remote.php", {w: 'getmmmodels', brand:brandID,model:$('.secondselect').val(),nolabel:1});
		}
	}

	function getModelsBy(brandID){
		$(".vehicleSelect.selectModel").load( config.ShopPath+"/remote.php", {w: 'getmodelsby', merk:brandID,model:$('.vehicleSelect.selectModel').val() });
	}
	
	function getModelsForSide(brandID){
		$("#sideWpa .SideSelectModel").load( config.ShopPath+"/remote.php", {w: 'getmodelsby', merk:brandID,model:$('#sideWpa .SideSelectModel').val() });
	}
	
	function getBrandstofBy(brandID, model){
		$(".vehicleSelect.selectBrandstof").load( config.ShopPath+"/remote.php", {w: 'getbrandstofby', merk:brandID,model:model,brandstof:$('.vehicleSelect.selectBrandstof').val() });
	}
	
	function getTransmissieBy(brandID, model, brandstof){
		var trans=$('.vehicleSelect.selectTransmissie').val();
		$.post(config.ShopPath+"/remote.php", { w: "gettransmissieby", merk:brandID,model:model,brandstof:brandstof, transmissie:trans }, function(data){
			if(data!=''){
				$(".vehicleSelect.selectTransmissie").html(data);
				$("label.transmissie").show();
				$(".vehicleSelect.selectTransmissie").show();
				GetPackageByOptions();
			}else{
				$("label.transmissie").hide();
				$(".vehicleSelect.selectTransmissie").hide();
			}
		}, "html");
	}
	
	function getMotoriseringBy(brandID, model, brandstof, transmissie, motorisering){
		var motorisering=$('.vehicleSelect.selectMotoriseringBouwjaar').val();
		$.post(config.ShopPath+"/remote.php", { w: "getmotoriseringandbouwjaarby", merk:brandID,model:model,brandstof:brandstof, transmissie:transmissie, motorisering:motorisering }, function(data){
			if(data!=''){
				$(".vehicleSelect.selectMotoriseringBouwjaar").html(data);
				$("label.motoriseringbouwjaar").show();
				$(".vehicleSelect.selectMotoriseringBouwjaar").show();
				GetPackageByOptions();
			}else{
				$("label.motoriseringbouwjaar").hide();
				$(".vehicleSelect.selectMotoriseringBouwjaar").hide();
			}
		}, "html");
	}
	
	function getTypesBy(brandID, model, brandstof, transmissie, motorisering, type){
		var type = $('.vehicleSelect.selectType').val();
		$.post(config.ShopPath+"/remote.php", { w: "gettypesby",merk:brandID,model:model,brandstof:brandstof, transmissie:transmissie,motorisering:motorisering,type:type }, function(data){
			if(data!=''){
				$(".vehicleSelect.selectType").html(data);
				$("label.type").show();
				$(".vehicleSelect.selectType").show();
				GetPackageByOptions();
			}else{
				$("label.type").hide();
				$(".vehicleSelect.selectType").hide();
			}
		}, "html");
		
	}
		
	function addToCart(productid){
		$.ajax({ url: config.ShopPath+'/cart.php?action=add&product_id='+productid, context: document.body, success: function(){
			//location.reload(true);
	  }});
	}
	
	function addVariationToCart(productid,variationid){
		$.post(config.ShopPath+"/remote.php", { w: "addtocart", product_id:productid, variation_id:variationid}, function(data){
			$('.refreshCart').click();
		}, "html");
	}
	
	function removeProductFromCart(productid){
		$.post(config.ShopPath+"/remote.php", { w: "removefromcart", product_id:productid}, function(data){
			$('.refreshCart').click();
		}, "html");
	}
	function removeVariationFromCart(productid,variation){
		$.post(config.ShopPath+"/remote.php", { w: "removevariationfromcart", product_id:productid, variation_id:variationid}, function(data){
			$('.refreshCart').click();
		}, "html");
	}
	
	function removeFromCart(productid){
		$.ajax({ url: config.ShopPath+'/cart.php?action=remove&product_id='+productid, context: document.body, success: function(){
			//location.reload(true);
	  }});
	}
	
	function addToCartAdditions(productid){
		$.ajax({ url: config.ShopPath+'/cart.php?action=addadditions&product_id='+productid, context: document.body, success: function(){
			$('.refreshCart').click();
	  }});
	}
	
	function removeFromCartAdditions(productid){
		$.ajax({ url: config.ShopPath+'/cart.php?action=removeadditions&product_id='+productid, context: document.body, success: function(){
			$('.refreshCart').click();
		}});
	}
		
	function addToCartRemoveOtherBeurten(productid){
		$.ajax({ url: config.ShopPath+'/cart.php?action=addandremoveotherbeurten&product_id='+productid, context: document.body, success: function(){
			mmWerkplaatsBeurtenFormCheck();
			//$('.beurtchoosebutton input').removeAttr('disabled');
	  }});
	}
	
	function addToCartRemoveOtherVervangendVervoer(productid,variationid){
		$.ajax({ url: config.ShopPath+'/cart.php?action=addandremoveothervervangendvervoer&product_id='+productid+'&variation_id='+variationid, context: document.body, success: function(){
			mmWerkplaatsVervangendVervoerFormCheck();
	  }});
	}
	
	function addAppointmentToCart(){
		// set some vars
		var location=$('.locationselect').val();
		var date=$('.mmwawafspraakdatum').val();
		var dagdeel=$('.mmwawafspraakdagdeel').val();
		$.post(config.ShopPath+"/remote.php", { w: "addappointmenttocart", Vestiging:location, Datum:date, Tijd:dagdeel}, function(data){
			if(data!=''){
				
			}
		}, "html");
	}
	
	function addDescriptionToCart(desc){
		$.post(config.ShopPath+"/remote.php", { w: "adddescriptiontocart", desc:desc}, function(data){
			if(data!=''){
			}
		}, "html");
	}
	
	function emptyCartAndOtherVars(){
		$.ajax({ url: config.ShopPath+'/cart.php?action=emptycart', context: document.body, success: function(){
			
		}});
	}
	
	function addToSession(val,sessionName, sessionSubName){
		$.post(config.ShopPath+"/remote.php", { w: "addToSession", val:val, sessionname:sessionName,sessionsubname:sessionSubName}, function(data){
			if(data!=''){
				alert(data);
			}
			$('.refreshCart').click();
		}, "html");
	}
	
	function GetPackageByOptions(){
		var brand='';
		var model='';
		var brandstof='';
		var transmissie='';
		var motor='';
		var type='';
		if($('.vehicleSelect.selectBrand').val()!=''){
			brand = $('.vehicleSelect.selectBrand').val();
		}
		if($('.vehicleSelect.selectModel').val()!=''){
			model = $('.vehicleSelect.selectModel').val();
		}
		if($('.vehicleSelect.selectBrandstof').val()!=''){
			brandstof = $('.vehicleSelect.selectBrandstof').val();
		}
		if($('.vehicleSelect.selectTransmissie').val()!=''){
			transmissie = $('.vehicleSelect.selectTransmissie').val();
		}
		if($('.vehicleSelect.selectMotoriseringBouwjaar').val()!=''){
			motor = $('.vehicleSelect.selectMotoriseringBouwjaar').val();
		}
		if($('.vehicleSelect.selectType').val()!=''){
			type = $('.vehicleSelect.selectType').val();
			
		}
		//alert('Brand:'+brand+' - model:'+model+' - brandstof:'+brandstof+' - transmissie:'+transmissie+' - motor:'+motor+' - type:'+type);
		$.post(config.ShopPath+"/remote.php", { w: "GetPackageByOptions", merk:brand, model:model, brandstof:brandstof, transmissie:transmissie, motorisering:motor, type:type }, function(data){
			if(data!=''){
				//there is a package
				$('#mmwpa1 #packagenumber').val(data);
			}else{
				//there is not a package
			}
		}, "html");
		
		if($('#packagenumber').val()!=''){
			$('#mmwpa1 .stepform .nextbutton').attr('disabled', false);
			$('#mmwpa1 .stepform .nextbutton').addClass('active');
			return true;
		}else{
			$('#mmwpa1 .stepform .nextbutton').removeClass('active');
			$('#mmwpa1 .stepform .nextbutton').attr('disabled', true);
			return false;
		}
	}
	
	function createNewOption(){
		$('.mmprodcontenttable.inruilautoopties').append($('.mmprodcontenttable.inruilautoopties' + ' tr:last').clone());
	}

	function footerPush (bodyElement) {
	    if ( $(window).height() > $(document.body).height() ) {
	        if ( $.browser.msie ) {             //If Microsoft's IE
	            $(bodyElement).height( $(bodyElement).height() + ( $(window).height() - $(document.body).height()) - 0);
	        } else if ($.browser.mozilla) {     //If Mozilla's Firefox
	            $(bodyElement).height( $(bodyElement).height() + ( $(window).height() - $(document.body).height()) + 17 - 17);
	        } else if ($.browser.safari) {      //If Apple's Safari *or* Google's Chrome
	            $(bodyElement).height( $(bodyElement).height() + ( $(window).height() - $(document.body).height()) - 58);
	        } else {                            //Any other browser, default to 'standard' implementation
	            $(bodyElement).height( $(bodyElement).height() + ( $(window).height() - $(document.body).height()) - 0);
	        };
	    };
	    if ( $.browser.opera ) {     //If Opera do Paul Potts
	        if ( window.innerHeight > $(document.body).height() ) {
	            $(bodyElement).height( $(bodyElement).height() + ( window.innerHeight - $(document.body).height()) - 0 );
	        };
	    };
	};
	
	function clearSelectBoxes(x){
		if(x<=1){//reset model
			$('.vehicleSelect.selectModel').html('');
			$('#mmwpa1 #packagenumber').val('');
		}
		if(x<=2){//reset fuel
			$('.vehicleSelect.selectBrandstof').html('');	
			$('#mmwpa1 #packagenumber').val('');
		}
		if(x<=3){//reset transmissie
			$('.vehicleSelect.selectTransmissie').html('');
			$('#mmwpa1 #packagenumber').val('');
		}
		if(x<=4){//reset motorisering
			$('.vehicleSelect.selectMotoriseringBouwjaar').html('');
			$('.vehicleSelect.selectMotoriseringBouwjaar').hide();
			$('label.motoriseringbouwjaar').hide();
			$('#mmwpa1 #packagenumber').val('');
		}
		if(x<=5){//reset type
			$('.vehicleSelect.selectType').html('');
			$('.vehicleSelect.selectType').hide();
			$('label.type').hide();
			$('#mmwpa1 #packagenumber').val('');
		}
	}
	
	
	function handleWPA(){
		//##Werkplaats agenda page
		if($('.mmWerkplaatsagendaTabs').length>0){
			mmWerkplaatsShowCorrectContent();
			
			$('.mmWerkplaatsagendaTabs .enabled.prev > a').click(function() {
				var chosenTabId = $(this).attr('href');
				$(chosenTabId).next('.mmProductMainTab').children('.stepform').children('.previousbutton').click();
			});
			
			$('.mmWerkplaatsagendaTabs .enabled.next > a').click(function() {
				var chosenTabId = $(this).attr('href');
				$(chosenTabId).prev('.mmProductMainTab').children('.stepform').children('.nextbutton').click();
			});
			
			$('.mmProductMainTab #cartForm .ProductName > a').click(function() {
				var chosenTabId = $(this).attr('href');
				$(chosenTabId).prev('.mmProductMainTab').children('.stepform').children('.nextbutton').click();
			});
			
			//Cart content -> Product click -> Previous tab
			$('#cartForm .ProductName').click(function() {
				//$('.previousbutton').click();
			});
			
			//##First Tab: Voertuig
			if($('#mmwpa1 .stepform').length>0){
								
				//Ajax selects
				if($('.vehicleSelect.selectModel').val()==''){
					clearSelectBoxes(1);
					getModelsBy($('.vehicleSelect.selectBrand').val());
				}
				if($('.vehicleSelect.selectBrandstof').val()==''){
					clearSelectBoxes(2);
					getBrandstofBy($('.vehicleSelect.selectBrand').val(), $('.vehicleSelect.selectModel').val(), $('.vehicleSelect.selectBrandstof').val());
				}
				if($('.vehicleSelect.selectTransmissie').val()==''){
					clearSelectBoxes(3);
					getTransmissieBy($('.vehicleSelect.selectBrand').val(), $('.vehicleSelect.selectModel').val(), $('.vehicleSelect.selectBrandstof').val(), $('.vehicleSelect.selectTransmissie').val());
				}
				if($('.vehicleSelect.selectMotoriseringBouwjaar').val()==''){
					clearSelectBoxes(4);
					getMotoriseringBy($('.vehicleSelect.selectBrand').val(), $('.vehicleSelect.selectModel').val(),$('.vehicleSelect.selectBrandstof').val(), $('.vehicleSelect.selectTransmissie').val(), $('.vehicleSelect.selectMotoriseringBouwjaar').val());
				}
				if($('.vehicleSelect.selectType').val()==''){
					clearSelectBoxes(5);
					getTypesBy($('.vehicleSelect.selectBrand').val(), $('.vehicleSelect.selectModel').val(), $('.vehicleSelect.selectBrandstof').val(),$('.vehicleSelect.selectTransmissie').val(), $('.vehicleSelect.selectMotoriseringBouwjaar').val(), $('.vehicleSelect.selectType').val());
				}
				
				$('.vehicleSelect.selectBrand').change(function(){
					// first we clear all ather select boxes
					$('#mmwpa1 #packagenumber').val('');
					
					$('.vehicleSelect.selectModel').html('');
					$('.vehicleSelect.selectBrandstof').html('');
					$('.vehicleSelect.selectTransmissie').html('');
					
					$('.vehicleSelect.selectMotoriseringBouwjaar').html('');
					$('.vehicleSelect.selectMotoriseringBouwjaar').hide();
					$('label.motoriseringbouwjaar').hide();
					
					$('.vehicleSelect.selectType').html('');
					$('.vehicleSelect.selectType').hide();
					$('label.type').hide();
					
					getModelsBy($('.vehicleSelect.selectBrand').val());
					if($('#mmwpa1').is(':visible')){
					
					
					}
					emptyCartAndOtherVars();
					GetPackageByOptions();
				});
				$('.vehicleSelect.selectModel').change(function(){
					// first we clear all ather select boxes
					$('#mmwpa1 #packagenumber').val('');
					
					$('.vehicleSelect.selectBrandstof').html('');
					$('.vehicleSelect.selectTransmissie').html('');
					
					$('.vehicleSelect.selectMotoriseringBouwjaar').html('');
					$('.vehicleSelect.selectMotoriseringBouwjaar').hide();
					$('label.motoriseringbouwjaar').hide();
					
					$('.vehicleSelect.selectType').html('');
					$('.vehicleSelect.selectType').hide();
					$('label.type').hide();
					
					getBrandstofBy($('.vehicleSelect.selectBrand').val(), $('.vehicleSelect.selectModel').val(), $('.vehicleSelect.selectBrandstof').val());
					emptyCartAndOtherVars();
					GetPackageByOptions();
				});
				$('.vehicleSelect.selectBrandstof').change(function(){
					// first we clear all ather select boxes
					$('#mmwpa1 #packagenumber').val('');
					
					$('.vehicleSelect.selectTransmissie').html('');
					
					$('.vehicleSelect.selectMotoriseringBouwjaar').html('');
					$('.vehicleSelect.selectMotoriseringBouwjaar').hide();
					$('label.motoriseringbouwjaar').hide();
					
					$('.vehicleSelect.selectType').html('');
					$('.vehicleSelect.selectType').hide();
					$('label.type').hide();
				
					if(!GetPackageByOptions()){
						getTransmissieBy($('.vehicleSelect.selectBrand').val(), $('.vehicleSelect.selectModel').val(), $('.vehicleSelect.selectBrandstof').val(), $('.vehicleSelect.selectTransmissie').val());
						emptyCartAndOtherVars();
					}
				});
				$('.vehicleSelect.selectTransmissie').change(function(){
					// first we clear all ather select boxes
					$('.vehicleSelect.selectMotoriseringBouwjaar').html('');
					$('.vehicleSelect.selectMotoriseringBouwjaar').hide();
					$('label.motoriseringbouwjaar').hide();
					
					$('.vehicleSelect.selectType').html('');
					$('.vehicleSelect.selectType').hide();
					$('label.type').hide();
					
					if(!GetPackageByOptions()){
						getMotoriseringBy($('.vehicleSelect.selectBrand').val(), $('.vehicleSelect.selectModel').val(),$('.vehicleSelect.selectBrandstof').val(), $('.vehicleSelect.selectTransmissie').val(), $('.vehicleSelect.selectMotorisering').val());
						emptyCartAndOtherVars();
					}
					
				});
				$('.vehicleSelect.selectMotoriseringBouwjaar').change(function(){
					// first we clear all ather select boxes
					$('.vehicleSelect.selectType').html('');
					
					if(!GetPackageByOptions()){
						getTypesBy($('.vehicleSelect.selectBrand').val(), $('.vehicleSelect.selectModel').val(), $('.vehicleSelect.selectBrandstof').val(),$('.vehicleSelect.selectTransmissie').val(), $('.vehicleSelect.selectMotoriseringBouwjaar').val(), $('.vehicleSelect.selectType').val());
						emptyCartAndOtherVars();
					}
				});
				
				$('.vehicleSelect.selectType').change(function(){
					if(!GetPackageByOptions()){
						emptyCartAndOtherVars();
					}
				});
				
				if(GetPackageByOptions()){
					
				}
			}
			//##Second Tab: Beurten Form Check
			if($('#mmwpa2 .stepform').length>0){
				var prevBeurtValue=$('input:radio[name=beurt]:checked').val();
				$('input:radio[name=beurt]').click(function() {
					if($(this).val()!=prevBeurtValue){
						addToCartRemoveOtherBeurten($(this).val());
					}
					prevBeurtValue=$(this).val();
				});
				
				if($('#mmwpa2').is(':visible')){
					mmWerkplaatsBeurtenFormCheck();
				}
			}
			
			//##Third Tab: Overzicht
			if($('#mmwpa3 .stepform').length>0){
				//$('#mmwpa3 .CartContents .CartRemoveLink').attr('href','');
				$('.additions .aanvullingbutton').click(function() {
					if($(this).hasClass('aanvullingadd')){
						var productid = $(this).prev('.aanvullingproductid').val();
						var productvariationid='';
						if($('.Prod'+productid+' .aanvullingproductvariationid').length>0){
							productvariationid = $('.Prod'+productid+' .aanvullingproductvariationid').val();
						}
						if(productvariationid!=''){
							addVariationToCart(productid,productvariationid);
						}else if(productid!=''){
							addToCartAdditions(productid);
						}
						
					}else if($(this).hasClass('aanvullingremove')){
						var productid = $(this).prev('.aanvullingproductid').val();
						removeProductFromCart(productid);
					}
				});
			}
			
			//##Fourth Tab: Vervangend Vervoer Form Check
			if($('#mmwpa4 .stepform').length>0){
				$('.vervangendvervoerradio').click(function() {
					addToCartRemoveOtherVervangendVervoer($('.vervangendvervoerproductid').val(), $(this).val())
				});
				
				if($('#mmwpa4').is(':visible')){
					mmWerkplaatsVervangendVervoerFormCheck();
				}
			}
			
			//##Fifth Tab: Workplace agenda
			if($('#mmwpa5 .stepform').length>0){
				$('.agenda').hide();
				$('.agenda.rsd').show();
				
				mmWerkplaatsShowCorrectAgenda();
				
				$('.locationselect').change(function(e) {
					mmWerkplaatsShowCorrectAgenda();
				});
				
				var sessionDate = $('.mmwawafspraakdatum').val();
				var sessionDagdeel = $('.mmwawafspraakdagdeel').val();
				
				if(sessionDate.length>0 && sessionDagdeel.length>0){
					$('.agenda .available > a[rel*="'+ sessionDate +'"]a[link="'+ sessionDagdeel +'"]').parent('.available').addClass('active');
					//$(".agenda .available > a:rel:contains(" + sessionDate + ")")
				}
				//$("p:contains("+ vtxt +")").addClass("on");
				
				$('.agenda .available').click(function() {
					var date=$(this).children('a').attr('rel');
					var dagdeel=$(this).children('a').attr('link');
					
					var selecteddate = $(this).children('a').html();
					$('.agenda .available.active').removeClass('active');
					$(this).addClass('active');
					
					$('.mmwawafspraakdatum').attr('value', date);
					$('.mmwawafspraakdagdeel').attr('value', dagdeel);
					
					addAppointmentToCart();
					// vars set now add the product to the cart.
				});
			}
		}
	}
	
	function addCommas(nStr)
	{
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1)) {
			x1 = x1.replace(rgx, '$1' + '.' + '$2');
		}
		return x1 + x2;
	}
	
	var SideCarSelection = {
			init: function(){
				
				if($("#sideWpa .SideSelectTransmission").val()=='' || $("#sideWpa .SideSelectTransmission").val()==0){
					$("#sideWpa label.transmissie").hide();
					$("#sideWpa .SideSelectTransmission").hide();
					SideCarSelection.disableSubmit();
				}
				
				if($("#sideWpa .SideSelectModB").val()=='' || $("#sideWpa .SideSelectModB").val()==0){
					$("#sideWpa label.motoriseringbouwjaar").hide();
					$("#sideWpa .SideSelectModB").hide();
					SideCarSelection.disableSubmit();
				}
				
				if($("#sideWpa .SideSelectType").val()=='' || $("#sideWpa .SideSelectType").val()==0){
					$("#sideWpa label.type").hide();
					$("#sideWpa .SideSelectType").hide();
					SideCarSelection.disableSubmit();
				}
				
				$('#sideWpa .SideSelectBrands').live('change', function() {
					SideCarSelection.reloadVars(1);
				});
				
				$('#sideWpa .SideSelectModel').live('change', function() {
					SideCarSelection.loadFuel(false);
					SideCarSelection.reloadVars(2);
				});
				$('#sideWpa .SideSelectFuel').live('change', function() {
					SideCarSelection.loadTransmission(false);
					SideCarSelection.reloadVars(3);
				});
				$('#sideWpa .SideSelectTransmission').live('change', function() {
					SideCarSelection.loadModB(false);
					SideCarSelection.reloadVars(4);
				});
				$('#sideWpa .SideSelectModB').live('change', function() {
					SideCarSelection.loadType(false);
				});
				$('#sideWpa .SideSelectType').live('change', function() {
					SideCarSelection.loadType(false);
					SideCarSelection.activateSubmit();
				});
				
				$('#sideWpa .mmReset').live('click', function() {
					SideCarSelection.clearSelections();
					SideCarSelection.reloadVars(0);
					SideCarSelection.disableSubmit();
				});
				SideCarSelection.loadFuel(false);
			},
			
			reloadVars: function(x){
				switch(x){
					case 0:
						$("#sideWpa .SideSelectBrands").val('0');
						/*$("#sideWpa .SideSelectBrands options").each(function(e){
							$(e).removeAttr('disabled');
							$(e).removeAttr('selected');
						});*/
						//$("#sideWpa .SideSelectBrands:eq(0)").addAttr('selected','selected');
						//$("#sideWpa .SideSelectBrands:eq(0)").addAttr('disabled','disabled');
						
						$("#sideWpa .SideSelectModel").val('');
						$("#sideWpa .SideSelectFuel").val('');
						$("#sideWpa .SideSelectTransmission").val('');
						$("#sideWpa .SideSelectModB").val('');
						$("#sideWpa .SideSelectType").val('');
						
						SideCarSelection.disableSubmit();
						
						SideCarSelection.loadModels(true);
						SideCarSelection.loadFuel(true);
						SideCarSelection.loadTransmission(true);
						SideCarSelection.loadModB(true);
						SideCarSelection.loadType(true);
					break;	
					case 1:
						$("#sideWpa .SideSelectFuel").val('');
						$("#sideWpa .SideSelectTransmission").val('');
						$("#sideWpa .SideSelectModB").val('');
						$("#sideWpa .SideSelectType").val('');
						SideCarSelection.disableSubmit();
						
						SideCarSelection.loadFuel(true);
						SideCarSelection.loadTransmission(true);
						SideCarSelection.loadModB(true);
						SideCarSelection.loadType(true);
					break;	
					case 2:
						$("#sideWpa .SideSelectTransmission").val('');
						$("#sideWpa .SideSelectModB").val('');
						$("#sideWpa .SideSelectType").val('');
						SideCarSelection.disableSubmit();
						SideCarSelection.loadTransmission(true);
						SideCarSelection.loadModB(true);
						SideCarSelection.loadType(true);
						
					break;	
					case 3:
						$("#sideWpa .SideSelectModB").val('');
						$("#sideWpa .SideSelectType").val('');
						SideCarSelection.disableSubmit();
						SideCarSelection.loadModB(true);
						SideCarSelection.loadType(true);
					break;	
					case 4:
						$("#sideWpa .SideSelectType").val('');
						SideCarSelection.loadType(true);
						SideCarSelection.disableSubmit();
					break;	
				}
			},
			
			loadModels: function(auto){
				var postvars=$('#sideWpa form').serialize();
				if(postvars!=''){
					postvars+='&w=getmodelsby';
				}else{
					return;
				}
				$.post(config.ShopPath+"/remote.php", postvars , function(data){
					if(data!=''){
						$("#sideWpa .SideSelectModel").html(data);
					}
				}, "html");
			},
			
			loadFuel: function(auto){
				var postvars=$('#sideWpa form').serialize();
				if(postvars!=''){
					postvars+='&w=getbrandstofby';
				}else{
					return;
				}
				$.post(config.ShopPath+"/remote.php", postvars , function(data){
					if(data!=''){
						$("#sideWpa .SideSelectFuel").html(data);
					}
				}, "html");
				
			},
			
			loadTransmission: function(auto){
				var postvars=$('#sideWpa form').serialize();
				if(postvars!=''){
					postvars+='&w=gettransmissieby';
				}else{
					return;
				}
				$.post(config.ShopPath+"/remote.php", postvars , function(data){
					if(data!=''){
						$("#sideWpa .SideSelectTransmission").html(data);
						if(!auto){	
							$("#sideWpa label.transmissie").show();
							$("#sideWpa .SideSelectTransmission").show();
						}
					}else{
						$("#sideWpa label.transmissie").hide();
						$("#sideWpa .SideSelectTransmission").hide();
					}
				}, "html");
			},
			
			loadModB: function(auto){
				var postvars=$('#sideWpa form').serialize();
				if(postvars!=''){
					postvars+='&w=getmotoriseringandbouwjaarby';
				}else{
					return;
				}
				$.post(config.ShopPath+"/remote.php", postvars , function(data){
					if(data!=''){
						$("#sideWpa .SideSelectModB").html(data);
						if(!auto){	
							$("#sideWpa label.motoriseringbouwjaar").show();
							$("#sideWpa .SideSelectModB").show();
						}
					}else{
						$("#sideWpa label.motoriseringbouwjaar").hide();
						$("#sideWpa .SideSelectModB").hide();
					}
				}, "html");
			},
			
			loadType: function(auto){
				var postvars=$('#sideWpa form').serialize();
				if(postvars!=''){
					postvars+='&w=gettypesby';
				}else{
					return;
				}
				$.post(config.ShopPath+"/remote.php", postvars , function(data){
					if(data!=''){
						$("#sideWpa .SideSelectType").html(data);
						if(!auto){	
							$("#sideWpa label.type").show();
							$("#sideWpa .SideSelectType").show();
						}
					}else{
						$("#sideWpa label.type").hide();
						$("#sideWpa .SideSelectType").hide();
					}
				}, "html");
			},
			SetType: function(auto){
				var postvars=$('#sideWpa form').serialize();
				if(postvars!=''){
					postvars+='&w=settype';
				}else{
					return;
				}
				$.post(config.ShopPath+"/remote.php", postvars , function(data){
					if(data!=''){
						
					}else{
						
					}
				}, "html");
			},
			clearSelections: function(){
				postvars='&w=killSelections';
				$.post(config.ShopPath+"/remote.php", postvars , function(data){
					//location.reload(true);
				}, "html");
			},
			disableSubmit: function(){
				if($("#sideWpa.Small .mmSubmit").length==0){
					$("#sideWpa .mmSubmit").attr('disabled','disabled');
					$("#sideWpa .mmSubmit").addClass('disable');
				}
			},
			activateSubmit: function(){
				$("#sideWpa .mmSubmit").removeAttr('disabled');
				$("#sideWpa .mmSubmit").removeClass('disable');
			}
			
	};
	
