$().ready(function() {
	$('.datepicker').datepicker({
		dateFormat:'yy-mm-dd',
		beforeShow: function(input, inst) { $(this).attr('disabled','disabled'); },
		onClose: function(dateText, inst) { $(this).attr('disabled',''); }
	});
	
	$('.ui-button').hover(function() {
		$(this).addClass('ui-state-hover');
	}, function() {
		$(this).removeClass('ui-state-hover');
	});
});

function is_numeric(e) {

	var c = e.which ? e.which : e.keyCode;
	if (c > 31 && (c < 48 || c > 57)) return false;
	return true;
	
}

function generate_email(display_text,to_name) {
  var domain = "@yahoo.co.uk";
  display_text = (display_text == to_name) ? to_name+domain : display_text;
	document.write("<a href='mailto:"+to_name+domain+"' title='Email "+to_name+domain+"'>"+display_text+"</a>");
}

function validate(form) {
	
	var valid = true;
	$(form).find('.required').each(function() {
		
		if ($(this).attr('id')=='artwork-image' && $('#atwork-id').val()) {
		
		} else {
			
			if ($(this).val()=="") {
				$(form).find('tr.error').show().find('span.err').html('Highlighted fields are required');
				//$(form).find('.error').show().find('span.err').html('Highlighted fields are required');
				//$(this).css({'border':'1px solid #FFCCCC'});
				$(this).addClass('invalid');
				valid = false;
			}
			
		}
	});
	return valid;
}
