// JavaScript Document
$(function(){
	var cal;
	var $this;

	var checkForMouseout = function(event)
	{
		var el = event.target;
		
		while (true){
			if (el == cal) {
				return true;
			} else if (el == document) {
				$this.dpClose();
				return false;
			} else {
				el = $(el).parent()[0];
			}
		}
	};

	$('.date-pick')
		.datePicker({startDate:'01/01/1996'})
		.bind(
			'dpDisplayed',
			function(event, datePickerDiv)
			{
				cal = datePickerDiv;
				$this = $(this);
				$(document).bind(
					'mouseover',
					checkForMouseout
				);
			}
		).bind(
			'dpClosed',
			function(event, selected)
			{
				$(document).unbind(
					'mouseover',
					checkForMouseout
				);
			}
		);

});





