/*
$Source: /file_server/cvsroot/sonor/Sonor_AS_FE/docs/sonor/deutsch/functions.js,v $
$Date: 2004/04/16 13:17:50 $
$Revision: 1.7 $
*/


/*****************************************************************
Confirm-Dlg does only popup when the condition is true.																													  14.08.2003 14:08
*****************************************************************/
function pruefen_condition (n_FormId, sz_Command, sz_Question, b_Condition)
{
	if (b_Condition)
	{
		if (confirm (sz_Question))
		{
			submit_command (n_FormId, sz_Command);
		}
	}
	else
	{
		submit_command (n_FormId, sz_Command);
	}

	return ;
}  // pruefen

function pruefen (n_FormId, sz_Command, sz_Question)
{
	if (confirm (sz_Question))
	{
		submit_command (n_FormId, sz_Command);
	}

	return ;
}  // pruefen

function submit_command (n_FormId, sz_Command)
{
		document.forms[n_FormId].elements[sz_Command].value='x';
		document.forms[n_FormId].submit();
	return ;
}  // submit_command

function setValue(n_FormId, sz_Attribute, val)
{
	document.forms[n_FormId].elements[sz_Attribute].value=val;
}  // setValue

function addValue(n_FormId, sz_Attribute, val)
{
	var ivalue = document.forms[n_FormId].elements[sz_Attribute].value;

	if (ivalue.length == 0)
	{
		setValue(n_FormId, sz_Attribute, val);
	}
	else
	{
		ivalue = ivalue + "," +val;
		setValue(n_FormId, sz_Attribute, ivalue);
	}
}  // addValue

function v_ChangePageAndSubmitSubMenu (sz_ObjectName, sz_NextPage, n_NextLevel)
	/*****************************************************************
		Changes the page and saves the current input
		It is important that the include 'navigation_fields.html' is
		placed within the second form on the page (form[1]), so the
		hidden fields were set correctly.
														23.05.2003 10:14
	 *****************************************************************/
{


	this.document.forms[1].elements['hidden-'+ sz_ObjectName + '-nextPage'].value=sz_NextPage;
	this.document.forms[1].elements['hidden-'+ sz_ObjectName + '-level1'].value=n_NextLevel;
	this.document.forms[1].elements['command-'+ sz_ObjectName + '-set_level'].value='x';
	this.document.forms[1].submit();

}  // v_ChangePageAndSubmitSubMenu

function v_ChangePageAndSubmitTopMenu (sz_NextPage, n_NextLevel)
	/*****************************************************************
		Changes the page and saves the current input
		It is important that the include 'navigation_fields.html' is
		placed within the second form on the page (form[1]), so the
		hidden fields were set correctly.
												     TH	23.05.2003 10:14
	 *****************************************************************/
{

	this.document.forms[1].elements['hidden-sys_topnavigation-nextPage'].value=sz_NextPage;
	this.document.forms[1].elements['hidden-sys_topnavigation-level1'].value=n_NextLevel;
	this.document.forms[1].elements['command-sys_topnavigation-set_level'].value='x';
	this.document.forms[1].submit();

}  // v_ChangePageAndSubmit

function setRadioValue (n_FormId, sz_Attribute, val, n_AnzRb)
	/*****************************************************************
  		Changes the value of a radio button. It is important that
  		the number of radiobuttons is given by the programmer, so
  		the JS can do the rest.

												     TH	28.05.2003
	*****************************************************************/
{
	for (i=0; i < n_AnzRb; i++)
	{
		if (document.forms[n_FormId].elements[sz_Attribute][i].value == val)
		{
			document.forms[n_FormId].elements[sz_Attribute][i].checked = true;
		}
	}

}  // setRadioValue


function PBURLPopupShow(formName, popupName, target) {
	var form  = (!IsIE()&&CSBVers>=5)?document.forms[formName]:CSFindElement(formName);
	var popup = form.elements[popupName];
	window.open(PBEURL (popup.options[popup.selectedIndex].value), target);
	popup.selectedIndex = 0;
}


