var helpWindow;
function openHelpWindow (url) {
	if (!helpWindow || helpWindow.closed) {
		helpWindow = window.open(url,'helpWindow','width=810,height=600,left=200,top=80,scrollbars=yes');
	} else {
		helpWindow.focus();
		helpWindow.location.href=url;
	}
	return false;
}

var wikiWindow;
function openWikiWindow () {
	var url = '/index.php?modus=1&page_id=16702';		// using a constant modus=1
	if (openWikiWindow.arguments.length > 0 ) url = url + '&id=' + openWikiWindow.arguments[0];
	if (openWikiWindow.arguments.length > 1 ) url = url + '#' + openWikiWindow.arguments[1];
	if (!wikiWindow || wikiWindow.closed) {
		wikiWindow = window.open(url,'wikiWindow','width=980,height=690,left=10,top=10,scrollbars=yes,resizable=yes');
	} else {
		wikiWindow.focus();
		wikiWindow.location.href=url;
	}
	return false;
}

var imgWindow;
function openImgWindow (url,param) {
	if (!imgWindow || imgWindow.closed) {
		imgWindow = window.open(url,'imgWindow',param);
	} else {
		imgWindow.focus();
		imgWindow.location.href=url;
	}
	return false;
}

var contactWindow;
function openContactWindow (url,param) {
	if (!contactWindow || contactWindow.closed) {
		contactWindow = window.open(url,'adminWindow',param);
	} else {
		contactWindow.focus();
		contactWindow.location.href=url;
	}
	return false;
}

var newsletterWindow;
function openNewsletterWindow (url, mail, country) {
	url = url + '&mail=' + mail + '&country=' + country;
	if (!newsletterWindow || newsletterWindow.closed) {
		newsletterWindow = window.open(url,'newsletterWindow','width=860,height=640,left=40,top=50,scrollbars=yes');

	} else {
		newsletterWindow.focus();
		newsletterWindow.location.href=url;
	}
	return false;
}

function goto_page (url) {
	document.location.href=url;
	return false;
}

var sweepWindow;
function openSweepWindow (url, mail) {
	url = url + '&mail=' + mail;
	if (!sweepWindow || sweepWindow.closed) {
		sweepWindow = window.open(url,'sweepWindow','width=830,height=580,left=100,top=50,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');

	} else {
		sweepWindow.focus();
		sweepWindow.location.href=url;
	}
	return false;
}

var feedbackWindow;
function openFeedbackWindow (url) {
	if (!feedbackWindow || feedbackWindow.closed) {
		feedbackWindow = window.open(url,'feedbackWindow','width=830,height=520,left=80,top=40');

	} else {
		feedbackWindow.focus();
		feedbackWindow.location.href=url;
	}
	return false;
}

var userOwnWindow;
function openUserOwnWindow (url) {
	if (!userOwnWindow || userOwnWindow.closed) {
		userOwnWindow = window.open(url,'userOwnWindow','width=830,height=700,left=20,top=20,scrollbars=yes,resizeable=yes,status=yes');

	} else {
		userOwnWindow.focus();
		userOwnWindow.location.href=url;
	}
	return false;
}

var SendaFriendWindow;
function openSendAFriendWindow (url, url_link) {
	url = url+"&sendafriend_page="+url_link;
	if (!SendaFriendWindow || SendaFriendWindow.closed) {
		SendaFriendWindow = window.open(url,'SendAFriendWindow','width=880,height=700,left=20,top=20,scrollbars=yes,resizeable=yes,status=yes');
	} else {
		SendaFriendWindow.focus();
		SendaFriendWindow.location.href=url;
	}
	return false;
}

var PrintAPageWindow;
function openPrintAPageWindow (url) {
	if (!PrintAPageWindow || PrintAPageWindow.closed) {
		PrintAPageWindow = window.open(url,'PrintAPageWindow','width=600,height=600,left=20,top=20,scrollbars=yes,resizeable=yes,status=yes');
	} else {
		PrintAPageWindow.focus();
		PrintAPageWindow.location.href=url;
	}
	return false;
}

