jQuery(function() {
	jQuery('a[qtip]').each(function() {
		jQuery(this).qtip({
			content: jQuery(this).attr('qtip'),
			position: {
				target: 'mouse',
				corner: {
					target: 'topMiddle',
					tooltip: 'bottomMiddle'
				}
			},
			style: {
				tip: 'bottomMiddle',
				background: '#679720',
				color: 'white',
				fontSize: '11px',
				lineHeight: '14px',
				padding: '0 6px',
				width: {
					min: 150,
					max: 600
				},
				border: {
					width: 8,
					radius: 8,
					color: '#679720'
				},
				name: 'green'
			}
		});
	});
	jQuery('#loginbutton').click(function() {
		jQuery('#loginbutton').qtip('hide');
		jQuery('#loginbutton').fadeOut('fast');
		jQuery('#accountinfo').slideDown('fast', function() {
			jQuery('#log').focus();
		});
	}).each(function() {
		jQuery(this).qtip({
			content: jQuery('#loginbutton').attr('qtip'),
			position: {
				target: 'mouse',
				corner: {
					target: 'bottomMiddle',
					tooltip: 'topMiddle'
				}
			},
			style: {
				tip: 'topMiddle',
				background: '#679720',
				color: 'white',
				fontSize: '11px',
				lineHeight: '14px',
				padding: '0 6px',
				width: {
					min: 150,
					max: 600
				},
				border: {
					width: 8,
					radius: 8,
					color: '#679720'
				},
				name: 'green'
			}
		});
	}).css('cursor', 'pointer');
	jQuery('.accordion').each(function() {
		jQuery(this).accordion({
			autoHeight: false,
			collapsible: true,
			active: false
		});
		jQuery('h2', this).css({ 'font-size': '1.2em', 'margin-top': '7px' });
	});
	if (jQuery('.form-submitted').length) {
		jQuery('form.elistform').hide();
	}
	jQuery('#signup-form').dialog({
		autoOpen: false,
		modal: true,
		buttons: {
			'Sign Up': function() {
				jQuery('#signup-form form').submit();
				jQuery(this).dialog('close');
			}
		}
	});
	jQuery('a[href=#signup-form]').click(function() {
		jQuery('#signup-form').dialog('open');
		return false;
	});
});

function InitMyDelivery() {
	jQuery('#subDelivery1').click(function() {
		jQuery('.mydelivery .deliveryemail').removeClass('hidden');
		jQuery('.mydelivery .deliveryphone').addClass('hidden');
	});
	jQuery('#subDelivery2').click(function() {
		jQuery('.mydelivery .deliveryemail').addClass('hidden');
		jQuery('.mydelivery .deliveryphone').removeClass('hidden');
	});
	jQuery('.mydelivery input[name=subPhone]').focus(function() {
		if (jQuery(this).val() == '(xxx) yyy-zzzz') {
			jQuery(this).val('');
		}
	}).blur(function() {
		if (jQuery(this).val() == '') {
			jQuery(this).val('(xxx) yyy-zzzz');
		}
	}).trigger('blur');
}
