function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function getWindowWidth() {
    var windowWidth = 0;
    if (typeof(window.innerWidth) == 'number') {
        windowWidth = window.innerWidth;
    }
    else {
        if (document.documentElement && document.documentElement.clientWidth) {
	        windowWidth = document.documentElement.clientWidth;
        }
        else {
	        if (document.body && document.body.clientWidth) {
		        windowWidth = document.body.clientWidth;
	        }
        }
    }
    return windowWidth;
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

browser = BrowserDetect.browser;

var lastElemId = "about-the-office";

var newLocation = "about-the-office";
var newLocationChanged = false;
var locChange = false;
var locationDuplicate = "";
var forceChange = false;

function setLastElemId ( elemId ) {
	//locChange = true;
	//locationDuplicate = elemId;
	lastElemId = elemId;
	forceChange = true;
}

function showElem ( elemId ) {
	if ( lastElemId == elemId ) {
		return;
	}
	lastElemId = elemId;
	
	var str = new String ( window.location );
	var ii = 0;
	for ( var i = 0; i < str.length; i++ ) {
		if ( str.charAt ( i ) == "#" ) {
			ii = i;
			break;
		}
	}
	str = str.substring ( 0, ii - 1 );
	var str2 = str;
	window.location = "#" + elemId;
	if ( forceChange ) {
		forceChange = false;
		locationDuplicate = elemId;
		locChange = true;
	}
}

function showElem2 ( elemId ) {
	/*
	if ( lastElemId == elemId ) {
		return;
	}
	*/
	
	lastElemId = elemId;
	newLocation = elemId;
	newLocationChanged = true;
	locChange = true;
	locationDuplicate = elemId
	
	/*
	var str = new String ( window.location );
	var ii = 0;
	for ( var i = 0; i < str.length; i++ ) {
		if ( str.charAt ( i ) == "#" ) {
			ii = i;
			break;
		}
	}
	str = str.substring ( 0, ii - 1 );
	window.location = str + "#" + elemId;
	*/
}

var destHei = 25;
var lastPage = "_init_";

function func2 ( param ) {
	destHei = Number ( param );
//	document.getElementById("contentFrame").height = param;
}

function func3 ( param ) {
	document.getElementById("contentFrame").height = param;
	destHei = Number ( param );
}
//var query = window.location.search.substring(1);


function fint () {
	var cf = document.getElementById("contentFrame");
	var mm = document.getElementById("mainbox");
	if ( cf != null ) {
		if ( cf.height != null ) {
			var tmp2 = Math.max ( 320, Math.round ( Number ( cf.height ) + ( destHei - Number ( cf.height ) ) * 0.28 ) );
			if ( ( Math.abs ( Number ( cf.height ) - destHei ) < 2 ) && ( Math.abs ( Number ( cf.height ) - destHei ) > 0 ) ) {
				cf.height = destHei;		
			} else if ( Math.abs ( Number ( cf.height ) - destHei ) > 0 ) {
				cf.height = tmp2;
				if ( mm != null ) {
					//alert ( mm.offsetTop );
				}
			}
			
		}
	}
	if ( newLocationChanged ) {
		window.location = "#" + newLocation;
		
		newLocationChanged = false;
	}
	
	var q = String(window.location);
	var np = "";
	if ( q.indexOf ('#') > 0 ) {
		q = q.substring(q.indexOf('#')+1);
		np = q;
	}
	if ( np != lastPage ) {
		if ( cf != null ) {
			if ( np == "" ) 
				cf.src = "./tresci/about-the-office.html";
			else
				cf.src = "./tresci/" + np + ".html";
			lastPage = np;
		}
	} else if ( locChange == true ) {
		locChange = false;
		if ( cf != null ) {
			cf.src = "./tresci/" + locationDuplicate + ".html";
			lastPage = locationDuplicate;
		}
	}
	setTimeout ( "fint()", 50 );
}
fint ();
