$(document).ready(function() {

    
$('.linkedDatepicker').datepicker({ 
    beforeShow: readSelected,
    onSelect: updateLinked, 
    minDate: 0, 
    maxDate: +365, 
    showOn: 'both', 
    dateFormat:'m/dd/yy',
    buttonImageOnly: true, 
    buttonImage: 'http://www.ocmdhotels.com/images/ocmdhotels/calendar2.gif',
    gotoCurrent: true,
    showAnim: 'slideDown'
   })

var currentTime = new Date();
var amonth = currentTime.getMonth() + 1;
var aday = currentTime.getDate();
var ayear = currentTime.getFullYear();
if(aday<10) aday= "0" + aday;

    $('.selectMonth').val(amonth);
    $('.selectDay').val(aday);  
    $('.selectYear').val(ayear); 


$('.linkedDatepicker2').datepicker({ 
    beforeShow: readSelected2,
    onSelect: updateLinked2, 
    minDate: 0, 
    maxDate: +365, 
    showOn: 'both', 
    dateFormat:'m/dd/yy',
    buttonImageOnly: true, 
    buttonImage: 'http://www.ocmdhotels.com/images/ocmdhotels/calendar2.gif',
    gotoCurrent: true,
    showAnim: 'slideDown'
   })
   
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate()+1);
var amonth2 = tomorrow.getMonth() + 1;
var aday2 = tomorrow.getDate();
var ayear2 = tomorrow.getFullYear();
if(aday2<10) aday2= "0" + aday2;

    $('.selectMonth2').val(amonth2);
    $('.selectDay2').val(aday2);  
    $('.selectYear2').val(ayear2); 

});


// Prepare to show a date picker linked to three select controls  
function readSelected() {  
    $('.linkedDatepicker').val($('.selectMonth').val() + '/' +  
        $('.selectDay').val() + '/' + $('.selectYear').val());  
    return {};}  


// Update three select controls to match a date picker selection  


	function updateLinked(date) {  
	var temp = new Array();
	temp = date.split('/');

	mnth = temp[0] * 1;
	dy = temp[1] * 1;
	yr = temp[2] * 1;
	
	if(dy<10) dy= "0" + dy;
	
	$('.selectMonth').val(mnth);
    $('.selectDay').val(dy);
    $('.selectYear').val(yr); 
	
	}

// Prepare to show a date picker linked to three select controls  
function readSelected2() {  
    $('.linkedDatepicker2').val($('.selectMonth2').val() + '/' +  
        $('.selectDay2').val() + '/' + $('.selectYear2').val());  
    return {};}  


// Update three select controls to match a date picker selection  


	function updateLinked2(date) {  
	var temp = new Array();
	temp = date.split('/');

	mnth = temp[0] * 1;
	dy = temp[1] * 1;
	yr = temp[2] * 1;
	
	if(dy<10) dy= "0" + dy;
	
	
	$('.selectMonth2').val(mnth);
    $('.selectDay2').val(dy);
    $('.selectYear2').val(yr); 
	
	}

