// routenplaner
function user_routenplaner(zipcode, city, street, number, district)
{
	get('id_zipcode').value = zipcode;
	get('id_city').value = city;
	get('id_street').value = street;
	get('id_number').value = number;
	get('id_district').value = district;
}

// ortslage
function user_ortslage(zipcode, city)
{
	get('id_zipcode_weather').value = zipcode;
	get('id_city_weather').value = city;
	get('id_zipcode_map').value = zipcode;
	get('id_city_map').value = city;
}


// kontaktformular
function contact_textmsg_in(_standard)
{
	if(get('txt_message').value == _standard)
	{
		get('txt_message').value = "";
	}

}
function contact_textmsg_out(_standard)
{
	if(get('txt_message').value == "")
	{
		get('txt_message').value = _standard;
	}
}

// background color changer
function bcc(_this, _color)
{
	_this.style.backgroundColor = _color;
}

// reset search fields, setzt die suchfelder auf ihren anfangswert zurück
function rsf()
{
	var i = (KEYSTANDARD.length)

	for(;i>=0;i--)
	{
		// i > 0 (search_i)
		if(i > 0)
		{
			if(get("search_"+(i-1)) && !is_list(get("search_"+(i-1))))
			{
				get("search_"+(i-1)).value = KEYSTANDARD[i];
				KEYDEFAULT_SET[i-1] = 1;
				$("#search_"+(i-1)).attr('class', "fg_search_field_default");
			}
			setcookie("search_"+(i-1)+"-"+SHOWID, "", -1);
		}
		// i = 1 (searchkey)
		else
		{
			if(get("searchkey") && !is_list(get("searchkey")))
			{
				get("searchkey").value = KEYSTANDARD[1];
				KEYDEFAULT_SET[0] = 1;
				$('#searchkey').attr('class', "fg_search_field_default");
			}

			if(GLOBALSEARCHKEY == 1)
			{
				setcookie("globalsearchkey", "", -1);
			}
			else
			{
				setcookie("searchkey-"+SHOWID, "", -1);
			}
		}
	}

}

function save_key(_this)
{
	if(GLOBALSEARCHKEY == 1 && _this.id == "searchkey")
	{
		setcookie("globalsearchkey", cookie_encode(get_select_text(_this.id)), 3600000);
	}
	else
	{
		setcookie(_this.id+"-"+SHOWID, cookie_encode(get_select_text(_this.id)), 3600000);
	}
}


function save_numeric_key(_this, _event)
{
	onlynumeric(_this, _event);

	if(GLOBALSEARCHKEY == 1 && _this.id == "searchkey")
	{
		setcookie("globalsearchkey", cookie_encode(get_select_text(_this.id)), 3600000);
	}
	else
	{
		setcookie(_this.id+"-"+SHOWID, cookie_encode(get_select_text(_this.id)), 3600000);
	}
}

function cookie_encode(_str)
{
	//_str = replace_all("&", "%24", _str);
	_str = replace_all("&", "&amp;", _str);
	_str = replace_all("\"", "&quot;", _str);
	_str = replace_all("'", "&#039;", _str);
	_str = replace_all("+", "&#43;", _str);

	_str = replace_all("\u00A0", "", _str);
	_str = replace_all("u00A0", "", _str);

	_str = replace_all("!", "%21", _str);
	_str = replace_all("/", "%2f", _str);
	_str = replace_all("?", "%3f", _str);
	_str = replace_all("ä", "%e4", _str);
	_str = replace_all("ö", "%f6", _str);
	_str = replace_all("ü", "%fc", _str);
	_str = replace_all("ß", "%df", _str);
	_str = replace_all(" ", "%20", _str);
	_str = replace_all("#", "%23", _str);

	_str = replace_all("\\", "", _str);
	_str = replace_all(";", "-SEMI-", _str);

	return trim(_str);
}

function trim(s) {
	while (s.substring(0,1) == ' ') {
		s = s.substring(1,s.length);
	}
	while (s.substring(s.length-1,s.length) == ' ') {
		s = s.substring(0,s.length-1);
	}
	return s;
}

//setcookie (name, value, lifetime)
