function wer_ist_online() {

	if (document.getElementById('id_wer_ist_online')) {
		AjaxGet ('wer_ist_online_ajax','/ajax.php','&aktion=wer_ist_online','wer_ist_online_callback');
	}
	return false;
}

function wer_ist_online_callback(XML) {

	//alert(XML);

	if (document.getElementById('id_wer_ist_online')) {

		wer_ist_online_div = document.getElementById('id_wer_ist_online');
		wer_ist_online_div.innerHTML = '';

		string_online = "";
		strichpunkt = "";

		for (i=0;i<XML.getElementsByTagName('person').length;i++) {
			string_online += strichpunkt+'<a href="'+domain+'/b2b/mitglieder-netzwerk/'+XML.getElementsByTagName('person')[i].getAttribute('id')+'">'+XML.getElementsByTagName('person')[i].firstChild.nodeValue+'</a> ';
			if (!strichpunkt) strichpunkt = ";";
		}

		wer_ist_online_div.innerHTML = string_online;

		window.setTimeout("wer_ist_online()", 1000);
	}

	return false;
}

function suche_starten(eingabefeld) {

	feld = 'id_'+eingabefeld;
	q_feld = 'id_q_'+eingabefeld;

	suchstring = document.getElementById(feld).value;

	//alert(eingabefeld);

	new_suchstring = "";

	for (i=0;i<suchstring.length;i++) {
		zeichen = suchstring.substr(i,1);
		if (zeichen != "+") {
			if (zeichen != "'") {
				new_suchstring = new_suchstring+zeichen;
			}
		} else {
			new_suchstring = new_suchstring+"%2B";
		}
	}
	document.getElementById(q_feld).value = Url.encode(new_suchstring);

	//alert(document.getElementById(q_feld).value);

}

function set_font_size(wert) {
	alert(wert);
	document.body.style.fontSize = '100%';
}

function set_aktion(aktion,referer,id,param,get_params) {
	if (param) {
		flag = confirm(param);
	} else {
		flag = true;
	}
	if (!get_params) {
		get_params = "";
	}
	if (flag) {
		link = domain+"/?aktion="+aktion+"&referer="+referer+"&id="+id+get_params;
		window.location.href=link;
	} else {
		return false;
	}
}

function select_language() {

	link = domain+"/?set_language="+document.getElementById('id_language').value;

	window.location.href=link;

}

function dateimanager() {
	alert("open");
}

function chk(wert) {
	if (!confirm(wert)) {
		return false;
	}
}

function funk(sub,bereich,code) {

	alert(sub+" "+bereich+" "+code);

}

function vorschau(link) {

	window.open(link);

}

function form_add_field(name,maxlength) {

	id = 'id_span_'+name;

	if (document.getElementsByName(name+"[]").length < 20) {

		document.getElementById(id).innerHTML = document.getElementById(id).innerHTML+'<input name="'+name+'[]" type="text" maxlength="'+maxlength+'" /><br />';
		document.getElementById(id).focus();

	} else {
		alert(form_add_field_maximale_anzahl_erreicht);
	}

}

function help(id) {

	//alert("Hilfe für den Bereicht:\n\n"+id+"\n\nanzeigen!");

}

function AddMSNContact(name) {
	//if (!is_ie) {
		//alert(error_msg);
		//return false;
	//} else {
		//MsgrObj.AddContact(0, name);
		//return false;
	//}
	alert("Diese Funktion wird zur Zeit von MSN nicht unterstuetzt!");
}

function google_map(bereich,id) {
	map_width = 800;
	map_height = 600;
	win_google_map = window.open('/google_map/?map_width='+map_width+'&map_height='+map_height+'&bereich='+bereich+'&id='+id,'id_win_google_map','width='+map_width+',height='+map_height);
}

function google_map_chk(strasse,plz,ort,land) {
	map_width = 800;
	map_height = 600;
	win_google_map = window.open('/google_map/?map_width='+map_width+'&map_height='+map_height+'&bereich=chk&strasse='+strasse+'&plz='+plz+'&ort='+ort+'&land='+land,'id_win_google_map','width='+map_width+',height='+map_height);
}

function block_open_close(id,start) {
	if (document.getElementById('id_'+id).style.visibility == "hidden") {
		document.getElementById('id_pfeil_'+id).src = '/images/icons/block_offen.gif';
		document.getElementById('id_'+id).style.height = 'auto';
		document.getElementById('id_'+id).style.visibility = 'visible';
		document.getElementById('id_'+id).style.padding = '6px';
		if (start != 1) {
			//location.href="#id_anker_"+id;
		}
	} else {
		document.getElementById('id_pfeil_'+id).src = '/images/icons/block_geschlossen.gif';
		//hoehe = document.getElementById('id_'+id).style.height;
		//alert(hoehe);
		//alert(document.getElementById('id_'+id).style.height.value);
		//for (i=document.getElementById('id_'+id).style.height;i>0;i--) {
		//	document.getElementById('id_'+id).style.height = i+'px';
		//	alert(i);
		//}
		document.getElementById('id_'+id).style.height = '0px';
		document.getElementById('id_'+id).style.padding = '0px';
		document.getElementById('id_'+id).style.visibility = 'hidden';
		//location.href="#top";
	}
}

function artikel_drucken(bereich,id) {
	print();
}

function artikel_empfehlen(link,goto_link) {
	window.location.href=link+"/?link="+goto_link;
}

function email_senden(string) {
	location.href=string;
}

function get_geocode(felder) {

	geocoder = new GClientGeocoder();

	var string = "";
	var array_felder = felder.split("#");

	for (i=0;i<array_felder.length;i++) {

		string += " "+document.getElementById(array_felder[i]).value;

		//alert(array_felder[i]);

	}

	//alert(string);

	geocoder.getLatLng(string,getPoint);

	return false;

}

function getPoint (point) {
	if (point) {
		document.getElementById('id_Lng').value = point.lng();
		document.getElementById('id_Lat').value = point.lat();
		var send = true;
	} else {
		document.getElementById('id_Lng').value = "0.0";
		document.getElementById('id_Lat').value = "0.0";
		var send = true;
	}

	call_submit();
}

function form_textarea_maxlength (akt_feld,laenge) {

	//alert("hallo");

	akt_laenge = akt_feld+"_akt_laenge";

	a = laenge - document.getElementById(akt_feld).value.length;

	document.getElementById(akt_laenge).innerHTML = a;

	if (document.getElementById(akt_feld).value.length > laenge) {

		i = document.getElementById(akt_feld).value.substring(0,parseInt(laenge));

		document.getElementById(akt_feld).value = i;
		document.getElementById(akt_laenge).value = 0;

	}
}

var Url = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

