//var popUpWin=0;

function popUpWindow(URLStr, name, left, top, width, height)
{
  /*if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
	width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'
  }*/
  popUpWin = open(URLStr, name, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes');
  popUpWin.focus();
}

var G_idPart="";
var timeOut;

function searchIdRec(elt, idPart) {
	for (var i=elt.childNodes.length-1; i>=0; i--) {
		//alert(elt.childNodes[i].nodeName+" "+elt.childNodes[i].id);
		if (elt.childNodes[i].id!=null && (elt.childNodes[i].id.substring(0,idPart.length))==idPart) {
			ScrollToElement(elt.childNodes[i]);
		}
		else {
			searchIdRec(elt.childNodes[i],idPart);
		}
	}
}

function keyPressed(e) {
	if (timeOut!=null) {
		clearTimeout(timeOut);
	}
	timeOut = window.setTimeout("timer()",1000);
	var KeyID = (window.event) ? event.keyCode : e.which;
  //alert("You pressed: "+KeyID);// + String.fromCharCode(e.which) + ".");
	var KeyChar = String.fromCharCode(KeyID);
	if (KeyID>=97 && KeyID<=122) {
		KeyChar=KeyChar.toUpperCase();
	}
	G_idPart+=KeyChar;
	//var elt = document.getElementById("itemsAnchored");
	//searchIdRec(elt,G_idPart);
}

function ScrollToElement(theElement){

  var selectedPosX = 0;
  var selectedPosY = 0;
              
  while(theElement != null){
    selectedPosX += theElement.offsetLeft;
    selectedPosY += theElement.offsetTop;
    theElement = theElement.offsetParent;
  }                     		      
 window.scrollTo(selectedPosX,selectedPosY);
}

function timer() {
	searchIdRec(document.body,G_idPart);
	G_idPart="";
}
//document.captureEvents(event.KEYPRESS); 
document.onkeypress = keyPressed;


