var __isFF = false;
var __isIE = false;
var __isOpera = false;
var __isKHTML = false;
var __isMacOS = false;
var __isChrome = false;
if	(navigator.userAgent.indexOf('Macintosh')!= -1)			__isMacOS=true;
if	(navigator.userAgent.toLowerCase().indexOf('chrome')>-1)	__isChrome=true;
if	( (navigator.userAgent.indexOf('Safari')!= -1)
	||(navigator.userAgent.indexOf('Konqueror') != -1)){
		var __KHTMLrv = parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Safari')+7, 5));
		if	(__KHTMLrv > 525)	{
			__isFF=true;
			var __FFrv = 1.9
		} else
			__isKHTML=true
} else	if	(navigator.userAgent.indexOf('Opera')!= -1)	{
		__isOpera=true;
		__OperaRv=parseFloat(navigator.userAgent.substr(navigator.userAgent.indexOf('Opera')+6, 3))
} else	if	(navigator.appName.indexOf("Microsoft")!= -1){
		__isIE=true;
		if	(navigator.appVersion.indexOf("MSIE 8.0")!= -1
			&& document.compatMode != "BackCompat")
				__isIE=8
} else	{
	__isFF=true;
	var __FFrv = parseFloat(navigator.userAgent.split("rv:")[1])
};

// alert ('FF:'+__isFF+'; IE:'+__isIE+'; Opera:'+__isOpera+'; Konquerer:'+__isKHTML+'; MacOS:'+__isMacOS+'; Chrome:'+__isChrome);


var menu;	// MenuObject
var page;	// Holds current page
// Languages
var nl		= 'nederlands';
var uk		= 'english';

// Depending on domain choose default language
var lang	= nl;	if	(document.domain	== 'www.cureris.com')	lang		= uk;
			if	(document.domain	== 'cureris.com')	lang		= uk;
// What is the other language (for menu-bar)
var otherLang	= uk;	if 	(lang			== uk)			otherLang	= nl;

function initPage()	{
	menu = new dhtmlXMenuObject('menu');
	menu.setIconsPath('./images/');
	menu.attachEvent('onClick', menuClick);
	loadLang();

// Any direct page request ? (default always 'home')
	page	= parent.window.location.search;
	page	= page.replace('?','');
//	if	(page == '')	page	= 'home.html';
	menuClick('__'+page);
}

function switchLang()	{
	tmp		= lang;
	lang		= otherLang;
	otherLang	= tmp;

	loadLang();

	menuClick('__'+page);
}

function loadLang()	{
	document.getElementById('logo').innerHTML = "<img src='"+"./"+lang+"/images/logocureris.jpg'>";

	menu.clearAll();
	menu.setTopText("<a onClick='switchLang()'><img src='"+"./"+otherLang+"/images/flag.jpeg' width='24px' height='19px' border='0'></a>");
	menu.loadXML('./'+lang+'/xml/curerismenu.xml?now=' + new Date().getTime());
}

function menuClick(id) {
	if 	(id.substr(2)	!= '')		page	= id.substr(2);
	if 	(page		== '')		page	= 'home.html';
	if	(id.substr(0,2)	== 'DD'){	location = page;			return;}
	if	(id.substr(0,2)	== 'XX'){	window.open(page,'Cureris.nl','');	return;}

	document.getElementById('myData').innerHTML = "<iframe class='myFrame' allowTransparency='true' src='"+"./"+lang+"/"+page+"'></iframe>";
}


// Get User Parameters

function gup(name)	{
	name		= name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS	= "[\\?&]"+name+"=([^&#]*)";
	var regex	= new RegExp( regexS );
	var results	= regex.exec( window.location.href );
	if	(results == null)
		return "";
	else
		return results[1];
}

var myWidth = 0, myHeight = 0;

function getSizes() {
	if( typeof( window.innerWidth ) == 'number' )	{		//Non-IE
		myWidth		= window.innerWidth;
		myHeight	= window.innerHeight;
	}
	else 	if 	(document.documentElement
			&&	(  document.documentElement.clientWidth
				|| document.documentElement.clientHeight
				)
			)	{					//IE 6+ in 'standards compliant mode'
			myWidth	 = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
	}
	else 	if 	(document.body
			&&	(  document.body.clientWidth
				|| document.body.clientHeight
				)
			)	{					//IE 4 compatible
			myWidth	 = document.body.clientWidth;
			myHeight = document.body.clientHeight;
	}
//  return new Array(myWidth, myHeight);
}

function setDataDivSize(myElement,alterWidth,alterHeight)	{
	getSizes();
//alert(myElement);
	var d = document.getElementById(myElement);
	var b = d.offsetTop;
//	var hereWidth	= myWidth-18;
	var hereHeight	= myHeight-10;
	if	(__isIE)	{						// IE has different measurement !
//		hereWidth	= myWidth-22;
		hereHeight	= myHeight-32;
	}
	d.style.height = (hereHeight-b+alterHeight) + 'px';
//	d.style.width	= (hereWidth+alterWidth) + 'px';
}

function setElemHeight(myElement)	{
	if	(!__isIE)	{						// Do NOT for IE
		var d = document.getElementById(myElement);
		alert(d.scrollHeight+'  '+d.clientHeight);
		if	(d.scrollHeight > d.clientHeight)	d.style.height = d.scrollHeight + 'px';
		alert(d.scrollHeight+'  '+d.clientHeight);
	}
}
