﻿function Get(getID){
	return document.getElementById(getID);
};

function AdaptLayout(bgUrl, cntWidth, cntHeight){
	var divMain = Get('main');
	divMain.style.backgroundImage = 'url(' +bgUrl + ')';
	/**/
	var divContent = Get('content');
	if (divContent != null) {
		divContent.style.width = cntWidth + 'px';
		divContent.style.height = cntHeight + 'px';
	}
};

function fadeOut(divID, time)
{
    var speed = Math.round(time / 100);
    var frame = 0;
    for(fade = 100; fade > 0; fade--)
    {
		setTimeout("setOpacity('"+divID+"', "+fade+")", (speed * frame));
		frame++;
	}
};

function fadeIn(divID, time)
{
	var speed = Math.round(time / 100);
	var frame = 0;

	for(fade = 0; fade < 100; fade++)
	{ 
		setTimeout("setOpacity('"+divID+"', "+fade+")", (speed * frame));
		frame++;
	}
};

function setOpacity(id, opacity)
{
	var element = document.getElementById(id);
	if(document.all)
		element.style.filter = "alpha(opacity=" + opacity + ")";
	else
		element.style.opacity = opacity / 100;
};

function Get(IDobj)
{
	return document.getElementById(IDobj);
};

function Clear(obj)
{
	if(obj != null)
		while(obj.hasChildNodes())
			obj.removeChild(obj.firstChild);
};

function SetSelected(obj, container)
{
	if(typeof(obj) == 'string')
		obj = Get(obj);
	if(obj == null && container == null) return;
	var parent = container;
	if(obj != null)
		parent = obj.parentNode;
	//
	for(var i = 0; i < parent.childNodes.length; i++)
		parent.childNodes[i].className = (parent.childNodes[i] == obj)?'selected':'';
};

function SetVisible(obj, container)
{
	if(typeof(obj) == 'string')
		obj = Get(obj);
	if(obj == null && container == null) return;
	var parent = container;
	if(obj != null)
		parent = obj.parentNode;
	//
	for(var i = 0; i < parent.childNodes.length; i++)
	{
		if(parent.childNodes[i].style != null)
			parent.childNodes[i].style.display = (parent.childNodes[i] == obj)?'':'none';
	}
};
