function thickboxResize() {  
    var boundHeight = 630; // minimum height  
	var minHeight = 100; //
    var viewportHeight =(self.innerHeight || (document.documentElement.clientHeight || (document.body.clientHeight || 0)))  
  console.log('viewportHeight: '+viewportHeight);
    $('a.thickbox').each(function(){  
        var text = $(this).attr("href");  
        if ( viewportHeight < boundHeight)  
        {  
			var heightTB = Math.round(viewportHeight * .8);
			if (heightTB < minHeight){
				heightTB = minHeight;
			}
            text = text.replace(/height=[0-9]*/,'height=' + heightTB);  
        }  
        else   
        {  
		var heightTB = boundHeight;
            text = text.replace(/height=[0-9]*/,'height=' + heightTB);  
        }  
        var topMargin = (heightTB+20)/2;
        $('#TB_ajaxContent').css({height:heightTB});
        $('#TB_window').css({'margin-top': -topMargin});
        $(this).attr("href", text);  
    });  
    
}  
  
$(window).bind('load', thickboxResize );  
$(window).bind('resize', thickboxResize );  
  
