var hso = {};
//Page elements
hso.el = {};
//Dom-ready events
hso.domready = {};
//Dom-ready events
hso.util = {};
//Page name
hso.page = '';

//Kill console.log if it doesn't exist
if (window.console === undefined) {
    window.console = {
        log: function () {}
    };
}


hso.util.clearForm = function() {
	
	if(confirm('Are you sure you want to clear your information? This cannot be undone.')) {
	
		$('form')[0].reset()
		$('form input')
		 .not(':button, :submit, :reset, :hidden')
		 .val('')
		 .removeAttr('checked')
		 .removeAttr('selected');
		$('form textarea').val('');
		
	}
}

hso.util.toggleExchangeTicketForm = function(event) {
	
	if(this.value == 'exchange') {
		hso.el.exchangeTicketFieldset.show();
	}
	else {
		hso.el.exchangeTicketFieldset.hide();
	}
}

hso.util.toggleAdminViewEdit = function(event) {
	event.preventDefault();
	var anchor = $(event.target);
	anchor.parents('tr').find('div.record-details').toggle();

}

hso.util.showAdminRecordDetails = function(event) {
	event.preventDefault();
	
	var recordDetails = $(this).parents('tr').find('div.record-details').clone();
	
	$('body').append(recordDetails);
	
	recordDetails.show();
	
	
	
	$('a.close', recordDetails).click(hso.util.removeAdminRecordDetails);
				
	$('input.date',recordDetails).each(function(){
		
		if($(this).val() != '') {
			$(this).datepicker({defaultDate: $(this).val()});
		}
		else {
			$(this).datepicker();
		}
		
	})
	
	
	
}

hso.util.removeAdminRecordDetails = function(event) {
	event.preventDefault();
	$(this).parents('div.record-details').remove();
}
