/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var $ = jQuery.noConflict();
$(document).ready(function(){

    $('.post_comments_paginator').livequery(function(e){
        $(this).find('a').each(function(index,item){
            $(item).bind("click", function(){
                $.ajax({
                    type: 'post',
                    url: $(item).attr('href'),
                    error: function(){},
                    success: function(t)
                    {
                        $('.gallery_comments_div').html(t);
                    }
                });
                return false;
            });
        });
    });

     $('#gallery_add_form').livequery(function(e){        
          $(this).submit(function(e)
         {
            var options={
                success: function(r)
                {
                   $('.gallery_comment_output').html(r);
                }
            };
            $(this).ajaxSubmit(options);
            return false;
        });
    });
   
     $('.gallery_comments').livequery(function(e){
        
        $(this).find('a').each(function(index,item){
            $(item).bind("click", function(){
                $.ajax({
                    type: 'post',
                    url: $(item).attr('href'),
                    error: function(){},
                    success: function(t)
                    {
                        $('.gallery_comments_container').html(t);
                    }
                });
                
                return false;
            });
        });
    });


    $('a[rel=lightbox]').livequery(function(e){
            	$(this).lightBox();
        });

    $('.galleries').find('img').each(function(index,item){
        
        $(this).tooltip({
            delay: 0,
            showURL: false,
            track: true,
            fade: 250,
            bodyHandler: function() {
                return '<p><img src="'+$(this).attr('src')+'"></p>';                
            }
        });
    });
    $('.gallery_paginator').livequery(function(e){
	    $(this).find('a').each(function(index,item){
	        $(item).bind("click", function(){            
	            $('.gallery_photo_preview').html('<div style="padding-top:220px;padding-left:220px;"><img src="/layouts/sou_aktualnosci/img/ajax-loader.gif"></div>');
	            $.ajax({
	                type: 'post',
	                url: $(item).attr('href'),
	                error: function(){},
	                success: function(t)
	                {                    
	                    $('.gallery').html(t);
	                }
	            });
	  
	            return false;
	        });
	    });
    });
    $('.photoVote a').click(function(e){
    	var photoVote = $(this).parents('div.photoVote');
        $.ajax({
            type: 'post',
            url: $(this).attr('href'),
            error: function(){},
            success: function(t)
            {                    
				photoVote.html(t);
            }
        });	  
        return false;
    });   
    $('.photoVote a').mouseover(function(e) {
    	$(this).addClass('current');
    	$('.photoVote a').each(function(){
    		$(this).addClass('active');
    		if($(this).hasClass('current'))
    		{
    			$(this).removeClass('current');
    			return false;
    		}
    	});
    });    
    $('.photoVote a').mouseout(function(e) {
		$('.photoVote a').removeClass('active');
    });     

});

