var $_basedir = '/';
var $_defaultPath = $_basedir + 'default';
var $_layout = 'opersan';
var $_module = 'site'
var $_layoutPath = $_module + '/layouts/' + $_layout;

$(function(){
    $('a[rel="external"]').addClass('external').attr('target','_blank');
    $('a[href="#"]').not('.external').click(function(){return false});
    $('img[vspace]').css({marginTop: $(this).attr('vspace') + 'px',marginBottom: $(this).attr('vspace') + 'px'})
    $('img[hspace]').css({marginLeft: $(this).attr('vspace') + 'px',marginRight: $(this).attr('vspace') + 'px'})
    $(window)
        .resize(function(){
            width=$(this).width();
            if(width > 996){
                left =  ((width - 996) / 2) + 735;
                divIdiomaWidth = (width - left) - 21;
                $('#selecione-o-idioma').css('marginLeft',parseInt(left)+'px').width(parseInt(divIdiomaWidth)+'px');
            } else
                $('#selecione-o-idioma').css('marginLeft','735px').width('240px');
            
        })
        .triggerHandler('resize');
    $('#selecione-o-idioma').show();
    try{
        $('input[src]').each(function(i,e){
            newButton = $('<input />').attr({
                type: 'image',
                id: $(e).attr('id'),
                name: $(e).attr('name'),
                'class': $(e).attr('class'),
                src: $(e).attr('src')
            }).addClass('hoverImage');
            $(e).replaceWith(newButton);
        })
        $('.hoverImage').hover(function(){
            src = $(this).attr('src');
            ext = src.split('.').pop();
            newsrc = src.replace('.' + ext, '-hover.' + ext);
            $(this).attr('src', newsrc);
        }, function(){
            $(this).attr('src', $(this).attr('src').replace('-hover', ''));
        });
    }
    catch(e){
        $.error(e.toString())
    }
})
