//Hover menu handling
var ZPayment = Class.create({
	frm : '#z_payment',
	initialize: function() {
	},
	handle: function() {
		var t = this;
		jQuery(document).ready(function () {
			jQuery(this.frm).submit(
				function() {
					//test if the tandc box exists is checked
					var tc = jQuery('#z_tandc_agree');
					if(jQuery(tc).length > 0) {
						if(!jQuery(tc).attr('checked')) {
							jQuery(this).find('#z_tandc_agree_message').show('fast');
							t.toggle_submit(true);//enable
							return false;
						} else {
							jQuery(this).find('#z_tandc_agree_message').hide('fast');
							t.toggle_submit(false);//disable
							return true;
						}
					} else {
						t.toggle_submit(false);//disable
						return true;
					}
				}
			);
		});
	},
	toggle_submit : function(toggle) {
		//once submitted, minimise double click events
		jQuery(this.frm).find(':submit').each(
			function() {
				if(!toggle) {
					//disable
					jQuery(this).attr('disabled','disabled');
					jQuery(this).addClass('button-disabled');
				} else {
					//enable
					jQuery(this).removeAttr('disabled');
					jQuery(this).removeClass('button-disabled');
				}
			}
		);
		return true;
	}
});
