
window.addEvent( 'domready', function() {
	$$( 'a' ).each( function( a, i ) {
		a.setAttribute( 'target', '_top' );
	}, this );
	
	$$( 'a.toggle' ).each( function( a, i ) {
		a.setAttribute( 'target', '_self' );
	}, this );
	
	$$( 'a.post-next' ).each( function( a, i ) {
		a.setAttribute( 'target', '_self' );
	}, this );
	
	$$( 'a.post-previous' ).each( function( a, i ) {
		a.setAttribute( 'target', '_self' );
	}, this );
	
	$$( 'div.navigation div.align-center a' ).each( function( a, i ) {
		a.setAttribute( 'target', '_self' );
	}, this );
	
	$$( 'div.post-entry' ).each( function( entry, i ) {
		var gallery = entry.getElement( 'div.gallery' );
		if ( gallery != null ) {
			gallery.getElements( 'a' ).each( function( a, j ) {
				a.setAttribute( 'target', '_blank' );
			}, this );
		}
	}, this );
	
	resizeIFrame();
} );

window.addEvent( 'load', resizeIFrame );

function resizeIFrame() {
	window.parent.resizeIframe( document.body.offsetHeight + 20 );
	//window.parent.resizeCaller();
	
	var loc = new String( window.location.href );
	var ai = loc.indexOf( '#' );
	if ( ai >= 0 ) {
		var anchor = new String( loc.substring( ai + 1, loc.length ) );
		if ( anchor.length > 0 ) {
			$( anchor ).scrollIntoView( true );
		}
	}
}
