function iPhone (mapvar, mapdiv){
	this.map = mapvar;
	if(typeof mapdiv == "undefined"){
		this.mapDiv = this.map.getContainer();
		}
	else this.mapDiv = mapdiv;

	this.touchPositionX = 0;
	this.touchPositionY = 0;
	this.isZooming = false;
	this.webkitTranslateX = 0;
	this.webkitTranslateY = 0;
	var centerPoint = this.map.fromLatLngToDivPixel(this.map.getCenter());
   	this.mapCenterX = centerPoint.x;
    	this.mapCenterY = centerPoint.y;
	var that = this;

	this.panToTouch = function (aTouch) {
		that.webkitTranslateX += (aTouch.clientX - that.touchPositionX);
		that.webkitTranslateY += (aTouch.clientY - that.touchPositionY);
		that.touchPositionX = aTouch.clientX;
		that.touchPositionY = aTouch.clientY;
		}         
	
	this.mapDiv.ontouchstart = function(e){
		that.webkitTranslateX = 0;
		that.webkitTranslateY = 0;
    		if (!(e.touches.length > 1)) {
      			that.touchPositionX = e.touches[0].clientX;
       			that.touchPositionY = e.touches[0].clientY;
       			}
		};
	this.mapDiv.ontouchmove = function(e){
    			if (!(e.touches.length > 1)) {
       				that.panToTouch(e.touches[0]);
    				}
			};
	this.mapDiv.ontouchend = function(e){
		if(!(e.changedTouches.length>1)){
   			 if ((that.webkitTranslateX == 0) || (that.webkitTranslateY == 0)) {
				var ctr = that.map.fromDivPixelToLatLng(new GPoint(e.changedTouches[0].clientX,e.changedTouches[0].clientY));
				var z = map.getZoom() + 1;
        	   		that.map.setCenter(ctr,z);
        		
		 		}
			}
		};
 
	this.mapDiv.ongestureend = function(e) {
 	 	that.isZooming = false;
		that.webkitTranslateX = 0;
		that.webkitTranslateY = 0;
		};

	this.mapDiv.ongesturechange = function(e) {
		e.preventDefault();
		if(!that.isZooming){
			var z = Math.log(e.scale)/Math.log(2);
			if (z != 0){
				var zoom = parseInt(that.map.getZoom() + z);
				that.map.setZoom(zoom);
				that.isZooming = true;
				}
			}
		};
	}
function hideAddressBar() { window.scrollTo(0, 1);  }
