function setfocus(obj)
{
	/**
	 * gesamter Inhalt des Feldes markieren.
	 */
	
	if(obj.value == "egal" || obj.value == "Ort oder Plz" || obj.value == "Location")
	{	obj.value = "";
		obj.focus();
		obj.select();
	}
	else
	{
		
	}
	
	
}


function xtd(obj)
{	
	/**
	 * alle bisherigen felder schließen
	 */
	gEBI("hpspxwhatx").style.display = "none";
	gEBI("hpspxwhenx").style.display = "none";
	if (gEBI("hpspxwhere_list"))
	{	gEBI("hpspxwhere_list").style.display = "none";
	}
	if (gEBI("hpspxloca_list"))
	{	gEBI("hpspxloca_list").style.display = "none";
	}

	/**
	 * Aktuelles Feld anzeigen
	 */
	var sourcefield = obj.name;
	
	var xtdfieldname = sourcefield + "x";
	var xtdfield = gEBI(xtdfieldname);
	if (xtdfield)
	{	xtdfield.style.display =(xtdfield.style.display == "none") ? 'block' : 'none';
		setatcpos(sourcefield,xtdfieldname); // Position setzen
	}
	
}


function xtdorder(obj)
{	closedfi();
	
	/**
	 * Aktuelles Feld anzeigen
	 */
	var sourcefield = obj.id;
	var xtdfieldname = sourcefield + "x";
	
	var xtdfield = gEBI(xtdfieldname);
	if (xtdfield)
	{	xtdfield.style.display =(xtdfield.style.display == "none") ? 'block' : 'none';
		setatcpos(sourcefield,xtdfieldname,1,7); // Position setzen
	}
	
}

function xtdstreet()
{	closedfi();
	if (gEBI("xtdstreetx"))
	{	var streetfield = gEBI("xtdstreetx")
		if (streetfield.style.display!=="block")	
		{	streetfield.style.display =  'block';
		}
	}
}

function closestreet()
{	if (gEBI("xtdstreetx"))
	{	var streetfield = gEBI("xtdstreetx")
		streetfield.style.display =  'none';
	}
}

/**
 * alle bisherigen felder schließen
 */
function closedfi()
{
	if (gEBI("hpspxwhatx"))
	{	gEBI("hpspxwhatx").style.display = "none";
	}
	
	if (gEBI("hpspxwhenx"))
	{	gEBI("hpspxwhenx").style.display = "none";
	}
	
	if (gEBI("hpspxwhere_list"))
	{	gEBI("hpspxwhere_list").style.display = "none";
	}
	if (gEBI("hpspxloca_list"))
	{	gEBI("hpspxloca_list").style.display = "none";
	}
	
	if (gEBI("spsortorderbyx"))
	{	gEBI("spsortorderbyx").style.display = "none";
	}
	if (gEBI("spsortordersortx"))
	{	gEBI("spsortordersortx").style.display = "none";
	}
	if (gEBI("sphitsx"))
	{	gEBI("sphitsx").style.display = "none";
	}
	if (gEBI("spumkreisfilterx"))
	{	gEBI("spumkreisfilterx").style.display = "none";
	}
}

/**
 * schliesst ein extended Feld 
 */
function cxtd(obj,event)
{	
	var current_mouse_target = null;
	if( event.toElement ) {				
		current_mouse_target  = event.toElement;
	} else if( event.relatedTarget ) {				
		current_mouse_target = event.relatedTarget;
	}
	if( !icof(obj, current_mouse_target) && obj != current_mouse_target ) {
		obj.style.display = 'none';
	}
	
}

function icof(parent, child)
{	if( child != null ){			
		while( child.parentNode ) {
			if( (child = child.parentNode) == parent ) {
				return true;
			}
		}
	}
	return false;
}



/**
 * Feldwert uebernehmen
 */
function taketo(value,targetfield,spval)
{	var target = gEBI(targetfield);
	if (target)
	{	
		// hiddenval speichern
		if (spval!="")
		{	var hfieldname = targetfield+"val";
			var hfield = gEBI(hfieldname);
			if (hfield)
			{	hfield.value = spval;
			}
		}
		
		if (value != "Stichwortsuche")
		{	target.value = value;
		}
		// Extended Field schließen
		xtdfield = targetfield + "x";
		gEBI(xtdfield).style.display = "none";
	}
}

