
// init loader
var loader = new Loader();
loader.setScriptPath("/static/js/");
loader.addFile("lib/prototype.js");
loader.addFile("imgReplace.js");
loader.addFile("animator.js");

loader.addClass("brand_hover");
loader.addClass("brand_switchPicture");

loader.load();

function onDocumentLoad ()
{

	// main navigation:
	try {
		new brand_hover( [$$('#metanav li')] );
		new brand_switchPicture( [$$('#metanav li.main')] );
	}
	catch (e) {}

	text2image($$('#main .teaser_wide h1, #main .maincontent h1 '),{
		font: "QuadraatOTHead-Bold.ttf",
		width: '530',
		height: '20',
		color: '000000',
		size: '13',
		positionx: 0,
		positiony: 14,
		replaceElement: {
			tagName: "h1",
			className: "img"
		}
	});

	text2image($$('#main .teaser_wide h2, #main .maincontent h2'),{
		font: "QuadraatOTHead-Light.ttf",
		width: '530',
		height: '',
		color: '000000',
		size: '13',
		positionx: 0,
		positiony: 14,
		replaceElement: {
			tagName: "h2",
			className: "img"
		}
	});


	text2image($$('#main .teaser_container .textarea h1'),{
		font: "QuadraatOTHead-Bold.ttf",
		width: '190',
		height: '20',
		color: '000000',
		size: '13',
		positionx: 0,
		positiony: 13,
		replaceElement: {
			tagName: "h1",
			className: "img"
		}
	});

	text2image($$('#main .teaser_container .teaser_right .quotation p'),{
		font: "QuadraatOTHead-Bold.ttf",
		width: '375',
		height: '',
		color: '000000',
		size: '13',
		positionx: 0,
		positiony: 20,
		replaceElement: {
			tagName: "p",
			className: "img"
		}
	});
	
	text2image($$('#left .teaser p span, #left .txtimgteaser p span '),{
		font: "QuadraatOTHead-Light.ttf",
		width: '150',
		height: '',
		color: '000000',
		size: '12',
		positionx: 0,
		positiony: 0,
		replaceElement: {
			tagName: "span",
			className: "img"
		}
	});


	text2image($$('#sidebar .teaser_block .teaser h3, #slidebox em.img'),{
		font: "QuadraatOTHead-Bold.ttf",
		width: '160',
		height: '',
		color: '000000',
		size: '10',
		positionx: 0,
		positiony: 10,
		replaceElement: {
			tagName: "h3",
			className: "img"
		},
		modifyValue : function (vari)
		{
			return vari.toUpperCase();
		}
	});
	

/*
	text2image($$('#sidebar .teaser_block .teaser h3, #slidebox em.img'),{
		font: "QuadraatOTHead-Bold.ttf",
		width: '160',
		height: '12',
		color: '000000',
		size: '10',
		positionx: 0,
		positiony: 0,
		replaceElement: {
			tagName: "h3",
			className: "img"
		},
		modifyValue : function (vari)
		{
			return vari.toUpperCase();
		}
	});
*/
	try {
		if ($('slideheaderimages')) {
			// headerimages
			animBackgroundHelper = null;
			var animBackground = Class.create();
			animBackground.prototype = {
				initialize : function (element) {
					this.images = $('slideheaderimages').getElementsByTagName('img');
					for (i=0;i<this.images.length;i++) {
						if(i != 0) {
							$(this.images[i]).setOpacity(0);
							this.images[i].style.zIndex = 2;
						}
						else {
							$(this.images[i]).setOpacity(100);
							this.images[i].style.zIndex = 3;
							this.images[i].style.display = "block";
						}
					}
					this.actual = 0;
					if(this.images.length != 1) {
						new PeriodicalExecuter(this.changeImage,4);
					}
					animBackgroundHelper = this;
				},
				changeImage : function () {
					images = animBackgroundHelper.images;
					if(animBackgroundHelper.actual == images.length -1) {
						animBackgroundHelper.images[0].style.display = "block";
						animBackgroundHelper.images[animBackgroundHelper.actual].style.zIndex = 2;
						animBackgroundHelper.images[0].style.zIndex = 3;
						ex9 = new Animator({transition: Animator.makeEaseOut(3),duration: 4000});
						ex9.addSubject(new NumericalStyleSubject(animBackgroundHelper.images[animBackgroundHelper.actual], 'opacity', 1, 0));
						ex9.addSubject(new NumericalStyleSubject(animBackgroundHelper.images[0], 'opacity', 0, 1));
						ex9.play();
						animBackgroundHelper.actual = 0;
					}
					else {
						animBackgroundHelper.images[animBackgroundHelper.actual +1].style.display = "block";
						animBackgroundHelper.images[animBackgroundHelper.actual].style.zIndex = 2;
						animBackgroundHelper.images[animBackgroundHelper.actual + 1].style.zIndex = 3;
						ex9 = new Animator({transition: Animator.makeEaseOut(3),duration: 4000});
						ex9.addSubject(new NumericalStyleSubject(animBackgroundHelper.images[animBackgroundHelper.actual], 'opacity', 1, 0));
						ex9.addSubject(new NumericalStyleSubject(animBackgroundHelper.images[animBackgroundHelper.actual + 1], 'opacity', 0, 1));
						ex9.play();
						animBackgroundHelper.actual ++;
					}
				}
			}
			new animBackground();
		}
	}
	catch (e) {}
	
	try {
		if ($('portal_images')) {
			// headerimages
			animPortalBackgroundHelper = null;
			var animPortalBackground = Class.create();
			animPortalBackground.prototype = {
				initialize : function (element) {
					this.images = $('portal_images').getElementsByTagName('img');
					for (i=0;i<this.images.length;i++) {
						if(i != 0) {
							$(this.images[i]).setOpacity(0);
							this.images[i].style.zIndex = 2;
						}
						else {
							$(this.images[i]).setOpacity(100);
							this.images[i].style.zIndex = 3;
							this.images[i].style.display = "block";
						}
					}
					this.actual = 0;
					if(this.images.length != 1) {
						new PeriodicalExecuter(this.changeImage,4);
					}
					animPortalBackgroundHelper = this;
				},
				changeImage : function () {
					images = animPortalBackgroundHelper.images;
					if(animPortalBackgroundHelper.actual == images.length -1) {
						animPortalBackgroundHelper.images[0].style.display = "block";
						animPortalBackgroundHelper.images[animPortalBackgroundHelper.actual].style.zIndex = 2;
						animPortalBackgroundHelper.images[0].style.zIndex = 3;
						ex9 = new Animator({transition: Animator.makeEaseOut(3),duration: 4000});
						ex9.addSubject(new NumericalStyleSubject(animPortalBackgroundHelper.images[animPortalBackgroundHelper.actual], 'opacity', 1, 0));
						ex9.addSubject(new NumericalStyleSubject(animPortalBackgroundHelper.images[0], 'opacity', 0, 1));
						ex9.play();
						animPortalBackgroundHelper.actual = 0;
						// Hide Sliding Images Change to Content
						hideStartAnimation();
					}
					else {
						animPortalBackgroundHelper.images[animPortalBackgroundHelper.actual +1].style.display = "block";
						animPortalBackgroundHelper.images[animPortalBackgroundHelper.actual].style.zIndex = 2;
						animPortalBackgroundHelper.images[animPortalBackgroundHelper.actual + 1].style.zIndex = 3;
						ex9 = new Animator({transition: Animator.makeEaseOut(3),duration: 4000});
						ex9.addSubject(new NumericalStyleSubject(animPortalBackgroundHelper.images[animPortalBackgroundHelper.actual], 'opacity', 1, 0));
						ex9.addSubject(new NumericalStyleSubject(animPortalBackgroundHelper.images[animPortalBackgroundHelper.actual + 1], 'opacity', 0, 1));
						ex9.play();
						animPortalBackgroundHelper.actual ++;
					}
				}
			}
			new animPortalBackground();
		}
	}
	catch (e) {}

}