
// init loader
var loader = new Loader();
loader.setScriptPath("/static/js/");
loader.addFile("lib/prototype.js");

loader.addFile("lib/animator.js");
loader.addFile("lib/swfobject.js");
loader.addFile("lib/trimpath-template.js");

loader.addFile("lib/custom_form_elements.js");

loader.addFile("lib/greybox/AJS.js");
loader.addFile("lib/greybox/AJS_fx.js");
loader.addFile("lib/greybox/gb_scripts.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.sis.main_navigation.hover");
loader.addClass("at.sis.classhover.hover");
loader.addClass("at.sis.checklist.click_hover");
loader.addClass("at.sis.citations.slider");


loader.load();
//loader.loadProxy("http://cms.salzburg.info/index.php/de/intern/script-proxy/");


function onDocumentLoad ()
{
	
	//Main Navigation
	try {
		new at.sis.main_navigation.hover( [ $$('#nav .item')] );
	} catch (e) {}
	
	//Initialisierung custom form elements
	try {
		Custom.init();
	} catch (e) {}

	//Productlist
	try {
		new at.sis.classhover.hover( [ $$('#mainbody .txt .p_list_blk .item')] );
	} catch (e) {}
	
	//Checklist
	try {
		new at.sis.checklist.click_hover( $$('#mainbody .txt .checklistblk .ok'), $$('#mainbody.teaserbox .head .image'), $('batch') );
	} catch (e) {}

	//Citations
	try {
		var citations = $$("#citation .txt p");
		if (citations.length > 0) {
			new at.sis.citations.slider( citations );

		}	
	} catch (e) {}

}

function GetWindowSize (w) {
    w = window;
    var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
    var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
    return [width, height]
}

function resizeFlashBackground () {
	
	var size = GetWindowSize();
	$("backgroundFlash").setAttribute("width",size[0]);
	$("backgroundFlash").setAttribute("height",size[1]);
}

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;
}


