﻿function popup(URL, width, height, id, type)
{
	URL = URL + '?id=' + id + '&type=' + type;

	WindowName="CalcNet";

	settings=
	"toolbar=no,location=no,directories=no,"+
	"status=no,menubar=no,scrollbars=yes,"+
	"resizable=yes,width=" + width + ",height=" + height + "";

	winRef = window.open(URL,'_blank',settings);
	winRef.focus();
}

function modalPopup(URL, width, height, id, type)
{ 
	URL = URL + '?id=' + id + '&type=' + type;

	showPopWin(URL, width, height, false);
}

function preeviewPDF(URL)
{
//	showPopWin(URL, 800, 600, false);

	WindowName="CalcNet - PDF preview";

	var width = 800;
	var height = 600;
	
	settings=
	"toolbar=no,location=no,directories=no,"+
	"status=no,menubar=no,scrollbars=yes,"+
	"resizable=yes,width=" + width + ",height=" + height + "";

	winRef = window.open(URL,'_blank',settings);
	winRef.focus();
}

function writeToParent(el1, el2, el3, Code, Message)
{	
	e = window.top.document.getElementById(el1);
	e.value = Code + ': ' + Message;

	e = window.top.document.getElementById(el2);
	e.value = Code;

	e = window.top.document.getElementById(el3);
	e.value = Message;

	window.top.hidePopWin()
	/*
	a = opener.document.getElementById(el1);
	a.value = Code + ': ' + Message;

	b = opener.document.getElementById(el2);
	b.value = Code;

	window.close();
	*/
}			

function pageLoaded()
{
//	var pyramidHeight = new Array(98, 49, 38, 38, 31, 31);
//	var pyramidWidth = 313;
	var pyramidHeight = new Array(72, 36, 28, 28, 23, 22);
	var pyramidWidth = 230;
	var yPos = 550;

	for (var i = 1; i <= 6; i++)
	{
		var e = document.getElementById("pyramidDiv" + i);
		e.style.visibility = "hidden";
		e.style.position = "absolute";
		e.style.top = yPos + "px";
		e.style.left = "4px";
		e.style.width = pyramidWidth + "px";
		e.style.height = pyramidHeight[i - 1];
		e.style.zIndex = 0;
//		e.style.backgroundColor = "#ffffff";
		e.style.backgroundImage = "url(Images/pyramid" + i + "small.gif)";
		e.style.backgroundRepeat = "no-repeat";
		e.style.filter = "alpha(opacity=50)";
		e.style.opacity = ".5";

		yPos += pyramidHeight[i - 1];
	}

	setPyramideOpacity(1);
	showPyramide(0, true);

	document.getElementById("tree1").style.visibility = "visible";
	Loader(false, 'loaderShadow', 'loaderText', 'main');
}

function showPyramide(id, show)
{
	if (id == 0)
		for (var i = 1; i <= 6; i++)
			document.getElementById("pyramidDiv" + i).style.visibility = (show)? "visible":"hidden";
	else
		document.getElementById("pyramidDiv" + id).style.visibility = (show)? "visible":"hidden";
}

function setPyramideOpacity(id)
{
	var opacity;

	for (var i = 1; i <= 6; i++)
	{
		opacity = (i == id)? 100:50;

		document.getElementById("pyramidDiv" + i).style.filter = "alpha(opacity=" + opacity + ")";
		document.getElementById("pyramidDiv" + i).style.opacity = (opacity > 0)? (opacity / 100):0;
	}
}

function Loader(show, srcBg, srcText, dst)
{
	LoaderShadow(show, srcBg, dst);

	window.setTimeout("LoaderText(" + show + ",'" + srcText + "','" + dst + "');", 20);
}

function LoaderShadow(show, srcBg, dst)
{
	var loaderShadow = document.getElementById(srcBg);
	var target = document.getElementById(dst);

	loaderShadow.style.top = target.offsetTop;
	loaderShadow.style.left = target.offsetLeft;
	loaderShadow.style.width = target.offsetWidth;
	loaderShadow.style.height = target.offsetHeight;
	loaderShadow.style.visibility = (show)? "visible":"hidden";
}

function LoaderText(show, srcText, dst)
{
	var loaderText = document.getElementById(srcText);
	var target = document.getElementById(dst);

//	loaderText.style.top = target.offsetTop + (target.offsetHeight - loaderText.offsetHeight) / 3;
	loaderText.style.top = 300;
	loaderText.style.left = target.offsetLeft + (target.offsetWidth - loaderText.offsetWidth) / 2;
	loaderText.style.visibility = (show)? "visible":"hidden";
}

function setMinHeight()
{
	var height = document.getElementById('main').offsetHeight;

	if (height < 650)
		document.getElementById('main').style.height = 650;
}

