/*
$Source: /file_server/cvsroot/sonor/Sonor_AS_FE/docs/sonor/functions.js,v $
$Date: 2005/02/09 15:27:27 $
$Revision: 1.6 $
*/


/*****************************************************************
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;
}

/*****************************************************************
	Opens a window with the given URL, size and position
					 						  07.11.2003 08:47
*****************************************************************/
function fensterauf_position (path, WindowName, sizeX, sizeY, posX, posY)
{
		url = path;
        jobfenster = open(url, WindowName, "toolbar=0,location=0,scrollbars=1,resizable=1,status=0,menubar=0,left=" + posX + ",top=" + posY + ",left=" + posX  + ",width=" + sizeX + ",height=" + sizeY );
        jobfenster.focus();
} // fensterauf

function fensterauf(path, sizeX, sizeY)
{
        posX = (screen.width - sizeX) / 2;
        posY = (screen.height - sizeY) / 2;
		url = path;

        jobfenster = open(url, "", "toolbar=0,location=0,scrollbars=1,resizable=1,status=0,menubar=1,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",width=" + sizeX + ",height=" + sizeY );
        jobfenster.focus();
} // fensterauf

/*****************************************************************
	`description`
												  09.02.2005 11:04
*****************************************************************/
function flashani(path, sizeX, sizeY)
{
        posX = (screen.width - sizeX) / 2;
        posY = (screen.height - sizeY) / 2;
		url = path;

        jobfenster = open(url, "", "toolbar=0,location=0,scrollbars=0,resizable=1,status=0,menubar=0,screenX=" + posX + ",screenY=" + posY + ",left=" + posX + ",width=" + sizeX + ",height=" + sizeY );
        jobfenster.focus();
} // fensterauf

function flashaniResize(sizeX, sizeY)
{
	n_ResizeToX = sizeX + 15;
	n_ResizeToY = sizeY + 35;

//	alert ("document.body.offsetWidth=" + document.body.offsetWidth
//			+ " document.body.offsetHeight=" + document.body.offsetHeight);

	top.window.resizeTo (n_ResizeToX, n_ResizeToY);
	top.window.moveTo (0, 0);
} // fensterauf

