﻿
	var APP_ROOT;
	var THEME_ROOT = 'themes/brandbox.ws/';
			
	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.GetElementHeight();
		},
		
		/*
		 * 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';
				
			}
		},
    
     GetElementHeight: function() {
     
      elm = document.body;
      elmWrap = document.getElementById('Wrap');
      if (document.layers){
        if (!elm.height)
          elm.height = elm.clip.height;
          bodyHeight = elm.height;
          wrapHeight = elmWrap.height;
          wrapWidth = elmWrap.width;
	      } else if (typeof(elm.style && elm.style.height) == 'number'){
	        bodyHeight = elm.style.height;
	        wrapHeight = elmWrap.style.height;
          wrapWidth = elmWrap.style.width;
	      } else if (typeof(elm.style && elm.style.height) == 'string' && !isNaN(parseInt(elm.style.height))){
	        bodyHeight = parseInt(elm.style.height);
	        wrapHeight = parseInt(elmWrap.style.height);
          wrapWidth = parseInt(elmWrap.style.width);
	      } else if (elm.offsetHeight){
	        bodyHeight = elm.offsetHeight;
	        wrapHeight = elmWrap.offsetHeight;
	        wrapWidth = elmWrap.offsetWidth;
	      } else if (typeof(elm.style && elm.style.pixelHeight) == 'number'){
	        bodyHeight = elm.style.pixelHeight;
	        wrapHeight = elmWrap.style.pixelHeight;
	        wrapWidth = elmWrap.style.pixelWidth;
	      } else if (elm.clientHeight){
	        bodyHeight = elm.clientHeight;
	        wrapHeight = elmWrap.clientHeight;
	        wrapWidth = elmWrap.clientWidth;
	      }
	    	    
	   	 	var viewportHeight = document.documentElement.clientHeight;
	   	 	var viewportWidth = document.documentElement.clientWidth;
		    var marginTop = ((viewportHeight - wrapHeight)/ 2 - 10);
		    var marginLeft = ((viewportWidth - wrapWidth)/ 2 - 10);
		   	
		    if(marginTop < 0)
		    	marginTop = 0; 
		    	
	      document.getElementById('Wrap').style.marginTop = marginTop + "px";
	      document.getElementById('Wrap').style.marginLeft = marginLeft + "px";
	      document.body.style.backgroundPosition = "center "+((viewportHeight/2) - 244)+"px";
	      document.getElementsByTagName('html')[0].style.overflow = 'hidden';
	      
	      if(viewportHeight < 630) {
	      	document.getElementsByTagName('html')[0].style.overflow = 'scroll';
	      	document.body.style.backgroundPosition = "center center";
	      }
	      if(viewportWidth < 1018) {
	      	document.getElementsByTagName('html')[0].style.overflow = 'scroll';
	      	document.body.style.backgroundPosition = ((-332))+"px center";
	      }
	      if(viewportHeight > 630 && viewportWidth < 1018) {
	      	document.body.style.backgroundPosition = ((-332))+"px "+((viewportHeight/2) - 244)+"px";
	      }
      }
	}
