var activeTherapeutCat = false; // therapeutHolder

var activeTherapeutTab = "thInfos"; // therapeutPage

function thShow(tab, praxisNr, lat, lng, titleName, contentString){
	jQuery('#Tab' + activeTherapeutTab).css('font-weight', 'normal');
	jQuery('#Tab' + activeTherapeutTab).css('color', '#DFDFDF');
	jQuery('#Tab' + tab).css('font-weight', 'bold');
	jQuery('#Tab' + tab).css('color', '#72A505');
	jQuery('#' + activeTherapeutTab).fadeOut(300, function(){
		jQuery('#' + tab).fadeIn(300);
		activeTherapeutTab = tab;
		if(praxisNr){
			initializeMap(praxisNr, lat, lng, titleName, contentString);
		}
	});
}

function initializeMap(praxisNr, lat, lng, titleName, contentString){
	var latlng = new google.maps.LatLng(lat, lng);
	var myOptions = {
		zoom: 10,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById("mapPraxis" + praxisNr), myOptions);
	google.maps.event.trigger(map, 'resize');
	pointAddress(lat, lng, titleName, contentString, map);
}


function pointAddress(lat, lng, titleName, contentString, map) {
	var myLatlng = new google.maps.LatLng(lat, lng);
    
	var marker = new google.maps.Marker({
		position: myLatlng, 
		map: map, 
		title: titleName
	});   

	
	var infowindow = new google.maps.InfoWindow({
		content: contentString
	});

	google.maps.event.addListener(marker, 'click', function() {
	  infowindow.open(map, marker);
	});
	  infowindow.open(map, marker);
	
	//alert("Geocode was not successful for the following reason: " + status);
  }



function loadTherapeuten(offset, forceKat){
	var text = jQuery('#searchText').val();
	var land = jQuery('#searchLand').val();
	var geschlecht = jQuery('#searchGeschlecht').val();
	var lehr = jQuery('#searchLehr').attr('checked');
	if(!forceKat)
		var kat = jQuery('#searchKat').val();
	else
		var kat = forceKat;
		
	if(!offset)
		offset = 0;

	var params = encodeURI(
		"?text=" + text + "&land=" + land + "&geschlecht=" + geschlecht + "&lehr=" + lehr + "&kat=" + kat + "&offset=" + offset); 

	jQuery('#therapeutResults').hide(0, function(){
		jQuery('#therapeutLoading').show(0);
	});
	
	jQuery('#therapeutResults').load('/tools/therapeuten/' + params, function(){
		jQuery('#therapeutLoading').fadeOut(200, function(){
			jQuery('#therapeutResults').fadeIn(400);
		});
	
	});
}

function setTherapeutCat(param){
	if(!activeTherapeutCat)
		activeTherapeutCat = 'catAll';
	jQuery('#' + activeTherapeutCat).css('font-weight', 'normal');
	jQuery('#' + activeTherapeutCat).css('color', '#DFDFDF');
	jQuery('#cat' + param).css('font-weight', 'bold');
	jQuery('#cat' + param).css('color', '#90d006');
	activeTherapeutCat = "cat" + param;
	jQuery('#searchKat').val(param);
	loadTherapeuten();
}


function showNewPraxis(){
	jQuery('#newPraxis').toggle(400);
}

