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');
			
			if(selectedValue=='US'){
				usfooter = '<p class="green">You must be of legal drinking age in the country in which you are accessing this site.'
				+ '<br>By entering you agree to our terms &amp; conditions and our privacy policy.</p>'
				+ 'JAMESON&reg; Irish Whiskey. 40% Alc./Vol. (80 Proof). Product of Ireland.'
				+ '<br />&copy;2011 Imported by John Jameson Import Company, Purchase, NY'
				+ '<ul id="footerlinks" class="CMSListMenuUL">'
    			+ '<li class="CMSListMenuLI"><a href="/footerlinks/Privacy-Policy.aspx" class="CMSListMenuLink">Privacy Policy</a></li>'
    			+ '<li class="CMSListMenuLI"><a href="/footerlinks/Terms---Conditions.aspx" class="CMSListMenuLink">Terms &amp; Conditions</a></li>'
    			+ '<li class="CMSListMenuLI"><a href="/footerlinks/Sitemap.aspx" class="CMSListMenuLink">Sitemap</a></li>'
				+ '</ul>'
				+ '<p class="green">Irish Distillers and Pernod Ricard encourage a responsible attitude to the consumption of alcohol and actively discourage abuse and inapproriate consumption. Both companies are members of social aspects organisations which are active in the promotion of responsible drinking.</p>'
				+ '<p class="enjoy">TASTE RESPONSIBLY</p>';
				
				
				$('.verification').css('background','url(http://www.jamesonwhiskey.com/images/avg_us.jpg) no-repeat');
				$('#footerbottom').html(usfooter);
			}
			else{
				$('.verification').css('background','url(http://duxkfsvvo0kmo.cloudfront.net/images/avg.jpg) no-repeat');
			}
				
			var tryptychbottom = '<img id="tryptychbottom" src="/images/triptych-subtle-green.png" alt="Jameson" />';
			$('body').append(tryptychbottom);
			
			
			
			
						
		}
	}	
}


