function checkValue (input) {
	if(input.value==input.defaultValue)
		input.value="";
	else if(input.value=="")
		input.value=input.defaultValue;
}

/**
 * Extends the string primitive to have trim functionality
 */

String.prototype.ltrim = function () {
	return this.replace(/^ +/g, '');
}

String.prototype.rtrim = function () {
	return this.replace(/ +$/g, '');
}

String.prototype.trim = function () {
	return this.ltrim().rtrim();
}

$(function () {
	/*$('td.name').onclick(function () {
		console.log('clicked');
	  console.log($(this).children('a').attr('href'));
	});*/
  
  $('#formName').focus();
	$('#enquiryForm').attr('action', '/bin/cmail-form.html');
	
	$('#enquiryForm').submit(function () {	
		
		var validationPassed = true;
		$('.text, .textarea').each(function () {
			var input = $(this);
			
			if (input.val().trim() == '') {
        validationPassed = false;
				
				console.log("issue");
				
				input.css({ borderColor: '#c00' });
				input.change(function () {
				  input.css({ borderColor: '' });
				});
			}
			
		});
		
		if (validationPassed === false)
		{
			$('#error').html('Please fill out all fields');
		  return false;
		}
		
		return true;
	});
});
