
// init loader
var loader = new Loader();
loader.setScriptPath("/static/js/");
loader.addFile("lib/prototype.js");
loader.addFile("src/scriptaculous.js");
//loader.addFile("src/effects.js");
loader.addFile("lightbox.js");
loader.addFile("lib/animator.js");
loader.addFile("lib/swfobject.js");
loader.addFile("cookie.js");

loader.addClass("at.elements.calendar.init");

if(language == "de") {
	loader.addClass("at.elements.calendar.de");
}
else {
	loader.addClass("at.elements.calendar.en");
}

loader.addClass("at.elements.textreplace.image");

loader.addClass("at.schladmingdachstein.main_navigation.hover");

loader.addClass("at.schladmingdachstein.dropdowns.dropDown");
loader.addClass("at.schladmingdachstein.header.verticalSlider");

loader.addClass("at.schladmingdachstein.slidebox.slide");



loader.load();
//loader.loadProxy("http://www./tools/scriptproxy/loader.php");

function onDocumentLoad ()
{
	
	new at.schladmingdachstein.main_navigation.hover( [ $$('#metanav li') ] );
	
	try {
		if($('languages') != null){
			new at.schladmingdachstein.dropdowns.dropDown($('languages'));
		}	
	} catch (e) {}

	try {
		if($('villageselect') != null) {
			new at.schladmingdachstein.dropdowns.dropDown($('villageselect'));
		}
	} catch (e) {}
	
	//Initialisierung fuer Anfragebox
	if($('headerbox') != null)
	{
		requests = $('headerbox').getElementsByClassName('request_entry');
		new at.schladmingdachstein.header.verticalSlider(requests,28,151);
		
		
		//init Calendar
		new at.elements.calendar.init({
			button : 'free_rooms_Cal',
			output : "input",
			dayInput: 'free_rooms.arrivalDay',
 			monthInput: 'free_rooms.arrivalMonth',
			yearInput: 'free_rooms.arrivalYear',
			updateFieldOnStartup : true
		});
	}
	
	if($('slidebox_container') != null)
	{
		new at.schladmingdachstein.slidebox.slide($('slidebox'));
	}

	
	// replace text to images
	if (language != "ru") {
		var imageReplacer = new at.elements.textreplace.image("/static/cache/headlines/",{appendFilename: true});
		
		imageReplacer.add({
			elements: $$('#metanav em'),
			options: {
			font: 'sansb6.ttf',
			width: '',
			height: 15,
			color: '64696e',
			size: '11',
			positionx: 0,
			positiony: 12,
			replaceElement: {
				tagName: "em",
				className: "image"
			},
			modifyValue : function (vari)
			{
				return vari.toUpperCase();
			}
		}});
		
		imageReplacer.add({
			elements: $$('#headerbox .head em'),
			options: {
			font: 'sansb6.ttf',
			width: '',
			height: 15,
			color: '465a00',
			size: '11',
			positionx: 0,
			positiony: 12,
			replaceElement: {
				tagName: "em",
				className: "image"
			},
			modifyValue : function (vari)
			{
				return vari.toUpperCase();
			}
		}});
		
		imageReplacer.add({
			elements: $$('#headerbox .headline h3'),
			options: {
			font: 'sansb6.ttf',
			width: '',
			height: 15,
			color: '465a00',
			size: '11',
			positionx: 0,
			positiony: 12,
			replaceElement: {
				tagName: "h3",
				className: "image"
			},
			modifyValue : function (vari)
			{
				return vari.toUpperCase();
			}
		}});
		
		imageReplacer.add({
			elements: $$('#villageselect em'),
			options: {
			font: 'sansb6.ttf',
			width: '',
			height: 15,
			color: '465a00',
			size: '11',
			positionx: 0,
			positiony: 12,
			replaceElement: {
				tagName: "em",
				className: "image"
			},
			modifyValue : function (vari)
			{
				return vari.toUpperCase();
			}
		}});
		
		imageReplacer.add({
			elements: $$('#left .head h2, #right .teaser h2'),
			options: {
			font: 'sansb6.ttf',
			width: 150,
			height: '',
			color: '64696e',
			size: '11',
			positionx: 0,
			positiony: 12,
			replaceElement: {
				tagName: "h2",
				className: "image"
			},
			modifyValue : function (vari)
			{
				return vari.toUpperCase();
			}
		}});
	
		imageReplacer.add({
			elements: $$('#left .box h2'),
			options: {
			font: 'sansb6.ttf',
			width: '',
			height: '',
			color: '64696e',
			size: '11',
			positionx: 0,
			positiony: 12,
			replaceElement: {
				tagName: "h2",
				className: "image"
			},
			modifyValue : function (vari)
			{
				return vari.toUpperCase();
			}
		}});
		
		imageReplacer.add({
			elements: $$('#center .boxbig h2'),
			options: {
			font: 'sansb6.ttf',
			width: '700',
			height: '',
			color: '64696e',
			size: '11',
			positionx: 0,
			positiony: 12,
			replaceElement: {
				tagName: "h2",
				className: "image"
			},
			modifyValue : function (vari)
			{
				return vari.toUpperCase();
			}
		}});
		
		imageReplacer.add({
			elements: $$('#center .headline.schladming-rohrmoos h1'),
			options: {
			font: 'sansb4.ttf',
			width: 560,
			height: '',
			color: '88060E',
			size: '17',
			positionx: 0,
			positiony: 23,
			replaceElement: {
				tagName: "h1",
				className: "image"
			}
		}});
		
		imageReplacer.add({
			elements: $$('#center .headline.pichl-reiteralm h1'),
			options: {
			font: 'sansb4.ttf',
			width: 560,
			height: '',
			color: '013C80',
			size: '17',
			positionx: 0,
			positiony: 23,
			replaceElement: {
				tagName: "h1",
				className: "image"
			}
		}});
		
		imageReplacer.add({
			elements: $$('#center .headline h1'),
			options: {
			font: 'sansb4.ttf',
			width: 560,
			height: '',
			color: '465a00',
			size: '17',
			positionx: 0,
			positiony: 23,
			replaceElement: {
				tagName: "h1",
				className: "image"
			}
		}});
		
		imageReplacer.start();
	}
	
	initLightbox();
}

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(destinationURL.length > 0) {
		if(target == "_blank") {
			window.open(destinationURL);
		}
		else {
			location.href = destinationURL;
		}
	}
	return false;
}


