// iTERRA 3.0 template JavaScript include: generic list (c) 2007 by evanto media AG

prevStyle="";
prevRow=null;	
	
function toggleFilter (listname) 
{
  if (document.getElementById)
  {
	filterRow = document.getElementById(listname + "_filter");
	if (filterRow)
	{  
      if (filterRow.style.display == "none")
	  {
		filterRow.style.display = ""; 
		document.getElementById("__" + listname + "_filterstatus").value = 'on';
	  }
	  else 
	  {
	    filterRow.style.display = "none";
		document.getElementById("__" + listname + "_filterstatus").value = 'off';
	  }	
	}
	else
	  alert ("Filter Row not found!");
  }
}

function selectRow (rowId, listname) 
{
  if (document.getElementById)
	document.getElementById(listname + "_buttons").style.display = "";

  if (rowId) 
  {
	if (prevRow)
	{
	  document.getElementById(prevRow).className = prevStyle;  
	  document.getElementById(listname + "_img_" + prevRow).src = "/images/iterra/list/it-bt-select.gif";  
	}
	
	row = document.getElementById(rowId);
	if (row)
	{
	  prevStyle     = row.className;
	  prevRow       = rowId;
	  row.className = "ListRowSelect";
    }	  
	
	rowimg = document.getElementById(listname + "_img_" + rowId);
	if (rowimg)
	{
	  rowimg.src = "/images/iterra/list/it-bt-select-active.gif";
    }	  

	hfRowId = document.getElementById("__rowid_" + listname);
	if (hfRowId)
	{
	  hfRowId.value=rowId;
	}
	else alert("rowid could not be set!")
  }
}

function doConfirm (listname, messagetext) 
{
  if (document.getElementById)
  {
	dialog = document.getElementById(listname + "_confirm");
	if (dialog)
	{  
		dialogtext = document.getElementById(listname + "_confirm_text");
		if (dialogtext)
		{	// set action text
			dialogtext.innerHTML = messagetext;
		}
		
		defWidth = 250;
		defHeight = 150;
		offsetx = 200;
		offsety = 250;
			
		// IE
		if (document.documentElement.clientWidth && window.navigate)
		{
			dialog.style.left = (window.event.clientX + document.documentElement.scrollLeft - defWidth) + "px";
			dialog.style.top  = (window.event.clientY + document.documentElement.scrollTop - offsety) + "px";
			// dialog.style.left = ((document.documentElement.clientWidth - defWidth) / 2) - offsetx;
			// dialog.style.top  = ((document.documentElement.clientHeight - defHeight) / 2) - offsety;
		}

		// Mozilla, Opera
		if (window.netscape)
		{
			if (window.pagexoffset) alert ("event");
			dialog.style.left = "100px";
			dialog.style.top  = (window.innerHeight - 400) + "px";
		}
		
		dialog.style.display = ""; 
	}
	else
	  alert ("Dialog not found!");
  }
  return false;
}

function doAbort (listname) 
{
  if (document.getElementById)
  {
	dialog = document.getElementById(listname + "_confirm");
	if (dialog)
	{  
		dialog.style.display = "none"; 
	}
	else
	  alert ("Dialog not found!");
  }
  return false;
}

