var ajaxObjects = new Array();
function insertOptionBefore(myText,MyValue,lstObj)
{
  var elSel = document.getElementById(lstObj);

  if (elSel.selectedIndex >= 0) {
    var elOptNew = document.createElement('option');
    elOptNew.text = myText;
    elOptNew.value = MyValue;

    var elOptOld = elSel.options[elSel.selectedIndex];
    try {
      elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
    }
    catch(ex) {
      elSel.add(elOptNew, elSel.selectedIndex); // IE only
    }
  }
}
function removeOptionSelected(lstObj)
{
  var elSel = document.getElementById(lstObj);
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
    if (elSel.options[i].selected) {
      elSel.remove(i);
    }
  }
}

function appendOptionLast(myText,MyValue,lstObj)
{
  var elOptNew = document.createElement('option');
  elOptNew.text = myText;
  elOptNew.value = MyValue;
  //elOptNew.setAttribute("onchange",MyAlert());
  var elSel = document.getElementById(lstObj);

  try {
    elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
}

function changeSelectedIndex (newIndex,lstObj){
	var elSel = document.getElementById(lstObj);
	elSel.options[newIndex].selected = true;
}

function removeOptionLast(lstObj)
{
  var elSel = document.getElementById(lstObj);
  if (elSel.length > 0)
  {
    elSel.remove(elSel.length - 1);
  }
}

function removeAllOption(lstObj)
{
  var elSel = document.getElementById(lstObj);
  while (elSel.length > 0)
  {
    elSel.remove(elSel.length - 1);
  }
}

function deleteAllChilds(contain)
{
	tbody = document.getElementById(contain);
		while(tbody.hasChildNodes())
			tbody.removeChild(tbody.firstChild);
}
function showAjaxContent(ajaxIndex,windowId)
{
	document.getElementById(windowId).innerHTML = ajaxObjects[ajaxIndex].response;			
}
function addContentFromUrl(url,windowId)
{
	
	var ajaxIndex = ajaxObjects.length;
	ajaxObjects[ajaxIndex] = new sack();
	ajaxObjects[ajaxIndex].requestFile = url;	// Specifying which file to get
	ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxContent(ajaxIndex,windowId); };	// Specify function that will be executed after file has been found
	ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function	

}
