/*-------------------------------------------------------------------------------------------------------
 FUNCTIONS FOR STEP 1 OF ESTIMATE FORM
-------------------------------------------------------------------------------------------------------*/

// Hide residence size option if business or single item move.	
$(function() 
   {
   $(".hideresidencesize").click(function() 
	   {
		$("#residencesize").hide("slow");
		});
	});

	
// Show residence size option only if residential move desired.
$(function() 
   {
   $(".showresidencesize").click(function() 
	   {
  	   $("#residencesize").show("slow");
		});
	});

	
// Datepicker function
$(function() 
   {
   $("#datepicker").datepicker(
	   {
	   numberOfMonths: 2,
		minDate:1
		});
	});

	



/*-------------------------------------------------------------------------------------------------------
 FUNCTIONS FOR STEP 2 OF ESTIMATE FORM
-------------------------------------------------------------------------------------------------------*/
	
// Toggle to show storage facility name for start location.
$(function()
   {
   $("#starttype").click(function() 
	   {
      var selectedStartType = $('#starttype').val();
      if (selectedStartType == '3')
         {
  		   $("#startdistancediv").show("slow");
  		   $("#startstoragenamediv").hide("slow");
  		   $("#startfloordiv").hide("slow");
  		   $("#startelevatordiv").hide("slow");
  		   $("#startelevatortypediv").show("slow");
  		   $("#startelevatorreservediv").show("slow");
			}
      else if (selectedStartType == '4')
         {
  		   $("#startdistancediv").hide("slow");
  		   $("#startstoragenamediv").show("slow");
  		   $("#startfloordiv").hide("slow");
  		   $("#startelevatordiv").hide("slow");
  		   $("#startelevatortypediv").hide("slow");
  		   $("#startelevatorreservediv").hide("slow");
			}
      else
		   {
  		   $("#startdistancediv").show("slow");
  		   $("#startstoragenamediv").hide("slow");
  		   $("#startfloordiv").show("slow");
  		   $("#startelevatordiv").show("slow");
  		   $("#startelevatortypediv").hide("slow");
  		   $("#startelevatorreservediv").hide("slow");
			}
		});
	});

	
// Toggle to show storage facility name for end location.
$(function()
   {
   $("#endtype").click(function() 
	   {
      var selectedEndType = $('#endtype').val();
      if (selectedEndType == '3')
         {
  		   $("#enddistancediv").show("slow");
  		   $("#endstoragenamediv").hide("slow");
  		   $("#endfloordiv").hide("slow");
  		   $("#endelevatordiv").hide("slow");
  		   $("#endelevatortypediv").show("slow");
  		   $("#endelevatorreservediv").show("slow");
			}
      else if (selectedEndType == '4')
         {
  		   $("#enddistancediv").hide("slow");
  		   $("#endstoragenamediv").show("slow");
  		   $("#endfloordiv").hide("slow");
  		   $("#endelevatordiv").hide("slow");
  		   $("#endelevatortypediv").hide("slow");
  		   $("#endelevatorreservediv").hide("slow");
			}
      else
		   {
  		   $("#enddistancediv").show("slow");
  		   $("#endstoragenamediv").hide("slow");
  		   $("#endfloordiv").show("slow");
  		   $("#endelevatordiv").show("slow");
  		   $("#endelevatortypediv").hide("slow");
  		   $("#endelevatorreservediv").hide("slow");
			}
		});
	});

	
// Furniture disassembly toggle.
$(function()
   {
   $("#disassemble").click(function() 
	   {
      if ($('#disassemble').is(':checked'))
         {
   		$("#disassemblebox").show("slow");
			}
      else
		   {
  		   $("#disassemblebox").hide("slow");
			}
		});
	});



	

/*-------------------------------------------------------------------------------------------------------
 FUNCTIONS FOR FAQ
-------------------------------------------------------------------------------------------------------*/
	
// FAQ toggle to show answers to questions.	
$(function() 
   {
   $(".faq").find('dt').click(function()
	   {
   	var answer = $(this).next();
					 if (answer.is(':visible')) {
							 answer.slideUp('slow');
					 } else {
							 answer.slideDown('slow');
					 }
		});
	});
	

	
/*-------------------------------------------------------------------------------------------------------
 FUNCTIONS FOLLOWUP FORM
-------------------------------------------------------------------------------------------------------*/

// Toggle to show and hide movers from list.	
$(function() 
   {
   $(".movercheckbox").click(function()
	   {
      var selectedCheckBox = $(this).val();

      if ($(this).is(':checked'))
		   {
			$("#" + selectedCheckBox).slideDown("fast");
			}
		else
		   {
			$("#" + selectedCheckBox).slideUp("fast");
			}
		});
	});

	
// Toggle to show and hide acutal time worked for each mover
$(function() 
   {
   $(".moverdetails").find('.entiremovecheckbox').click(function()
	   {
      var selectedOption = $(this).next('.timeworkeddiv');

		
      if (selectedOption.is(':visible'))
		   {
			selectedOption.hide('fast');
			}
		else
			{
			selectedOption.show('fast');
		   }
		});
	});

	
