function equalHeight(group) {
    tallest = 0;
    group.each(function() {
        thisHeight = $JQ(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
	$JQ("#fourBoxes .box .content").height(tallest);
	$JQ("#fourBoxes .box .content img").css('position','absolute');
	$JQ("#fourBoxes .box .content img").css('bottom','0');
}


$JQ(window).load(function() {

	// image centered - subSidebar
	var subSidebarWidth = $JQ('#subSidebar').width();
	var imageWidth = $JQ('#subSidebar img').width();	
	var total = subSidebarWidth - imageWidth ;
	var margin = total/2 + 'px';
	$JQ('#subSidebar img').css('margin-left',margin);
	
	// image centered - subSidebar
	var subSidebarRightWidth = $JQ('#subSidebarRight').width();
	var imageWidthRight = $JQ('#subSidebarRight img').width();	
	var total2 = subSidebarRightWidth - imageWidthRight ;
	var margin2 = total2/2 + 'px';
	$JQ('#subSidebarRight img').css('margin-left',margin2);
	
		
	// image centered - frontpage boxes
	var frontpageContentBoxWidth = $JQ('#fourBoxes .box .content').width();
	
	$JQ('#fourBoxes .box .picture img').each(function() { 	
		var frontpageImageWidth = $JQ(this).width();	
		var frontpageTotal = frontpageContentBoxWidth - frontpageImageWidth;
		var frontpageMargin = frontpageTotal/2 + 'px';
		$JQ(this).css('margin-left',frontpageMargin);
	});
	
	// when subSidebar has a less height than subContent
	var contentHeight = $JQ('#content').height();
	var imageHeight = $JQ('#subSidebar img').height();	
	if( contentHeight < imageHeight) {
		$JQ('#content').height(imageHeight + 100);
	}
	
	
	$JQ('#subSidebar').height($JQ('#subContent').height());
	$JQ('#subSidebarRight').height($JQ('#subContent').height());	
	
	
	var subContentHeight = $JQ('#subContent').height();
	
	var imagesubSidebarRightHeight = $JQ('#contentFullWidth #subSidebarRight img').height();
	var totalHeight = subContentHeight - imagesubSidebarRightHeight;
	var alignMiddle = totalHeight/2 + 'px';
	$JQ('#contentFullWidth #subSidebarRight img').css('top',alignMiddle);
	
	var imagesubSidebarLeftHeight = $JQ('#contentFullWidth #subSidebar img').height();
	var totalHeight2 = subContentHeight - imagesubSidebarLeftHeight;
	var alignMiddle2 = totalHeight2/2 + 'px';
	$JQ('#contentFullWidth #subSidebar img').css('top',alignMiddle2);	

	
	$JQ('#subSidebar').append('<br />');	
	$JQ('#subSidebarRight').append('<br />');
	
});


// login scripts

$JQ(document).ready(function() {
	
//    $JQ('#newUserLink').click(
//	function() {
//		$JQ('#newUserForm').fadeIn('fast');
//	});
	
    $JQ('#cancelCreateNewUserLink').click(
	function() {
		$JQ('#newUserForm').fadeOut('fast');
	});	
	
//    $JQ('#retrievePasswordLink').click(
//	function() {
//		$JQ('#loginForm').fadeOut('fast');
//		$JQ('#retrievePassword').fadeIn('fast');
//		$JQ('#newUserForm').fadeOut('fast');
//	});	
	
//    $JQ('#cancelretrievePasswordLink').click(
//	function() {
//		$JQ('#retrievePassword').fadeOut('fast');
//		$JQ('#loginForm').fadeIn('fast');
//	});		
	
	
});


// frontapage boxes - the same height
$JQ(document).ready(function() {
    setTimeout(function() {
	    equalHeight($JQ("#fourBoxes .box .content"));
	}
    , 500);
});



