// init loader
var loader = new Loader();
loader.setScriptPath("/static/js/");
loader.addFile("lib/prototype.js");
loader.addFile("lib/trimpath-template.js");

loader.addClass("at.elements.calendar.init");

if(language == "de") {
	loader.addClass("at.elements.calendar.de");
}
else {
	loader.addClass("at.elements.calendar.en");
}

loader.load();

function onDocumentLoad () {
	
	// calendar:
	try {
		if( $('inquiryform') != null ) {
			new at.elements.calendar.init({
				button : 'date1click',
				output : "input",
				dayInput: 'beginDate',
				monthInput: 'beginMonth',
				yearInput: 'beginYear',
				updateFieldOnStartup : true
			});
		}
	}
	catch (e) {}
	
}


window.onload = onDocumentLoad;


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;
}

function openWindow(url) {
	fenster = window.open(url, "_blank", "width=620,height=420,status=yes,scrollbars=yes,resizable=yes");
	fenster.focus();
	return false;
}