﻿/*
Event.observe(window, 'load', function() {
	var sideMenuBottom = getOffsetTop($("SideMenu"))+$("SideMenu").scrollHeight+50;
	var bottomImgHeight = $("BottomBackgroundImg").getHeight('height');
	var textEnd = getOffsetTop($("Footer"));
	
	var bottomImgStart = textEnd-bottomImgHeight;	

	if(bottomImgStart < sideMenuBottom){
		$("PageContent").setStyle({'padding-bottom':'300px'});
		
		textEnd = getOffsetTop($("Footer"));		
		bottomImgStart = textEnd-bottomImgHeight;			
	}
	
	$("BottomBackgroundWrap").setStyle({height:(textEnd)+'px'});

		
	$("BottomBackgroundImg").setStyle({top:(bottomImgStart)+'px'});
	$("BottomBackgroundImg").show();
	}); 
	
*/

Event.observe(window, 'load', function() {
    var menuPaddingBottom = 50;
    
    var bgImg = $("BgImg");
    var pageContentInner = $("PageContentInner");
    var contentMenu = $("ContentMenu");
    if(!bgImg || !pageContentInner || !contentMenu) return;

    if($("tempImg").getWidth('width') == 28) return;

    bgImg.setStyle({left:(contentMenu.offsetLeft)+'px'});
    bgImg.setStyle({width:($("tempImg").getWidth('width'))+'px'});
    bgImg.setStyle({height:($("tempImg").getHeight('height'))+'px'});
    

    var contentMenuBottom = contentMenu.offsetTop + contentMenu.getHeight('height') + menuPaddingBottom;
    var contentMenuHeight = contentMenu.getHeight('height') + menuPaddingBottom;
	var bgImgHeight = $("BgImg").getHeight('height');
	var pageContentInnerBottom = pageContentInner.offsetTop + pageContentInner.getHeight('height');
    
        
    if((pageContentInnerBottom - bgImgHeight) < contentMenuBottom){
        bgImg.setStyle({top: contentMenuBottom+"px"});
        var bgImageBottom = contentMenu.offsetTop + contentMenu.getHeight('height')
        pageContentInner.setStyle({height:(contentMenuHeight+bgImgHeight)+"px"});
    }else{
        bgImg.setStyle({top:(pageContentInnerBottom - bgImgHeight)+"px"});
    }
    
    bgImg.show();
        
});