﻿
	var APP_ROOT;
	var THEME_ROOT = 'themes/freizeitcenter-oberrhein.de/';
	var Site = {
		
		IE: !!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1),
		IEVersion: navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE ")+5, 1),
		
		/*
		 * Site.__init
		 */
		__init: function(isStatic) {
			
			// Pfad nach laden der Seite setzen
			APP_ROOT = (typeof WebSite == "object" || isStatic ? '' : '../');
			
			this.load_PNG();
			this.load_Background();

			document.getElementById('Clouds').onload = Site.load_Background;
			window.onresize = Site.load_Background;
			window.onload = Site.load_Background;
      
			if(document.getElementById('SearchButton'))
				document.getElementById('SearchButton').value = '';
			
		},
		
		/*
		 * Site.load_PNG
		 */
		load_PNG: function() {
			
			if(!this.IE || this.IEVersion != 6)
				return;
			var images = document.getElementsByTagName('img');
			
			for (var c = 0; c < images.length; c++) {
				
				if (!images[c].src.match(/\.png/))
					continue;
				
	  		images[c].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + images[c].src + "')";
	      images[c].src = APP_ROOT + 'skins/brandbox_default/icons/others/spacer.gif';
				
			}
		},
		
		/*
		 * load_Background
		 */
		load_Background: function() {

			var
				ScreenX = 0,
				ScreenY = 0,
				RatioWidth = 0,
				RatioHeight = 0,
				Ratio = 0;

			ScreenX =
				self.innerWidth ||
				document.documentElement.clientWidth ||
				document.body.clientWidth;

			ScreenY =
				self.innerHeight ||
				document.documentElement.clientHeight ||
				document.body.clientHeight;

			CloudsImage = new Image();
      CloudsImage.src = document.getElementById('Clouds').src;
      CloudsWidth  = CloudsImage.width;
      CloudsHeight = CloudsImage.height;

      RatioWidth    = ScreenX / CloudsWidth;
			RatioHeight   = ScreenY / CloudsHeight;

			if(RatioWidth >= RatioHeight){
        document.getElementById('Clouds').width = ScreenX;
        document.getElementById('Clouds').height = CloudsHeight * (document.getElementById('Clouds').width / CloudsWidth);
        document.getElementById('Background').style.left = 0;
        document.getElementById('Background').style.top = -((document.getElementById('Clouds').height - ScreenY)/2)+"px";
        document.getElementById('Background').style.width = document.getElementById('Clouds').width+"px";
        document.getElementById('Background').style.height = document.getElementById('Clouds').height+"px";
      } else {
        document.getElementById('Clouds').height = ScreenY;
        document.getElementById('Clouds').width = CloudsWidth * (document.getElementById('Clouds').height / CloudsHeight);
        document.getElementById('Background').style.left = -((document.getElementById('Clouds').width - ScreenX)/2)+"px";
        document.getElementById('Background').style.top = 0;
        document.getElementById('Background').style.height = document.getElementById('Clouds').height + "px";
        document.getElementById('Background').style.width = document.getElementById('Clouds').width + "px";
      }
		}
	}
	