$(function(){
	$('#DOB').val($('#DOB').attr('data-default'));
  $('#DOB').focus(function(){
    if($('#DOB').val()==$('#DOB').attr('data-default')){
      $('#DOB').val('');
    }
  });
	$('#DOB').blur(function(){
    if($('#DOB').val()==''){
      $('#DOB').val($('#DOB').attr('data-default'));
    }
  });
	
  $.preLoadImages("/images/nav/sales_off.gif",
          "/images/nav/contact_off.gif",
					"/images/nav/rentals_off.gif",
					"/images/nav/application_off.gif",
          "/images/nav/sales_on.gif",
					"/images/nav/contact_on.gif",
					"/images/nav/rentals_on.gif",
					"/images/nav/application_on.gif");
  
	//$('a.inline').colorbox({width:"400px", height:"400px", iframe:true});
	//$('a.colorbox').colorbox();
  $("a.colorbox").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
	$("img.rollovers").hover(function(){
		this.src = this.src.replace("_off","_on");
		},
		function(){
			this.src = this.src.replace("_on","_off");
		}
	);
	
	//$('#banners').cycle({
	//	fx: 'fade'
	//});
	
	$("a.jqbookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;
		
		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing
		} else { 
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}
	
	});
  
  $('#mapSidebar article:even').css('backgroundColor','#cccccc');
  
  $(".forms").validationEngine();
	
	$("ul.dropdown li").dropdown();
	
	$('#nav>li>ul').hide();
	$('#nav>li').mouseover(function(){
			// create a reference to the active element (this)
			// so we don't have to keep creating a jQuery object
			$heading = $(this);
			// check to see if any sub menus are open
			if ($heading.siblings().find('ul:visible').size()!=0) {
					// close open sub menus
					$heading.siblings().find('ul:visible').slideUp(100, function(){
							// open current menu if it's closed
							$heading.find('ul:hidden').slideDown(100);
					});
			}
			else {
					// open current menu if it's closed
					$heading.find('ul:hidden').slideDown(100);
			}
	});
});
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

$.fn.dropdown = function() {
	$(this).hover(function(){
		$(this).addClass("hover");
		$('> .dir',this).addClass("open");
		$('ul:first',this).css('visibility', 'visible');
	},function(){
		$(this).removeClass("hover");
		$('.open',this).removeClass("open");
		$('ul:first',this).css('visibility', 'hidden');
	});
}

