$(document).ready(function(){
	
	$('.contactDetails').live('submit', function() { // catch the form's submit event
	console.log( $(this).serialize() )
	    $.ajax({ // create an AJAX call...
	        data: $(this).serialize(), // get the form data
	        type: 'post', // GET or POST
	        url: $(this).attr('action'), // the file to call
	        success: function(response) { // on success..
	            $('.ui-tabs-panel:visible').html(response); // update the DIV
	        }
	    });
	    return false; // cancel original event to prevent form submitting
	});	
	
	
	// Create popout
	$('#dialog').dialog({
			bgiframe: true,
			modal: true,
			buttons: {
				Ok: function() {
					$(this).dialog('close');
				}
			}
		}); 	
	
	$("#pet_dob").datepicker( {
		changeYear: true,
		constrainInput: true,		
		dateFormat: 'dd/mm/yy',
		maxDate: '+0d'
		});


	$('input.datepicker').live('click', function() {
		$(this).datepicker({
		changeYear: true,
		constrainInput: true,		
		dateFormat: 'dd/mm/yy',
		minDate: '+0d',
		showOn:'focus'
		}).focus();
	});

	$(function() {
		$("#accordion").accordion({autoHeight: false});
	});

	
	$(".microchip_type").change(function(){
		selectedVal = $(".microchip_type").val().toLowerCase();
		console.log(selectedVal)
		if(selectedVal == 'other'){
			$(".microchip_type_other").show()
		}else{
			$(".microchip_type_other").hide()
		}
	}).change()
	
	
	$(".pet_type").change(function(){
		selectedVal = $(".pet_type").val().toLowerCase();
		if( selectedVal == 'other'){
			$(".pet_type_other").show()
		}else{
			$(".pet_type_other").hide()
		}
	}).change()
})