function setCookie(name, value) {
	var expiration = new Date();
	var sevenDays = expiration.getTime() + (7 * 24 * 60 * 60 * 1000);
	expiration.setTime(sevenDays);
	var curCookie = name + "=" + escape(value) + ";expires=" + escape(expiration.toGMTString()) + ";path=/;";
	document.cookie = curCookie;
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}

function clearField (thisfield, placeholder) {
	if (thisfield.value == placeholder) { thisfield.value = ''}
}

function addMarker(lat,lng,address,info_text,pin,short,map) {
	var newIconBase = new GIcon();
	newIconBase.image = pin;

	newIconBase.iconSize = new GSize(30,50);
	newIconBase.iconAnchor = new GPoint(14,45);
	newIconBase.infoWindowAnchor = new GPoint(30,0);
	var point, marker;
	var show = true;

	if (lat!="" && lng!="") {
		point = new GLatLng(lat,lng);
		marker = new GMarker(point,{icon:newIconBase,title:short});
		if (show) {
			if (info_text != "") {
				GEvent.addListener(marker, "click", function() {
					marker.openInfoWindowHtml(info_text);
					map.setCenter(new GLatLng(lat,lng), map.getZoom());
				});
			}
			map.addOverlay(marker);
			markers[markers.length]=marker;
			marker_texts[marker_texts.length] = info_text;
		}
	} else if (address!="") {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					show = false;
					//alert(address + " nicht gefunden");
				} else {
					marker = new GMarker(point,{icon:newIconBase,title:short});
					GEvent.addListener(marker, "click", function() {
						marker.openInfoWindowHtml(info_text);
						map.setCenter(point, map.getZoom());
					});
					map.addOverlay(marker);
					marker.openInfoWindowHtml(info_text);
					map.setCenter(point, 14);
				}
			}
		);
	}
}

function addMarkerShort(lat,lng,address,info_text,pin,short,map) {
	var newIconBase = new GIcon();
	newIconBase.image = pin;

	newIconBase.iconSize = new GSize(30,50);
	newIconBase.iconAnchor = new GPoint(14,45);
	newIconBase.infoWindowAnchor = new GPoint(30,0);
	var point, marker;
	var show = true;

	if (lat!="" && lng!="") {
		point = new GLatLng(lat,lng);
		marker = new GMarker(point,{icon:newIconBase,title:short});
		if (show) {
			if (info_text != "") {
				GEvent.addListener(marker, "click", function() {
					marker.openInfoWindowHtml(info_text);
					map.setCenter(new GLatLng(lat,lng), map.getZoom());
				});
			}
			map.addOverlay(marker);
			markers[markers.length]=marker;
			marker_texts[marker_texts.length] = info_text;
		}
	} else if (address!="") {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					show = false;
					//alert(address + " nicht gefunden");
				} else {
					marker = new GMarker(point,{icon:newIconBase,title:short});
					GEvent.addListener(marker, "click", function() {
						marker.openInfoWindowHtml(info_text);
						map.setCenter(point, map.getZoom());
					});
					map.addOverlay(marker);
				}
			}
		);
	}
}

function insertQuicktimeObject(id,src,width,height,name) {
	document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+width+'" height="'+height+'" align=""');
	if (id.length > 0) document.write(' id="'+id+'"');
	if (name.length > 0) document.write(' name="'+name+'"');
	document.write('>\n');
	document.writeln('<param name="src" value="'+src+'" />');
	document.writeln('<param name="autoplay" value="true" />');
	document.writeln('<param name="controller" value="true" />');
	if ((id.length == 0) && (name.length > 0)) id = name;
	document.writeln('<embed src="'+src+'" width="'+width+'" height="'+height+'" name="'+id+'" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/de/quicktime/download/" controller="true"></embed>');
	document.writeln('</object>');
}

function insertWMVObject(id,src,width,height,name) {
	document.writeln('<object id="MediaPlayer" width="'+width+'" height="'+height+'" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject">');
	document.writeln('<param name="FileName" value="'+src+'" />');
	document.writeln('<param name="autostart" value="true" />');
	document.writeln('<param name="ShowControls" value="true" />');
	document.writeln('<embed type="application/x-mplayer2" src="'+src+'" name="MediaPlayer" width="'+width+'" height="'+height+'" ShowControls="1" autostart="1"> </embed>');
	document.writeln('</object>');
	return;
}
