var showPrompts = true

function checkParam(){
	var rv = 1
	var h = window.location.href.toString().split('?')
	var hi
	if (h.length > 1){
		h = h[1].split('&')
		for (var i=0; i<h.length; i++){
			hi = h[i].split('=')
			if (hi[0].toString().toLowerCase() == 'v'){ rv = hi[1] }
		}
	}
	return rv
}

function displayPrompts(){
	if (showPrompts){
		var j = 0
		for (var i=0; i<promptList.length; i++){
			if (promptList[i].substring(0,1) == '@'){
				document.write('<p class="headerBorder">' + promptList[i].substring(1,promptList[i].length) + '</p>')
			} else {
				document.write('<p class="border" id="Index' + j.toString() + '"><a class="topiclist" href="javascript:SeekTime(' + 
					j.toString() + ');">&nbsp;' + (j+1).toString() + '. ' + promptList[i] + '</a></p>')
				j++
			}
		}
		processIndexList()
	} else {
		var vName = checkParam().toString().toLowerCase()
		var r = ''
		switch (vName){
			case 'foldups.wmv':
				r = "../../console/content/vpbacking/gorillagrip.jpg"
				break
			case 't-handles.wmv':
				r = "../../console/content/vpbacking/thandle.jpg"
				break
			case 'protanium.wmv':
				r = "../../console/content/vpbacking/protanium.jpg"
				break
			case 'proguard.wmv':
				r = "../../console/content/vpbacking/proguard.jpg"
				break
			case 'prohold.wmv':
				r = "../../console/content/vpbacking/prohold.jpg"
				break
			case 'ballpoints.wmv':
				r = "../../console/content/vpbacking/ballend.jpg"
				break
			case 'precision.wmv':
				r = "../../console/content/vpbacking/machining.jpg"
				break
		}
		document.getElementById('IndexLinksDiv').style.backgroundImage = 'url("' + r + '")'
		document.getElementById('indexTopic1').innerHTML = 'Bondhus Video'
		document.getElementById('indexTopic2').innerHTML = ''
		document.getElementById('IndexLinksDiv').style.visibility = 'visible'
	}
}

function processIndexList(){
	for (var i=0; i<indexList.length; i++){ indexList[i] = indexList[i] / 30 }
}

var mpObj, mpTimer

function SeekTime( tIndex ){
//   if (navigator.appName == "Netscape" && !window.GeckoActiveXObject ){
      mpObj.controls.currentPosition = indexList[tIndex];
      mpObj.controls.play();
}

function ScrollToIndex( DivID, destIndex ){
   var nDestYCoord = destIndex.offsetTop; 
   var thisNode    = destIndex; 
   
   while ( thisNode.offsetParent && ( thisNode.offsetParent !=  document.body) ){ 
      thisNode     = thisNode.offsetParent; 
      nDestYCoord += thisNode.offsetTop; 
   }

   nCurWindowYPos = GetCurrentScrollYPos( DivID.id );

   if( destIndex.offsetTop + destIndex.offsetHeight > DivID.clientHeight ){      
      nDestYCoord -= DivID.clientHeight;
      if( nDestYCoord > DivID.scrollTop ){DivID.scrollTop = nDestYCoord;}
   }
}

function GetCurrentScrollYPos( DivID ){ 
   var aDivs = document.body.getElementsByTagName("DIV");
   for ( var i=0; i < aDivs.length; i++ ){ 
		var Div = aDivs[i]; 
		if ( Div.id == DivID ){return Div.scrollTop}
   }
   return 0;
}

function timerInit(){
	mpObj = document.getElementById('mediaPlayer')
	mpObj.focus()
	window.setInterval("timer()", 100);
//	mpTimer = window.setInterval(timer, 2000);
//	document.getElementById('IndexLinksDiv').style.visibility = 'visible'
}

function timer(){
   if( mpObj.playState == 3 ){

		var d = document.getElementById('IndexLinksDiv')
		if (d.style.visibility.toString().toLowerCase() == 'hidden'){
			if (mpObj.network.downloadProgress == 100){d.style.visibility = 'visible'}
		}
   
      var destIndex = null;
      var curTime = mpObj.controls.currentPosition;
      var len = indexList.length-1
      
      for (var i=0; i<len; i++){
	      if( curTime >= indexList[i] && curTime < indexList[i+1] ){
	         document.getElementById('Index' + i.toString() ).style.backgroundColor = '#ffffcc';
	         destIndex = document.getElementById('Index' + i.toString() );
	      } else {
	         document.getElementById('Index' + i.toString() ).style.backgroundColor = '';
	      }
      }
      if( destIndex != null ){ ScrollToIndex( document.getElementById('IndexLinksDiv'), destIndex ); }
   }     
}

function centerWindow(){
	if (window.top != window){return;}
	
	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;
	
	var locX = Math.round((self.screen.width - frameWidth) / 2)
	var locY = Math.round((self.screen.height - frameHeight) / 2)

	parent.window.moveTo(locX, locY);
	window.focus()
}


