function trim(str)
{
	return str.replace (/^\s+/, '').replace (/\s+$/, '');
}

function zcsearch()
{
	var search;
	search = $("#qfv").val();

	if (search.length >= 3)
	{
		$.ajax( 
		{ 
			type: "POST", 
			url: "http://www.public-arts.com/modules/projektverlaufe/zielcodesuche.php", 
			data: "search=" + search, 
			success: function(message) 
			{
				if (trim(message).length == 0) return;
				
				$("#suggest").empty(); 
				if (message.length > 0) 
				{
					$("#suggest").append(message); 
				}
			} 
		});
	}
	else
	{
		$("#suggest").empty();
	}
}

function selectsuggestion(id)
{
	$("#destcode").val(id);
	$("#suggest").empty();
}

function agsearch(idx)
{
	var search;
	search = $("#agsv" + idx).val();
	
	if (search.length >= 3)
	{
		$.ajax(
		{
			type: "POST",
			url: "http://www.public-arts.com/modules/angebote/textsuche.php",
			data: "search=" + search + "&idx=" + idx,
			success: function(message)
			{
				if (trim(message).length == 0) return;
		
				$("#agsuggest" + idx).empty();
				if (message.length > 0)
				{
					$("#agsuggest" + idx).append(message);	
				}
			}
		});
	}
	else
	{
		$("#agsuggest" + idx).empty();	
	}
}

function insertagtext(idx, text)
{
	$("#positionstext" + idx).val(text);
}

function inserttag(tag_before, tag_after){
  strSelection = document.selection.createRange().text;
  if (strSelection != "")
  document.selection.createRange().text = "[" + tag_before + "]" + strSelection + "[" + tag_after + "]";
}

function win_popup(theURL, winName, features) { //heißt beim Andreas MM_openBrWindow!
  window.open(theURL, winName, features);
}
