// JavaScript Document

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function dmovelogo()
{
	var logoElement = document.getElementById('headb');
	logoElement.style.top = '2px';
}

function setFooter() {
    if (document.getElementById) {
        var windowHeight = getWindowHeight();
		var windowWidth = getWindowWidth();
        if (windowHeight > 0 && windowWidth > 0) {
            var contentHeight = document.getElementById('hetc').offsetHeight;
            var footerElement = document.getElementById('foot');
			var racElement = document.getElementById('rightac');
			var lacElement = document.getElementById('leftac');
			var macElement = document.getElementById('middleac');
			var rlac2Element = document.getElementById('lbrl2');
			//var logoElement = document.getElementById('headb');
			var footerHeight = footerElement.offsetHeight;
			var allElement = document.getElementById('all');
			
			/*logoElement.style.position = 'relative';
			logoElement.style.left = '50%';
			logoElement.style.marginLeft = '-300px';
						*/
			if(racElement && lacElement)
			{
				racElement.style.marginRight = ((windowWidth - 940) / 2) + 'px';
				lacElement.style.marginLeft = ((windowWidth - 940) / 2) + 'px';
				if(rlac2Element && macElement)
				{
					racElement.style.marginRight = '3%';
					lacElement.style.marginLeft = '3%';
					macElement.style.height = lacElement.offsetHeight + 'px';
					
				}
				
				if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
				{
					//var ieversion=new Number(RegExp.$1);
					var ieversion = RegExp.$1;
					if (ieversion==6)
					{
						racElement.style.marginRight = '0px';
						lacElement.style.marginLeft = '0px';
						racElement.style.position = 'absolute';
						racElement.style.right = '50px';
						lacElement.style.position = 'absolute';
						lacElement.style.left = '50px';
					}
				}
			}
			
			footerElement.style.visibility = 'visible';
			footerElement.style.position = 'static';
            
			
			if ((windowHeight - contentHeight) >= 60) {
                
				footerElement.style.position = 'absolute';
                footerElement.style.bottom = '0px';
			}
			
        }
    }
}

function movelogo(event)
{
	if (document.getElementById) {
        var windowWidth = getWindowWidth();
		
		var logoElement = document.getElementById('headb');
		var vlogoElement = document.getElementById('logo');
		var x = event.clientX + (document.body.scrollLeft || document.documentElement.scrollLeft);
		var y = event.clientY + (document.body.scrollTop || document.documentElement.scrollTop);
		var xdep = 0;
		var i=0;
		
		if(x < windowWidth - 320 && x > 320)
		{
			xdep = ((x - windowWidth/2)/6);
		}
		if(x >= windowWidth - 320 || x <= 320)
		{
			if(x >= windowWidth - 320)
			{
				xdep = ((x - windowWidth/2)/6) + 1/x;
			}
			if(x <= 320)
			{
				xdep = ((x - windowWidth/2)/6) - 1/x;
			}
		}
		if(y > 150)
		{
			if(xdep > 0)
			{
				xdep = xdep - (y - 150)*0.5;
				if(xdep < 0)
				{xdep = 0;}
			}
			if(xdep < 0)
			{
				xdep = xdep + (y - 150)*0.5;
				if(xdep > 0)
				{xdep = 0;}
			}
		}
		
		if(windowWidth < 750)
		{
			logoElement.style.position = 'relative';
			logoElement.style.left = '50%';
			logoElement.style.marginLeft = '-300px';
		}
		if(windowWidth >= 750)
		{
			logoElement.style.position = 'absolute';
			
			var lmargl = -xdep - 300;
			if(logoElement.offsetLeft < windowWidth && logoElement.offsetLeft > 0)
			{
				logoElement.style.marginLeft =  lmargl + 'px';
				vlogoElement.style.marginLeft = -xdep/2 + 'px';
			}
			logoElement.style.top = '10px';
		}
		
        
    }
}

function addEvent(obj,event,fct)
{
  if(obj.attachEvent)
    {obj.attachEvent('on' + event,fct);}
  else
    {obj.addEventListener(event,fct,true);}
}


window.onload = function()
{
	setFooter();
	//addEvent(document,'mousemove',movelogo);
	//dmovelogo();
}

window.onresize = function()
{
	setFooter();
}

