﻿/* Browser information - viewport */



function init()
{
	if (document.getElementById)
	{
		var browserinformation = document.getElementById("browserinformation");
		if (browserinformation != null)
		{
			//init path and querystring
			var path = "/browser-information/viewport.aspx";
			var qs = "?qs=innerWidth|innerHeight|outerWidth|outerHeight|screenWidth|screenHeight|screenAvailWidth|screenAvailHeight|windowLeft|windowTop|colourDepth|scrollWidth|scrollHeight|documentWidth|documentHeight&amp;d=date";
			
			//get viewport information
			var innerWidth = "";
			var innerHeight = "";
			var outerWidth = "";
			var outerHeight = "";
			var screenWidth = "";
			var screenHeight = "";
			var screenAvailWidth = "";
			var screenAvailHeight = "";
			var windowLeft = "";
			var windowTop = "";
			var colourDepth = "";
			var scrollWidth = "";
			var scrollHeight = "";
			var documentWidth = "";
			var documentHeight = "";
			
			//innerHeight, innerWidth
			if (self.innerHeight) // all except Explorer
			{
				innerWidth = self.innerWidth;
				innerHeight = self.innerHeight;
			}
			else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
			{
				innerWidth = document.documentElement.clientWidth;
				innerHeight = document.documentElement.clientHeight;
			}
			else if (document.body) // other Explorers
			{
				innerWidth = document.body.clientWidth;
				innerHeight = document.body.clientHeight;
			}
			
			//outerWidth, outerHeight
			if (self.outerHeight)
			{
				outerWidth = self.outerWidth;
				outerHeight = self.outerHeight;
			}
			
			//screenWidth, screenHeight
			if (self.screen.height)
			{
				screenWidth = self.screen.width;
				screenHeight = self.screen.height;
			}
			
			//screenAvailWidth, screenAvailHeight
			if (self.screen.availHeight)
			{
				screenAvailWidth = self.screen.availWidth;
				screenAvailHeight = self.screen.availHeight;
			}
			
			//windowLeft, windowTop
			if (self.screenLeft)
			{
				windowLeft = self.screenLeft;
				windowTop = self.screenTop;
			}
			
			//colourDepth
			if (self.screen.colorDepth)
			{
				colourDepth = self.screen.colorDepth;
			}
			else if (self.screen.pixelDepth)
			{
				colourDepth = self.screen.pixelDepth;
			}
			
			//scrollWidth, scrollHeight
			if (document.body.scrollWidth)
			{
				scrollWidth = document.body.scrollWidth;
				scrollHeight = document.body.scrollHeight;
			}
			else if (document.documentElement.scrollWidth)
			{
				scrollWidth = document.documentElement.scrollWidth;
				scrollHeight = document.documentElement.scrollHeight;
			}
			
			//documentWidth, documentHeight
			if (document.body.offsetHeight)
			{
				documentWidth = document.body.offsetWidth;
				documentHeight = document.body.offsetHeight;
			}
			else if (document.documentElement.offsetHeight)
			{
				documentWidth = document.documentElement.offsetWidth;
				documentHeight = document.documentElement.offsetHeight;
			}
			
			
			qs = "?qs=" + innerWidth + "|" + innerHeight + "|" + outerWidth + "|" + outerHeight + "|" + screenWidth + "|" + screenHeight + "|" + screenAvailWidth + "|" + screenAvailHeight + "|" + windowLeft + "|" + windowTop + "|" + colourDepth + "|" + scrollWidth + "|" + scrollHeight + "|" + documentWidth + "|" + documentHeight;
			
			//append date to querystring to prevent caching
			var date = new Date();
			qs += "&amp;d=" + date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + "-" + date.getHours() + "-" + date.getMinutes() + "-" + date.getSeconds();
			
			//create image
			var img = document.createElement("img");
			img.setAttribute("src", path + qs);
			img.setAttribute("alt", "");
			img.setAttribute("width", "1");
			img.setAttribute("height", "1");
			
			browserinformation.appendChild(img);
		}
	}
}



if (window.addEventListener)
{
	window.addEventListener('load',init,false)
}
else if (window.attachEvent)
{
	window.attachEvent('onload',init)
}