$(document).ready(function() {

	$(function() {
		$(".ajxdate").datepicker({  changeMonth: true,    changeYear: true });
		$(".ajxdate").datepicker('option', {dateFormat: 'dd/mm/yy'});
	});


	$(function() {
		$(".ajxdatetime").datetimepicker();
		$(".ajxdatetime").datetimepicker('option', {dateFormat: 'yy-mm-dd'});
	});


	$(function() {
		$(".ajxbirthday").datepicker({  changeMonth: true, changeYear: true, yearRange: '1910:1999',
				beforeShow: function(input) { // do nothing
				 }
		});
		$('.ajxbirthday').datepicker('option', 'dateFormat', 'dd/mm/yy');

	});


	$(".ajxint").mask("999");

	$(".ajxcep").mask("99999-999");

	$(".ajxnumeric").numeric(",");

	$(".ajxlivedropdown").each(function() {
		var s = $(this).attr("id");	
		var arr = s.split(":");
		if (arr.length>2) {
			$(this).ajxLiveDropdown({ source: arr[0], keyfield:arr[1],labelfield:arr[2] });
		//	$(this).ajxLiveDropdown({ source: 'locais', keyfield:'Id',labelfield:'nome' });
		}
	});


	$(".ajxCaseCapitalize").blur(function() {

		function doCapitalize(txt) {
				
				function doUpper(s,checkMidWords) {
					if (checkMidWords) {
						if ($.inArray(s,AJX_MID_WORDS_NOCAPITALIZE)>=0) return s;
					}
					s = s.substring(0,1).toUpperCase() + s.substring(1,s.length);
					return s;
				}

			txt = jQuery.trim(txt);
			txt = txt.toLowerCase();
			while (txt.indexOf('  ')>0) str = str.replace(/  /g," ");
			var arr=txt.split(' ');
			var separator="";
			var sres = "";
			for (var i=0; i<arr.length; i++) {
				sres+=separator+doUpper(arr[i],((i>0) && (i<arr.length-1)));				
				separator=" ";
			}
			return sres;			

		}

		var s = $(this).val();	
		s = doCapitalize(s);
		$(this).val(s);	
	});
	

	$(".ajxCaseUpper").blur(function() {
		var s = $(this).val();	
		s = s.toUpperCase();
		$(this).val(s);	
	});
	
	$(".ajxCaseLower").blur(function() {
		var s = $(this).val();	
		s = s.toLowerCase();
		$(this).val(s);	
	});



});
