$(document).ready(function() {
//	$('.formbox').corner('10px');

//	$('#xfsubmit').corner('10px');

//	$('#captcha_fail').corner('10px');

	$('input')
		.each(function(){
			var c=$(this).attr('type');
			$(this).addClass('xf'+c);
		});

	$('#xfsubmit, #xfreset')
		.hover(
			function(){ $(this).addClass('hover') },
			function(){ $(this).removeClass('hover') }
		);

	$('#where_other_text').hide();

	$('input[name="where"]')
		.click(function(){
			if ($(this).val()=='Other') {
				$('#where_other_text').fadeIn();
			} else {
				$('#where_other_text').fadeOut();
			}
		});

	$('#brochure')
		.click(function(){
			if(this.checked) {
				$(this).parent().siblings('p').addClass('highlight');
			} else {
				$(this).parent().siblings('p').removeClass('highlight');
			}
		});


	// validate signup form on keyup and submit
	$('#elist').validate({
		errorElement: 'em',
		errorPlacement: function(error,element) {
			if ( element.is('[name="where"]') )
				error.appendTo( $('#legend_where') );
			else if ( element.is('[name="title"]') )
				error.appendTo( $('#legend_title') );
			else if ( element.is('[name="lists"]') )
				error.appendTo( $('#p_lists') );
			else {
				error.appendTo( element.parent() );
			}
		},
		meta: 'validate',
		submitHandler: function(form) {
			$('#xfsubmit input')
				.attr('value','Sending...')
				.attr('disabled','disabled');
	   		form.submit();
		}
	});

	reloadCaptcha();

	$('#captcha_fail')
		.animate({opacity: 1.0}, 10000)
		.fadeOut('slow', function() { $(this).remove(); });

});



function reloadCaptcha() {
	var c = new Date();
	var d = c.strftime('%Y%m%d%H%M%S') + 'tarragontheatrecom-50-300.jpgx';
	$('#captcha_img').attr('src', 'http://www.opencaptcha.com/img/' + d );
	$('#captcha_code').attr('value', d );
}



jQuery.validator.addMethod("notEqualTo", function(value, element, params) { 
    return value != $(params).val();
}, $.format("Please enter a different value."));



