function viewportDimensions() {
	// From http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    // Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    // IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    // IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

	return {
		width:	myWidth, 
		height: myHeight
	}
}


document.getElementsByClassName = function(cl) {
var retnode = [];
var myclass = new RegExp('\\b'+cl+'\\b');
var elem = this.getElementsByTagName('*');
for (var i = 0; i < elem.length; i++) {
var classes = elem[i].className;
if (myclass.test(classes)) retnode.push(elem[i]);
}
return retnode;
};

function fixImgs() {
var viewport = viewportDimensions();
var pixlinks=document.getElementsByClassName('thickbox');
  for (i=0; i<pixlinks.length; i++) {
	pix = pixlinks[i].getElementsByTagName('img');
	for(j = 0; j < pix.length; j++)
	{
	    w=pix[i].width;
	    h=pix[i].height;
		if(pix[i].id == 'topic_image')
		{
			/*vw = (viewport.width * .75);
			if( w > vw)
			{
				f=1-((w - vw) / w);
			      pix[i].width=w * f;
			      pix[i].height=h * f;

			}*/

		}
		else if (w > 128) {
	      f=1-((w - 128) / w);
	      pix[i].width=w * f;
	      pix[i].height=h * f;
		}
	}
  }
}

