var headCenteredBoxId = 'HeadBox';
var contentAreaId = 'ContentArea';
var contentMainId = 'ContentMain';
var rightAreaId = 'RightArea';
var footAreaId = 'FootArea';
var newsAreaId = 'NewsArea';
var rightAreaContentId = 'RightAreaContent';
var rightContentLinksId = 'RightAreaContentLinks';

addLoadEvent(homeOnLoad);

function homeOnLoad()
{
	textAreaAutoAtachHOL();	
	window.onresize = resizeHendl;
	resizeHendl();
	
}

function resizeHendl(evt)
{
	if (document.getElementById("root0"))
	{
		if (document.getElementById("scroll0Content").scrollHeight+20 < document.getElementById("root0").offsetHeight)
		{
			var minHeight = 280;
			document.getElementById("root0").style.height = ((document.getElementById("scroll0Content").scrollHeight+20) > minHeight) ? (document.getElementById("scroll0Content").scrollHeight+20) : minHeight;
		}
	}
		
	setHeaderPosition();
	pepareContentPosition();
	setFooterPosition();
	setRightContentHeight();
}

function getMaxContentHeight()
{
	var contentArea = document.getElementById(contentAreaId);
	var contentMain = document.getElementById(contentMainId);
	var contentAreaHeight = parseInt(contentArea.offsetHeight);
	var contentMainHeight = parseInt(contentMain.offsetHeight);
	var MaxHeight = Math.max(contentAreaHeight,contentMainHeight);
	return MaxHeight;	
}

function setHeaderPosition()
{
	var LogoBox = document.getElementById("HeaderLogoBox");
	var HeadBox = document.getElementById(headCenteredBoxId);	
	var HeadBoxWidth = HeadBox.parentNode.clientWidth/2;
	var h_width = Math.round(HeadBoxWidth - 520) + "px";
	LogoBox.style.marginLeft = h_width; //520 - width of bg picture
}

function pepareContentPosition()
{
	var contentArea = document.getElementById(contentAreaId);
	var headCentered = document.getElementById(headCenteredBoxId);
	var HeadBoxWidth = headCentered.parentNode.clientWidth/2;
	var h_width = Math.round(HeadBoxWidth - 520)+178;//520 - width of bg picture
	contentArea.style.left = h_width + 'px';
}

function setFooterPosition()
{
	try{
		var footArea = document.getElementById(footAreaId);
		var rightArea = document.getElementById(rightAreaId);
		var contentArea = document.getElementById(contentAreaId);
		var AbsPos1 = getAbsPosition (contentArea);
		var AbsPos2 = getAbsPosition (rightArea);
		
		var MaxContentHeight = getMaxContentHeight();
		
		contentArea.style.height = MaxContentHeight + 'px';
		var FooterPos = Math.max(parseInt(AbsPos1.top) + MaxContentHeight,	parseInt(AbsPos2.top) + parseInt(rightArea.offsetHeight));
		footArea.style.top = FooterPos  + 'px';
    }
    catch(e)
    {
    	addLoadEvent(resizeHendl);
    }
}

function setRightContentHeight()
{
	var rightArea = document.getElementById(rightAreaId);
	var rightAreaContent = document.getElementById(rightAreaContentId);
	var newsArea = document.getElementById(newsAreaId);
	var contentArea = document.getElementById(contentAreaId);
	var footArea = document.getElementById(footAreaId);
	
	if (parseInt(rightAreaContent.offsetHeight) + parseInt(newsArea.offsetHeight) < getMaxContentHeight())
	{
		var footerAbsPos = getAbsPosition(footArea);
		var rightAreaContentAbsPos = getAbsPosition(rightAreaContent);
		rightAreaContent.style.height = (parseInt(footerAbsPos.top)- parseInt(rightAreaContentAbsPos.top)) + 'px';
	}
	else
	{
		var footerAbsPos = getAbsPosition(footArea);
		var contentAreaAbsPos = getAbsPosition(contentArea);
		contentArea.style.height =(parseInt(footerAbsPos.top)- parseInt(contentAreaAbsPos.top)) + 'px';
		// (parseInt(rightAreaContent.offsetHeight) + parseInt(newsArea.offsetHeight)) + "px";
	}
}

function getAbsPosition(cObj)
{
	var position = new Object;
	position.left=0;
	position.top=0;
	while(cObj.offsetParent)
	{
		position.left += cObj.offsetLeft;
		position.top += cObj.offsetTop;
		cObj = cObj.offsetParent;
	}
	return position;
}



function insertHeader(flash_src, xml_menu_path, swf_path)
{

	var varhtml = Math.ceil(5*Math.random());
	var varheader = flash_src;
	with(document){
		write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="770" height="179">');
		write('<param name="movie" value="' + varheader + '?varhtml=' + varhtml + '&globalUrl=' + swf_path + '&xml_menu_path=' + xml_menu_path + '" />');
		write('<param name="quality" value="high" />');
		write('<embed src="' + varheader + '?varhtml=' + varhtml + '&globalUrl=' + swf_path + '&xml_menu_path=' + xml_menu_path + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="770" height="179"></embed>');
		write('</object>');
	}
}

function insertContentMenu(swf_src, xml_menu_path, id)
{
	with(document){
		write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="84" height="425">');
		write('<param name="movie" value="' + swf_src + '?xml_menu_path=' + xml_menu_path + '&current_page_id='+ id +'" />');
		write('<param name="quality" value="high" />');
		write('<param name="wmode" value="transparent" />');
		write('<param name="allowScriptAccess" value="sameDomain" />');
		write('<embed src="' + swf_src + '?xml_menu_path=' + xml_menu_path + '&current_page_id='+ id +'" quality="high" allowScriptAccess="sameDomain" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="84" height="390"></embed>');
		write('</object>');
	}
}

function printer(evt) 
{
    evt = (evt) ? evt : ((window.event) ? event : null);
    if (evt.type == "mouseover") 
    {
    	var text = document.getElementById("text");
    	text.style.visibility = "visible";
    }
    else if(evt.type == "mouseout")
    {
    	var text = document.getElementById("text");
    	text.style.visibility = "hidden";
    }
}

/* --------------------------------------- */

