$(document).ready(function() {	
	
	$('.alteringRows .row:even').addClass('odd');
	
	$('li.mainMenuLi').hoverIntent(
		function() { $('.subMenu', this).slideDown('fast'); },					   
		function() { $('.subMenu', this).slideUp('fast'); }
	).css('zindex','9999');
	
	$('li.topMenuLi').hoverIntent(
		function() { $('.subMenuTop', this).slideDown('fast'); },					   
		function() { $('.subMenuTop', this).slideUp('fast'); }
	).css('zindex','99999');

	$('li.mainMenuLi').hover(
		function() { $(this).addClass('mainMenuHover'); },					   
		function() { $(this).removeClass('mainMenuHover'); }					   
	).css('zindex','9999');
	
	$('#topSection, #menuSection, #midSection, #searchBox').supersleight();
	$(".directions").colorbox({close:"Close",innerWidth:"820", innerHeight:"570", iframe:true});
    $(".video").colorbox({close:"Close", iframe:true, innerWidth:480, innerHeight:295});
    $(".popupbox").colorbox({close:"Close", iframe:true, innerWidth:650, innerHeight:550});
    $(".offerings").colorbox({close:"Close", iframe:true, innerWidth:1024, height:'92%'});
    $(".colorbox").colorbox({close:"Close"});

	$('.elements').cycle({ 
		timeout: 	0,
		random:		true,
		cleartypeNoBg: true
	});

	$('a[href*=#]').click(function() {
 		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
   			var $target = $(this.hash);
   			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
   			if ($target.length) {
  				var targetOffset = $target.offset().top;
  				$('html,body').animate({scrollTop: targetOffset}, 500);
   		 	return false;
   			}
  		}
  	});
  	
   	$('#tabs').tabs();

	setInterval("animation('clouds1','clouds2')", 100);

});

function PopupLink() {
	$.fn.colorbox({ 
		href: "/pages/popup-scheduleTestDrive.aspx",
		close:"Close", 
		iframe:true, 
		innerWidth:600, 
		innerHeight:400
	})
}



	var start1 = 0;
	var start2 = 0;

	function animation(div1, div2){
		
		start1 += 1;
		start2 += 3;
		
		if (!$.browser.msie){
			$('.'+ div1).fadeIn(5000);
			$('.'+ div2).fadeIn(5000);
		}
		else {
			$('.'+ div1).show();
			$('.'+ div2).show();
		}
		
		$('.'+ div1).css("background-position", start1+"px 0");
		$('.'+ div2).css("background-position", start2+"px 0");
		
	}
	
	function popup (url, target, width, height, options) {
		var _options = options + ",width=" + width + ",height=" + height;
		var top = (screen.height/2)-(height/2);
		var left = (screen.width/2)-(width/2);
		_options += ",top=" + top + ",left=" + left;
		var popupWindow = window.open(url, target, _options);
	}
	
