
// init loader
var loader = new Loader();
loader.setScriptPath("/static/source/js/");
loader.addFile("lib/prototype.js");

loader.addFile("src/scriptaculous.js");
loader.addFile("src/effects.js");
loader.addFile("lightbox.js");

loader.addFile("imagereplace.js");

loader.addFile("lib/animator.js");
loader.addFile("lib/swfobject.js");
loader.addFile("lib/cookie.js");
loader.addFile("lib/trimpath-template.js");
loader.addFile("at/wohlfuehlurlaub/quicksearch/quicksearch.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.wohlfuehlurlaub.dropdowns.dropDown");
loader.addClass("at.wohlfuehlurlaub.navigation.hover");

loader.addClass("at.wohlfuehlurlaub.headerbox.tabbing");

loader.addClass("at.wohlfuehlurlaub.watchlist.controller");
loader.addClass("at.wohlfuehlurlaub.watchlist.openWatchlist");

loader.addClass("at.wohlfuehlurlaub.gallery_slider.slider");

loader.addClass("at.wohlfuehlurlaub.hotel_tabbing.tabs");

loader.addClass("at.wohlfuehlurlaub.hotel_form.openFormPart");


loader.load();


function onDocumentLoad () {
	
	try {
		if($('watch_list') != null){	
			window.watchlist = new at.wohlfuehlurlaub.watchlist.controller();
			
			new at.wohlfuehlurlaub.watchlist.openWatchlist($('watch_list'));
		}
	} catch (e) {}
	
	try {
		if($('languages') != null)
		{
			new at.wohlfuehlurlaub.dropdowns.dropDown($('languages'));
		}
	} catch (e) {}
	
	//Main navigation
	new at.wohlfuehlurlaub.navigation.hover( [ $$('#main_nav li')] );

	//Headerbox (Tabbing)
	try {
		if($('headerbox') != null) {
			//init tabbing
			new at.wohlfuehlurlaub.headerbox.tabbing($('headerbox'));
		}
	} catch (e) {}
	
	//Hotel detailsite (Tabbing)
	try {
		if($('tab_navigation') != null) {
			//init tabbing
			new at.wohlfuehlurlaub.hotel_tabbing.tabs($('content'));
		}
	} catch (e) {}
	
	//Hotel detailsite (Form)
	try {
		if($('forms') != null) {
			new at.wohlfuehlurlaub.hotel_form.openFormPart($('forms'));
		}
	} catch (e) {}
	
	// Quicksearch
	setEventListeners();
	
	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(target == "_blank") {
		window.open(destinationURL);
	}
	else {
		location.href = destinationURL;
	}
}



