﻿// File JScript

function Get(getID){
	return document.getElementById(getID);
};

function ProductBoxHover(obj) 
{
	obj.className += ' productBoxHover';
};

function ProductBoxOut(obj) 
{
	obj.className = obj.className.split(' productBoxHover').join('');	
};


function ProductMenuHover(obj, hover) 
{
	obj.className = (hover)?'productMenuHover':'';
};

function ProductLinkHover(obj, hover) 
{
	obj.className = (hover)?'productLinkHover':'';
};

/**/
var htmlObjs = new Object();
function InitializeLayout()
{
	// get objects
	htmlObjs.footer	= Get('footer');
	htmlObjs.homepage	= Get('homepage');
	htmlObjs.anchor	= Get('anchor');

	// fix layout
	RepositionElements();
	// set onResize action
	window.onresize = RepositionElements;	
};

function RepositionElements()
{
	//
	var height = document.documentElement.clientHeight;
	var width = document.documentElement.clientWidth;
	var pageWidth = 0;
	var pageHeight = 0;
	if(window.innerHeight && window.scrollMaxY ) // Firefox
	{
		pageWidth = window.innerWidth + window.scrollMaxX;
		pageHeight = window.innerHeight + window.scrollMaxY;
	}
	else if(document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
	{
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	}
	else // works in Explorer 6 Strict, Mozilla (not FF) and Safari
	{
		pageWidth = document.body.offsetWidth + document.body.offsetLeft;
		pageHeight = document.body.offsetHeight + document.body.offsetTop;
	}
	
	// show top
	if(htmlObjs.anchor)
	{
		htmlObjs.anchor.style.display = (pageHeight > height)?'':'none';
		//alert((pageHeight > height)?'show top':'hide top');
	}

	//
	if(htmlObjs.footer && height > pageHeight)
	{
		var mT = height - pageHeight - htmlObjs.footer.clientHeight;
		if(htmlObjs.anchor && htmlObjs.anchor.style.display == 'none')
			mT += htmlObjs.anchor.clientHeight - 10;
		if(htmlObjs.homepage)
			mT -= 44;
		htmlObjs.footer.style.marginTop = mT + 'px';
	}
};