$(document).ready(function(){
	$("body img").noContext();
	
	if ($("#contactpage").length > 0) {
		$("#contactpage input[type='text']").each(function() {
			setItem($(this));
		});
		$("#contactpage textarea").each(function() {
			setItem($(this));
		});		
	}

	$('#contactpage form').submit(function(){
		var erro = false;
		$(this).find('input').each(function(){
			if($(this).attr("name") == 'email'){
				var matchArray = $(this).val().match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/);
				
				if (matchArray == null) {
					$(this).css({"color":"red"});
					erro = true;
				}else{
					$(this).css({"color":"black"});
					erro = false;					
				}
			}
		});
		if(erro)
			return false;
		else
			return true;
	});	
});

function setItem(item) {
	item.attr("oldtext", item.val());
	item.click(function(){
		if(item.val() == item.attr("oldtext")){
			item.val("");
		}else{
			
		}
	});
	item.blur(function(){
		if (item.val() == "") {
			item.val(item.attr("oldtext"));
		}
	});
};


/* --------------------------------------------------------------------------- */
