//########################################################################
//########################## CUSTOM Y-SLIDER #############################
//########################################################################
function YSliderControl() { }
	YSliderControl.prototype = new GControl();
	var YSLIDERLENGTH = 114;
	var MAXZOOM = 6;
	var INVERT_SLIDER = true;
	var STEP = Math.round(YSLIDERLENGTH/MAXZOOM);
	YSliderControl.prototype.setSlider = function(zoom) {
	if (INVERT_SLIDER)
	var zoom = MAXZOOM-zoom;
	var top = Math.round((YSLIDERLENGTH/MAXZOOM*zoom));
	this.slide.top = top;
	this.knob.style.top = top+"px";
}

YSliderControl.prototype.setZoom = function() {
	var z=Math.round(this.slide.top*MAXZOOM/YSLIDERLENGTH);
	if (INVERT_SLIDER)
	var z = MAXZOOM-z;
	this.map.setZoom(z);
}

YSliderControl.prototype.initialize = function(map) {
var that=this;
this.map = map;
var container = document.createElement("div");
container.style.width="24px";
container.style.height="114px";
this.knob = document.createElement("img"); 
this.knob.src = "files/gmapper/cntrl_slider.png";
container.appendChild(this.knob);
this.slide=new GDraggableObject(this.knob, {container:container});
map.getContainer().appendChild(container);
GEvent.addListener(map, "zoomend", function(a,b) {that.setSlider(b)});
GEvent.addListener(this.slide, "dragend", function() {that.setZoom()});
return container;
}

//## CUSTOM Y-SLIDER POSITION
YSliderControl.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(29, 110));
}
//########################################################################
//########################## CUSTOM Y-SLIDER ENDE ########################
//########################################################################


//########################################################################
//######################## CUSTOM MAP TYPE ###############################
//########################################################################
function CustomMapControl() {
}
CustomMapControl.prototype = new GControl();
// Creates a one DIV for each of the buttons and places them in a container
// DIV which is returned as our control element. We add the control to
// to the map container and return the element for the map class to
// position properly.
CustomMapControl.prototype.initialize = function(map) {
var container = document.createElement("div");

var mapTypeSelect = document.createElement("select");
this.setButtonStyle_(mapTypeSelect);
container.appendChild(mapTypeSelect);

// #### Options
var optTextArray = new Array("Normal","Satellit","Hybrid","Physikalisch");
var optValueArray = new Array(G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP,G_PHYSICAL_MAP);

    for(i=0; i <= optValueArray.length-1; i++)
    {
	var optString = document.createElement('option');
	optString.text = optTextArray[i];
	optString.value = optValueArray[i];

	try {
    		mapTypeSelect.add(optString, null);
  	}
  	catch(ex) {
    		mapTypeSelect.add(optString);
  	}
    }
// #### Options Ende

GEvent.addDomListener(mapTypeSelect, "change", function() {
	var mode = mapTypeSelect.options[mapTypeSelect.selectedIndex].value;
	if(mode == G_PHYSICAL_MAP)
	{
		map.addMapType(G_PHYSICAL_MAP);
	}
	map.setMapType(optValueArray[mapTypeSelect.selectedIndex]);
});

map.getContainer().appendChild(container);
return container;
}

CustomMapControl.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(19, 20));
}

CustomMapControl.prototype.setButtonStyle_ = function(button) {
var loader = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.traveldodo.com/yknob.png', sizingMethod='none');";
//button.style.width = "40px";
//button.style.height = "14px";
button.style.cursor = "pointer";
button.style.display = "inline";
button.style.filter= loader;
}
//########################################################################
//######################## CUSTOM MAP TYPE ENDE ##########################
//########################################################################


