//////////////////////////////////
//  New Window
//////////////////////////////////
function displayWindow(url,width,height) {
   //if(window.Win){
   //   window.Win.close();
   //}
   
	window.Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',screenX=0,screenY=0,top=0,left=0,resizable,scrollbars,location=0,status=1');
	//this.focus();
}

	
function displayWindowDetail(url,width,height) {
   //if(window.Win){
   //   window.Win.close();
   //}
   window.Win = window.open(url,"displayWindowDetail",'width=' + width + ',height=' + height + ',left=300,top=300,location=0,status=0');
   window.Win.focus();
}

//////////////////////////////////
//  Close New Window
//////////////////////////////////
function closeWin(){
   if(window.Win){
      window.Win.close();
   }
}

function findentry(pattern, list){
	
   // look for the pattern at the beginning of the word
   pattern = new RegExp("^" + pattern, "i");

    //spin through the list and look for a match
    // when you find one exit the loop
    for (n=0;n<list.length;n++){
       if(pattern.test(list[n].text)){
          list.selectedIndex=n;
          n=list.length;

       }
    }
}

function GetElement(id)
{
	var objects = document.all;
	
	for(i=0; i<objects.length; i++)
	{
		if(objects[i].id != null && objects[i].id.indexOf(id) >= 0 &&
				objects[i].id.length == objects[i].id.indexOf(id) + id.length)
			return objects[i];
	}

	return null;
}

function SelectRadioButton(buttonID, button)
{
	var objects = document.getElementsByTagName('input')
	
	// first turn off all of the radio buttons
	for(i=0; i<objects.length; i++)
	{
		if(objects[i].id != null && objects[i].id.indexOf(buttonID) >= 0 &&
				objects[i].id.length == objects[i].id.indexOf(buttonID) + buttonID.length)
			objects[i].checked = false;
	}
	
	button.checked = true;
}

function submitOnKeydown(buttonid, e)
{
	var btn = document.getElementById(buttonid);

	if (typeof btn == 'object')
	{
		if (e.keyCode == 13)
		{
			btn.focus();
			return false;
		}
	}
} 

function focusElement(id)
{
	var obj = document.getElementById(id);
	
	if (obj)
		obj.focus();
}
