$(function() {
   // handeling the search form	$('#search_form select').change( function() {		// switch keywords availibility
      if ($('#manufacturer')[0].value!='' || $('#body')[0].value!='' || $('#start_price')[0].value!='0' || $('#end_price')[0].value!='0')
         $('#keywords')[0].disabled = true;
      else $('#keywords')[0].disabled = false;

      // load new select
      /*if (this.name=='manufacturer') {
         $('#body')[0].disabled=true;      	$('#body').html('<option>Loading...</option>').load('inc/get_search_list.php', {manufacturer: this.value}, function() {$('#body')[0].disabled=false;} );
      }*/
      var changed_el = this;
      $('#search_form select').not('#change_currency_select').not('#'+changed_el.name).each(function (el) {      	//alert(this.value);
      	//alert(this.name);
      	//if ((this.value=='' || this.value=='0')) { // load from ajax
      	   this.disabled=true;
      	   $('#'+this.name)/*.html('<option value="">Loading...</option>')*/.load('inc/get_search_list.php', {      	   	manufacturer: $('#manufacturer')[0].value,
      	   	body: $('#body')[0].value,
      	   	start_price: $('#start_price')[0].value,
      	   	end_price: $('#end_price')[0].value,
      	   	get_type: this.name},
      	   	function() {      	   		this.disabled=false;
      	   		//changed_el.selected

      	   	}
      	   );
      	//}
		});
	});
	//if ($('#manufacturer')[0].value!='') $('#search_form select').trigger('change');


	// dealer select
	$('#dealer_select').change( function() {		var url;
		url = this[this.selectedIndex].text;
		url = url.replace(/([^a-zA-Z\-])/g,'-');
		url = url.replace(/\-+/g,'-');
		//url = url.replace('[^a-zA-Z\-]','-');
		//url = url.replace(' ','-');
		//url = url.replace(' ','-');
		//alert(this.selectedIndex);
		if (this.selectedIndex==0) window.location = 'index.html';
	   else window.location = url+'.html';
	});

	$('#change_currency_select').change( function() {      $('#change_currency')[0].value = this[this.selectedIndex].value;
      $('#form_usd').submit();
	});

});