

function envia_contato(form) {
    if (form.nome.value == ""){
	    alert('Os campos destacados são obrigatórios.');
	    form.nome.focus();
	    return false;
		
    }else if (form.fone.value == ""){
	    alert('Os campos destacados são obrigatórios.');
	    form.fone.focus();
	    return false;
		
    }else if (form.email.value == ""){
	    alert('Os campos destacados são obrigatórios.');
	    form.email.focus();
	    return false;
		
    }else if (!ChecaMail(form.email.value)){
	    alert('Você deve inserir um e-mail valido.');
	    form.email.focus();
	    return false;
		
    }else if (form.assunto.value == ""){
        alert('Os campos destacados são obrigatórios.');
	    form.assunto.focus();
	    return false;
		
	}else{
		form.submit();
		
	}
}

function showFoto(src, title){
    var a_false = document.createElement("a");
    a_false.rel = "lightbox";
	a_false.title = title;
    a_false.href = src;
    
    myLightbox.start(a_false);
    
    a_false = null;
}

function fireOnclick(objID) {
	var target=document.getElementById(objID);
	if(document.dispatchEvent) { // W3C
    	var oEvent = document.createEvent( "MouseEvents" );
    	oEvent.initMouseEvent("click", true, true,window, 1, 1, 1, 1, 1, false, false, false, false, 0, target);
    	target.dispatchEvent( oEvent );
    }else if(document.fireEvent) { // IE
    	target.fireEvent("onclick");
    }    
}

function ChecaMail(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;
    }
}

function MascaraFormata(src, mascara) {
	var campo   = src.value.length;
	var saida   = mascara.substring(0,1);
	var texto   = mascara.substring(campo);
	if(texto.substring(0,1) != saida) {
		src.value += texto.substring(0,1);
	}
}

function sonum(e) {
	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode can be used
		key = e.keyCode;
	} else if(e.which) {
		// netscape
		key = e.which;
	} else {
		// no event, so pass through
		return true;
	}
	if ((key > 47 && key < 58) || (key == 8 || key == 9 || key == 127)){
	}else{
		return false;
	}
}

