$( window ).bind( 'load', function(){
	paginacaoPrint();	modalCenter();
	onScroll();
	onFechar();
});
function paginacaoPrint()
{	var ref, src;
	$('a.paginacao').click(function(){
		ref = $(this);
		ref.siblings('a').removeClass('active');
		src = ref.siblings('img').attr('src').split('.jpg')[0];
		src = src.substr(0, src.length - 1) + ref.html() + ".jpg";
		ref.siblings('img').attr('src', src);
		ref.addClass('active');
		return false;
	});			
}

function modalCenter()
{
	var $this;
	
	$( '.modal' ).each(function(){
		$this = $( this );

		$this.css({
			'width': parseInt( $this.children(':eq(1)').attr( 'width' ) ) + 'px',
			'height': parseInt( $this.children(':eq(1)').attr( 'height' ) ) + 'px'
		});
		
		$this.css({
			'margin': '-' + ( $this.height() / 2 ) + 'px 0 0 -' + ( $this.width() / 2 ) + 'px'	
		})
		
		if ( $.browser.msie && $.browser.version.indexOf( '6' ) != -1 )
			$this.css( 'position', 'absolute' );
	});
}

function onScroll()
{
	$( window ).scroll(function( ev ){
		if( $( '.modal' ).is( ':visible' ) && $.browser.msie && $.browser.version.indexOf( '6' ) != -1 )
			$( '.modal:visible' ).css( 'top', $( window ).scrollTop() + ( $( window ).height() / 2 ) );
	});
}

function onFechar()
{
	var btFechar = $( 'a.btFechar' );
	
	btFechar.click(function(){
		$( this ).parent().modalToggle();
		
		return false;
	});
}