/****************************/
/*       www.wgry.pl        */
/*                          */
/* Author: Tomasz Nabrzeski */
/****************************/
var Tips = {
    timer: false,
    
    init: function() {
        $('body').append('<div id="tip" style="display:none;position:absolute;top:0;left:0"></div>');
        $('#tip').css('opacity', 0.9);
        
        $('.tip').mouseover(Tips.over);
        $('.tip').mousemove(Tips.move);
        $('.tip').mouseout(Tips.out);
    },
    
    over: function() {
        text = $(this).attr('title').split('::');
        $('#tip').html('<h1>'+text[0]+'</h1><p>'+text[1]+'</p>').show();
        $(this).attr('title','');
    },
    
    move: function(e) {
        x = document.all ? window.event.clientX : e.pageX;
        y = document.all ? window.event.clientY : e.pageY;
        
        $('#tip').css({'top': (y+15)+'px', 'left': (x+25)+'px'});
        
        e.preventDefault();
    },
    
    out: function() {
        $(this).attr('title',$('#tip h1').html()+'::'+$('#tip p').html());
        $('#tip').text('').hide();
    }
}

var Effects = {
    init: function() {
        var arVersion 	= navigator.appVersion.split("MSIE");
        var version 	= parseFloat(arVersion[1]);
    
        if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
            jQuery.each($('#top img'), function() {
                
                if ($(this).attr('src')) {
                    url    = $(this).attr('src');
                    width  = $(this).width();
                    height = $(this).height();
                    
                    $(this).attr('src', baseUrl + 'images/blank.gif');
                    $(this).css({'width': width + 'px',
                                 'height': height + 'px',
                                 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + url + "')"});
                } else if ($(this).css('background-image')) {
                    url = $(this).css('background-image');
                    url = url.substring(5, url.length - 2);
                    
                    $(this).css({'background': 'none',
                                 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='" + url + "')"});
                }
            });
        }
        
        jQuery.each($('ul li a.tip'), function(i, e) {
            $(e).attr('title', $(e).attr('title') + '::<img src="'+baseUrl+'img/'+$(e).attr('rel')+'.jpg" />');
        });
    }
}


$(document).ready(function(){
    Effects.init();
    Tips.init();
    
    jQuery.each($('span.views'), function(i, e) { $(e).html('Wyświetleń: ' + $(e).text()); });
    jQuery.each($('span.vote'), function(i, e) { $(e).html('Ocena: ' + $(e).text()); });
    jQuery.each($('span.votes'), function(i, e) { $(e).html('(głosów: ' + $(e).text() + ')'); });
    
    $('input.btn').mouseover(function(){$(this).addClass('hover')});
    $('input.btn').mouseout(function(){$(this).removeClass('hover')});
    
    $('#sizable div.voting').mousemove(function(){$('#sizable div.voting div.bar').hide()});
    $('#sizable div.voting').mouseout(function(){$('#sizable div.voting div.bar').show()});
    $('#sizable div.voting').append('<a href="?ocen=1" style="width:20%;z-index:6"></a><a href="?ocen=2" style="width:40%;z-index:5"></a><a href="?ocen=3" style="width:60%;z-index:4"></a><a href="?ocen=4" style="width:80%;z-index:3"></a><a href="?ocen=5" style="width:100%;z-index:2"></a>');
});
