// window.load support
var onloadEventHandlers = new Array();
function ProcessWindowLoad()
{
	for (var i = 0; i < onloadEventHandlers.length; i++)
	{
		onloadEventHandlers[i]();
	}
}

// Form reset support
var formResetEventHandlers = new Array();
function OnFormReset()
{
	for (var i = 0; i < formResetEventHandlers.length; i++)
	{
		formResetEventHandlers[i]();
	}
	if (typeof(controlChainParentIDs) != 'undefined') 
	{
		for (var i = 0; i < controlChainParentIDs.length; i++)
		{
			var controlChainParent = document.getElementById(controlChainParentIDs[i]);
			if (controlChainParent != null && controlChainParent.onchange != null)
			{
				controlChainParent.value = -1;
				controlChainParent.onchange();
			}
		}
	}
	if (typeof(multiSelectControlIDs) != 'undefined')
	{
		for (var j = 0; j < multiSelectControlIDs.length; j++)
		{
			ResetSelectedValues(multiSelectControlIDs[j]);
		}
	}
}

// Form disabling
function DisableForm()
{
	var inputs = document.getElementsByTagName('input');
	for(var i = 0; i < inputs.length; i++)
	{
		if(inputs[i].type == 'button' || inputs[i].type == 'submit')
		{
			inputs[i].removeAttribute('onclick', 0);
			inputs[i].disabled = true;
		}
	}
	var anchors = document.getElementsByTagName('a');
	for(var i = 0; i < anchors.length; i++)
	{
		if(anchors[i].href != null /*&& anchors[i].href.indexOf('javascript:') > 0*/)
		{
//			anchors[i].removeAttribute('href', 0);
            anchors[i].disabled = true;
		}
	}	

    document.body.disabled = true;
}

// First input focusing
function AdjustFormFocus()
{
	var inputs = document.getElementsByTagName('input');
	for(var i = 0; i < inputs.length; i++)
	{
		if(inputs[i].type == 'text')
		{
			inputs[i].focus();
			break;
		}
	}
}

//input handlers
function InputValidateLatin(id)
{
	var input = document.getElementById(id);
	if(input)
	{
		var v = input.value.replace(/[^a-zA-Z0-9\s\!@\#\$%\^&\*\(\)\-=\\\|\[\]\.></\+_`~\{\}'"\?;,:]*/g, "");
		if(v != input.value) {input.value = v;}
	}
}

//image viewer
function OpenPopUp(formURL, width, height) 
{
	width = Math.min(screen.availWidth, Math.max(width + 50, 100));
	height = Math.min(screen.availHeight, Math.max(height + 70, 100));

	pictureWindow = window.open(formURL, 'picturePopupWin', 
		'resizable=yes,scrollbars=yes,width=' + width + ',height=' + height);
	pictureWindow.resizeTo(width, height);
}

//Currency switcher
	function OnCurrencyRowEnter(rowid)
	{
		var row = document.getElementById(rowid);
		row.style.cursor = 'pointer';
		row.setAttribute('_bgcolor', row.style.backgroundColor, 0);
		row.style.backgroundColor = '#FFFFFF';
	}
	function OnCurrencyRowLeave(rowid)
	{
		var row = document.getElementById(rowid);
		row.style.cursor = 'default';
		row.style.backgroundColor = row.getAttribute('_bgcolor');
	}