/**
 * Highlight searchstring
 */
function hls(fi,wo)
{
	if (gEBI(fi))
	{	var fif = gEBI(fi)
		fif.innerHTML = ht(fif.innerHTML, wo);
	}
}

/**
 * Highlighttext 
 */
function ht(bt, st) 
{
    var STT = "<span class=\"hlsugg\">";
    var ENT = "</span>";
  
	var ret = "";
	var i = -1;
	var lcst = st.toLowerCase();
	var lcbt = bt.toLowerCase();
	
	while (bt.length > 0)
	{	i = lcbt.indexOf(lcst, i+1);
		if (i < 0)
		{	ret += bt;
	  		bt = "";
		} 
		else
		{	if (bt.lastIndexOf(">", i) >= bt.lastIndexOf("<", i))
			{	if (lcbt.lastIndexOf("/script>", i) >= lcbt.lastIndexOf("<script", i))
				{	ret += bt.substring(0, i) + STT + bt.substr(i, st.length) + ENT;
	      			bt = bt.substr(i + st.length);
	      			lcbt = bt.toLowerCase();
	      			i = -1;
	    		}
	  		}
		}
	}
  	return ret;
}


/**
 * Setfirstelement 
 */
function setfirst(listname,type) 
{	
	var first = gEBI(listname).getElementsByTagName("li")[0];
	if (first)
	{	
		// erstes Element highlighten
		first.className  = "acshighlight" 
		
		// ersten Wert in Hiddenfeld schreiben.
		if (type == 1)
		{	if (gEBI("hiddencity"))
			{	var setval = gEBI("hiddencity").value;
				gEBI("hpspxcityval").value = setval;
			}
		}
		else if (type == 2)
		{	if (gEBI("hiddenloca"))
			{	var setval = gEBI("hiddenloca").value;
				if (gEBI("hpspxlocaval"))
				{	gEBI("hpspxlocaval").value = setval;
				}
			}
		}
	}
}


function hlsug(obj,out)
{	if (out)
	{	obj.className = "";	
	}
	else
	{	obj.className = "acshighlight";	
	}
	
}

/**
 * set city into searchfield
 */
function setsugg(v,tp,tpv)
{	
	if (tp==1)
	{	// City suche
		var spf2 = gEBI('hpspxwhere');	
		if (spf2)
		{	var valf=gEBI('hpspxcityval');
			if (valf)
			{	valf.value = "city:"+tpv+"-"+v;	
			}
			spf2.value = v; /*Suchfeld setzen*/
		}
		// Location zuruecksetzen
		clearlocation();
		
		var sf = gEBI('hpspxwhere_list');
		if (sf)
		{	sf.style.display = 'none';
		}
	}
	else if (tp==2)
	{	// Location suche
		var spf2 = gEBI('hpspxloca');	
		if (spf2)
		{	var valf=gEBI('hpspxlocaval');
			if (valf)
			{	valf.value = "loca:"+tpv+"-"+v;	
			}
			spf2.value = v; /*Suchfeld setzen*/
		}
		// City zuruecksetzen
		clearcity();
		
		var sf = gEBI('hpspxloca_list');
		if (sf)
		{	sf.style.display = 'none';
		}
	}
}

function clearcity()
{	if (gEBI('hpspxwhere'))
	{	gEBI('hpspxwhere').value ="Ort oder Plz";
		gEBI('spxcitywrapper').className = "notactivefield";
		gEBI('spxlocationwrapper').className = "reactivefield";
	}
	
	if (gEBI('hpspxcityval'))
	{	gEBI('hpspxcityval').value = "";
		
	}
}

function clearlocation()
{	if (gEBI('hpspxloca'))
	{	gEBI('hpspxloca').value ="Location";
		gEBI('spxlocationwrapper').className = "notactivefield";
		gEBI('spxcitywrapper').className = "reactivefield";
	}
	if (gEBI('hpspxlocaval'))
	{	gEBI('hpspxlocaval').value = "";
	}
}


/**
 * clear hidden fields
 */
function clrhid(obj)
{	if (obj)
	{	var hfieldname = obj.name+"val";
		var hfield = gEBI(hfieldname);
		if (hfield)
		{	hfield.value = "";
		}
	}
}