$(function(){


				//'99' removed
				var vclass = ['68','67','63','65','70','62','69','72','61'];
				var awardsClass = ['CITY','SMINI','SFAM','LFAM','ESTATE','EXEC','MPV','NEXT'];
				var awardsText = ['City-car','Supermini','Small Family', 'Large Family','Family Estate','Executive','MPV','Next Generation'];
				
				//'all vehicles' removed
				var advertText = "Advert";
				var className = ['superminis','small family cars','large family cars','multi-purpose cars','sports utility cars','executive cars','sports/cabrio cars','small vans','city cars'];

				
				$("#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 
		    	};
		    	


			
			 //ajaxTime.php is called every second to get time from server
			   var refreshId = setInterval(function()
			   {
			    	var curIndex = $('#vclass').val();
			    	var currentIndex = $('#currentIndex').val();
			
					var index = $.inArray(curIndex,vclass);
					
					var newIndex = (currentIndex == '7') ? newIndex = 0 : newIndex = parseInt(currentIndex) + 1;
					
					$('#vclass').val(vclass[newIndex]); // this needs to be used for the ngc rating images.
					//$('#vclass').val(awardsClass[newIndex]); //this is used for car awards
					$('#currentIndex').val(newIndex);
					
					//$('#classSearch a i').text(className[newIndex]);
					
					
				 	
				 	if(vclass[newIndex] == 'AD')
				 	{
				 		$('.vehicleText').text(className[newIndex]);
				 		$('#ResultSet').fadeTo('fast',0.33);
				 		$('#ResultSet').html('<a href="/approved" ><img src="/i/testAD.png" class="advert"/></a>');
				 		$('#ResultSet').fadeTo('slow',1, function(){
						   	if (jQuery.browser.msie)  
							this.style.removeAttribute('filter');
						});
				 	}
				 	else
				 	{
				 		//$('#ResultSet').fadeTo('fast',0.33);
						$('#vehicleForm').ajaxSubmit(options);
						//$('.vehicleText').text('Top 3 ' + className[newIndex]);
						//$('.tab_middle strong').text('Awards 2011: ' + awardsText[newIndex]);
						$('.tab_middle strong').text('Top 3 ' + className[newIndex]);
					}
					
					if($('#approvedHolder a').is('.approved'))
						imgHTML = '<a href="/ratings.php"><img src="/i/car-rating-button.jpg" alt="green car rating image" title="More on Green Car Rating"/></a>';
					else
						imgHTML = '<a href="/approved/" class="approved"><img src="/i/approved-button.jpg" alt="approved button image" title="See list of Approved green cars"/></a>';
					
					
						$('#approvedHolder').fadeTo('fast',0.33).html(imgHTML).fadeTo('slow',1);
					
			   }, 15000);
			
			
			$('#searchMake').click(function(){
			
				window.location = '/manufacturers.php';
			
			});
			
			
			$('#slideshow1').show().cycle({timeout: 7000});
			$('#slideshow2').show().cycle({timeout: 7000});

});
