
var bl = function(){

	return{
		/*test: function (){
		advAJAX.get({
		url: "handler.php?action=test&json=true",
		onLoading : progress('on'),
		onComplete : progress('off'),
		onSuccess : function(obj) {
		var params = eval("(" + obj.responseText + ")");
		alert(params.test);
		}
		});
		}*/
		
		hideBubble : function(){
			var det = document.getElementById('detailBL');
			det.style.display = 'none';
			var el = document.getElementById('bodyGG');
			var p  = document.getElementById('pbodyGG');
			if (el){
				el.style.display = "block";
				p.src = "images/stateMin.gif";
				document.getElementById('abodyGG').href = "javascript: toggleWindowState('bodyGG');";
			}
		},
		
		showDetailsBL : function(id,idr){
			var el = document.getElementById('bodyGG');
			var p  = document.getElementById('pbodyGG');
			if (el){
				el.style.display = "none";
				p.src = "images/stateMax.gif";
			}
			
			// div einblenden
			var det = document.getElementById('detailBL');
			det.style.display = 'block';
			
			this.showDetails(id,idr);
		},


		showDetails : function (id,idr){

			advAJAX.post({
				url: "handler.php?id_bl="+id+"&idr="+idr,
				
				onLoading : function (){
					//Loading
					document.getElementById('imageBL').src = "images/loading1.gif";
					//Clear map   					
					mapObj = document.getElementById("mapDetails");
   					while (mapObj.childNodes.length){
   						mapObj.removeChild(mapObj.firstChild);
   					}
   					//Clear Data-Table
					tabObj = document.getElementById("tableDetails");
   					while (tabObj.childNodes.length){
   						tabObj.removeChild(tabObj.firstChild);
   					}
				},
				onComplete : function(){ },
				onSuccess : function(response) {

					var params = eval("(" + response.responseText + ")");
					var liste = "liste2";
				   	mapObj = document.getElementById("mapDetails");
				   	table = document.getElementById("tableDetails");
				   	
					for(var i=0;i<params.aps.length;i++){
						
						liste = liste=='liste2' ? 'liste3' : 'liste2';
						
						//Shape
						var shape = document.createElement("area");
						shape.href = params.aps[i].target;
						shape.shape = "circle";
						shape.coords = params.aps[i].shape;
						//shape.title = params.aps[i].firma;
						mapObj.appendChild(shape);
						
						var row = table.insertRow(0);
						var cell = row.insertCell(0);
						
						var link = document.createElement("a");
						link.href = params.aps[i].target;
						link.innerHTML = '<strong>' + params.aps[i].firma + '</strong>';
												
						cell.align = "left";
						cell.appendChild(link);
						cell.innerHTML+= '<br />'+params.aps[i].strasse+'<br />'+params.aps[i].plz+' '+params.aps[i].ort;
						cell.className = liste;
					}					
					document.getElementById('imageBL').src = 'bilder/bl/'+params.global.id+".jpg";
					
					// Action GG-Window
					document.getElementById('abodyGG').href = 'javascript: bl.hideBubble();';
				},
				onError: function(response){
					alert("Ein Fehler ist aufgetreten: "+ "\n" + response.status);
				}
			});
		}
		
	} //return
}();