// JavaScript Document
$(document).ready(function(){
		$('.calendarRange').calendar({fieldSettings: customRange, speed:"slow"});
		$("#icodFrom").click(function() { popUpCal.showFor($('#dFrom')[0]);  });
	    $("#icodTo").click(function() {	   popUpCal.showFor($('#dTo')[0]);   });

	function getDate(value) {
		fields = value.split('/');
		return (fields.length < 3 ? null :
		new Date(parseInt(fields[2], 10), parseInt(fields[1], 10) - 1, parseInt(fields[0], 10)));
	}	
	
	function customRange(input) {
		return {minDate: ((input.id == 'dTo') ? getDate($('#dFrom').val()) : null),
				maxDate: ((input.id == 'dFrom') ? getDate($('#dTo').val()) : null)};
	}    
});
