$(document).ready(function(){
	//alert( $('.cw_fixheight').height() );

	var leftMnuHeight = $('#cw_leftmenu').height();
	var headingHeight = $('.cw_fixheight .cw_boxheading').height();
	var btmLinkHeight;
	var contentHeightNew;
	btmLinkHeight  = $('.cw_fixheight .cw_morelink').height();

	var contentHeight = leftMnuHeight - headingHeight - btmLinkHeight;
	var currentContHeight = $('.cw_fixheight .cw_boxcontent').height();

	jQuery.each(jQuery.browser, function(i, val) {
	   if(i=="msie" && jQuery.browser.version.substr(0,1)<7){
		   contentHeight = contentHeight - 2; //Reduce extra 2px for IE6
	   }		  
	 });


	contentHeight = contentHeight - 25;//reduce 10px padding for div.cw_newbox div div div
	contentHeight = contentHeight - 20;//reduce 20px padding for div.cw_newbox .cw_boxheading
	if( btmLinkHeight  ){
		contentHeight = contentHeight - 10;//reduce 10px padding for div.cw_newbox div.cw_morelink
	}
	
	if( currentContHeight < contentHeight ){
		$('.cw_fixheight .cw_boxcontent').height( contentHeight );		
	}

	jQuery.each(jQuery.browser, function(i, val) {
	   if(i=="msie" && jQuery.browser.version.substr(0,1)<=7){

		   // Set font-size to 1px when box heading is blank
			$('.cw_boxheading').each(
				function(i, boxObj){
					if( $(boxObj).html() == '' || $(boxObj).find('span').length > 0 ){
						$(boxObj).css('font-size','1px');
						if( $(boxObj).find('span').length > 0 ){
							$(boxObj).find('span').css('font-size','1px');
						}
					}
				}
			);

		   $('.cw_fixheight .cw_newbox').each(
		   
			function(i, boxObj){
				contentHeightNew = contentHeight;				
				if( $(boxObj ).height() <  leftMnuHeight ){					
					while( $( boxObj ).height() <  leftMnuHeight ){
						contentHeightNew+=1;
						$( boxObj ).find('.cw_boxcontent').height( contentHeightNew );
					}
				}
				else if( $(boxObj ).height() >  leftMnuHeight ){
					$( boxObj ).find('.cw_boxcontent').css('overflow','hidden');
					contentHeightNew = contentHeight;

					//alert( 'Index'+ i + ' ' + leftMnuHeight + ' ' + $( boxObj ).height() + ' - ' + $( boxObj ).find('.cw_boxcontent').height() + $( boxObj ).find('h1').html() );
					while( $( boxObj ).height() >  leftMnuHeight ){
						contentHeightNew-=1;
						$( boxObj ).find('.cw_boxcontent').height( contentHeightNew );
					}
					//alert( 'applied NEW:: Index'+ i + ' ' + leftMnuHeight + ' ' + $( boxObj ).height() + ' - ' + $( boxObj ).find('.cw_boxcontent').height() + $( boxObj ).find('h1').html() );
				}
				//recheck height for IE6
				contentHeightNew = $( boxObj ).find('.cw_boxcontent').height();
				if( $(boxObj ).height() <  leftMnuHeight ){
					while( $( boxObj ).height() <  leftMnuHeight ){
						contentHeightNew+=1;
						$( boxObj ).find('.cw_boxcontent').height( contentHeightNew );
					}
				}
				
			 }

		);

			

	   }/*ENDIF IE 6 & 7 */
	 });

	

});
