//////////////////////////////////
//  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 Hilite(name,over)
{
	if(window.document.images) 
	{
		if (over)
		window.document.images[name].src = "/OLEA/images/" + name + "_ov.gif";
		else
		window.document.images[name].src = "/OLEA/images/" + name + ".gif";
	}
}


function disappear(obj,name) {

  if (obj.style.display == "none") {

    obj.style.display = "";

    window.document.images[name].src = "/OLEA/images/collapse3.gif";

  }

  else {

    obj.style.display = "none";

    window.document.images[name].src = "/OLEA/images/expand.gif";

  }

}

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();
}

function is_child_of(parent, child) {
			if( child != null ) {			
				while( child.parentNode ) {
					if( (child = child.parentNode) == parent ) {
						return true;
					}
				}
			}
			return false;
		}

function fixOnMouseOut(element, event, JavaScript_code) { 
    //alert("fix"); 
    var current_mouse_target = null; 
    if( event.toElement ) { 
    current_mouse_target = event.toElement; 
    } else if( event.relatedTarget ) { 
    current_mouse_target = event.relatedTarget;
    } 
    if( !is_child_of( element, current_mouse_target) && element != current_mouse_target ) { 
    eval(JavaScript_code); 
    } 
}
