/**
* @param string action
* @param string name of form, if not passed than the first form will be used!
* @param string GET variables for form submission
* @param boolean optional, validate form? defaults to true..
* @param string optional, target subform name
*
* @return boolean true if action could not be set! Adjusted to a direct call from onClick="return setFormAction(..)"
*/
function setFormAction(szAction,szForm,szVarString,bValidate,szTargetSubform)
{
	if (typeof bValidate == "undefined")
		bValidate = true;

	if (typeof szTargetSubform == "undefined")
		szTargetSubform = false;

	if (typeof szForm == "undefined")
		szForm = false;

	if (!szForm)
		szForm = 0;

	var form = document.forms[szForm];
	if (!form)
	{
		alert("Error: Could not find form ["+szForm+"]");
		return false;
	}

	var nodeAction = form.elements['szAction'];
	if (!nodeAction)
	{
		alert("Error: Could not set action value [form: "+form.name+" ("+szForm+"), action: "+szAction+"], action formelement not found!");
		return false;
	}

	if (!bValidate)
		szVarString = (szVarString && szVarString != '' ? szVarString + '&' : '') + 'bValidate=0';

	if (szTargetSubform && szTargetSubform != '')
		szVarString = (szVarString && szVarString != '' ? szVarString + '&' : '') + 'szTargetSubform='+szTargetSubform;

	if (szVarString && szVarString != '')
		form.action += '?' + szVarString;

	if (szTargetSubform && szTargetSubform != '')
		form.action += '#' + szTargetSubform;

	nodeAction.value = szAction;

	return true;
}

/**
* @param string action
* @param string name of form, if not passed than the first form will be used! Pass 0 if you do not want to set this parameter.
* @param string GET variables for form submission
*
* @return boolean true if action could not be set! Adjusted to a direct call from onClick="return submitFormAction(..)"
*/
function submitFormAction(szAction,szForm,szVarString)
{
	if (typeof szForm == "undefined")
		szForm = false;

	if (typeof szVarString == "undefined")
		szVarString = '';

	if (!szForm)
		szForm = 0;

	var form = document.forms[szForm];
	if (!form)
	{
		alert("Error: Could not find form ["+szForm+"]");
		return true;
	}

	var nodeAction = form.elements.szAction;
	if (!nodeAction)
	{
		alert("Error: Could not set action value!");
		return true;
	}

	if (szVarString != '')
		form.action += '?' + szVarString;

	nodeAction.value = szAction;

	form.submit();
	return false;
}

/**
* @param string href
* @param integer popup width
* @param integer popup height
* @param boolean popup scrollable?
* @param boolean popup resizable?
*
* @return boolean true if popup could not be opened! Adjusted to a direct call from onClick="return openPopup(..)"
*/
function openPopup(szFile,nWidth,nHeight,bScrollable,bResizable)
{
	window.open(szFile,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+(bScrollable ? 'yes' : 'no')+',resizable='+(bResizable ? 'yes' : 'no')+',width='+nWidth+',height='+nHeight+',top=100,left=100');

	return false;
}

/**
* @param object view
* @param string default value
*/
function removeDefault(oView,szDefault)
{
	if (oView.value == szDefault && szDefault != '')
		oView.value = '';
}
