 $(document).ready(function() {
/*
	$('#datepicker').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: '1900:1992',
		defaultDate: '-18y',
		maxDate: '-18y'
		
	});
	$('#date_of_birth').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: '1900:1992',
		defaultDate: '-18y',
		maxDate: '-18y' 
		
	});
	$('#home-time').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: '1900:2010'
	});
	$('#time_at_employer').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'mm/yy',
		yearRange: '1900:2010'
	});	
	
	
	$('#next_pay_date').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: '2009:2010',
		minDate: 0
	});
	$('#following_pay_date').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: '2009:2010',
		minDate: 0
	});
*/
var currentTimez = new Date();
var nextyear = currentTimez.getFullYear()+1;
var currentyear = currentTimez.getFullYear();
var agoyear = currentTimez.getFullYear()-17;





	$('#datepicker').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: '1900:'+agoyear,
		defaultDate: '-18y',
		maxDate: '-18y'
		
	});
	$('#date_of_birth').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: '1900:'+agoyear,
		defaultDate: '-18y',
		maxDate: '-18y' 
		
	});
	$('#home-time').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: '1900:'+currentyear
	});
	$('#time_at_employer').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'mm/yy',
		yearRange: '1900:'+currentyear
	});	
	
	
	$('#next_pay_date').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: currentyear+':'+nextyear,
		minDate: 0
	});
	$('#following_pay_date').datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'dd/mm/yy',
		yearRange: currentyear+':'+nextyear,
		minDate: 0
	});		


	if ($('#house_name').val() !=""){
	
		  $('#addressBlock').show()
	}else{
		$('#addressBlock').hide()
		
	}


	$('#theapp').bind('click',function(){
		$( "#dialog-modal" ).dialog({
			open: function(event, ui) { $('#dialog-modal').html('<img src="/img/paydayanimatedgraphic.gif" alt="Loading"/>'); },
			width: 330,
			height: 165,
			modal: true
		});
	});

	$('#pay_freq').bind('change',function(){
	
		var pay = $('#pay_freq').val();
		//alert(pay);
		PayDateSet(pay)
	
	})
	
	
	$('#em').attr('href','mailto:info@paydaloanseasy.co.uk?Subject=Query from Paydayloanseasy web site');

	$('#btnFind').bind('click',function(){
		pcaByPostcodeBegin();
	});
	
	$('#selectaddress').bind('change',function(){
		pcaFetchBegin();
	});
	
	$('#formName').focus(function(){
		$('#formName').attr('value','');	
			
	});
	$('#formEmail').focus(function(){
		$('#formEmail').attr('value','');	
			
	});
	$('#formPhone').focus(function(){
		$('#formPhone').attr('value','');	
			
	});
	$('#formComments').focus(function(){
		$('#formComments').attr('value','');	
			
	});
	
	$('.privacy_popup').bind('click',function(){
		window.open('/privacy.php','mywindow01','width=650,height=600,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=0,resizable=0');

	})
	$('.terms_popup').bind('click',function(){
		window.open('/terms.php','mywindow01','width=650,height=600,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,copyhistory=0,resizable=0');

	})	
	
	
});








