function ChangeImage(OldImage, NewImagePath)
{
	OldImage.src = NewImagePath;
}

function FillData(FirstViewID, FirstValueID, SecondViewID, SecondValueID, ThirdViewID, ThirdValueID, FourthViewID, FourthValueID, SaveID)
{
	FillInlineData(FirstViewID, FirstValueID, true);
	
	if (FourthValueID != null)
		FillInlineData(FourthViewID, FourthValueID);
	else
		SaveID = FourthViewID;
	
	if (ThirdValueID != null)
		FillInlineData(ThirdViewID, ThirdValueID);
	else
		SaveID = ThirdViewID;

	if (SecondValueID != null)
		FillInlineData(SecondViewID, SecondValueID);
			
	if (SaveID == null)
		SaveID = SecondViewID;
	
	Show(document.getElementById(SaveID));
}

function Hide(Object)
{
	Object.style.display = 'none';
}

function Show(Object)
{
	Object.style.display = 'block';
}

function FillInlineData(ViewID, ValueID, Focus)
{
	var view = document.getElementById(ViewID);
	Hide(view);
	
	var input = document.getElementById(ValueID);
	Show(input);
	
	input.value = view.innerHTML.replace(/\<BR>/g, "\n").replace(/\<br>/g, "");
	input.value = StripHTML(input.value);
	Resize(input);
	
	if (Focus)
		input.focus();
}

function Resize(Input)
{
	if (_isIE)
		Input.cols = 35;
	else if (_isOpera)
		Input.cols = 25;
		
	var _lines = Input.value.split('\n');
	var _oldRows = Input.rows;
	var _newRows = _lines.length;
	
	for (var i = 0; i < _lines.length; i++)
    {
        var _line = _lines[i];
        if (_line.length >= Input.cols)
			_newRows += Math.floor(_line.length / Input.cols);
    }
    
    if (_newRows > Input.rows)
		Input.rows = _newRows;
		
    if (_newRows < Input.rows)
		Input.rows = Math.max(1, _newRows);
}

function StripHTML(Text)
{
	var _expression = /<\S[^><]*>/g
	return Text.replace(_expression, "");
}

function SetClass (Object, CssClass)
{
	if (Object.className != CssClass)
		Object.className = CssClass;
}

function GoTo(Url)
{
	document.location.href = Url;
}

function OpenWindow(Url, Width, Height)
{
	var _left = (screen.availWidth - Width)/2;
	var _top = (screen.availHeight - Height)/2;
	
	window.open(Url, '', "location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes,width=" + Width + ",height=" + Height + ",top=" + _top + ",left=" + _left);
}