$(document).ready(function(){

	if($('#x1').val() == ''){
		$('#x1').val('Vārds...');
		$('#x1').focus(function(){ $('#x1').val('') });
	}
	$('#x1').focus(function(){ $('#x1').addClass('onclick') });

	$('.month_menu .month').change(function(){ calendar_select(this.value) });
	$('.month_menu .year').change(function(){ calendar_select(this.value) });

	$('.vd > tbody tr td').mouseout(function(){ $(this).removeClass('MouseOver') });
	$('.vd > tbody tr td').mouseover(function(){ $(this).addClass('MouseOver') });

	// Reminder
	$('a.Reminder, a.Reminder-long').click(function(){
		var data = $('div', this).html().split('@');
		if(data[1] != null){
			OpenSendSmsForm(userPhone, data[0], data[1], module);
		}
		return false;
	});

});


function calendar_load(t, d){
	$.ajax({
		type: "GET",
		url: "?t="+ t +"&d="+ d,
		dataType: "html",
		success: function(data){
			$('#calendar').html(data);
			$('.month_menu .month').change(function(){ calendar_select(this.value) });
			$('.month_menu .year').change(function(){ calendar_select(this.value) });

			$('a.Reminder, a.Reminder-long').click(function(){
				var data = $('div', this).html().split('@');
				if(data[1] != null){
					OpenSendSmsForm(userPhone, data[0], data[1], module);
				}
				return false;
			});
		}
	});
}


function calendar_select(data){
	var d = new Date();
	d.setMonth($('.month_menu .month').val() - 1 );
	d.setYear($('.month_menu .year').val() );

	//alert( d.getFullYear() +'#'+  month  );
	calendar_load( d.getTime() , $('#date').html() );
}


function namedays(){
	if($('#x1').val() == 'Vārds...'){
		$('#x1').val('');
	}
	return true;
}
