var timerId = null;

jQuery(document).ready(function() {

        $("#mascaraNews").scrollable({
                    size: 1,
                    items: '#mascara',
                    clickable: true,
                    keyboard:false,
                    speed: 1500,
                    circular: true,
                    next: '#newsBtProximo'}).circular().autoscroll({
                        steps: 1,
                        interval: 5000
        });

        

        $('#tabs').tabs();
        $('#tabs2').tabs();
        $('.datetime').datepicker({
            dateFormat: 'MM dd, yy,',
            duration: '',
            showTime: true,
            constrainInput: false,
            time24h: true
        });
        $('.datecalendar').datepicker({
            dateFormat: 'MM dd, yy',
            showTime: false,
            changeMonth: true,
            changeYear: true,
            yearRange: '-100:+10'
        });

        $(".onlyImage").change(function() {
            var filename = $(this).val();
            var file_arr = filename.split('.');
            var last_item = file_arr.length - 1;
            var file_ext = file_arr[last_item];
            if(file_ext == 'JPG' || file_ext == 'jpg' || file_ext == 'jpeg' || file_ext == 'gif' || file_ext == 'png' || file_ext == 'JPEG' || file_ext == 'GIF' || file_ext == 'PNG') {

            } else {
                $(this).val('');
                jAlert('Formato não permitido!<br/><br/>Formatos permitidos: jpg, jpeg, gif e png.');

            }
        });

        $(".onlyAudio").change(function() {
            var filename = $(this).val();
            var file_arr = filename.split('.');
            var last_item = file_arr.length - 1;
            var file_ext = file_arr[last_item];
            if(file_ext == 'mp3' || file_ext == 'MP3' ) {

            } else {
                $(this).val('');
                jAlert('Formato <b>'+file_ext+'</b> não é permitido!<br/><br/>Apenas arquivos MP3 são permitidos.');
            }
        });

        $('.subMenu').mouseenter(seguraMenu).mouseleave(function() { fechaMenu(500); });
        $('#menu').mouseleave(function() { fechaMenu(500); });

        $('.rnd5').corner("5px");
        $('.rnd10').corner("10px");

        $('#login-box').corner("tl cc:#fed501");
        $('#login-box').corner("tr cc:#fed501");
        $('#login-box').corner("bl cc:#ffffff");
        $('#login-box').corner("br cc:#ffffff");

        $('.boxCreme .corpo:first').corner("bottom cc:#e3d8b6 10px");
        $('.boxAzul .corpo:first').corner("bottom cc:#73c5d1 10px");
        $('.boxVerde .corpo:first').corner("bottom cc:#d2f5d4 10px");
        $('.boxAmarelo .corpo:first').corner("bottom cc:#f4f2c5 10px");

        $('.boxCreme .abas:first').corner("top cc:#e3d8b6 10px");
        $('.boxAzul .abas:first').corner("top cc:#73c5d1 10px");
        $('.boxVerde .abas:first').corner("top cc:#d2f5d4 10px");
        $('.boxAmarelo .abas:first').corner("top cc:#f4f2c5 10px");

        $('.boxCreme .titulo').corner("top cc:#e3d8b6 10px");
        $('.boxAzul .titulo').corner("top cc:#73c5d1 10px");
        $('.boxVerde .titulo').corner("top cc:#d2f5d4 10px");
        $('.boxAmarelo .titulo').corner("top cc:#f4f2c5 10px");

        $('.boxAzul .turma').corner("5px");
        $('.boxAzul .pontos').corner("5px");

        $('.boxAmarelo .turma').corner("cc:#f4f2c5 5px");
        $('.boxAmarelo .pontos').corner("cc:#f4f2c5 5px");

        $('.boxCreme .botao').corner("5px");
        $('.boxAzul .botao').corner("5px");
        $('.boxVerde .botao').corner("5px");
        $('.boxAmarelo .botao').corner("5px");

        $('.round15').corner("15px");
        $('.boxCreme').corner("10px");
        $('.boxAzul').corner("10px");
        $('.boxVerde').corner("10px");
        $('.boxAmarelo').corner("10px");

        $('.submenu_group li').corner("5px");
       
        //$('.botao2').corner("5px");
        //$('.botao3').corner("5px");
        
        

});

function abreMenu(i){
	clearTimeout(timerId);
	$('.subMenu:not(#subMenu'+i+')').slideUp();
	$('#subMenu'+i+':hidden').slideDown();
}

function fechaMenu(t){
	clearTimeout(timerId);
	timerId = setTimeout(function(){
		$('.subMenu').slideUp();
	},t);
}

function seguraMenu(){
	clearTimeout(timerId);
}

