$(function(){

				var vclass = ['3','2','5','4','1','6','7,8','99'];
				
				var className = ['small car','midsize car','large car','sta. wagon','sports utility','pickup','minivan','all vehicles'];

				
				$("#loading").ajaxStart(function(){

				   $(this).show();
	   
				   $('#ResultSet').fadeTo('slow', 0.33);

				});
				
				$("#loading").ajaxStop(function(){
				   $(this).hide();
				   
				   $('#ResultSet').fadeTo('slow', 1, function(){
					   if (jQuery.browser.msie)  
	            		this.style.removeAttribute('filter');
				    });
				    
				    //$(this).unbind("ajaxStart"); 
				   
				});
				
				
				var options = { 
			        target:        '#ResultSet'   // target element(s) to be updated with server response 
		    	};
		    	

			
			$(".class_left").click(function(event){
			
			
					var curIndex = $('#vclass').val();
			
					var index = $.inArray(curIndex,vclass);
					
					var newIndex = (index == '0') ? newIndex = 7 : newIndex = index - 1;
					
					$('#vclass').val(vclass[newIndex]);
					
					$('#classSearch a i').text(className[newIndex]);
				 			 
					$('#vehicleForm').ajaxSubmit(options);
				 
			});
			
			$(".class_right").click(function(event){
			
			
					var curIndex = $('#vclass').val();
			
					var index = $.inArray(curIndex,vclass);
					
					var newIndex = (index == '7') ? newIndex = 0 : newIndex = index + 1;
					
					$('#vclass').val(vclass[newIndex]);
					
					$('#classSearch a i').text(className[newIndex]);
				 
					$('#vehicleForm').ajaxSubmit(options);
				 

			});
			
			//ajaxTime.php is called every 15 seconds to get time from server
			   var refreshId = setInterval(function()
			   {
			    	var curIndex = $('#vclass').val();
			
					var index = $.inArray(curIndex,vclass);
					
					var newIndex = (index == '7') ? newIndex = 0 : newIndex = index + 1;
					
					$('#vclass').val(vclass[newIndex]);
					
					$('#classSearch a i').text(className[newIndex]);
				 
					$('#vehicleForm').ajaxSubmit(options);
					
			   }, 15000);
			

});