// Datepicker function for move followups	
$(function() 
   {
   $("#followupdatepicker").datepicker(
	   {
		maxDate:0,
		minDate: -3
		});
	});

// Datepicker function for move followups	
$(function() 
   {
   $(".alldatepicker").datepicker(
	   {
	   numberOfMonths: 2
		});
	});
	
// Toggle truck use for move followups.
$(function()
   {
   $("#followupservicetype").click(function() 
	   {
      var selectedServiceType = $('#followupservicetype').val();
      var selectedUseTruck = $('#usetruck').val();

      if (selectedServiceType == '1')
         {
  		   $("#usetruckdiv").slideDown("slow");

         // Show Bill of Lading and Estimate forms if truck used.
         if (selectedUseTruck == '1')
            {
        		$("#showformsdiv").slideDown("slow");
            }
			}
      else
		   {
  		   $("#usetruckdiv").hide("slow");
     		$("#showformsdiv").hide("slow");
			}
		});
	});


	
	
// Show Bill of Lading and Estimate forms if truck used.
$(function()
   {
   $("#usetruck").click(function() 
	   {
      var selectedUseTruck = $('#usetruck').val();
      if (selectedUseTruck == '1')
         {
     		$("#showformsdiv").slideDown("slow");
			}
      else
		   {
  		   $("#showformsdiv").hide("slow");
			}
		});
	});


	
	
// Toggle labor rate for move followups.
$(function()
   {
   $("#followupservicetype").click(function() 
	   {
      var selectedServiceType = $('#followupservicetype').val();
      if (selectedServiceType == '5')
         {
  		   $("#laborratediv").hide("slow");
			}
      else
		   {
  		   $("#laborratediv").slideDown("slow");
			}
		});
	});


// Toggle business name use for business move followups.
$(function()
   {
   $("#followupmovetype").click(function() 
	   {
      var selectedMoveType = $('#followupmovetype').val();
      var selectedUseTruck = $('#usetruck').val();
      if (selectedMoveType == '2')
         {
  		   $("#followupbusinessname").slideDown("slow");
     		$("#showformsdiv").hide("slow");
			}
      else
		   {
  		   $("#followupbusinessname").hide("slow");


         // Show Bill of Lading and Estimate forms if truck used.
         if (selectedUseTruck == '1')
            {
        		$("#showformsdiv").slideDown("slow");
            }
			}
		});
	});
	
// Latestart toggle.
$(function()
   {
   $("#startontime").click(function() 
	   {
      if ($('#startontime').is(':checked'))
         {
  		   $("#startexplaindiv").slideUp("slow");
			}
      else
		   {
   		$("#startexplaindiv").slideDown("slow");
			}
		});
	});
		

// Cash toggle.
$(function()
   {
   $("#usecash").click(function() 
	   {
      if ($('#usecash').is(':checked'))
         {
  		   $("#totalcashdiv").slideDown("slow");
			}
      else
		   {
   		$("#totalcashdiv").hide("slow");
			}
		});
	});

		
// Check toggle.
$(function()
   {
   $("#usecheck").click(function() 
	   {
      if ($('#usecheck').is(':checked'))
         {
  		   $("#totalcheckdiv").slideDown("slow");
  		   $("#tipcheckdiv").slideDown("slow");
  		   $("#checknumberdiv").slideDown("slow");
			}
      else
		   {
  		   $("#totalcheckdiv").hide("slow");
  		   $("#tipcheckdiv").hide("slow");
  		   $("#checknumberdiv").hide("slow");
			}
		});
	});
		
		
// Credit toggle.
$(function()
   {
   $("#usecredit").click(function() 
	   {
      if ($('#usecredit').is(':checked'))
         {
  		   $("#totalcreditdiv").slideDown("slow");
  		   $("#tipcreditdiv").slideDown("slow");
			}
      else
		   {
  		   $("#totalcreditdiv").hide("slow");
  		   $("#tipcreditdiv").hide("slow");
			}
		});
	});
		
		
// Credit toggle.
$(function()
   {
   $("#credit").click(function() 
	   {
      if ($('#credit').is(':checked'))
         {
  		   $("#totalcreditdiv").slideDown("slow");
  		   $("#tipcreditdiv").slideDown("slow");
			}
      else
		   {
  		   $("#totalcreditdiv").hide("slow");
  		   $("#tipcreditdiv").hide("slow");
			}
		});
	});
		

// Dialog for successful database queries
$(function() 
   {
	$("#dialog").dialog(
	   {
	   bgiframe: true,
	   modal: true,
	   buttons: 
	      {
		   OK: function() 
		      {
			   $(this).dialog('close');
			   }
		   }
	   });
   });	
	
	

	
/*-------------------------------------------------------------------------------------------------------
 FUNCTIONS WORK HOURS
-------------------------------------------------------------------------------------------------------*/
	
// Datepicker function for move followups	
$(function() 
   {
   $("#workhoursdatepicker").datepicker(
	   {
		maxDate:0,
		minDate: -3
		});
	});

