var myAgent = "";							// De userAgent (Browser)
var myWidth = 0;							// De bruikbare schermbreedte
var myHeight = 0;							// De bruikbare schermhoogte
var myScreenWidth = 0;						// De maximale schermbreedte
var myScreenHeight = 0;						// De maximale schermhoogte
var arrScreenWidth = new Array(800, 1024, 1152, 1280, 1400, 1440, 1920); 	// De ondersteunde schermbreedtes
var arrWidthCorr = new Array(0, 0, 0, 0, 0, 0, 0);							// De correcties op de gevonden schermbreedtes
var myScreenWidthIndex = 0;					// De indexwaarde van de gevonden schermbreedte in arrScreenWidth t.b.v. de arrWidthCorr
var myHeightCorr = 0;						// De correctie op de gevonden schermhoogte
var myWidthCorr = 0;						// De correctie op de gevonden schermbreedte

function getScreenSizes(parScreenWidth, parScreenHeight) 
	{
	myScreenWidth = parScreenWidth;
	myScreenHeight = parScreenHeight;
//	window.alert('myScreenWidth='+myScreenWidth+' myScreenHeight='+myScreenHeight);
	myScreenWidth = screen.width;
	myScreenHeight = screen.height;
//	window.alert('Screen.Width='+myScreenWidth+' Screen.Height='+myScreenHeight);
	myScreenWidthIndex = getIndex(arrScreenWidth, myScreenWidth);
//	window.alert('myScreenWidthIndex='+myScreenWidthIndex);
	myAgent = getAgent();
	switch(myAgent)
		{
		case "IE9 Comp":
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// ------v	800,1024,1152,1280,1400,1440,1920
			break;
		case "IE9":
			if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
				{
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
				}
			else
				{
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
				}
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// vvvvvvv	800,1024,1152,1280,1400,1440,1920
			break;
		case "IE8 Comp":
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// ------v	800,1024,1152,1280,1400,1440,1920
			break;
		case "IE8":
			if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
				{
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
				}
			else
				{
				myWidth = document.body.clientWidth;
				myHeight = document.body.clientHeight;
				}
			arrWidthCorr = Array(0, 0, 0, 0, 0, -4, 0);		// vvvvvvv	800,1024,1152,1280,1400,1440,1920
			break;
		case "IE7":
  			myWidth = document.documentElement.clientWidth;
  			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// ------	800,1024,1152,1280,1400,1440,1920
			break;
		case "FF 3":
			myWidth = window.innerWidth-Math.floor(22*window.innerWidth/1400);
  			myHeight = window.innerHeight;
			arrWidthCorr = Array(-4, 0, 2, 4, 6, 4, 14);	// vvvvvvv	800,1024,1152,1280,1400,1440,1920
			myHeightCorr = -10;
			break;
		case "Chrome 3":
  			myWidth = document.documentElement.clientWidth;
  			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(3, 3, 0, 0, 0, -4, 0);		// vv----v	800,1024,1152,1280,1400,1440,1920
			myHeightCorr = -5;
			break;
		case "Safari 5":
  			myWidth = document.documentElement.clientWidth;
  			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(3, 2, 0, 0, 0, -2, 0);		// vv----v	800,1024,1152,1280,1400,1440,1920
			myHeightCorr = -10;
			break;
		case "Safari 4":
  			myWidth = document.documentElement.clientWidth;
  			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(3, 2, 0, 0, 0, 0, 0);		// vv----v	800,1024,1152,1280,1400,1440,1920
			break;
		case "FF 2":
			myWidth = window.innerWidth-Math.floor(22*window.innerWidth/1400);
  			myHeight = window.innerHeight;
			arrWidthCorr = Array(-4, 0, 2, 4, 6, 6, 6);		// ----v--	800,1024,1152,1280,1400,1440,1920
			break;
		case "Opera 9":
			myWidth = window.innerWidth-Math.floor(22*window.innerWidth/1400);
  			myHeight = window.innerHeight;
			arrWidthCorr = Array(-8, -4, -2, 0, 4, 4, 12);	// vvvvvvv	800,1024,1152,1280,1400,1440,1920
			break;
		case "IE6":
  			myWidth = document.documentElement.clientWidth;
  			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "IE5":
  			myWidth = document.body.clientWidth;
  			myHeight = document.body.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "IE4":
  			myWidth = document.body.clientWidth;
  			myHeight = document.body.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "FF 1":
			myWidth = window.innerWidth-Math.floor(22*window.innerWidth/1400);
  			myHeight = window.innerHeight;
			arrWidthCorr = Array(-4, 0, 2, 4, 6, 6, 6);		// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "Opera 8":
			myWidth = window.innerWidth-Math.floor(22*window.innerWidth/1400);
  			myHeight = window.innerHeight;
			arrWidthCorr = Array(-8, -4, -2, 0, 4, 2, 2);	// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "Opera 7":
			myWidth = window.innerWidth-Math.floor(22*window.innerWidth/1400);
  			myHeight = window.innerHeight;
			arrWidthCorr = Array(-8, -4, -2, 0, 4, 2, 2);	// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "Chrome 2":
  			myWidth = document.documentElement.clientWidth;
  			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "Safari 3":
  			myWidth = document.documentElement.clientWidth;
  			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "Opera":
			myWidth = window.innerWidth-Math.floor(22*window.innerWidth/1400);
  			myHeight = window.innerHeight;
			arrWidthCorr = Array(-8, -4, -2, 0, 4, 2, 2);	// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "Non-IE":
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "IE 6+ type":
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// -------	800,1024,1152,1280,1400,1440,1920
			break;
		case "IE 4,8 type":
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// -------	800,1024,1152,1280,1400,1440,1920
			break;
		default:
			myWidth = 1380;
  			myHeight = 865;
			arrWidthCorr = Array(0, 0, 0, 0, 0, 0, 0);		// -------	800,1024,1152,1280,1400,1440,1920
		}
	myWidthCorr = arrWidthCorr[myScreenWidthIndex];
	myWidth = myWidth + myWidthCorr;
	myHeight = myHeight + myHeightCorr;
//	window.alert(myScreenWidthIndex + ' (OnLoad) Agent = ' + myAgent + ' Width = ' + myWidth + ' and Height = ' + myHeight + ' ScreenWidth = ' + myScreenWidth + ' and ScreenHeight = ' + myScreenHeight + ' WidthCorr = ' + myWidthCorr + ' HeightCorr = ' + myHeightCorr);
	return [myWidth, myHeight, myScreenWidth, myScreenHeight, myAgent, myWidthCorr, myHeightCorr];
	}

