/* Author: 

*/
$(function(){
	$('.datepickerx').datepicker();
	
	$(function(){

	var $nav = $("#nav-main");
	
	$nav.find("li").each(function() {
		if ($(this).find("ul").length > 0) {
			//show subnav on hover
			$(this).mouseenter(function() {
				$(this).find("ul").stop(true, true).slideDown();
			});
			//hide submenus on exit
			$(this).mouseleave(function() {
				$(this).find("ul").stop(true, true).slideUp();
			});
			
			$(this).find('ul').hide();
		}
	});
});
	
	$('#what-can-fit .slide').hide().first().show();
		
	$('#select-size').change(function() {
		var slide = $(this).val();
		$('#what-can-fit .slide').hide();
		$('#what-can-fit .' + slide).show();
		
	});
	
	$('.validate').validationEngine({scroll:false});
	
	$('.btn-process').click(function(e){
		$('.datepickerx').datepicker( "destroy" );
		if($(this).hasClass('btn-disabled')){
			e.preventDefault();
		}
		else {
			if($('.validate').validationEngine('validate')){
				$('.btn-process').addClass('btn-disabled');
				$('#form-loading').show();
			}
			else {
				$('.datepickerx').datepicker();	
			}
			
		}
		
	});
	
		
//		$('#btn-storage-quote').click(function(){
//			$('#free-quote-form').attr('action', '/request-a-storage-estimate');
//		});
//		$('#btn-moving-quote').click(function(){
//			$('#free-quote-form').attr('action', '/request-a-moving-estimate');
//		});
	
//	var $productSelect = $('#container-select'),
//		$productList = $('#product-list'),
//		$products = $productList.children('.product');
//	
//	if($productSelect.length > 0){
//		$products.click(function(e){
//			e.preventDefault();
//			var $this = $(this),
//				id = $this.attr('rel');
//				
//				
//				
//			$products.removeClass('selected');
//			$this.addClass('selected');
//			$productSelect.val(id);//.children('option[value='+id+']').select();
//			
//		});
//		
//		var startingId = $productSelect.val();
//		$products.filter(function(item){
//			if ($(this).attr('rel') == startingId) return true;
//			return false;
//		}).addClass('selected');
//	}
//	
	$('#location-dropdown').change(function() {
		window.location = $(this).val();
	});

	if($('#video-player').length > 0){
		flowplayer("video-player", "/video/flowplayer-3.2.7.swf");
	}


});

$('[placeholder]').focus(function() {
  var input = $(this);
  if (input.val() == input.attr('placeholder')) {
    input.val('');
    input.removeClass('placeholder');
  }
}).blur(function() {
  var input = $(this);
  if (input.val() == '' || input.val() == input.attr('placeholder')) {
    input.addClass('placeholder');
    input.val(input.attr('placeholder'));
  }
}).blur();
















