
path = new Array();
path.push('/static/js/lib/prototype.js');
path.push('/static/js/animator.js');
path.push('/static/js/slidebox.js');
path.push('/static/js/imgReplace.js');
path.push('/static/js/swfobject.js');
path.push('/static/js/functions.js');
path.push('/static/js/animBackground.js');

loadScrips(path);


function onDocumentLoad () {
	var font = 'TheSans-B7Bold.ttf';
	if (lang == "ru") {
		font = 'MyriadPro-Semibold.ttf';
	}
	
	if (lang == "ru") {
		text2image($$('#navi .menu em.img'),{
			font: font,
			width: '250',
			height: '16',
			color: 'ffffff',
			size: '10',
			positionx: 0,
			positiony: 0,
			replaceElement: {
				tagName: "em",
				className: "img"
			},
			modifyValue : function (vari)
			{
				return vari.toUpperCase();
			}
		});
	}
	else {
		text2image($$('#navi .menu em.img'),{
			font: font,
			width: '180',
			height: '16',
			color: 'ffffff',
			size: '10',
			positionx: 0,
			positiony: 0,
			replaceElement: {
				tagName: "em",
				className: "img"
			},
			modifyValue : function (vari)
			{
				return vari.toUpperCase();
			}
		});	
	}
	
	text2image($$('h1.img'),{
		font: font,
		width: '520',
		height: '24',
		color: 'f50000',
		size: '12',
		positionx: 0,
		positiony: 15,
		replaceElement: {
			tagName: "div",
			className: "h1"
		},
		modifyValue : function (vari)
		{
			return vari.toUpperCase();
		}
	});
	
	text2image($$('h4.img'),{
		font: font,
		width: '520',
		height: '18',
		color: 'ffffff',
		size: '12',
		positionx: 0,
		positiony: 0,
		replaceElement: {
			tagName: "div",
			className: "h4"
		},
		modifyValue : function (vari)
		{
			return vari.toUpperCase();
		}
	});
	
	text2image($$('h2.img'),{
		font: font,
		width: '155',
		height: '15',
		color: 'ffffff',
		size: '10',
		positionx: 0,
		positiony: 0,
		replaceElement: {
			tagName: "div",
			className: "h2"
		},
		modifyValue : function (vari)
		{
			return vari.toUpperCase();
		}
	});
	
	text2image($$('h3.webcam'),{
		font: font,
		width: '',
		height: '',
		color: 'cccccc',
		size: '10',
		positionx: 0,
		positiony: 0,
		replaceElement: {
			tagName: "h3",
			className: "webcam"
		},
		modifyValue : function (vari)
		{
			return vari.toUpperCase();
		}
	});
	
	new portalSlidebox();
	new langSelect();
	
	//new animBackground();
	$("site").style.display = 'block';
	
	new Ajax.Updater('kompaktContent','/extensions/geoip/ajax.php',{parameters: 'lang=' + lang,onComplete: function () { replaceHeading("h1"); replaceHeading("h2"); } });
}


window.onload = onDocumentLoad;


function loadScrips (path)
{
	for(i=0;i<path.length;i++)
	{
		document.write('<script type="text/javascript" src="' + path[i] + '"></script>');
	}
}

function setOpacity(element,value) {
	element.style.opacity = value/100;
	element.style.filter = 'alpha(opacity=' + value + ')';
}

function toogleKitzKompakt()
{	
	if(!$('kompaktContent').style.bottom || parseInt($('kompaktContent').style.bottom) < 0)
	{
		start = -230;
		end = 0;
	}
	else
	{
		start = 0;
		end = -230;
	}
	
	ex9 = new Animator({transition: Animator.makeEaseOut(3),duration: 2000});
	ex9.addSubject(new NumericalStyleSubject($('kompaktContent'), 'bottom', start, end));
	ex9.play();
}


function toogleSearchAndBook()
{
	if(!$('searchandbookbox').style.right || parseInt($('searchandbookbox').style.right) < 0)
	{
		start = -200;
		end = 0;
	}
	else
	{
		start = 0;
		end = -200;
	}
	
	ex9 = new Animator({transition: Animator.makeEaseOut(3),duration: 2000});
	ex9.addSubject(new NumericalStyleSubject($('searchandbookbox'), 'right', start, end));
	ex9.play();
}

function gotoLink (htmlElement) {
	
	var destinationURL = "";
	var target = "";
	
	if(htmlElement.href) {
		destinationURL = htmlElement.href;
		target = htmlElement.getAttribute("target");
	}
	else {
		if(htmlElement.childNodes) {
			if(htmlElement.getElementsByTagName("a")) {
				destinationURL = htmlElement.getElementsByTagName("a")[0].href;
				target = htmlElement.getElementsByTagName("a")[0].getAttribute("target");
			}
		}
	}
	
	if(target == "_blank") {
		window.open(destinationURL);
	}
	else {
		location.href = destinationURL;
	}
}
