
function fetchSize() {
  var myWidth = 0, myHeight = 0;
  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 myWidth + "!" + myHeight
}

function fetchInnerSize(){
	var frameWidth = 0
	var frameHeight = 0
	if (self.innerWidth){
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	else return "0,0";
	return frameWidth.toString() + ',' + frameHeight.toString()
}

function centerWindow(){
	// ***** Override to repait narrow console links scattered around the Internet
//	var s = fetchInnerSize().split(',')
	var s = '790,540'.split(',')
	parent.window.resizeTo(300,400)
	var c = fetchInnerSize().split(',')
	var newW = parseInt(s[0],10) + (300 - parseInt(c[0],10))
	var newH = parseInt(s[1],10) + (400 - parseInt(c[1],10))
	parent.window.resizeTo(newW,newH)
	var locX = Math.round((self.screen.width - newW) / 2)
	var locY = Math.round((self.screen.height - newH) / 2)
	parent.window.moveTo(locX, locY);
	window.focus()
}

function centerMe(){
	centerLogo()
	if (window.showModelessDialog){
		var siz = fetchSize().toString().split("!")
		window.dialogWidth = (720 + (720-parseInt(siz[0],10))) + 'px'
		window.dialogHeight = (530 + (530-parseInt(siz[1],10))) + 'px'
	}
	centerWindow()
}

function fillTitle(t){
	var d = window.top.document.getElementById('contentTitle')
	d.innerHTML = t
}

function fillCrawlLine(t){
	var d = window.top.document.getElementById('crawlLine')
	d.innerHTML = t
}

function btnCrawlLine(obj){
	var d = window.top.document.getElementById('crawlLine')
	d.innerHTML = obj.alt
}

function hiliteBtn(obj, pth){
	var a, b

	a = document.getElementById("ntool")
	if (a != b){a.src = 'graphics/ntool.jpg'}

	for (var i = 1; i <= 7; i++){
		a = document.getElementById("tool" + i.toString())
		if (a != b){a.src = 'graphics/tool' + i.toString() + '.jpg'}
	}
	
	for (var i = 1; i <= 8; i++){
		a = document.getElementById("topic" + i.toString())
		if (a != b){a.src = 'graphics/topic' + i.toString() + '.jpg'}
	}
	
	if (obj != b){obj.src = 'graphics/' + obj.id.toString() + 'in.jpg'}
	
	a = document.getElementById("displayiframe")
	a.src = pth
}

function centerLogo(){
	var a, b

	a = document.getElementById("theLogo")
	if (a != b){
		a.style.left = Math.round((180 - parseInt(a.width,10)) / 2).toString() + "px"
		a.style.top = Math.round((53 - parseInt(a.height,10)) / 2).toString() + "px"
	}
}

function openFlagWindow(){
	window.open("../console/flag.htm","BondhusLanguageConsole",
			"location=0,menubar=0,toolbar=0,directories=0,resizable=0,status=0,dependent=0,width=600,height=420"); 
}
