
// 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.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.zugspitze.main_navigation.hover");
loader.addClass("at.zugspitze.portalslider.teaserslider");

loader.addClass("at.zugspitze.dropdowns.dropDown");

loader.load();
//loader.loadProxy("http://cms.salzburg.info/index.php/de/intern/script-proxy/");


function onDocumentLoad ()
{
	
	//Main Navigation
	try {
		new at.zugspitze.main_navigation.hover( [ $$('#main_nav li')], [ $$('#main_nav li ul li')]  );
	} catch (e) {}
	
	
	//Portal Teaser Slider
	try {
		if($('portal_teaser') != null)
		{
			new at.zugspitze.portalslider.teaserslider($('portal_teaser'));
		}
	} catch (e) {}
	
	
	try {
		if($('languages') != null)
		{
			new at.zugspitze.dropdowns.dropDown($('languages'));
		}
	} catch (e) {}
	
	//Presspictures function
	/*try {
		if($('picture_list') != null) {
			requests = $('picture_list').getElementsByClassName('pp_info');
			new at.schneiders.press.verticalSlider(requests,24,85);
		}
	} catch (e) {}*/
	
	// replace text to images	
	/*if (language == "de" || language == "en") {
		var imageReplacer = new at.elements.textreplace.image("/static/cache/headlines/",{appendFilename: true});	
		
		if (portal == "congress") {
			imageReplacer.add({
				elements: $$('#enquirybox .head_line h3'),
				options: {
				font: 'cgb.ttf',
				width: '170',
				height: '',
				color: '003C78',
				size: '10.2',
				positionx: 0,
				positiony: 13,
				replaceElement: {
					tagName: "h3",
					className: "r_img"
				},
				modifyValue : function (vari)
				{
					return vari.toUpperCase();
				}
			}});
		}
	
		imageReplacer.start();
	}*/
	
	try {
		if($('portal') != null) {
			window.setTimeout(function () {
				resizeFlashBackground();
			},500);	
			window.onresize = resizeFlashBackground;
		}
	} catch (e) {}

	try {
		if($('shopcart') != null) {	
			var shopObject = new shopCart($('shopcart'));
		}
	} catch (e) {}
	
	try {
		if($('weather_zugspitze') != null) {	
			initWeatherBox = window.setInterval("changeWeatherArea()", 5000);
		}
	} catch (e) {}
	
}

function changeWeatherArea () {
	$z_style = $('weather_zugspitze');
	$c_style = $('weather_classic');
	if ($z_style.getStyle('display') == "block") {
		$z_style.setStyle({ display: 'none' });
		$c_style.setStyle({ display: 'block' });
	}
	else {
		$c_style.setStyle({ display: 'none' });
		$z_style.setStyle({ display: 'block' });
	}
}

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(target == "_blank") {
		window.open(destinationURL);
	}
	else {
		location.href = destinationURL;
	}
}

