function suche() {
	var erweitert = document.getElementById('erweiterte-suche-deutschland');
	var suche = document.getElementById('telefonbuch-suche-deutschland');
	var hiddenfeld = document.getElementById('erweitert');
	if (erweitert.className=="open"){
		erweitert.className="";
		suche.className="open";
		hiddenfeld.value="";
	}
	else{	
		erweitert.className="open";
		suche.className="";
		hiddenfeld.value="true";
	}
}

function doPrint() {
	setTimeout("startPrint()",1000);
}
function startPrint() {
	this.focus();
	this.print();
}
function sendDetailLink() {
 var lnk = parent.location.href;
 if (parent.getDetailLink) {
  lnk = "http://" + location.host + parent.getDetailLink();
 }
 location.href="mailto:?body=" + escape(lnk);
}

function go(url) { location.href=  url; }
function fokus() {
	if (document.getElementById("Name")!=undefined && document.getElementById('erweitert').value=='') document.getElementById("Name").focus();
	else if (document.getElementById("Name_e")!=undefined){
		 document.getElementById("Name_e").focus();
	}
	else if (document.getElementById("Ort")!=undefined){
		 document.getElementById("Ort").focus();
	}
}

//Googlemaps
var map = null;
var geocoder = null;

function load(type) {
	if(type == "small") {
		zoom = 15;
		controls = new Array("GSmallMapControl");
	} else {
		zoom = 20;
		controls = new Array("GLargeMapControl","GMapTypeControl","GOverviewMapControl");
	}

	if (GBrowserIsCompatible()) {
		if (document.getElementById("map-address")!=undefined)
			var address = document.getElementById("map-address").innerHTML;
		if (document.getElementById("infotext")!=undefined)
			var infotext = "<div id=\"bubble\">" + document.getElementById("infotext").innerHTML + "</div>";
		map = new GMap2(document.getElementById("map"));
		geocoder = new GClientGeocoder();		
		if (geocoder) {
			geocoder.getLatLng(address,
			function(point) {
				if (!point) {
					alert(address + " wurde nicht gefunden!");
				} else {
					map.setCenter(point, zoom);
					var marker = new GMarker(point);
					map.addOverlay(marker);					
					if(type != "small")
						marker.openInfoWindowHtml(infotext + '<p><a href=http://maps.google.de/maps?daddr=' + escape(address) + '>' + 'Route berechnen: Hierher' + '</a>' + ' - ' + '<a href=http://maps.google.de/maps?saddr=' + escape(address) + '>' + 'Von Hier' + '</a></p>');					
				}
			}
			);
		}
		//showLocation();

		for(i=0;i<controls.length;i++) {
			c = controls[i];
			eval('map.addControl(new ' + c +'())');
			//eval("map.addControl(new c())");
			//map.addControl(new GMapTypeControl());
			//map.addControl(new GOverviewMapControl());
		}
	}
}
//End Googlemaps

function windowHeight() {
	if (window.innerHeight) {
		var hoehe=window.innerHeight;
	} else if (document.compatMode && document.compatMode == "CSS1Compat") {
		var hoehe=document.documentElement.clientHeight;
	} else if (document.body.clientHeight) {
		var hoehe=document.body.clientHeight;
	} else {
		var hoehe=null;
	}
	return hoehe;
}

function windowWidth() {
	if (window.innerWidth) {
		var breite=window.innerWidth;
	} else if (document.compatMode && document.compatMode == "CSS1Compat") {
		var breite=document.documentElement.clientWidth;
	} else if (document.body.clientWidth) {
		var breite=document.body.clientWidth;
	} else {
		var breite=null;
	}
	return breite;
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) { 
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	return [curleft,curtop];
	}
	return;
}
function getMapHeight(x) {
	pos = findPos(document.getElementById("map"));	
	topPos = pos[1];
	mapheight = windowHeight()-topPos+x;
	//alert(windowHeight() + ' ' + topPos);
	if (mapheight<300)
		mapheight = 300;
	return mapheight + "px";
}
function setMapHeight(x) {
	document.getElementById("map").style.height=getMapHeight(x);
}
function getMapWidth() {
	mapwidth = windowWidth()-document.getElementById("show-company-deutschland").offsetWidth-70;
		if (mapwidth<200 )
			mapwidth = 200;
	return mapwidth + "px";
}
function setMapWidth() {
	document.getElementById("map-vorschau").style.width=getMapWidth();
}
function externalLinks() {
	if(!document.getElementsByTagName) return;
	var links,a,i;
	links = document.getElementsByTagName("a");
	for(i=0;i<links.length;i++) {
		a = links[i];
		if(a.getAttribute("rel") && a.getAttribute("rel").indexOf("external") > -1) {
			 a.onclick = function() {
				 window.open(this.href);
				 return false;
			 }
		 }
	 }
}

/*
var border = RUZEE.ShadedBorder.create({
'#filter-deutschland, #cylex_tabView1 form': { borderType:'shadow', cornerRadius:10, shadowWidth: 3 },
'div.kategorie-deutschland h2':{borderType:'simple',cornerRadius:5,edges:'lt'},
'div.tag-cloud-deutschland h2':{borderType:'simple',cornerRadius:5,edges:'lt'},
'dl.kategorie-deutschland dt':{borderType:'simple',cornerRadius:5,edges:'lt'},
'div#col1 dl dt':{borderType:'simple',cornerRadius:5,edges:'lt'},
'div#col2 dl dt':{borderType:'simple',cornerRadius:5,edges:'lt'},
'div.tag-cloud-deutschland':{borderType:'fade',cornerRadius:3,edges:'rb'},
'dl.kategorie-deutschland, dl.plz-vorwahl':{borderType:'fade',cornerRadius:3,edges:'rb'},
'div#col1 dl':{borderType:'fade',cornerRadius:3,edges:'rb'},
'div#col2 dl':{borderType:'fade',cornerRadius:3,edges:'rb'},
'div.kategorie-deutschland':{borderType:'fade',cornerRadius:3,edges:'rb'}
});*/
window.onload=function(){
	//border.render();
	fokus();
	externalLinks();
	if (document.location.href.indexOf("/profil/")!=-1) {
		setMapWidth();
		setMapHeight(-50);
		load("small");	
	}
	if (document.location.href.indexOf("/anfahrt/")!=-1)
	{
		setMapHeight(-10);
		load();	
	}	
};

if (document.location.href.indexOf("/anfahrt/")!=-1)
{	window.onresize=function(){setMapHeight(-10);}
	
}

if (document.location.href.indexOf("/profil/")!=-1)
{	window.onresize=function(){setMapWidth();setMapHeight(-50);}
}