var SendAFriendWindow;
function openSendAFriendWindow (url) {
	if (!SendAFriendWindow || SendAFriendWindow.closed) {
		SendAFriendWindow = window.open(url,'SendAFriendWindow','width=800,height=550,left=20,top=20,scrollbars=yes,resizeable=yes,status=yes');
	} else {
		SendAFriendWindow.focus();
		SendAFriendWindow.location.href=url;
	}
	return false;
}

var memoWindow;
function openMemoWindow (url) {
	if (!memoWindow || memoWindow.closed) {
		memoWindow = window.open(url,'memoWindow','width=650,height=800,left=300,top=100,toolbar=yes,menubar=yes,scrollbars=yes,resizeable=yes,location=yes,status=yes');

	} else {
		memoWindow.focus();
		memoWindow.location.href=url;
	}
	return false;
}

var offerTxtWindow;
function openOfferTxtWindow (url) {
	if (!offerTxtWindow || offerTxtWindow.closed) {
		offerTxtWindow = window.open(url,'memoWindow','width=600,height=200,left=610,top=330,toolbar=no,menubar=no,scrollbars=yes,resizeable=yes,location=no,status=no');

	} else {
		offerTxtWindow.focus();
		offerTxtWindow.location.href=url;
	}
	return false;
}

var calendarWindow;
function openCalendarWindow (url) {
	if (!calendarWindow || calendarWindow.closed) {
		calendarWindow = window.open(url,'calendarWindow','width=725,height=320,left=400,top=360,scrollbars=yes,resizeable=yes');

	} else {
		calendarWindow.focus();
		calendarWindow.resizeTo(725,320);
		calendarWindow.location.href=url;
	}
	return false;
}

function markCheckbox (id) {
	var box  = document.getElementById('checkbox_' + id);
	var cell = document.getElementById('tab_cell_' + id);
	cell.style.background = box.checked ? '#ffff80' : '#ffffff';
}

function setOpenerIframeSrc(id, height, width, src) {
	var iframe = opener.document.getElementById(id + "_iframe");
	if (iframe) {
		iframe.src = src;
	} else {
		appendOpenerIframe(id, height, width, src);
	}
	return false;
}

function appendOpenerIframe (id, height, width, src) {
	var parent = opener.document.getElementById(id);
	var iframe = opener.document.createElement("iframe");
	iframe.setAttribute("id", id + "_iframe");
	iframe.setAttribute("height", height);
	iframe.setAttribute("width", width);
	iframe.setAttribute("src", src);
	parent.appendChild(iframe);
}

function removeIframe (id) {
	var parent = document.getElementById(id);
	var iframe = document.getElementById(id + "_iframe");
	if (iframe) parent.removeChild(iframe);
	return false;
}


//######################## DROPDOWN ###########################
var dd_supported     = false;
var dd_menuEl        = null;
var dd_submenuEls    = new Array();
var dd_activeSubmenu = false;
var dd_hideTimer     = null;

function dd_init() {
  if (!document.getElementById) return;
  dd_menuEl = document.getElementById('dd');
  if (!dd_menuEl) return;
  dd_supported = true;
  dd_addBasicMouseHandlers(dd_menuEl.getElementsByTagName('A'));
  dd_findSubmenuElemens(dd_menuEl);
}

function dd_findSubmenuElemens(elem) {
  if (!dd_supported) return;
  var elems = elem.childNodes;
  //alert("länge-elems: "+elems.length);
  for (var i = 0; i < elems.length; i++) {
    var node = elems[i];
    if (node.nodeName != 'TD') continue;
    var submenu = node.getElementsByTagName('UL');
    if (submenu.length > 0) {
      dd_submenuEls[i] = submenu[0];
    }
    dd_addMouseHandlers(node, i);
  }
}

function dd_addMouseHandlers(elem, index) {
  if (!dd_supported) return;
  var elems = elem.childNodes;
  for (var i = 0; i < elems.length; i++) {
    var node = elems[i];
    if (node.nodeName == 'A') {
      node.onmouseover = new Function('dd_SubmenuMouseOverHandler(' + index + ')');
    }
  }
}

