﻿// JavaScript Document
var homepage = function() {
	this.navLi = $('#nav li').children('ul').hide().end();
    this.menuHome = $('#menu-home');
	this.init();
};

homepage.prototype = {

    init: function () {
        this.setMenu();
        this.createMenuHome();
        $('#nav > li:last, #menu-home > ul > li:last').addClass('last');
    },

    // Enables the slidedown menu, and adds support for IE6

    setMenu: function () {
        this.navLi.hover(function () {
            // mouseover
            $(this).find('> ul').stop(true, true).fadeIn('fast').slideDown('slow');
        }, function () {
            // mouseout
            $(this).find('> ul').stop(true, true).fadeOut('fast');
        });
    },

    createMenuHome: function () {
        var menuProdutos = $('a[href$="Produtos.aspx"]').next().clone();
        this.menuHome.append(menuProdutos).children().show();
        $('#menu-home > ul > li > a').each(function () {
            var corners = $('<div class="corner_tl"></div><div class="corner_tr"></div><div class="corner_bl"></div><div class="corner_br"></div>');
            var idname = $(this).text().toLowerCase();
            var idname1 = removeAccents(idname);
            $(this).parent('li').attr('id', idname1);
            corners.appendTo($(this).parent('li'));
        });

        /*$('#menu-home > ul > li').hover(function () {
            // mouseover
            $(this).find('> ul').stop(true, true).slideDown();
        }, function () {
            // mouseout
            $(this).find('> ul').stop(true, true).slideUp('fast');
        }); */
        
        $('#menu-home > ul > li').click(function () {
            $('#menu-home > ul > li > ul').each(function(){
                $(this).stop(true, true).slideUp('fast');
            });
            if($(this).find('> ul').css('display') == 'block'){
                $(this).find('> ul').slideUp();
            }else{
                $(this).find('> ul').stop(true, true).slideDown();
            }
        });        
    }



};

function removeAccents(strAccents) {
        strAccents = strAccents.split('');
        strAccentsOut = new Array();
        strAccentsLen = strAccents.length;
        //var accents =    ['À','Á','Â','Ã','Ä','Å','à','á','â','ã','ä','å','Ò','Ó','Ô','Õ','Õ','Ö','Ø','ò','ó','ô','õ','ö','ø','È','É','Ê','Ë','è','é','ê','ë','ð','Ç','ç','Ð','Ì','Í','Î','Ï','ì','í','î','ï','Ù','Ú','Û','Ü','ù','ú','û','ü','Ñ','ñ','Š','š','Ÿ','ÿ','ý','Ž','ž']  ;
        var accents = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';
        var accentsOut = ['A','A','A','A','A','A','a','a','a','a','a','a','O','O','O','O','O','O','O','o','o','o','o','o','o','E','E','E','E','e','e','e','e','e','C','c','D','I','I','I','I','i','i','i','i','U','U','U','U','u','u','u','u','N','n','S','s','Y','y','y','Z','z'];
        for (var y = 0; y < strAccentsLen; y++) {
        //alert(strAccents[y]);
        //alert(accents.indexOf(strAccents[y]));
            if (accents.indexOf(strAccents[y]) != -1) {
                strAccentsOut[y] = accentsOut[accents.indexOf(strAccents[y])];
            }
            else
                strAccentsOut[y] = strAccents[y];
        }
        strAccentsOut = strAccentsOut.join('');
        return strAccentsOut;
    }

$(function() {	
    new homepage(); 
    $("#noticias").jCarouselLite({  
        vertical: true,  
        visible: 1,
        hoverPause:true,  
        auto:3000,  
        speed:1500  
    });      
});
