// Home Page - Leftnav vehicle search #########################################################
  function toggleDiv(element)
  {
    if(document.getElementById(element).style.display == 'none')
    {
      document.getElementById(element).style.display = 'block';
    }
    else if(document.getElementById(element).style.display == 'block')
    {
      document.getElementById(element).style.display = 'none';
    }
  }

  function listModels(make) {
	  // Prevent a pointless Ajax request when the page first loads.
	  if(make != '')
	  {
		  $.ajax({
			  type: "POST",
			  dataType: 'json',
			  url: 'cache/vehicle_model/' + make.toLowerCase() + '.json',
			  success: function(data) {
			  	$('#model').children().remove();
			  	$('#model').append(
			  			$("<option></option>").attr("value",'').text('> Select Model')
			  	);
			  	$.each(data.data, function(key, value) {
			  		if(key != '') {
				  		$('#model').
				  			append($("<option></option>").
				  			attr("value",key).
				  			text(value));
			  		}
			  	});
			  }
		  });
	  }
  }

  function set() {

    listModels(document.getElementById('make').value);

  }
  function orderBy()
  {


    document.myform.orderby.value = document.getElementById('sortby').value;
    document.myform.submit();
  }
  function nothing()
  {
  }
  function submit(id)
  {
    document.myform.action="/search/page/"+id;
    document.myform.submit();
  }
  function updatePaginateLink(pageNo,numRows,filter)
  {
    $.ajax({

      type: "POST",

      url: "ajaxpaginate.php",

      data: "pageNo="+pageNo+"&numRows="+numRows+"&filter="+filter,

      success: function(msg)

               {

                 $("#page-selecter-area").html(msg);
				 $("#page-selecter-area2").html(msg);

               }

    });


  }

// END OF Home Page - Leftnav vehicle search #########################################################



// Home Page - Featured Cars Carousel #########################################################

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
	try {
    jQuery('#mycarousel').jcarousel({
        auto: 6,
        wrap: 'last',
        initCallback: mycarousel_initCallback,
		size: 10,
		scroll: 5
    });
    }catch(e){
// carousel probbably not on this page
    }
});

// END OF Home Page - Featured Cars Carousel #########################################################

