searchText = '';
function checkSearchForm(text)
{
	if (text == 'Produkte, Artikel, Leser suchen' || text == 'Spiele und Artikel suchen')
	{ 
		searchText = text;
		suchen = document.getElementsByName('strSearch');
		for (var i = 0; i < suchen.length;i++)
		{	suchen[i].value = '';				}
	}
	
}

function SearchLeft()
{
	var check = true;
	var suchen = document.getElementsByName('strSearch');
	
	for (var i = 0; i < suchen.length;i++)
	{	
		if (suchen[i].value != '')
		{	check = false;	}
	}
	if (check)
	{	
		for (var i = 0; i < suchen.length;i++)
		{	suchen[i].value = searchText;				}
	}
}

function setSearchBuffed()
{
	var text = jQuery.trim(jQuery('#searchVal').val());
	var text2 = htmlEditFormat(text);
   	var regEx = /=[^=]*$/;
	var regEx2 = /=/;
	var org_action = jQuery('#searchForm').attr('action');
	
	if(text.toLowerCase() == 'produkte, artikel, leser suchen'
		|| jQuery.trim(text2).length <= 0)
	{
		jQuery('#searchVal').val('').focus(); return(false);
	}
	if (jQuery('#searchForm').attr('action').search(regEx2) <= 0)
	{
		jQuery('#searchForm').attr('action', htmlEditFormat(search_form.action)+'?strSearch='+text2).submit();
		return(false);
	}
	if (text2.search(regEx) > 0)
	{
		var endP = text2.length;
		var startP = text2.search(regEx) + 1;
		text2 = text2.substr(startP, endP);
	}
	window.open(jQuery('#searchForm').attr('action') + text2, '_blank');
	jQuery('#searchVal').val('').focus();

	return(false);
}

function setQL(text)
{
	text2 = htmlEditFormat(text);
	var search_form = document.getElementById('searchForm');
   	var regEx = /=[^=]*$/;
	var regEx2 = /=/;
	if (text2.search(regEx) > 0)
	{
		var endP = text2.length;
		var startP = text2.search(regEx) + 1;
		text3 = text2.substr(startP, endP);
	}
	if (search_form.action.search(regEx2) > 0)
	{
		var newEnd = search_form.action.search(regEx2);
		search_form.action = Left(search_form.action, newEnd);
		search_form.action = htmlEditFormat(search_form.action)+"="+text2;
	}
	else
	{
		search_form.action = htmlEditFormat(search_form.action)+'?strSearch='+text2;
	}
   	$('#searchVal').val(text2);
   	search_form.submit();
}

function htmlEditFormat(h)
{	return h.split("&").join("& amp;").split( "<").join("& lt;").split(">").join("& gt;");	}

function adjustFacebook()
{
	ColdFusion.Window.create('fbEdit','facebook Einstellungen','/webservices/facebook/overview.cfm',
							 {
								 center:true,
								 closable:true,
								 draggable:true,
								 modal:true,
								 initshow:true,
								 resizable:false,
								 width:550,
								 height:500,
								 callbackHandler:endFacebookAdjust
							 });

	// needed in cynamite vB: closes js popup after close of cf window
	if(typeof closevBPopup != 'undefined') {	
		ColdFusion.Window.onHide('fbEdit', closevBPopup);
	}
}

function endFacebookAdjust()
{	ColdFusion.Window.onHide('fbEdit', hideanddestroyPopup);	}

function hideanddestroyPopup()
{	ColdFusion.Window.resetHTML('fbEdit');	}

function moveLogin()
{
	if (jQuery('#login_list').hasClass('login_form_adminbar'))
	{	jQuery('#login_list').css('display', 'none').removeClass('login_form_adminbar');	}
	else
	{	jQuery('#login_list').css('display', 'block').addClass('login_form_adminbar');	}
}

function toggleLogin(id)
{
	if (jQuery('#login_list').hasClass('login_form_adminbar'))
	{	jQuery('#login_list').css('display', 'none')
						.removeClass('login_form_adminbar');	}
	
	if (jQuery('#'+id).css('display')=='block')
	{	jQuery('#'+id).css('display', 'none');						}
	else
	{	jQuery('#'+id).css('display', 'block');						}
	
	if (jQuery('#Login').length > 0 && jQuery('#Login').is(':visible'))
	{	document.getElementById('Login').focus();				}
}