function getIndex(Arr, Arg)
	{
//	window.alert('Arr:'+Arr+' Arg:'+Arg);
	var N = Arr.length;
//	window.alert('N:'+N);
	for (var I = 0; I < N; I++)
		{
//		window.alert('Arr['+I+']='+Arr[I]+' :: '+Arg);
		if (Arr[I] >= Arg)
//			window.alert('Geselecteerd:'+Arr[I]);
			return I;
		}
//	window.alert('Geselecteerd:'+Arr[N-1]);
	return N-1;
	}
	
function getAgent() 
	{
	var myAgent = "unknown";
//	window.alert(navigator.userAgent);
	//note: userAgent in IE7 WinXP returns: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)	
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion>=9) {
			myAgent = "IE9"; }
		else if (ieversion>=8) {
			myAgent = "IE8"; }
		else if (ieversion>=7) {
			myAgent = "IE7"; 
			if (navigator.userAgent.indexOf("Trident/4.0")>-1) {
			myAgent = "IE8 Comp"; }
			if (navigator.userAgent.indexOf("Trident/5.0")>-1) {
			myAgent = "IE9 Comp"; }
				}
		else if (ieversion>=6) {
			myAgent = "IE6"; }
		else if (ieversion>=5) {
			myAgent = "IE5"; }
		else if (ieversion>=4) {
			myAgent = "IE4"; }
		}
	//Note: userAgent in FF2.0.0.13 WinXP returns: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13
	else if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ffversion>=3) {
			myAgent = "FF 3"; }
		else if (ffversion>=2) {
			myAgent = "FF 2"; }
		else if (ffversion>=1) {
			myAgent = "FF 1"; }
		}
	//Note: userAgent in Opera9.24 WinXP returns: Opera/9.24 (Windows NT 5.1; U; en)
	//         userAgent in Opera 8.5 (identified as IE) returns: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Opera 8.50 [en]
	//         userAgent in Opera 8.5 (identified as Opera) returns: Opera/8.50 (Windows NT 5.1; U) [en]
	else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);
		var oprversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (oprversion>=9) {
			myAgent = "Opera 9"; }
		else if (oprversion>=8) {
			myAgent = "Opera 8"; }
		else if (oprversion>=7) {
			myAgent = "Opera 7"; }
		else {
			myAgent = "Opera"; }
		}
	//Note: userAgent in Chrome 3.0.195.38 WinXP returns: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0
	else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Chrome/x.x (ignoring remaining digits);
		var chrversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (chrversion>=3) {
			myAgent = "Chrome 3"; }
		else if (chrversion>=2) {
			myAgent = "Chrome 2"; }
		}
	//Note: userAgent in Safari 4.0.4 WinXP returns: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10
	else if (/Version[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Safari/x.x (ignoring remaining digits);
		var safversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		if (safversion>=5) {
			myAgent = "Safari 5"; }
		else if (safversion>=4) {
			myAgent = "Safari 4"; }
		else if (safversion>=3) {
			myAgent = "Safari 3"; }
		}
	//Non-IE type
	else if (typeof(window.innerWidth) == 'number') {
		myAgent = "Non-IE";
 		}
	//IE 6+ in 'standards compliant mode'
	else if(document.documentElement &&   (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		myAgent = "IE 6+ type";
		}
	//IE 4 and 8 compatible
	else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
		myAgent = "IE 4,8 type"; 		
		} 
	return myAgent;
	}
	
