//<![CDATA[
// Google Map Maker script v.1.1
// (c) 2006 Richard Stephenson http://www.donkeymagic.co.uk
// Email: donkeymagic@gmail.com
// http://mapmaker.donkeymagic.co.uk
var map;
var allGMarkers=[];
var icon0;
var newpoints = new Array();
 
function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function'){ 
		window.onload = func
	} else { 
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
 
addLoadEvent(loadMap2);
//addLoadEvent(addPoints);

function loadMap2(){
	var infoWindow = new google.maps.InfoWindow();
		
	addMarker=function(lat,lng,title,placeType,placeId,placeContent){
		var marker = new google.maps.Marker({
				position: new google.maps.LatLng(lat,lng),
				map: map,
				title: title
			});
			
			marker.id 					= placeId;
			marker.lat					= lat;
			marker.lng					= lng;
			marker.title				= title;
			marker.placeContent = placeContent;
			//marker.placeType 		= placeType;
			marker.category 		= placeType;
			allGMarkers.push(marker);
				
			google.maps.event.addListener(marker, "click", function() {
				infoWindow.setContent(placeContent);
				infoWindow.open(map, marker);
			});
	}
	

	var options = {
		zoom: 6,
		center: new google.maps.LatLng(38.11727165830543, 24.54345703125),
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		scrollwheel: false
	};
	map = new google.maps.Map(document.getElementById('map'), options);
	
	var placesTechnogroup={'query':[
		{'id': 27,'content': '<div class="map-text"><strong>Technogroup Larisa</strong><br/>τηλ: 210.6851161, 210.6851987<br/>fax: 210.6851845</div>','lat': 39.631076770083666,'lng':22.412109375,'title':'Technogroup Larisa'},
		{'id': 28,'content': '<div class="map-text"><strong>Technogroup Irakleio</strong><br/>τηλ: 210.6851161, 210.6851987<br/>fax: 210.6851845</div>','lat': 35.32633026307483,'lng':25.13671875,'title':'Technogroup Irakleio'},
		{'id': 29,'content': '<div class="map-text"><strong>Technogroup Athens</strong><br/>Παπανικολή 40, 15232 ΧΑΛΑΝΔΡΙ<br/>τηλ: 210.6851161, 210.6851987<br/>fax: 210.6851845<br/>email: <a href="mailto:office@technogroup.gr">office@technogroup.gr</a></div>','lat': 38.02084677558329,'lng':23.793468475341797,'title':'Technogroup'}
		]};
	
	for (var i = 0; i < placesTechnogroup.query.length; i++) {
		var query = placesTechnogroup.query[i];
		marker=addMarker(query.lat,query.lng,query.title,query.placeType,query.id,query.content);
	}		
		
 
	
	
	function showMarkers(category) {
		for (var i=0; i<allGMarkers.length; i++) {
			if (allGMarkers[i].category == category) {
				allGMarkers[i].setVisible(true);
			}
		}
		$("#category-"+category).checked = true;
	}
	
	function hideMarkers(category) {
		for (var i=0; i<allGMarkers.length; i++) {
			if (allGMarkers[i].category == category) {
				/////allGMarkers[i].setMap(null);
				allGMarkers[i].setVisible(false);
			}
		}
	 $("#category-"+category).checked = false;
		//map.closeInfoWindow();
	}
	

	
}
 
function addPoints() {
	newpoints[0] = new Array(39.631076770083666, 22.412109375, icon0, 'technogroup Larisa', 'τηλ: 210.6851161,210.6851987 fax: 210.6851845'); 
	newpoints[1] = new Array(35.32633026307483, 25.13671875, icon0, 'technogroup Irakleio', 'τηλ: 210.6851161,210.6851987 fax: 210.6851845'); 
	newpoints[2] = new Array(38.02084677558329, 23.793468475341797, icon0, 'technogroup', 'Παπανικολή 40, 15232 ΧΑΛΑΝΔΡΙ τηλ: 210.6851161,210.6851987 fax: 210.6851845 email: office@technogroup.gr'); 
 
	for(var i = 0; i < newpoints.length; i++) {
		//var point = new GPoint(newpoints[i][1],newpoints[i][0]);
//		var popuphtml = newpoints[i][4] ;
//		var marker = createMarker(point,newpoints[i][2],popuphtml);
//		map.addOverlay(marker);
		var myLatlng = new google.maps.LatLng(newpoints[i][1],newpoints[i][0]);
		var contentString = newpoints[i][4] ;
		var infowindow = new google.maps.InfoWindow({
			content: contentString
		});
		var marker = new google.maps.Marker({
			position: myLatlng,
			map: map,
			title:newpoints[i][3]
		});
		google.maps.event.addListener(marker, 'click', function() {
		  infowindow.open(map,marker);
		});
	
	}

}
 
function createMarker(point, icon, popuphtml) {
	var popuphtml = "<div id=\"popup\">" + popuphtml + "<\/div>";
	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(popuphtml);
	});
	return marker;
}

