﻿var map;
var point = function (x, y, n, url, name, sum, ico) {
    this.x = x;
    this.y = y;
    this.number = n || 1;
    this.url = url;
    this.name = name;
    this.sum = sum;
    this.icon = new GIcon();
    this.icon.image = ico || "http://www.yilbasindaistanbulda.com/images/gmapicon.gif";
    this.icon.shadow = "";
    this.icon.iconSize = new GSize(25, 30);
    this.icon.shadowSize = new GSize(40, 30);
    this.icon.iconAnchor = new GPoint(17, 30);
    this.icon.infoWindowAnchor = new GPoint(22, 19);
    this.icon.infoShadowAnchor = new GPoint(18, 25);
    this.GPoint = function () {
        if (!this.gpoint) this.gpoint = new GLatLng(this.x, this.y);
        return this.gpoint;
    };
    this.GMarker = function () {
    try {
        if (!this.marker) this.marker = new GMarker(this.GPoint(), this.icon);
        var html = "<div style=\"width:200px; overflow:hidden; background-color:#fff; padding:5px; \">" +
                   "<img src=\"/etkinlik/{0}/gorsel/112x80\" style=\"margin-bottom:10px;\" align=\"left\" />" +
                   "<h1 style=\"float:left;  font-size:16px; color:#c82115;  float:left; margin:0;\">{1}</h1>" +
                   "<p style=\"font-size:11px; color:#464444; float:left; margin:0;\">{2}</p>" +
                   "</div>";
        html = html.replace(/\{0\}/g, this.url).replace(/\{1\}/g, this.name)
                .replace(/\{2\}/g, this.sum);
        
        var marker = this.marker;
        
        
        GEvent.addListener(marker, "mouseover", function () {
            //marker.openInfoWindowHtml(html);
        });
        
        return marker;
        } catch (e) {alert(e);}
    }
}
var googleMap = function () {
    if (!GBrowserIsCompatible()) return null;
	var _mZoomIn = 'Büyült';
	var _mZoomOut = 'Küçült';
	var _mZoomSet = 'Yakınlaşma seviyesi';
	var _mPanWest = 'Sola';
	var _mPanEast = 'Sağa';
	var _mPanNorth = 'Yukarı';
	var _mPanSouth = 'Asağı';
	var _mLastResult = 'Son ekrana geri dön';
	var _mZoomDrag = 'Yakınlaşma seviyesi';
	
	G_NORMAL_MAP.getName = function(short) { 
		if(short) {return "Harita"} 
		return "Harita"; 
	}
	G_HYBRID_MAP.getName = function(short) { 
		if(short) {return "Karma"} 
		return "Karma"; 
	}
	G_SATELLITE_MAP.getName = function(short) { 
		if(short) {return "Uydu"} 
		return "Uydu"; 
    }
    this.add = function (x,y, url, name, sum, ico) {
        if (!this.points) this.points = new Array();
        this.points[this.points.length] = new point(parseFloat(x),parseFloat(y), this.points.length, url, name, sum, ico);
        return this.points[this.points.length-1];
    };
    this.getPoint = function (index) {
        return this.points[index];
    };
    this.getGPoint = function (index){
        return this.getPoint(index).GPoint();
    };
    this.prepare = function(el) {
        map = new GMap2(document.getElementById(el), { size: new GSize(296, 246) });
	    map.addControl(new GSmallMapControl());	//// new GLargeMapControl()
	    map.addControl(new GMapTypeControl());
	    map.setCenter(this.getGPoint(0), 17); // Orta noktayı ilk elemana göre belirle
        for (var i = 0; i<this.points.length; map.addOverlay(this.points[i].GMarker()), i++);
    }
}
