/**
	Function: toggles the streetview overlay
	Global Vars:
	map
	streetviewcontrol
	streetOverlay
	**/
function customZoomControl() {
	this.id = "customZoomControl";
	this.map; // map object
	this.last; 	// last clicked
}
customZoomControl.prototype = new GControl();

customZoomControl.prototype.printable = function() { return true; }
customZoomControl.prototype.selectable = function() { return true; }
customZoomControl.prototype.createContent = function() {
	// zooms from 0 to 19
	var html = "";
	html += "<ul>";
	html += "<li id='zoomCloser' class='bigZoomButton zoomButton'></li>";
	html += "<li id='zoom19' class='smallZoom  zoomButton'></li>";
	html += "<li id='zoom18' class='smallZoom zoomButton'></li>";
	html += "<li id='zoom17' class='smallZoom zoomButton'></li>";
	html += "<li id='zoom16' class='smallZoom zoomButton'></li>";
	html += "<li id='zoom14' class='smallZoom zoomButton'></li>";
	html += "<li id='zoom12' class='smallZoom zoomButton'></li>";
	html += "<li id='zoom10' class='smallZoom zoomButton'></li>";
	html += "<li id='zoom8' class='smallZoom zoomButton'></li>";
	html += "<li id='zoomFarther' class='bigZoomButton zoomButton'></li>";
	html += "</ul>";
	return html;
}

customZoomControl.prototype.initialize = function(map) { 
	this.mapContainer = map.getContainer();
	this.map = map;
	
	this.container = document.createElement("div");
	$(this.container).attr("id",this.id);
	
	$(this.container).append(this.createContent());
	
	$(this.mapContainer).append(this.container);
	
	var last;
	_this = this;
	
	// events
	$(this.container).find("li").bind("click", {map:map,last:last, control:$(this)}, function() {
		var zoom = map.getZoom();
		if($(this).attr("id")=="zoomCloser") {
			if(map.getZoom()==19) return null;
			map.setZoom(zoom+1);
			var zoom = map.getZoom();
			if(customZoomControl.prototype.moveSlider(zoom)==true) {
				if(last) $(last).attr("class","smallZoom zoomButton");
				$("#zoom"+zoom).attr("class","smallZoom zoomButton chosenZoom");
				last = $("#zoom"+zoom);
			}
		}
		else if($(this).attr("id")=="zoomFarther") {
			if(map.getZoom()==0) return null;
			map.setZoom(zoom-1);
			
			var zoom = map.getZoom();
			if(customZoomControl.prototype.moveSlider(zoom)==true) {
				if(last) $(last).attr("class","smallZoom zoomButton");
				$("#zoom"+zoom).attr("class","smallZoom zoomButton chosenZoom");
				last = $("#zoom"+zoom);
			}
		}
		else {
			if(last) $(last).attr("class","smallZoom zoomButton");
			last = $(this);
			$(this).attr("class","smallZoom zoomButton chosenZoom");
			
			var id = $(this).attr("id");
			var s = id.substr(4,2);
			var zoom = parseFloat(s);
			map.setZoom(zoom);
		}
	});
	
	this.last = last;
	return this.container;
}
customZoomControl.prototype.setZoom = function(zoom) { /* called by map object **/
	var zoom = map.getZoom();
	if(customZoomControl.prototype.moveSlider(zoom)==true) {
		if(this.last) $(this.last).attr("class","smallZoom zoomButton");
		$("#zoom"+zoom).attr("class","smallZoom zoomButton chosenZoom");
		this.last = $("#zoom"+zoom);
	}
}

customZoomControl.prototype.moveSlider = function(zoom) {
	var change = true;
	switch(zoom) {
		case 19:break;
		case 18:break;
		case 17:break;
		case 16:break;
		case 15:change=false;break;
		case 14:break;
		case 13:change=false;break;
		case 12:break;
		case 11:change=false;break;
		case 10:break;
		case 9:change=false;break;
		case 8:break;
		default:change=true;break;
	}
	//alert(change+" "+zoom);
	return change;
}
customZoomControl.prototype.getDefaultPosition = function() { 
	this.defaultPos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,10));
	return this.defaultPos;
}
