//////////////////////////////////
//  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();
}

function displayWindowByName(url,windowName,width,height) 
{
   window.Win = window.open(url,windowName,'width=' + width + ',height=' + height + ',screenX=0,screenY=0,top=0,left=0,resizable,scrollbars,location=0,status=1');
}

//////////////////////////////////
//  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 SelectRadioButtonTest(buttonID, button, repName, objName, objID, classID) {
    
    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;
    }

    var rows = document.getElementsByTagName('tr')

    // first turn off all of the radio buttons
    for (i = 0; i < rows.length; i++) {
        if (rows[i].id != null && rows[i].id.indexOf(objName) >= 0 &&
				(rows[i].id.length == rows[i].id.indexOf(objName) + objName.length))
            rows[i].removeAttribute("class");
    }

    if (classID.length > 0 && objID.length > 0) {
        document.getElementById(objID).setAttribute("class", classID);
    }

    button.checked = true;
}

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 ShowAnswer(ID){
		var obj = 'Short' + ID;
		var obj2 = 'Full' + ID;
		if(document.getElementById(obj).style.display == "block"){
			document.getElementById(obj).style.display = "none";
			document.getElementById(obj2).style.display = "block";
		}else{
			document.getElementById(obj).style.display = "block";
			document.getElementById(obj2).style.display = "none";
		}
}

function HideOnSubmit(clientID) {
    var ctrl = document.getElementById(clientID);

    if (ctrl) {
        ctrl.style.visibility = 'hidden';
    }
}

function CatchPropagation(event) {
    if (!event) var event = window.event;
    if (event.bubbles) {
        event.cancelBubble = true;
        if (event.stopPropagation) event.stopPropagation();
    }
}

var timeoutID;
function selectOptionRdo(val) {
    clearTimeout(timeoutID);
    __doPostBack(val, '');
}
