var fluidlib =
{
	avg:
	{
		init: function()
		{			
			//get culture variable
			var jj_culture = $('#lng').attr('value');

			var $countrySelect = $('#ctl00_a_dcs');
			var aPressed = new Array();
			var aPattern = new RegExp('[^0-9]+', 'g');

			/*
			//alert('here');
			function ageVerification() {
			var aElement = $('.ddmmyyyy input:text');
			var aPattern = new RegExp('[^0-9]+', 'g');
			var aPressed = new Array();
			//$(aElement).click(function () {
			//    $(this).select();
			//}).focus(function () {
			//    $(this).select();
			//})
			$(aElement).keydown(function () {
			aPressed.push('1');
			}).keyup(function () {
			aPressed.shift();
			var aVal = this.value;
			aVal = aVal.replace(aPattern, '');
			if (aVal != this.value) this.value = aVal;
			if (this.value.length >= Number($(this).attr('maxlength')) && aPressed.length == 0) {
			$(this).next().focus();
			}
			}).eq(0).focus();
			};
			*/
			var $txtDay = $('#ctl00_a_txtDay');
			var $txtMonth = $('#ctl00_a_txtMonth');
			var $txtYear = $('#ctl00_a_txtYear');

			$txtDay.click(function() {
			    var $this = $(this);
			    if ($this.attr('value') == 'DD') {
			        $this.attr('value', '');
			        $this.focus();
			    }
			}).focus(function() {
			    var $this = $(this);
			    if ($this.attr('value') == 'DD') {
			        $this.attr('value', '');
			        $this.focus();
			    }
			}).keydown(function() {
			    aPressed.push('1');
			}).keyup(function() {
			    aPressed.shift();
			    var aVal = this.value;
			    aVal = aVal.replace(aPattern, '');
			    if (aVal != this.value) this.value = aVal;
			    if (this.value.length >= Number($(this).attr('maxlength')) && aPressed.length == 0) {
			        $(this).next().focus();
			    }
			});

			$txtMonth.click(function() {
			    var $this = $(this);
			    if ($this.attr('value') == 'MM') {
			        $this.attr('value', '');
			        $this.focus();
			        //ageVerification();
			    }
			}).focus(function() {
			    var $this = $(this);
			    if ($this.attr('value') == 'MM') {
			        $this.attr('value', '');
			        $this.focus();
			        //ageVerification();
			    }
			}).keydown(function() {
			    aPressed.push('1');
			}).keyup(function() {
			    aPressed.shift();
			    var aVal = this.value;
			    aVal = aVal.replace(aPattern, '');
			    if (aVal != this.value) this.value = aVal;
			    if (this.value.length >= Number($(this).attr('maxlength')) && aPressed.length == 0) {
			        $(this).next().focus();
			    }
			});

			$txtYear.click(function() {
			    var $this = $(this);
			    if ($this.attr('value') == 'YYYY') {
			        $this.attr('value', '');
			        $this.focus();
			        //ageVerification();
			    }
			}).focus(function() {
			    var $this = $(this);
			    if ($this.attr('value') == 'YYYY') {
			        $this.attr('value', '');
			        $this.focus();
			        //ageVerification();
			    }
			}).keydown(function() {
			    aPressed.push('1');
			}).keyup(function() {
			    aPressed.shift();
			    var aVal = this.value;
			    aVal = aVal.replace(aPattern, '');
			    if (aVal != this.value) this.value = aVal;
			    if (this.value.length >= Number($(this).attr('maxlength')) && aPressed.length == 0) {
			        $(this).next().focus();
			    }
			});	
			
			//if MIDDLE ENDIAN format (MM-DD-YYYY)
			selectedValue = $countrySelect.val();
			if(selectedValue=='US' || selectedValue=='PH' || selectedValue=='FM' || selectedValue=='CA' || selectedValue=='BZ')
				$txtMonth.after($txtDay).addClass('firstfield');
				
			var tryptychbottom = '<img id="tryptychbottom" src="/images/triptych-subtle-green.png" alt="Jameson" />';
			$('body').append(tryptychbottom);
			
			
						
		}
	}	
}


