var contato = {
    init: function()
    {
        
        var opened = location.search.split("=")[1];
        var all = $('.accordion dd');
        $(all).hide();
        
        if(opened != null) { $(all).eq(opened).show(); }
        
        $('.accordion dt').live('click',function(){
            if($(this).next().is(':visible')){
                $(all).stop().slideUp(300);
            }else{
                $(all).stop().slideUp(300);
                $(this).next().stop().slideDown(300);
            }
        });
        
    }
};

$(document).ready(function() {
    contato.init();
    $('input:text, textarea').focus(function() {
    $(this).css({ border: 'solid 1px #d1d1d1', backgroundColor: '#efefef' });
    });
});

function isFilled(field) {
    if ($(field).val() == '') return false;
    else return true;
}

function highlight(field) {
    $(field).css({ border: 'solid 1px red', backgroundColor: '#f7d0d0' });
}

function warnShow(field) {
    $(field).fadeIn(1000, function() { setTimeout(function() { $(field).fadeOut(1000); }, 5000); });
}

function onlyNumbers(e, tipo) {
    var keynum;
    var keychar;
    var numcheck;

    if (window.event) // IE
    {
        keynum = e.keyCode;
    }
    else if (e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }
    keychar = String.fromCharCode(keynum)
    if (tipo == 'int') {
        numcheck = /\d/;
        if (numcheck.test(keychar) == true || keynum == undefined || keynum == 8) return true;
        else return false;
    }
    if (tipo == 'decimals') {
        numcheck = /\d/;
        if (numcheck.test(keychar) == true || keynum == 44 || keynum == 46 || keynum == undefined || keynum == 8) return true;
        else return false;
    }
}

function checkEmail(val) {
    var pattern = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    return pattern.test(val);
}