
var videoNumber = 0

function btnReference(w){
	return "bondhus.wmv,ballpoints.wmv,foldups.wmv,t-handles.wmv,precision.wmv,proguard.wmv,prohold.wmv,protanium.wmv".split(',')[w-1]
}

function placeBtns(){
	//  92  437-68
	var hspacer
	if (theLang == 'en'){
		hspacer = Math.round((632 - (8*68)) / 3)
	} else {
		hspacer = Math.round((632 - (7*68)) / 3)
	}
	
	var x = 52 + 68 + hspacer
	var btn
	var i, srt
	var btnOrder = "1,3,4,8,6,7,2,5".split(',')
	if (theLang == 'en'){ srt = 1 } else { srt = 2 }
	for (var j=srt; j<9; j++){
		i = btnOrder[j-1]
		document.write("<div class='shadow' style='left:" + (x-1).toString() + "px;'>&nbsp;</div>")
		btn = "<img id='btn" + i.toString() + "' src='graphics/btn" + i.toString() + ".jpg' class='btnClass1' style='left:" + x.toString() + "px;' " +
			"onclick='pushBtn(" + i.toString() + ")' " +
			"onmouseover='btnRollover(" + i.toString() + ")' onmouseout='btnRolloverOut()' " +
			"alt = '' " +
			">"
		document.write(btn)
		x += 68
		if (i==4){ x+= hspacer}
	}
}

function highlightBtn(w){
	var btn, srt
	if (theLang == 'en'){ srt = 1 } else { srt = 2 }
	for (var i=srt; i<9; i++){
		btn = document.getElementById('btn' + i.toString())
		btn.src = 'graphics/btn' + i.toString() + '.jpg'
	}
	btn = document.getElementById('btn' + w.toString())
	btn.src = 'graphics/btnin' + w.toString() + '.jpg'
}

function pushBtn(w){
	videoNumber = w
	highlightBtn(w)
	var cRef = 'console'
	if (theLang != 'en'){cRef += '-' + theLang.toString()}
	document.getElementById("displayiframe").src = "../" + cRef + "/content/video_ctrl.asp?v=" + btnReference(w)
}

function btnRollover(w){
	var rDiv = document.getElementById('crawlLine')
	if (theLang == 'en'){
		rDiv.innerHTML = '<b>' + vidTitle(btnReference(w)) + '</b>' + ' - ' + vidDesc(btnReference(w))
	} else {
		centerCrawlline('<b>' + foreignCrawlLine(btnReference(w)) + '</b>')
	}
}

function btnRolloverOut(){
	if (videoNumber == 0){
		centerCrawlline(buttonAbove())
	} else {
		centerCrawlline(currentlyPlaying() + ' ' + '<b>' + vidTitle(btnReference(videoNumber)) + '</b>')
	}
}

function centerCrawlline(s){
	var rDiv = document.getElementById('crawlLine')
	rDiv.innerHTML = '<center><img src="graphics/tg.gif" width="1px" height="20px" >' + s + '</center>'
}

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(){
	var s = fetchInnerSize().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 openFlagWindow(){
	window.open("flag.htm","BondhusLanguageConsole",
			"location=0,menubar=0,toolbar=0,directories=0,resizable=0,status=0,dependent=0,width=600,height=400"); 
}