//########################################################################
//######################## CUSTOM ZOOM CONTROL ###########################
//########################################################################
function CustomZoomControl() {
}
CustomZoomControl.prototype = new GControl();
CustomZoomControl.prototype.initialize = function(map) {

var container = document.createElement("div");
container.style.width = "45px";
container.style.height = "155px";
container.style.background = "url(files/gmapper/cntrl_bg.png)";
container.style.backgroundColor = "#f2f2f2";
container.style.backgroundRepeat = "no-repeat";

var upButton = document.createElement("img");
container.appendChild(upButton);
upButton.src = "files/gmapper/cntrl_btn_up.png";
upButton.style.marginLeft = "15px";
upButton.style.marginTop = "3px";	
upButton.style.cursor = "pointer";	

GEvent.addDomListener(upButton, "click", function() {
	map.panDirection(0, +1);
});

var leftButton = document.createElement("img");
container.appendChild(leftButton);
leftButton.src = "files/gmapper/cntrl_btn_left.png";
leftButton.style.marginLeft = "5px";
leftButton.style.marginTop = "0px";	
leftButton.style.marginBottom = "0px";
leftButton.style.display = "inline";	
leftButton.style.cursor = "pointer";

GEvent.addDomListener(leftButton, "click", function() {
	map.panDirection(+1, 0);
});	

var rightButton = document.createElement("img");
container.appendChild(rightButton);
rightButton.src = "files/gmapper/cntrl_btn_right.png";
rightButton.style.marginLeft = "2px";
rightButton.style.marginTop = "0px";
rightButton.style.marginBottom = "0px";
rightButton.style.display = "inline";	
rightButton.style.cursor = "pointer";	

GEvent.addDomListener(rightButton, "click", function() {
	map.panDirection(-1, 0);
});

var downButton = document.createElement("img");
container.appendChild(downButton);
downButton.src = "files/gmapper/cntrl_btn_down.png";
downButton.style.marginLeft = "15px";
downButton.style.marginBottom = "0px";
downButton.style.cursor = "pointer";	

GEvent.addDomListener(downButton, "click", function() {
	map.panDirection(0, -1);
});
		
var zoomBox = document.createElement("div");
zoomBox.style.width = "80px";
zoomBox.style.height = "15px";
zoomBox.style.marginLeft = "5px";
zoomBox.style.marginTop = "5px";

var zoomInButton = document.createElement("img");
zoomBox.appendChild(zoomInButton);
zoomInButton.src = "files/gmapper/cntrl_btn_plus.png";
zoomInButton.style.marginLeft = "0px";
zoomInButton.style.display = "inline";
zoomInButton.style.cursor = "pointer";

GEvent.addDomListener(zoomInButton, "click", function() {
	map.zoomIn();
});

var zoomOutButton = document.createElement("img");
zoomBox.appendChild(zoomOutButton);
zoomOutButton.src = "files/gmapper/cntrl_btn_minus.png";
zoomOutButton.style.marginLeft = "2px";
zoomOutButton.style.marginTop = "0px";
zoomOutButton.style.display = "inline";
zoomOutButton.style.cursor = "pointer";	

GEvent.addDomListener(zoomOutButton, "click", function() {
	map.zoomOut();
});	
container.appendChild(zoomBox);

map.getContainer().appendChild(container);
return container;
}

//## CUSTOM ZOOM POSITION
CustomZoomControl.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(19, 20));
}
//########################################################################
//######################## CUSTOM ZOOM CONTROL ENDE ######################
//########################################################################


//########################################################################
//############################# CUSTOM OVERLAY ###########################
//########################################################################
function CustomOverlay() {
}
CustomOverlay.prototype = new GControl();
CustomOverlay.prototype.initialize = function(map) 
{
var container = document.createElement("div");
container.style.width = document.getElementById("gmapper_map").offsetWidth+"px";
container.style.height = document.getElementById("gmapper_map").offsetHeight+"px";
container.style.background = "url(files/tmp_/"+overlay+".gko.png)";

map.getContainer().appendChild(container);
return container;
}
CustomOverlay.prototype.getDefaultPosition = function() {
return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0));
}
//########################################################################
//########################## CUSTOM OVERLAY ENDE #########################
//########################################################################