function dd_addBasicMouseHandlers(elems) {
	//alert("dm: "+elems.length);
  for (var i = 0; i < elems.length; i++) {
    var node = elems[i];
    node.onmouseover = dd_BasicMouseOverHandler;
    node.onmouseout  = dd_BasicMouseOutHandler;
  }
}

function dd_SubmenuMouseOverHandler(index) {
  if (!dd_supported) return;
  //alert("dm: "+dd_hideTimer);
  if (dd_hideTimer) {
    window.clearTimeout(dd_hideTimer);
    dd_hideTimer = null;
  }
  for (var i = 0; i < dd_submenuEls.length; i++) {
    if (i == index) continue;
    if (!dd_submenuEls[i]) continue;
    dd_submenuEls[i].style.visibility = 'hidden';
  }
  dd_activeSubmenu = index;
  if (dd_submenuEls[index]) dd_submenuEls[index].style.visibility = 'inherit';
}

function dd_BasicMouseOutHandler() {
  if (!dd_supported) return;
  if (dd_hideTimer)  return;
  dd_hideTimer = window.setTimeout('dd_hideSubmenu(' + dd_activeSubmenu + ')', 300);
}

function dd_BasicMouseOverHandler() {
  if (!dd_supported) return;
  if (!dd_hideTimer) return;
  window.clearTimeout(dd_hideTimer);
  dd_hideTimer = null;
}
 
function dd_hideSubmenu(index) {
  if (!dd_supported) return;
  if (!dd_submenuEls[index]) return;
  dd_submenuEls[index].style.visibility = 'hidden';
}

//################### ENDE DROPDOWN #########################//

//################### LANDKARTEN ... #######################//
function schieben(nummer) {
	position = nummer * 200 * (-1);
	document.getElementById("aktkarte").style.left = position+"px";
}

function moveleft(nummer) {
	position = nummer * 200 * (-1);
	document.getElementById("aktkarte").style.left = position+"px";
}

function senden() {
	document.f.submit();
}

//################### ENDE LANDKARTEN #########################//

//################### GOOGLE-MAP .... #########################//
var map;
var geocoder;
var icon;

function initialize() {
	map = new GMap2(document.getElementById("kartenuebersicht"));
	map.setCenter(new GLatLng(document.f2.q2.value, document.f2.q1.value), 5);
	geocoder = new GClientGeocoder();
	
	icon = new GIcon();
	icon.image = "/img/all/icon.googlemap.pointer.png";
	icon.shadow = "/img/all/icon.googlemap.shadow.png";
	icon.iconSize = new GSize(32, 32);
	icon.shadowSize = new GSize(50, 32);
	icon.iconAnchor = new GPoint(6, 20);
	icon.infoWindowAnchor = new GPoint(5, 1);
	
	icon_bitt = new GIcon();
	icon_bitt.image = "/img/all/icon.bitt.pointer.png";
	icon_bitt.shadow = "/img/all/icon.bitt.shadow.png";
	icon_bitt.iconSize = new GSize(80, 13);
	icon_bitt.shadowSize = new GSize(90, 23);
	icon_bitt.iconAnchor = new GPoint(6, 20);
	icon_bitt.infoWindowAnchor = new GPoint(5, 1);
}

function addAddressToMap(response) {
	map.clearOverlays();
	if (!response || response.Status.code != 200) {
		point_bitt = new GLatLng(48.79390492102,15.36813583505);
		point = new GLatLng(document.f2.q2.value,document.f2.q1.value);
		map.setCenter(new GLatLng(document.f2.q2.value, document.f2.q1.value), 10);
	} else {
		point_bitt = new GLatLng(48.79390492102,15.36813583505);
		place = response.Placemark[0];
		point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
		map.setCenter(new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]), 10);
	}
	marker = new GMarker(point, icon);
	map.addOverlay(marker);
	
	marker_bitt = new GMarker(point_bitt, icon_bitt);
	map.addOverlay(marker_bitt);
	
	_mPreferMetric = true;
	//var OMap = new GOverviewMapControl(); 
    //OMap.hide(true);
	//map.addControl(OMap);
	
	map.addControl(new GSmallZoomControl());

}

function showLocation() {
	geocoder.getLocations(document.f2.q.value, addAddressToMap);
}