// JavaScript Document

function highlight_item (item) {
	highlight_item_generic(item, 'highlight_low', 'highlight_high_link');
}

function highlight_item_generic (item, normal, highlight) {
	
	jQuery(function($) {
				jQuery(item).mouseover(function() {
					jQuery(item).addClass(highlight);
					jQuery(item).removeClass(normal);
				});
				
				jQuery(item).mouseout(function(event) {
					jQuery(item).removeClass(highlight);
					jQuery(item).addClass(normal);
				});
			});
}

function highlight (item, normal, highlight) {
	jQuery(item).addClass(highlight);
	jQuery(item).removeClass(normal);
}

function unhighlight (item, normal, highlight) {
	jQuery(item).removeClass(highlight);
	jQuery(item).addClass(normal);
}

function testaMail()
{
	if(document.form.newsletter.value =="")
		{
			alert("\tInforme um e-mail para receber a nossa newsletter.");
			return false;
		}
	else if(!checkMail(document.form.newsletter.value))
		{
			alert("\tInforme um e-mail válido para receber nossa newsletter.");
			return false;
		}	
	else
	{
		document.form.submit();
		return true;
	}
}

function checkMail(mail){
        var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
        if(typeof(mail) == "string"){
                if(er.test(mail)){ return true; }
        }else if(typeof(mail) == "object"){
                if(er.test(mail.value)){ 
                                        return true; 
                                }
        }else{
                return false;
                }
}