
window.addEvent('domready', function() {
	h = $('footer').getPosition().y;
	if (h > 964) {
		if ( h < 1264 ) {
			o = ( h - 1264 )-300;
		} else {
			o = 0;
		}
		$('background').setStyle('background-position','left '+ o +'px');
		var offset = 80-((window.getWidth()-709)*.17);//  this is our secret formula for gaining balance on the page
		if (offset < 0 ) offset = 0;
		$('container').setStyle('left', offset );
		sHeight = $('sbWrapperLeft').getSize().y;
		//console.log('sHeight= '+sHeight);
		cHeight = $('content').getSize().y;
		//console.log('cHeight= '+cHeight);
		if (sHeight+150 > cHeight) { 
			$('content').setStyle('height',sHeight+54); 
		}
	}
	FLIR.init( { path: '/flir/' } );
	FLIR.replace( 'h1.header_title' , new FLIRStyle({ 
																		 cFont:'sinablack',
																		 /*mode:'wrap',*/
																		 cColor:'2C3306',
																		 cSize:30,
																		 hq:true,
																		 realFontHeight:true
																		 }) );
	//
	window.addEvent('resize', function() {
	  var offset = 80-((window.getWidth()-709)*.17);
	  if (offset < 0 ) offset = 0;
	  $('container').setStyle('left', offset );
	  });
	imageAdjust();
});

function imageAdjust() {
	var lineHeight = 18;
	//  the offset is enough to drop the top of the image down to the x-height and bring the bottom up to the baseline
	//  it's found experimentally, but it could be computed.
	var offset = 11; 
	$$('#maincontent img').each( function(image) {
		if (image.getProperty('class').test('float')) {  // we're only going to adjust floated images
			var h = image.getProperty('height');
			if (h % lineHeight >= 0.5) {  //  reverse rounding
				var newHeight = (Math.floor(h/lineHeight)*lineHeight)-11;
				} else { 
				var newHeight = (Math.ceil(h/lineHeight)*lineHeight)-11;
				}
			image.removeProperties('height','width');
			image.setStyle('height',newHeight );
			}
		});
	}
//

