$(document).ready(function() {
initContentBox();
});

var basicWidth;

function initContentBox()
{
	// saves the basic width
	basicWidth = $("div#content-box-offset-left").css("width");
	
	// make quadrat
	var heightEm = $("div#content-box").height() / 10;
	var widthEm = $("div#content-box").width() / 10;

	if(heightEm > widthEm) {
		// avoid making the box to wide
		if(heightEm < 60) {
			$("div#content-box").css("width",heightEm+"em");
		}
	} else {
		$("div#content-box").css("height",widthEm+"em");
	}
	
	// resize listener
	$(window).resize(function () 
	{
		if(browserIeVersion() && browserIeVersion() < 7)
		{ // minWidth IE < 7
    		calculateBox();
		}
    }); 

	if(browserIeVersion() && browserIeVersion() < 7)
	{ // minWidth IE < 7
		// first calculation
		calculateBox();
	}
}

function calculateBox()
{
	// erstmal immer auto
	$("div#content-box-offset-left").css("width", basicWidth);

	var maxWidthEm = $("div#content-box-offset-left").css("max-width");
	maxWidthEm = parseFloat(maxWidthEm);
	var currentWidth = $("div#content-box-offset-left").width() / 10;
	if(currentWidth >= maxWidthEm)
	{
		$("div#content-box-offset-left").css("width", maxWidthEm+"em");
	}

}


