$(function() {
	 setTimeout('Init()', 1000);
	  $('#slider').nivoSlider();
	// alert('test');
		$('.l .image').click(function() {
			window.location = '/';
		});
	  $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)  
  
		$("ul.menu li span").parent().hover(function() { //When trigger is clicked...  
			//Following events are applied to the subnav itself (moving subnav up and down)  
				$(this).parent().hover(function() {  
				}, function(){  
					$(this).find("ul.subnav").each(function() {
						if(($(this).attr('status') == 'down') && ($(this).attr('status') != 'scroll')) {
							$(this).attr('status','scroll'); 
							$(this).hide();
							$(this).attr('status','up');
						}
					});
				});  
				$(this).find("ul.subnav").each(function() {
					if(($(this).attr('status') != 'down') && ($(this).attr('status') != 'scroll')) {
						$(this).attr('status','scroll'); 
						$(this).slideDown('fast');
						$(this).attr('status','down');
					}
				});
			//	$(this).find('ul.subnav').attr('status','scroll').slideDown('fast').show().attr('status','down'); 
				//$(this).find('ul.subnav'); //Drop down the subnav on click 
				//$(this).find('ul.subnav').; 
			
			
	  
			
	  
			//Following events are applied to the trigger (Hover events for the trigger)  
			}).hover(function() {  
				$(this).children("span").addClass("subhover"); //On hover over, add class "subhover"  
			}, function(){  //On Hover Out  
				$(this).children("span").removeClass("subhover"); //On hover out, remove class "subhover"  
		}); 
	
});

function Init() {
	
	ResizeColumn();
	
      
	 
}

function ResizeColumn() {
	var LeftHeight =0;
	  var RightHeight =0;
	  var Calc = 0;
	  LeftHeight = $('.contentCars').outerHeight();
	  LeftHeight = LeftHeight + $('.contentNews').outerHeight();
	  RightHeight = $('.homepageBanner').outerHeight();
	  RightHeight = RightHeight + $('.content').outerHeight();
	  if(LeftHeight > RightHeight) {
		  Calc = LeftHeight - RightHeight;
		  $('.main .wrapper .r .content').height($('.main .wrapper .r .content').height()+Calc);
	  } else {
		  Calc = RightHeight - LeftHeight;
		  $('.contentCars').height($('.contentCars').height()+Calc);
	  }
	  $(".contentCars, .homepageBanner").equalizeCols();
}

function BannerSwap(name) {
	document.getElementById('mainImage').innerHTML = '<img src="' + name + '" style="width: 470px;">';
}
