﻿
var bounds = new GLatLngBounds();
var baseIcon = new GIcon();
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);


function createMarker(point, window, color,title,num) {
bounds.extend(point);
var icon = new GIcon(baseIcon);
icon.image = "http://corelevelrea.com/common/maps/" + color  + "/marker" + num + ".png";
var marker = new GMarker(point, icon);

//      var marker = new GMarker(point, {title:title});
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(window);
});

return marker;
}


function load(pointsrow,mycolor) {

if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng(59.07822222, 22.37633333),13);
mypoints=pointsrow.split("~!~");
for (y=0; y<mypoints.length; y++)
{
myinfo=mypoints[y].split("|");
//alert(myinfo[0] + " " + myinfo[1]);
if(myinfo[0]!='' && myinfo[0]!=0 && myinfo[2]!='' && myinfo[0]!=999 ){
map.addOverlay(createMarker(new GLatLng(myinfo[0], myinfo[1]), myinfo[2], mycolor,myinfo[3],y+1));
}
}

var center_lat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) / 2.0;
var center_lng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) / 2.0;
var center = new GLatLng(center_lat,center_lng)
var zoom = map.getBoundsZoomLevel(bounds);
if (zoom>14) {zoom=14};
map.setCenter(center,zoom);
}
checkCookie();
}

function showmap(id){
if (id==1){
showLayer('hidemap');
hideLayer('showmap');
setCookie('mapview',1,365)
}else{
showLayer('showmap');
hideLayer('hidemap');
setCookie('mapview',0,365)
}
}


function showLayer(id) {
var lyr = getElemRefs(id);
if (lyr && lyr.css) lyr.css.display = "block";
}

function hideLayer(id) {
var lyr = getElemRefs(id);
if (lyr && lyr.css) lyr.css.display = "none";
}

function getElemRefs(id) {
var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(id,document): null;
if (el) el.css = (el.style)? el.style: el;
return el;
}






function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=")
if (c_start!=-1)
{
c_start=c_start + c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))
}
}
return ""
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function checkCookie()
{
mapview=getCookie('mapview')
if (mapview==0){
//HIDE MAP
showmap(0);
}
}










