function getContent() 
{
    return document.getElementById('text_').value;
}
function setContent(content) 
{
    return document.getElementById('text_').value = content;
}

function hideChilds(id, node)
{
	switch($('#childs'+id).css('display'))
	{
		case 'inline':
		{
			$('#childs'+id).css('display', 'none');
			node.innerHTML = '[+]';
			break;
		}
		case 'none':
		{
			$('#childs'+id).css('display', 'inline');
			node.innerHTML = '[--]';
			break;
		}	
	}
}	

function createEditor(id)
{
	var node;
	if(id > 0)
		node = '#addComm'+id;
	else
		node = '#newComment';
	if(BrowserType() == 'MSIE') 
	{
		$(node + ' input').each(function(i){
			switch(i)
			{
				case 0:
				{
					$(this).unbind('click');
					$(this).bind('click',function(){TagInsert_2('[b]', '[/b]', 'text_'+id);});
					break;
				}
				case 1:
				{
					$(this).unbind('click');
					$(this).bind('click',function(){TagInsert_2('[i]', '[/i]', 'text_'+id);});
					break;
				}
				case 2:
				{
					$(this).unbind('click');
					$(this).bind('click',function(){TagInsert_2('[u]', '[/u]', 'text_'+id);});
					break;
				}
				case 3:
				{
					$(this).unbind('click');
					$(this).bind('click',function(){TagInsert_2('[a]', '[/a]', 'text_'+id);});
					break;
				}
			}
		});
	}
	else
	{
		$(node + ' input').each(function(i){
			switch(i)
			{
				case 0:
				{
					$(this).unbind('click');
					$(this).bind('click',function(){return pnhEditTextarea('text_'+id, 'bold');});
					break;
				}
				case 1:
				{
					$(this).unbind('click');
					$(this).bind('click',function(){return pnhEditTextarea('text_'+id, 'cursive');});
					break;
				}
				case 2:
				{
					$(this).unbind('click');
					$(this).bind('click',function(){return pnhEditTextarea('text_'+id, 'u');});
					break;
				}
				case 3:
				{
					$(this).unbind('click');
					$(this).bind('click',function(){return pnhEditTextarea('text_'+id, 'a_href');});
					break;
				}
			}
		});
	}
}

function addCommentForm(id)
{
	$('.addCommentForm').each(function(i){
		$(this).attr('innerHTML', '');
		$(this).css('display', 'none');
	});
	if(id > 0)
	{
		$('#addComm'+id).append($('#newCommentForm').attr('innerHTML'));
		$('#addComm'+id+' textarea').each(function(i)
		{
			$(this).attr('name', 'text_'+id);
			$(this).attr('id', 'text_'+id);
			$(this).attr('width', '10%');
			createEditor(id);
		});
		$('#addComm'+id).css('display', 'inline');
		$('#addComm'+id).find('.more').each(function(i)
		{
			if(i==0)
				$(this).bind('click', function(){addComment(id)});
		});
	}
	else if(id == 0)
	{
		$('#newComment').append($('#newCommentForm').attr('innerHTML'));
		$('#newComment').find('.more').each(function(i)
		{
			if(i==0)
				$(this).bind('click', function(){addComment(null)});
		});
		$('#newComment textarea').each(function(i)
		{
			$(this).attr('name', 'text_'+id);
			$(this).attr('id', 'text_'+id);
			$(this).attr('width', '80%');
				createEditor(0);
		});
		$('#newComment').css('display', 'inline');
	}
	
	if('#corpLink')
	{
		$('#corpLink').unbind('click');
		$('#corpLink').bind('click', function()
		{
			$("#text_"+id).attr('value', $("#text_"+id).attr('value')+ AddCorp());
		});
	}
}

function waitingForm(id, mode)
{
	if(id > 0)
	{
		if(mode)
		{
			$('#waitDiv'+id).append($('#waitingForm').attr('innerHTML'));	
			$('#waitDiv'+id).css('display', 'inline');
		}
		else
		{
			$('waitDiv'+id).attr('innerHTML', '');
			$('#waitDiv'+id).css('display', 'none');
		}
	}
	else
	{
		if(mode)
		{
			$('#waitDivNew').append($('#waitingForm').attr('innerHTML'));	
			$('#waitDivNew').css('display', 'inline');
		}
		else
		{
			$('#waitDivNew').attr('innerHTML', '');
			$('#waitDivNew').css('display', 'none');
		}
	}
}

function setWaitMsg(id, text)
{
	if(id > 0)
	{
		var name = '#waitDiv'+id;
	}
	else
	{
		var name = '#waitDivNew';
	}
	$(name).find('#waitngMessage').each(function(i)
	{
		$(this).attr('innerHTML', text);
	});
}


    