/*
 * Validate email address for search
 */

jQuery.validator.setDefaults({
    errorElement: 'div',
    errorClass: 'errorFields'
});

$(document).ready(function(){
	$('#searchemail').validate({
		errorPlacement: function(error, element) {
			error.appendTo(element.next().children())
		},
		rules: {
			emailaddress: {
				required: true,
				email: true
			}
		},
		submitHandler: function(form){
			document.getElementById('loading').style.display='block';
			document.getElementById('search').style.display='none';
			form.submit();
		}
	});
	
	$('#emailaddress').focus(function(){
		if (this.value == this.defaultValue){  
			this.value = '';  
		}  
		if(this.value != this.defaultValue){  
			this.select();  
		} 
	});
	
	$('#emailaddress').blur(function() {
		if (this.value == ''){  
			this.value = (this.defaultValue ? this.defaultValue : '');  
		}  
	}); 
})
